package com.njcn.influx.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.njcn.influx.bo.po.JobDetailInfluxDB;
import com.njcn.influx.config.IdMappingCache;
import com.njcn.influx.service.JobDetailInfluxDBService;
import com.njcn.oracle.bo.param.DataAsynParam;
import com.njcn.oracle.bo.param.JobQueryParam;
import com.njcn.oracle.bo.po.JobDetail;
import com.njcn.oracle.service.JobDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * Description:
 * Date: 2024/1/9  9:13【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/jobDetail")
@Api(tags = "同步任务")
@AllArgsConstructor
public class JobDetailInfluxDBController {

    private final JobDetailInfluxDBService jobDetailInfluxDBService;
    private  final  IdMappingCache idMappingCache;
    @PostMapping("/jobQuery")
    @ApiOperation("任务查询")
    @ApiImplicitParam(name = "jobQueryParam", value = "任务查询参数", required = true)
    public IPage<JobDetailInfluxDB> jobQuery(@RequestBody JobQueryParam jobQueryParam){
        IPage<JobDetailInfluxDB> jobDetails = jobDetailInfluxDBService.selectByParam(jobQueryParam);
        return jobDetails;//HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, jobDetails, "任务查询");
    }
    @PostMapping("/jobRemove")
    @ApiOperation("任务移除")
    @ApiImplicitParam(name = "jobQueryParam", value = "任务移除参数", required = true)
    public boolean jobRemove(@RequestBody JobDetailInfluxDB jobDetail){
        boolean b = jobDetailInfluxDBService.jobRemove(jobDetail);
        return b;
    }

    @GetMapping("/refreshIdCache")
    @ApiOperation("刷新缓存")
    public Boolean refreshIdCache() {
        DataAsynParam dataAsynParam = new DataAsynParam();
        idMappingCache.init();
        return true;// HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, "数据同步");
    }
}
