9 小时以前 9bad721754fe8bbe2e5f459d0706e0fefac569f3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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));
    }
 
}