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

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.dal.dataobject.biz.EvaluationTemplatesConfigDO;
import cn.iocoder.yudao.module.system.service.biz.EvaluationTemplatesConfigService;
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 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/evaluationTemplatesConfig")
@Validated
public class EvaluationTemplatesConfigController {

    @Resource
    private EvaluationTemplatesConfigService evaluationTemplatesConfigService;

    @PostMapping("/create")
    @Operation(summary = "创建评估问卷模板能力得分配置")
    public CommonResult<Long> createEvaluationTemplatesConfig(@RequestBody EvaluationTemplatesConfigDO createReqVO) {
        return success(evaluationTemplatesConfigService.createEvaluationTemplatesConfig(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新评估问卷模板能力得分配置")
    public CommonResult<Boolean> updateEvaluationTemplatesConfig(@RequestBody EvaluationTemplatesConfigDO updateReqVO) {
        evaluationTemplatesConfigService.updateEvaluationTemplatesConfig(updateReqVO);
        return success(true);
    }

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


    @GetMapping("/get")
    @Operation(summary = "获得评估问卷能力得分配置")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<EvaluationTemplatesConfigDO> getEvaluationTemplatesConfig(@RequestParam("id") Long id) {
        EvaluationTemplatesConfigDO evaluationTemplatesConfig = evaluationTemplatesConfigService.getEvaluationTemplatesConfig(id);
        return success(evaluationTemplatesConfig);
    }

    @GetMapping("/getEvaluationTemplatesConfigList")
    @Operation(summary = "获取评估问卷模板列表")
    public  CommonResult<List<EvaluationTemplatesConfigDO>> getEvaluationTemplatesConfigList(@RequestParam("evaluationTemplateId") Long evaluationTemplateId ){
        return success(evaluationTemplatesConfigService.getEvaluationTemplatesConfigList(evaluationTemplateId));
    }

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

}