package com.lanyuanxiaoyao.service.hudi.controller;

import com.lanyuanxiaoyao.service.hudi.service.HdfsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * hudi目标库的hdfs操作
 *
 * @author lanyuanxiaoyao
 * @date 2024-01-24
 */
@RestController
@RequestMapping("hdfs")
public class HdfsController {
    private static final Logger logger = LoggerFactory.getLogger(HdfsController.class);

    private final HdfsService hdfsService;

    public HdfsController(HdfsService hdfsService) {
        this.hdfsService = hdfsService;
    }

    @GetMapping("exists_hudi_table_by_flink_job_id_alias")
    public Boolean existsHudiTable(
            @RequestParam("flink_job_id") Long flinkJobId,
            @RequestParam("alias") String alias
    ) {
        return hdfsService.existsHudiTable(flinkJobId, alias);
    }

    @GetMapping("exists_hudi_table_by_hdfs")
    public Boolean existsHudiTable(@RequestParam("hdfs") String hdfs) {
        return hdfsService.existsHudiTable(hdfs);
    }

    @GetMapping("exists_path")
    public Boolean existsPath(@RequestParam("hdfs") String hdfs) {
        return hdfsService.existsPath(hdfs);
    }
}
