/**
 * Copyright 2019 DH
 * All right reserved.
 * 项目名称: 大恒泰山系统
 * 创建日期:2023/4/26
 */
package org.springblade.etl.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.enums.EtlModeEnum;
import org.springblade.etl.EtlTaskManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/***
 * Date:2023/4/26
 * Title:ETL接口
 * Description：对本文件的详细描述，原则上不能少于30字
 * @author dylan
 * @version 1.0
 * Remark：认为有必要的其他信息
 */
@RestController
@RequestMapping("galaxy-business/etl")
@AllArgsConstructor
@Api(value = "ETL接口", tags = "ETL接口")
@Slf4j
public class EtlController extends BladeController {
    @Resource
    private EtlTaskManager etlTaskManager;

    @GetMapping("/rain/rerun")
    @ApiOperationSupport(order = 1)
    public R<String> etlRainDataCollect() {
        String id = Func.random(100);
        etlTaskManager.submitRainDataEtlTask(EtlModeEnum.ETL_LAST.getCode(),id);
        return R.data("ok");
    }

    @GetMapping("/river/rerun")
    @ApiOperationSupport(order = 1)
    public R<String> etlRiverDataCollect() {
        String id = Func.random(100);
        etlTaskManager.submitRiverDataEtlTask(EtlModeEnum.ETL_LAST.getCode(),id);
        return R.data("ok");
    }

    @GetMapping("/rsvr/rerun")
    @ApiOperationSupport(order = 1)
    public R<String> etlRsvrDataCollect() {
        String id = Func.random(100);
        etlTaskManager.submitRsvrDataEtlTask(EtlModeEnum.ETL_LAST.getCode(),id);
        return R.data("ok");
    }

    @GetMapping("/ground/rerun")
    @ApiOperationSupport(order = 1)
    public R<String> etlGroundDataCollect() {
        String id = Func.random(100);
        etlTaskManager.submitGroundDataEtlTask(EtlModeEnum.ETL_LAST.getCode(),id);
        return R.data("ok");
    }



}
