package cn.iocoder.yudao.module.system.controller.admin.biz;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.dal.dataobject.biz.EvaluationProcessConfigDO;
import cn.iocoder.yudao.module.system.service.biz.EvaluationProcessConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


@Tag(name = "管理后台 - 能力评估配置")
@RestController
@RequestMapping("/sys/evaluationProcessConfig")
@Validated
public class EvaluationProcessConfigController {

    @Resource
    private EvaluationProcessConfigService evaluationProcessConfigService;

    @PostMapping("/create")
    @Operation(summary = "创建能力评估配置")
    public CommonResult<Long> createEvaluationProcessConfig(@Valid @RequestBody EvaluationProcessConfigDO createReqVO) {
        return success(evaluationProcessConfigService.createEvaluationProcessConfig(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新能力评估配置")
    public CommonResult<Boolean> updateEvaluationProcessConfig(@Valid @RequestBody EvaluationProcessConfigDO updateReqVO) {
        evaluationProcessConfigService.updateEvaluationProcessConfig(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除能力评估配置")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Boolean> deleteEvaluationProcessConfig(@RequestParam("id") Long id) {
        evaluationProcessConfigService.deleteEvaluationProcessConfig(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得能力评估配置")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<EvaluationProcessConfigDO> getEvaluationProcessConfig(@RequestParam("id") Long id) {
        EvaluationProcessConfigDO evaluationProcessConfig = evaluationProcessConfigService.getEvaluationProcessConfig(id);
        return success(evaluationProcessConfig);
    }



    @GetMapping("/getEvaluationProcessConfigList")
    @Operation(summary = "获取能力评估配置列表")
    @Parameter(name = "evaluationProcessId", description = "评估表Id", required = true, example = "1024")
    public CommonResult<List<EvaluationProcessConfigDO>> getEvaluationProcessConfigList(@RequestParam("evaluationProcessId") Long evaluationProcessId){
        return success(evaluationProcessConfigService.getEvaluationProcessConfigList(evaluationProcessId));
    }




//    @GetMapping("/page")
//    @Operation(summary = "获得能力评估配置分页")
//    @PreAuthorize("@ss.hasPermission('sys:evaluation-process-config:query')")
//    public CommonResult<PageResult<EvaluationProcessConfigRespVO>> getEvaluationProcessConfigPage(@Valid EvaluationProcessConfigPageReqVO pageReqVO) {
//        PageResult<EvaluationProcessConfigDO> pageResult = evaluationProcessConfigService.getEvaluationProcessConfigPage(pageReqVO);
//        return success(BeanUtils.toBean(pageResult, EvaluationProcessConfigRespVO.class));
//    }
//
//    @GetMapping("/export-excel")
//    @Operation(summary = "导出能力评估配置 Excel")
//    @PreAuthorize("@ss.hasPermission('sys:evaluation-process-config:export')")
//    @ApiAccessLog(operateType = EXPORT)
//    public void exportEvaluationProcessConfigExcel(@Valid EvaluationProcessConfigPageReqVO pageReqVO,
//              HttpServletResponse response) throws IOException {
//        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
//        List<EvaluationProcessConfigDO> list = evaluationProcessConfigService.getEvaluationProcessConfigPage(pageReqVO).getList();
//        // 导出 Excel
//        ExcelUtils.write(response, "能力评估配置.xls", "数据", EvaluationProcessConfigRespVO.class,
//                        BeanUtils.toBean(list, EvaluationProcessConfigRespVO.class));
//    }

}