xiaoyi
3 天以前 abf1c0a35d85d38239ff5d2ed746a4e4b797c9d1
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
95
96
97
98
99
100
101
102
103
104
package cn.iocoder.yudao.module.mes.controller.admin.pd.product;
 
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.mes.controller.admin.pd.product.vo.MesPdProductAuditReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.pd.product.vo.MesPdProductPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.pd.product.vo.MesPdProductRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.pd.product.vo.MesPdProductSaveReqVO;
import cn.iocoder.yudao.module.mes.service.pd.product.MesPdProductService;
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.servlet.http.HttpServletResponse;
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.io.IOException;
 
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - MES 产品档案")
@RestController
@RequestMapping("/mes/pd/product")
@Validated
public class MesPdProductController {
 
    @Resource
    private MesPdProductService productService;
 
    @PostMapping("/create")
    @Operation(summary = "创建产品档案")
    @PreAuthorize("@ss.hasPermission('mes:pd-product:create')")
    public CommonResult<Long> createProduct(@Valid @RequestBody MesPdProductSaveReqVO createReqVO) {
        return success(productService.createProduct(createReqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "更新产品档案")
    @PreAuthorize("@ss.hasPermission('mes:pd-product:update')")
    public CommonResult<Boolean> updateProduct(@Valid @RequestBody MesPdProductSaveReqVO updateReqVO) {
        productService.updateProduct(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除产品档案")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:pd-product:delete')")
    public CommonResult<Boolean> deleteProduct(@RequestParam("id") Long id) {
        productService.deleteProduct(id);
        return success(true);
    }
 
    @GetMapping("/get")
    @Operation(summary = "获得产品档案")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('mes:pd-product:query')")
    public CommonResult<MesPdProductRespVO> getProduct(@RequestParam("id") Long id) {
        return success(productService.getProduct(id));
    }
 
    @GetMapping("/page")
    @Operation(summary = "获得产品档案分页")
    @PreAuthorize("@ss.hasPermission('mes:pd-product:query')")
    public CommonResult<PageResult<MesPdProductRespVO>> getProductPage(@Valid MesPdProductPageReqVO pageReqVO) {
        return success(productService.getProductPage(pageReqVO));
    }
 
    @GetMapping("/export-excel")
    @Operation(summary = "导出产品档案 Excel")
    @PreAuthorize("@ss.hasPermission('mes:pd-product:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportProductExcel(@Valid MesPdProductPageReqVO pageReqVO,
                                   HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        PageResult<MesPdProductRespVO> pageResult = productService.getProductPage(pageReqVO);
        ExcelUtils.write(response, "产品档案.xls", "数据", MesPdProductRespVO.class, pageResult.getList());
    }
 
    @PutMapping("/submit")
    @Operation(summary = "提交审批(未提交/驳回→审批中)")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:pd-product:submit')")
    public CommonResult<Boolean> submitProduct(@RequestParam("id") Long id) {
        productService.submitProduct(id);
        return success(true);
    }
 
    @PutMapping("/audit")
    @Operation(summary = "审批产品档案(审批中→通过/驳回)")
    @PreAuthorize("@ss.hasPermission('mes:pd-product:audit')")
    public CommonResult<Boolean> auditProduct(@Valid @RequestBody MesPdProductAuditReqVO auditReqVO) {
        productService.auditProduct(auditReqVO.getId(), auditReqVO.getPass(), auditReqVO.getAuditRemark());
        return success(true);
    }
 
}