package com.changhu.module.miniProgram.controller;

import com.changhu.common.annotation.CheckUserType;
import com.changhu.common.annotation.JsonBody;
import com.changhu.common.db.enums.EnterprisesUnitType;
import com.changhu.common.db.enums.UserType;
import com.changhu.common.pojo.vo.SelectNodeVo;
import com.changhu.module.miniProgram.pojo.params.AssessmentRecordParams;
import com.changhu.module.miniProgram.pojo.vo.AssessmentCriteriaRuleVo;
import com.changhu.module.miniProgram.service.SupervisionAssessmentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 20252
 * @createTime 2024/11/22 下午2:47
 * @desc SupervisionAssessmentController...
 */
@Tag(name = "微信小程序-监督考核")
@JsonBody
@RequestMapping("/mp/sa")
@CheckUserType(userTypes = UserType.MINI_PROGRAM_POLICE)
@RestController
public class SupervisionAssessmentController {

    @Autowired
    private SupervisionAssessmentService supervisionAssessmentService;

    @Operation(summary = "根据类型获取考核项目列表")
    @GetMapping("/ckProjectListByType")
    public List<SelectNodeVo<Long>> ckProjectListByType(@RequestParam EnterprisesUnitType type) {
        return supervisionAssessmentService.assessmentCriteriaListByType(type);
    }

    @Operation(summary = "根据考核项目获取考核规则")
    @GetMapping("/assessmentCriteriaRulesByCkProjectId")
    public List<AssessmentCriteriaRuleVo> assessmentCriteriaRulesByCkProjectId(@RequestParam Long ckProjectId) {
        return supervisionAssessmentService.assessmentCriteriaRulesByCkProjectId(ckProjectId);
    }

    @Operation(summary = "提交考核记录")
    @PostMapping("/submitAssessmentRecord")
    public void submitAssessmentRecord(@Validated @RequestBody AssessmentRecordParams params) {
        supervisionAssessmentService.submitAssessmentRecord(params);
    }
}
