package com.securitycontrol.background.controller;

import com.securitycontrol.background.service.TaskCheckService;
import com.securitycontrol.common.core.domain.Result;
import com.securitycontrol.common.core.web.controller.BaseController;
import com.securitycontrol.common.core.web.page.TableDataInfo;
import com.securitycontrol.common.log.annotation.Log;
import com.securitycontrol.common.log.enums.OperationType;
import com.securitycontrol.entity.background.dto.ClassCheckDto;
import com.securitycontrol.entity.background.vo.ClassCheckVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 任务指派及跟踪 业务
 */
@RequestMapping(value = "/task/check/")
@RestController
@Slf4j
public class TaskCheckController  extends BaseController {


    @Autowired
    private TaskCheckService service;

    /**
     * 分页查询施信息
     * @param dto
     * @return
     */
    @GetMapping("getPageList")
    @Log(title = "任务指派跟踪", menu = "风险值班管理->任务指派跟踪", grade = OperationType.QUERY_BUSINESS, details = "查询列表", type = "业务日志")
    public TableDataInfo getPageList(ClassCheckDto dto) {
        try{
            startPage();
            List<ClassCheckVo> list = service.getPageList(dto);
            return getDataTable(list);
        }catch (Exception e){
            log.error(e.toString(),e);
            return getDataTableBad(new ArrayList<>(),e.toString());
        }
    }
    /**
     * 查询 已分配数据集合
     * @param dto
     * @return
     */
    @GetMapping("getClassList")
    @Log(title = "任务查询", menu = "风险值班管理->任务指派跟踪", grade = OperationType.QUERY_BUSINESS, details = "查询列表", type = "业务日志")
    public TableDataInfo getClassList(ClassCheckDto dto) {
        try{
            startPage();
            List<ClassCheckVo> list = service.getClassList(dto);
            return getDataTable(list);
        }catch (Exception e){
            log.error(e.toString(),e);
            return getDataTableBad(new ArrayList<>(),e.toString());
        }
    }

    @PostMapping("dutyFpClass")
    @Log(title = "分配任务", menu = "风险值班管理->任务指派跟踪", grade = OperationType.QUERY_BUSINESS, details = "查询列表", type = "业务日志")
    public Result<String>  dutyFpClass(@RequestBody ClassCheckDto dto){
            return  service.dutyFpClass(dto);
    }

    @PostMapping("delTask")
    @Log(title = "移除任务", menu = "风险值班管理->任务指派跟踪", grade = OperationType.QUERY_BUSINESS, details = "查询列表", type = "业务日志")
    public Result<String>  delTask(@RequestBody ClassCheckDto dto){
        return  service.delTask(dto);
    }


    @PostMapping("delAllTask")
    @Log(title = "移除全部任务", menu = "风险值班管理->任务指派跟踪", grade = OperationType.QUERY_BUSINESS, details = "查询列表", type = "业务日志")
    public Result<String>  delAllTask(@RequestBody ClassCheckDto dto){
        return  service.delAllTask(dto);
    }

}
