package org.jeecg.modules.deliver.cmos.job.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.deliver.cmos.domain.CsfResponse;
import org.jeecg.modules.deliver.cmos.job.service.CmosTaskService;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("cmos/task")
public class CmosTaskController {

    final CmosTaskService cmosTaskService;

    /**
     * 任务调度接口
     * <p>地址示例：发票上传任务 /cmos/task/fpsc</p>
     *
     * @param type 任务类型
     * @return
     */
    @GetMapping("{type}")
    public CsfResponse execute(@PathVariable("type") String type) {

        CsfResponse response = new CsfResponse();
        response.setRtnCode(CsfResponse.RTN_CODE.SUCCESS);
        response.setRtnMsg(CsfResponse.RTN_MSG.SUCCESS);

        // 业务逻辑处理
        this.cmosTaskService.execute(type);

        return response;
    }

}
