package cn.iocoder.yudao.module.qcreport.controller.admin.template;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.module.qcreport.controller.admin.template.vo.QcReportTemplatePageReqVO;
|
import cn.iocoder.yudao.module.qcreport.controller.admin.template.vo.QcReportTemplateRespVO;
|
import cn.iocoder.yudao.module.qcreport.controller.admin.template.vo.QcReportTemplateSaveReqVO;
|
import cn.iocoder.yudao.module.qcreport.dal.dataobject.template.QcReportTemplateDO;
|
import cn.iocoder.yudao.module.qcreport.service.template.QcReportTemplateService;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jakarta.annotation.Resource;
|
import jakarta.validation.Valid;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
@Tag(name = "管理后台 - 智能质检报告模板")
|
@RestController
|
@RequestMapping("/qc-report/template")
|
@Validated
|
public class QcReportTemplateController {
|
|
@Resource
|
private QcReportTemplateService templateService;
|
|
@PostMapping("/create")
|
@Operation(summary = "创建报告模板")
|
@PreAuthorize("@ss.hasPermission('qc-report:template:create')")
|
public CommonResult<Long> createTemplate(@Valid @RequestBody QcReportTemplateSaveReqVO createReqVO) {
|
return success(templateService.createTemplate(createReqVO));
|
}
|
|
@PutMapping("/update")
|
@Operation(summary = "更新报告模板")
|
@PreAuthorize("@ss.hasPermission('qc-report:template:update')")
|
public CommonResult<Boolean> updateTemplate(@Valid @RequestBody QcReportTemplateSaveReqVO updateReqVO) {
|
templateService.updateTemplate(updateReqVO);
|
return success(true);
|
}
|
|
@DeleteMapping("/delete")
|
@Operation(summary = "删除报告模板")
|
@Parameter(name = "id", description = "编号", required = true)
|
@PreAuthorize("@ss.hasPermission('qc-report:template:delete')")
|
public CommonResult<Boolean> deleteTemplate(@RequestParam("id") Long id) {
|
templateService.deleteTemplate(id);
|
return success(true);
|
}
|
|
@PostMapping("/copy")
|
@Operation(summary = "复制报告模板")
|
@Parameter(name = "id", description = "编号", required = true)
|
@PreAuthorize("@ss.hasPermission('qc-report:template:create')")
|
public CommonResult<Long> copyTemplate(@RequestParam("id") Long id) {
|
return success(templateService.copyTemplate(id));
|
}
|
|
@GetMapping("/get")
|
@Operation(summary = "获得报告模板")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@PreAuthorize("@ss.hasPermission('qc-report:template:query')")
|
public CommonResult<QcReportTemplateRespVO> getTemplate(@RequestParam("id") Long id) {
|
QcReportTemplateDO template = templateService.getTemplate(id);
|
return success(BeanUtils.toBean(template, QcReportTemplateRespVO.class));
|
}
|
|
@GetMapping("/page")
|
@Operation(summary = "获得报告模板分页")
|
@PreAuthorize("@ss.hasPermission('qc-report:template:query')")
|
public CommonResult<PageResult<QcReportTemplateRespVO>> getTemplatePage(@Valid QcReportTemplatePageReqVO pageReqVO) {
|
PageResult<QcReportTemplateDO> pageResult = templateService.getTemplatePage(pageReqVO);
|
return success(BeanUtils.toBean(pageResult, QcReportTemplateRespVO.class));
|
}
|
|
@GetMapping("/selectable")
|
@Operation(summary = "获得可用于出件的模板列表",
|
description = "三个条件同时满足才会返回:报告类型一致、模板已启用、当前版本已发布且画布有可渲染的内容。"
|
+ "最后一条挡的是「打开过设计器但没放组件」的版本——它渲染出来是一张白纸且不报错。")
|
@Parameter(name = "reportType", description = "报告类型,即 mes_qc_type 的数值字符串", required = true, example = "1")
|
@PreAuthorize("@ss.hasPermission('qc-report:template:query')")
|
public CommonResult<List<QcReportTemplateRespVO>> getSelectableTemplateList(
|
@RequestParam("reportType") String reportType) {
|
List<QcReportTemplateDO> list = templateService.getSelectableTemplates(reportType);
|
return success(BeanUtils.toBean(list, QcReportTemplateRespVO.class));
|
}
|
|
}
|