liu
23 小时以前 a08832337f8de6a53edebbab1fb0b5a3bd1785aa
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
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 java.util.List;
import java.util.Map;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 
@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 = "提交准入申请审批(启动协同办公流程)")
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:update')")
    public CommonResult<Boolean> submitApply(@RequestParam("id") Long id,
                                             @RequestParam("processDefinitionKey") String processDefinitionKey) {
        applyService.submitApply(id, processDefinitionKey, getLoginUserId());
        return success(true);
    }
 
    @GetMapping("/approve-process-list")
    @Operation(summary = "获取准入申请审批流程列表")
    @PreAuthorize("@ss.hasPermission('srm:supplier-apply:query')")
    public CommonResult<List<Map<String, Object>>> getApproveProcessList() {
        return success(applyService.getSupplierApplyApproveProcessDefinitionList());
    }
 
}