package com.zcloud.safetyDutyList.web.tasklist;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.safetyDutyList.api.tasklist.TaskListServiceI;
import com.zcloud.safetyDutyList.dto.clientobject.tasklist.TaskDetailCO;
import com.zcloud.safetyDutyList.dto.clientobject.tasklist.TaskDetailInfoCO;
import com.zcloud.safetyDutyList.dto.clientobject.tasklist.TaskExecutionCO;
import com.zcloud.safetyDutyList.dto.tasklist.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 任务详情控制器
 * <p>
 * 提供任务详情的查询、新增、关闭、评分等接口，
 * 委托TaskListServiceI处理业务逻辑。
 */
@Api(tags = "任务详情")
@RequestMapping("/${application.gateway}/taskDetail")
@RestController
@AllArgsConstructor
public class TaskDetailController {
    /** 安全责任清单服务接口（任务详情相关操作统一通过该接口处理） */
    private final TaskListServiceI taskListService;

    @ApiOperation("获取任务列表（模板）")
    @PostMapping("/list")
    public PageResponse<TaskDetailCO> listPage(@Validated @RequestBody TaskDetailPageQry qry) {
        return taskListService.listTaskDetailPage(qry);
    }

    // 批量插入 - 此接口废弃
//    @ApiOperation("新增任务")
//    @PostMapping("/save")
//    public SingleResponse<TaskDetailCO> add(@Validated @RequestBody TaskDetailSaveCmd cmd) {
//        return taskListService.addTaskDetail(cmd);
//    }

    @ApiOperation("批量保存任务")
    @PostMapping("/saveBatch")
    public MultiResponse<TaskDetailCO> addBatch(@Validated @RequestBody List<TaskDetailSaveBatchCmd> cmds) {
        return taskListService.addTaskDetailBatch(cmds);
    }

//    @ApiOperation("编辑任务")
//    @PostMapping("/edit")
//    public SingleResponse<TaskDetailCO> edit(@Validated @RequestBody TaskDetailEditCmd cmd) {
//        return taskListService.editTaskDetail(cmd);
//    }

    @ApiOperation("获取任务详情")
    @GetMapping("/{detailId}")
    public SingleResponse<TaskDetailInfoCO> getByDetailId(@PathVariable String detailId) {
        return taskListService.getByTaskDetailId(detailId);
    }
}
