package com.hz.pm.api.projectdeclared.controller;

import com.hz.pm.api.projectdeclared.manage.ReviewChecklistManage;
import com.hz.pm.api.projectdeclared.model.dto.ReviewChecklistApproveDTO;
import com.hz.pm.api.projectlib.model.req.ProjectListReq;
import com.hz.pm.api.projectlib.model.vo.ProjectReviewCheckListItemVO;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.log.annotation.WebLog;
import com.wflow.bean.dto.FormsReviewChecklistDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Classname ReviewChecklistController
 * @Description
 * @Date 2023/11/7 17:00
 * @Author PoffyZhang
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/review-checklist")
@Api(value = "Review-Checklist", tags = "审查清单")
@RequiredArgsConstructor
public class ReviewChecklistController {

    private final ReviewChecklistManage reviewChecklistManage;

    @ApiOperation(value = "建设方案后审查清单", notes = "建设方案后审查清单")
    @GetMapping("/list")
    public PageVo<ProjectReviewCheckListItemVO> list(@ModelAttribute ProjectListReq req) {
        return reviewChecklistManage.projectLibList(req);
    }

    @ApiOperation(value = "审查清单审核", notes = "审查清单审核")
    @PostMapping("/approve")
    @WebLog("审查清单审核")
    public String approve(@RequestBody List<ReviewChecklistApproveDTO> dtos) {
        return reviewChecklistManage.approve(dtos);
    }

    @ApiOperation(value = "查看某个项目的意见汇总", notes = "查看某个项目的意见汇总")
    @GetMapping("/summary-list/{projectCode}")
    public List<FormsReviewChecklistDto> summaryList(@PathVariable String projectCode) {
        return reviewChecklistManage.summaryList(projectCode);
    }

    @ApiOperation(value = "意见汇总提交", notes = "意见汇总提交")
    @PostMapping("/summary/{projectCode}")
    @WebLog("意见汇总提交")
    public String summary(@PathVariable String projectCode) {
        return reviewChecklistManage.summary(projectCode);
    }
}
