package com.lanyuanxiaoyao.service.hudi.controller;

import com.lanyuanxiaoyao.service.hudi.service.TableService;
import org.eclipse.collections.api.map.ImmutableMap;
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 表
 *
 * @author lanyuanxiaoyao
 * @date 2023-07-07
 */
@RestController
@RequestMapping("table")
public class TableController {
    private static final Logger logger = LoggerFactory.getLogger(TableController.class);

    private final TableService tableService;

    public TableController(TableService tableService) {
        this.tableService = tableService;
    }

    @GetMapping("schema")
    public ImmutableMap<String, Object> schema(
            @RequestParam("flink_job_id") Long flinkJobId,
            @RequestParam("alias") String alias
    ) throws Exception {
        return tableService.schema(flinkJobId, alias);
    }

    @GetMapping("schema_hdfs")
    public ImmutableMap<String, Object> schema(
            @RequestParam("hdfs") String hdfs
    ) throws Exception {
        return tableService.schema(hdfs);
    }
}
