liu
昨天 dd69dd49c98e2d8fdd9b1c77e97923bde0d57b57
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
111
112
113
114
115
package cn.iocoder.yudao.module.bpm.controller.admin.definition;
 
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.bpm.controller.admin.definition.vo.autoapprove.BpmProcessAutoApproveConfigPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.autoapprove.BpmProcessAutoApproveConfigRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.autoapprove.BpmProcessAutoApproveConfigSaveReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessAutoApproveConfigDO;
import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessAutoApproveService;
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;
 
/**
 * BPM 流程免审批配置 Controller
 *
 * 用于按流程控制「是否跳过 OA 审批」:开关开启后,单据提交时流程照常实例化,
 * 但所有人工审核节点由引擎自动通过,下游业务动作不受影响。
 *
 * @author 超级管理员
 */
@Tag(name = "管理后台 - BPM 流程免审批配置")
@RestController
@RequestMapping("/bpm/process-auto-approve")
@Validated
public class BpmProcessAutoApproveController {
 
    @Resource
    private BpmProcessAutoApproveService processAutoApproveService;
 
    @PutMapping("/update-by-key")
    @Operation(summary = "按流程定义的 Key 设置免审批开关",
            description = "不存在则新增、存在则更新,供流程列表的行内开关直接调用")
    @Parameter(name = "processDefinitionKey", description = "流程定义的 Key", required = true, example = "purchase_request_approve")
    @Parameter(name = "autoApprove", description = "是否免审批", required = true, example = "true")
    @Parameter(name = "remark", description = "备注", example = "该流程暂不上 OA")
    @PreAuthorize("@ss.hasPermission('bpm:process-auto-approve:update')")
    public CommonResult<Boolean> updateAutoApproveByKey(@RequestParam("processDefinitionKey") String processDefinitionKey,
                                                        @RequestParam("autoApprove") Boolean autoApprove,
                                                        @RequestParam(value = "remark", required = false) String remark) {
        processAutoApproveService.updateAutoApproveByKey(processDefinitionKey, autoApprove, remark);
        return success(true);
    }
 
    @PutMapping("/update-global")
    @Operation(summary = "设置全局免审批总开关",
            description = "开启后所有流程一律免审批(优先于各流程自己的开关);关闭后恢复为按各流程自己的开关判定")
    @Parameter(name = "autoApprove", description = "是否开启全局免审批", required = true, example = "true")
    @Parameter(name = "remark", description = "备注", example = "全部流程暂不上 OA")
    @PreAuthorize("@ss.hasPermission('bpm:process-auto-approve:update')")
    public CommonResult<Boolean> updateGlobalAutoApprove(@RequestParam("autoApprove") Boolean autoApprove,
                                                         @RequestParam(value = "remark", required = false) String remark) {
        processAutoApproveService.updateGlobalAutoApprove(autoApprove, remark);
        return success(true);
    }
 
    @GetMapping("/global")
    @Operation(summary = "获得全局免审批总开关状态")
    @PreAuthorize("@ss.hasPermission('bpm:process-auto-approve:query')")
    public CommonResult<Boolean> getGlobalAutoApprove() {
        return success(processAutoApproveService.isGlobalAutoApprove());
    }
 
    @GetMapping("/list")
    @Operation(summary = "获得全部免审批配置", description = "供前端一次性拉取「流程 Key -> 是否免审批」的映射")
    @PreAuthorize("@ss.hasPermission('bpm:process-auto-approve:query')")
    public CommonResult<List<BpmProcessAutoApproveConfigRespVO>> getConfigList() {
        List<BpmProcessAutoApproveConfigDO> list = processAutoApproveService.getConfigList();
        return success(BeanUtils.toBean(list, BpmProcessAutoApproveConfigRespVO.class));
    }
 
    @GetMapping("/page")
    @Operation(summary = "获得免审批配置分页")
    @PreAuthorize("@ss.hasPermission('bpm:process-auto-approve:query')")
    public CommonResult<PageResult<BpmProcessAutoApproveConfigRespVO>> getConfigPage(
            @Valid BpmProcessAutoApproveConfigPageReqVO pageReqVO) {
        PageResult<BpmProcessAutoApproveConfigDO> pageResult = processAutoApproveService.getConfigPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, BpmProcessAutoApproveConfigRespVO.class));
    }
 
    @PostMapping("/create")
    @Operation(summary = "创建免审批配置")
    @PreAuthorize("@ss.hasPermission('bpm:process-auto-approve:update')")
    public CommonResult<Long> createConfig(@Valid @RequestBody BpmProcessAutoApproveConfigSaveReqVO createReqVO) {
        return success(processAutoApproveService.createConfig(createReqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "更新免审批配置")
    @PreAuthorize("@ss.hasPermission('bpm:process-auto-approve:update')")
    public CommonResult<Boolean> updateConfig(@Valid @RequestBody BpmProcessAutoApproveConfigSaveReqVO updateReqVO) {
        processAutoApproveService.updateConfig(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除免审批配置", description = "删除后该流程恢复为正常人工审批")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('bpm:process-auto-approve:update')")
    public CommonResult<Boolean> deleteConfig(@RequestParam("id") Long id) {
        processAutoApproveService.deleteConfig(id);
        return success(true);
    }
 
}