4 小时以前 4d15fa8051884869c5b612d0641508874cc71811
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
105
106
107
108
109
110
package cn.iocoder.yudao.module.srm.controller.admin.apply;
 
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.srm.controller.admin.apply.vo.*;
import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierApplyDO;
import cn.iocoder.yudao.module.srm.service.apply.SrmSupplierApplyService;
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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - SRM 供应商准入")
@RestController
@RequestMapping("/srm/supplier-apply")
@Validated
public class SrmSupplierApplyController {
 
    @Resource
    private SrmSupplierApplyService applyService;
 
    @PostMapping("/create")
    @Operation(summary = "创建准入申请")
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:create')")
    public CommonResult<Long> createApply(@Valid @RequestBody SrmSupplierApplySaveReqVO createReqVO) {
        return success(applyService.createApply(createReqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "更新准入申请")
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:update')")
    public CommonResult<Boolean> updateApply(@Valid @RequestBody SrmSupplierApplySaveReqVO updateReqVO) {
        applyService.updateApply(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除准入申请")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:delete')")
    public CommonResult<Boolean> deleteApply(@RequestParam("id") Long id) {
        applyService.deleteApply(id);
        return success(true);
    }
 
    @GetMapping("/get")
    @Operation(summary = "获取准入申请详情")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:query')")
    public CommonResult<SrmSupplierApplyRespVO> getApply(@RequestParam("id") Long id) {
        return success(BeanUtils.toBean(applyService.getApply(id), SrmSupplierApplyRespVO.class));
    }
 
    @GetMapping("/page")
    @Operation(summary = "获取准入申请分页")
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:query')")
    public CommonResult<PageResult<SrmSupplierApplyRespVO>> getApplyPage(@Valid SrmSupplierApplyPageReqVO pageReqVO) {
        return success(BeanUtils.toBean(applyService.getApplyPage(pageReqVO), SrmSupplierApplyRespVO.class));
    }
 
    @PutMapping("/submit")
    @Operation(summary = "提交申请")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:update')")
    public CommonResult<Boolean> submitApply(@RequestParam("id") Long id) {
        applyService.submitApply(id);
        return success(true);
    }
 
    @PutMapping("/review-purchase")
    @Operation(summary = "采购审核")
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:update')")
    public CommonResult<Boolean> reviewPurchase(@Valid @RequestBody SrmSupplierApplyReviewReqVO reqVO) {
        applyService.reviewPurchase(reqVO.getId(), reqVO.getOpinion(), reqVO.getPassed());
        return success(true);
    }
 
    @PutMapping("/review-quality")
    @Operation(summary = "质量审核")
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:update')")
    public CommonResult<Boolean> reviewQuality(@Valid @RequestBody SrmSupplierApplyReviewReqVO reqVO) {
        applyService.reviewQuality(reqVO.getId(), reqVO.getOpinion(), reqVO.getPassed());
        return success(true);
    }
 
    @PutMapping("/review-finance")
    @Operation(summary = "财务审核")
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:update')")
    public CommonResult<Boolean> reviewFinance(@Valid @RequestBody SrmSupplierApplyReviewReqVO reqVO) {
        applyService.reviewFinance(reqVO.getId(), reqVO.getOpinion(), reqVO.getPassed());
        return success(true);
    }
 
    @PutMapping("/approve")
    @Operation(summary = "通过后自动创建供应商")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:update')")
    public CommonResult<Boolean> approve(@RequestParam("id") Long id) {
        applyService.approve(id);
        return success(true);
    }
 
}