|
1 | 1 | package com.codingapi.example.api.meta; |
2 | 2 |
|
3 | 3 | import com.codingapi.example.app.cmd.meta.pojo.FlowCmd; |
4 | | -import com.codingapi.example.infra.flow.user.FlowUserRepository; |
| 4 | +import com.codingapi.example.app.cmd.meta.service.FlowRecordRouter; |
5 | 5 | import com.codingapi.springboot.flow.pojo.FlowResult; |
6 | 6 | import com.codingapi.springboot.flow.pojo.FlowStepResult; |
7 | 7 | import com.codingapi.springboot.flow.pojo.FlowSubmitResult; |
8 | 8 | import com.codingapi.springboot.flow.result.MessageResult; |
9 | | -import com.codingapi.springboot.flow.service.FlowService; |
10 | | -import com.codingapi.springboot.flow.user.IFlowOperator; |
11 | 9 | import com.codingapi.springboot.framework.dto.response.Response; |
12 | 10 | import com.codingapi.springboot.framework.dto.response.SingleResponse; |
13 | 11 | import lombok.AllArgsConstructor; |
|
23 | 21 | @AllArgsConstructor |
24 | 22 | public class FlowRecordCmdController { |
25 | 23 |
|
26 | | - private final FlowService flowService; |
27 | | - private final FlowUserRepository flowUserRepository; |
| 24 | + private final FlowRecordRouter flowRecordRouter; |
28 | 25 |
|
29 | 26 | @PostMapping("/startFlow") |
30 | 27 | public SingleResponse<FlowResult> startFlow(@RequestBody FlowCmd.StartFlow request) { |
31 | | - IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName()); |
32 | | - return SingleResponse.of(flowService.startFlow(request.getWorkCode(), current, request.getBindData(), request.getAdvice())); |
| 28 | + return SingleResponse.of(flowRecordRouter.startFlow(request)); |
33 | 29 | } |
34 | 30 |
|
35 | 31 | @PostMapping("/getFlowStep") |
36 | 32 | public SingleResponse<FlowStepResult> getFlowStep(@RequestBody FlowCmd.FlowStep request) { |
37 | | - IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName()); |
38 | | - return SingleResponse.of(flowService.getFlowStep(request.getWorkCode(), request.getBindData(), current)); |
| 33 | + return SingleResponse.of(flowRecordRouter.getFlowStep(request)); |
39 | 34 | } |
40 | 35 |
|
41 | | - |
42 | 36 | @PostMapping("/trySubmitFlow") |
43 | 37 | public SingleResponse<FlowSubmitResult> trySubmitFlow(@RequestBody FlowCmd.SubmitFlow request) { |
44 | | - IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName()); |
45 | | - if (request.getRecordId() > 0) { |
46 | | - return SingleResponse.of(flowService.trySubmitFlow(request.getRecordId(), current, request.getBindData(), request.getOpinion())); |
47 | | - } else { |
48 | | - return SingleResponse.of(flowService.trySubmitFlow(request.getWorkCode(), current, request.getBindData(), request.getOpinion())); |
49 | | - } |
| 38 | + return SingleResponse.of(flowRecordRouter.trySubmitFlow(request)); |
50 | 39 | } |
51 | 40 |
|
52 | | - |
53 | 41 | @PostMapping("/submitFlow") |
54 | 42 | public SingleResponse<FlowResult> submitFlow(@RequestBody FlowCmd.SubmitFlow request) { |
55 | | - IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName()); |
56 | | - if (current.isFlowManager()) { |
57 | | - return SingleResponse.of(flowService.interfere(request.getRecordId(), current, request.getBindData(), request.getOpinion())); |
58 | | - } else { |
59 | | - return SingleResponse.of(flowService.submitFlow(request.getRecordId(), current, request.getBindData(), request.getOpinion())); |
60 | | - } |
| 43 | + return SingleResponse.of(flowRecordRouter.submitFlow(request)); |
61 | 44 | } |
62 | 45 |
|
63 | 46 | @PostMapping("/custom") |
64 | 47 | public SingleResponse<MessageResult> customFlowEvent(@RequestBody FlowCmd.CustomFlow request) { |
65 | | - IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName()); |
66 | | - return SingleResponse.of(flowService.customFlowEvent(request.getRecordId(), current, request.getButtonId(), request.getBindData(), request.getOpinion())); |
| 48 | + return SingleResponse.of(flowRecordRouter.customFlowEvent(request)); |
67 | 49 | } |
68 | 50 |
|
69 | | - |
70 | 51 | @PostMapping("/save") |
71 | 52 | public Response save(@RequestBody FlowCmd.SaveFlow request) { |
72 | | - IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName()); |
73 | | - flowService.save(request.getRecordId(), current, request.getBindData(), request.getAdvice()); |
| 53 | + flowRecordRouter.save(request); |
74 | 54 | return Response.buildSuccess(); |
75 | 55 | } |
76 | 56 |
|
77 | 57 | @PostMapping("/recall") |
78 | 58 | public Response recall(@RequestBody FlowCmd.RecallFlow request) { |
79 | | - IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName()); |
80 | | - flowService.recall(request.getRecordId(), current); |
| 59 | + flowRecordRouter.recall(request); |
81 | 60 | return Response.buildSuccess(); |
82 | 61 | } |
83 | 62 |
|
84 | | - |
85 | 63 | @PostMapping("/transfer") |
86 | 64 | public Response transfer(@RequestBody FlowCmd.TransferFlow request) { |
87 | | - IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName()); |
88 | | - IFlowOperator target = flowUserRepository.getFlowOperatorById(request.getTargetUserId()); |
89 | | - flowService.transfer(request.getRecordId(), current, target, request.getBindData(), request.getAdvice()); |
| 65 | + flowRecordRouter.transfer(request); |
90 | 66 | return Response.buildSuccess(); |
91 | 67 | } |
92 | 68 |
|
93 | | - |
94 | 69 | @PostMapping("/postponed") |
95 | 70 | public Response postponed(@RequestBody FlowCmd.PostponedFlow request) { |
96 | | - IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName()); |
97 | | - flowService.postponed(request.getRecordId(), current, request.getTimeOut()); |
| 71 | + flowRecordRouter.postponed(request); |
98 | 72 | return Response.buildSuccess(); |
99 | 73 | } |
100 | 74 |
|
101 | | - |
102 | 75 | @PostMapping("/urge") |
103 | 76 | public Response urge(@RequestBody FlowCmd.UrgeFlow request) { |
104 | | - IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName()); |
105 | | - flowService.urge(request.getRecordId(), current); |
| 77 | + flowRecordRouter.urge(request); |
106 | 78 | return Response.buildSuccess(); |
107 | 79 | } |
108 | 80 |
|
109 | | - |
110 | 81 | @PostMapping("/remove") |
111 | 82 | public Response remove(@RequestBody FlowCmd.RemoveFlow request) { |
112 | | - IFlowOperator current = flowUserRepository.getUserByUsername(request.getUserName()); |
113 | | - flowService.remove(request.getRecordId(), current); |
| 83 | + flowRecordRouter.remove(request); |
114 | 84 | return Response.buildSuccess(); |
115 | 85 | } |
116 | 86 |
|
|
0 commit comments