package com.zcloud.safetyDutyList.web.tasklist;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.safetyDutyList.api.tasklist.TaskListServiceI;
import com.zcloud.safetyDutyList.dto.clientobject.tasklist.*;
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.*;

/**
 * 执行反馈控制器
 * <p>
 * 提供反馈提交、反馈列表查询、反馈周期分组查询、反馈详情等接口，
 * 委托TaskListServiceI处理业务逻辑。
 */
@Api(tags = "执行反馈")
@RequestMapping("/${application.gateway}/feedback")
@RestController
@AllArgsConstructor
public class FeedbackController {
    /** 安全责任清单服务接口（反馈相关操作统一通过该接口处理） */
    private final TaskListServiceI taskListService;

    @ApiOperation("提交反馈")
    @PostMapping("/save")
    public SingleResponse<FeedbackCO> addFeedback(@Validated @RequestBody FeedbackAddCmd cmd) {
        return taskListService.addFeedback(cmd);
    }

    @ApiOperation("删除反馈")
    @PostMapping("/delete/{id}")
    public SingleResponse deleteFeedback(@PathVariable Long id) {
        return taskListService.deleteFeedback(id);
    }

    @ApiOperation("编辑反馈")
    @PostMapping("/edit")
    public SingleResponse<FeedbackCO> editFeedback(@Validated @RequestBody FeedbackEditCmd cmd) {
        return taskListService.editFeedback(cmd);
    }

    @ApiOperation("获取反馈周期分组列表")
    @PostMapping("/periodGroupList")
    public MultiResponse<FeedbackPeriodGroupCO> periodGroupList(@RequestBody FeedbackPeriodGroupQry qry) {
        return taskListService.feedbackPeriodGroupList(qry);
    }

    @ApiOperation("获取反馈列表")
    @PostMapping("/list")
    public PageResponse<FeedbackCO> feedbackList(@Validated @RequestBody FeedbackListQry qry) {
        return taskListService.feedbackPage(qry);
    }

    @ApiOperation("获取反馈详情")
    @GetMapping("/{feedbackId}")
    public SingleResponse<FeedbackCO> getByFeedbackId(@PathVariable String feedbackId) {
        return taskListService.getByFeedbackId(feedbackId);
    }

//    @ApiOperation("获取异常记录列表")
//    @PostMapping("/exception/list")
//    public PageResponse<FeedbackExceptionCO> exceptionPage(@RequestBody FeedbackExceptionPageQry qry) {
//        return taskListService.exceptionPage(qry);
//    }
}
