|
| 1 | +package v1 |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "gin-vue-admin/global" |
| 6 | + "gin-vue-admin/model" |
| 7 | + "gin-vue-admin/model/request" |
| 8 | + "gin-vue-admin/model/response" |
| 9 | + "gin-vue-admin/service" |
| 10 | + "github.com/gin-gonic/gin" |
| 11 | +) |
| 12 | + |
| 13 | +// @Tags WorkflowProcess |
| 14 | +// @Summary 创建WorkflowProcess |
| 15 | +// @Security ApiKeyAuth |
| 16 | +// @accept application/json |
| 17 | +// @Produce application/json |
| 18 | +// @Param data body model.WorkflowProcess true "创建WorkflowProcess" |
| 19 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" |
| 20 | +// @Router /workflowProcess/createWorkflowProcess [post] |
| 21 | +func CreateWorkflowProcess(c *gin.Context) { |
| 22 | + var workflowProcess model.WorkflowProcess |
| 23 | + _ = c.ShouldBindJSON(&workflowProcess) |
| 24 | + err := service.CreateWorkflowProcess(workflowProcess) |
| 25 | + if err != nil { |
| 26 | + response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c) |
| 27 | + } else { |
| 28 | + response.OkWithMessage("创建成功", c) |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +// @Tags WorkflowProcess |
| 33 | +// @Summary 删除WorkflowProcess |
| 34 | +// @Security ApiKeyAuth |
| 35 | +// @accept application/json |
| 36 | +// @Produce application/json |
| 37 | +// @Param data body model.WorkflowProcess true "删除WorkflowProcess" |
| 38 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" |
| 39 | +// @Router /workflowProcess/deleteWorkflowProcess [delete] |
| 40 | +func DeleteWorkflowProcess(c *gin.Context) { |
| 41 | + var workflowProcess model.WorkflowProcess |
| 42 | + _ = c.ShouldBindJSON(&workflowProcess) |
| 43 | + err := service.DeleteWorkflowProcess(workflowProcess) |
| 44 | + if err != nil { |
| 45 | + response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c) |
| 46 | + } else { |
| 47 | + response.OkWithMessage("删除成功", c) |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +// @Tags WorkflowProcess |
| 52 | +// @Summary 批量删除WorkflowProcess |
| 53 | +// @Security ApiKeyAuth |
| 54 | +// @accept application/json |
| 55 | +// @Produce application/json |
| 56 | +// @Param data body request.IdsReq true "批量删除WorkflowProcess" |
| 57 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}" |
| 58 | +// @Router /workflowProcess/deleteWorkflowProcessByIds [delete] |
| 59 | +func DeleteWorkflowProcessByIds(c *gin.Context) { |
| 60 | + var IDS request.IdsReq |
| 61 | + _ = c.ShouldBindJSON(&IDS) |
| 62 | + err := service.DeleteWorkflowProcessByIds(IDS) |
| 63 | + if err != nil { |
| 64 | + response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c) |
| 65 | + } else { |
| 66 | + response.OkWithMessage("删除成功", c) |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +// @Tags WorkflowProcess |
| 71 | +// @Summary 更新WorkflowProcess |
| 72 | +// @Security ApiKeyAuth |
| 73 | +// @accept application/json |
| 74 | +// @Produce application/json |
| 75 | +// @Param data body model.WorkflowProcess true "更新WorkflowProcess" |
| 76 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" |
| 77 | +// @Router /workflowProcess/updateWorkflowProcess [put] |
| 78 | +func UpdateWorkflowProcess(c *gin.Context) { |
| 79 | + var workflowProcess model.WorkflowProcess |
| 80 | + _ = c.ShouldBindJSON(&workflowProcess) |
| 81 | + err := service.UpdateWorkflowProcess(&workflowProcess) |
| 82 | + if err != nil { |
| 83 | + response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c) |
| 84 | + } else { |
| 85 | + response.OkWithMessage("更新成功", c) |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +// @Tags WorkflowProcess |
| 90 | +// @Summary 用id查询WorkflowProcess |
| 91 | +// @Security ApiKeyAuth |
| 92 | +// @accept application/json |
| 93 | +// @Produce application/json |
| 94 | +// @Param data body model.WorkflowProcess true "用id查询WorkflowProcess" |
| 95 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" |
| 96 | +// @Router /workflowProcess/findWorkflowProcess [get] |
| 97 | +func FindWorkflowProcess(c *gin.Context) { |
| 98 | + var workflowProcess model.WorkflowProcess |
| 99 | + _ = c.ShouldBindQuery(&workflowProcess) |
| 100 | + err, reworkflowProcess := service.GetWorkflowProcess(workflowProcess.ID) |
| 101 | + if err != nil { |
| 102 | + response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c) |
| 103 | + } else { |
| 104 | + response.OkWithData(gin.H{"reworkflowProcess": reworkflowProcess}, c) |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +// @Tags WorkflowProcess |
| 109 | +// @Summary 用id查询工作流步骤 |
| 110 | +// @Security ApiKeyAuth |
| 111 | +// @accept application/json |
| 112 | +// @Produce application/json |
| 113 | +// @Param data body model.WorkflowProcess true "用id查询WorkflowProcess" |
| 114 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" |
| 115 | +// @Router /workflowProcess/findWorkflowStep [get] |
| 116 | +func FindWorkflowStep(c *gin.Context) { |
| 117 | + var workflowProcess model.WorkflowProcess |
| 118 | + _ = c.ShouldBindQuery(&workflowProcess) |
| 119 | + err, workflow := service.FindWorkflowStep(workflowProcess.ID) |
| 120 | + if err != nil { |
| 121 | + response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c) |
| 122 | + } else { |
| 123 | + response.OkWithData(gin.H{"workflow": workflow}, c) |
| 124 | + } |
| 125 | +} |
| 126 | + |
| 127 | +// @Tags WorkflowProcess |
| 128 | +// @Summary 分页获取WorkflowProcess列表 |
| 129 | +// @Security ApiKeyAuth |
| 130 | +// @accept application/json |
| 131 | +// @Produce application/json |
| 132 | +// @Param data body request.WorkflowProcessSearch true "分页获取WorkflowProcess列表" |
| 133 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" |
| 134 | +// @Router /workflowProcess/getWorkflowProcessList [get] |
| 135 | +func GetWorkflowProcessList(c *gin.Context) { |
| 136 | + var pageInfo request.WorkflowProcessSearch |
| 137 | + _ = c.ShouldBindQuery(&pageInfo) |
| 138 | + err, list, total := service.GetWorkflowProcessInfoList(pageInfo) |
| 139 | + if err != nil { |
| 140 | + response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c) |
| 141 | + } else { |
| 142 | + response.OkWithData(response.PageResult{ |
| 143 | + List: list, |
| 144 | + Total: total, |
| 145 | + Page: pageInfo.Page, |
| 146 | + PageSize: pageInfo.PageSize, |
| 147 | + }, c) |
| 148 | + } |
| 149 | +} |
| 150 | + |
| 151 | +// @Tags WorkflowProcess |
| 152 | +// @Summary 开启工作流 |
| 153 | +// @Security ApiKeyAuth |
| 154 | +// @accept application/json |
| 155 | +// @Produce application/json |
| 156 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" |
| 157 | +// @Router /workflowProcess/startWorkflow [post] |
| 158 | +func StartWorkflow(c *gin.Context) { |
| 159 | + business := c.Query("businessType") |
| 160 | + wfInfo := model.WorkflowBusinessStruct[business]() |
| 161 | + c.ShouldBindJSON(wfInfo) |
| 162 | + err := service.StartWorkflow(wfInfo) |
| 163 | + if err != nil { |
| 164 | + response.FailWithMessage(err.Error(), c) |
| 165 | + return |
| 166 | + } |
| 167 | + response.OkWithMessage("启动成功", c) |
| 168 | +} |
| 169 | + |
| 170 | +// @Tags WorkflowProcess |
| 171 | +// @Summary 提交工作流 |
| 172 | +// @Security ApiKeyAuth |
| 173 | +// @accept application/json |
| 174 | +// @Produce application/json |
| 175 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" |
| 176 | +// @Router /workflowProcess/completeWorkflowMove [post] |
| 177 | +func CompleteWorkflowMove(c *gin.Context) { |
| 178 | + business := c.Query("businessType") |
| 179 | + wfInfo := model.WorkflowBusinessStruct[business]() |
| 180 | + c.ShouldBindJSON(wfInfo) |
| 181 | + err := service.CompleteWorkflowMove(wfInfo) |
| 182 | + if err != nil { |
| 183 | + response.FailWithMessage(err.Error(), c) |
| 184 | + return |
| 185 | + } |
| 186 | + response.OkWithMessage("启动成功", c) |
| 187 | +} |
| 188 | + |
| 189 | +// @Tags WorkflowProcess |
| 190 | +// @Summary 我发起的工作流 |
| 191 | +// @Security ApiKeyAuth |
| 192 | +// @accept application/json |
| 193 | +// @Produce application/json |
| 194 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" |
| 195 | +// @Router /workflowProcess/getMyStated [get] |
| 196 | +func GetMyStated(c *gin.Context) { |
| 197 | + if claims, exists := c.Get("claims"); !exists { |
| 198 | + errStr := "从Gin的Context中获取从jwt解析出来的用户ID失败, 请检查路由是否使用jwt中间件" |
| 199 | + global.GVA_LOG.Error(errStr) |
| 200 | + response.FailWithMessage(errStr, c) |
| 201 | + } else { |
| 202 | + waitUse := claims.(*request.CustomClaims) |
| 203 | + err, wfms := service.GetMyStated(waitUse.ID) |
| 204 | + if err != nil { |
| 205 | + errStr := err.Error() |
| 206 | + global.GVA_LOG.Error(errStr) |
| 207 | + response.FailWithMessage(errStr, c) |
| 208 | + return |
| 209 | + } |
| 210 | + response.OkWithData(gin.H{"wfms": wfms}, c) |
| 211 | + } |
| 212 | +} |
| 213 | + |
| 214 | +// @Tags WorkflowProcess |
| 215 | +// @Summary 我的待办 |
| 216 | +// @Security ApiKeyAuth |
| 217 | +// @accept application/json |
| 218 | +// @Produce application/json |
| 219 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" |
| 220 | +// @Router /workflowProcess/getMyNeed [get] |
| 221 | +func GetMyNeed(c *gin.Context) { |
| 222 | + if claims, exists := c.Get("claims"); !exists { |
| 223 | + errStr := "从Gin的Context中获取从jwt解析出来的用户ID失败, 请检查路由是否使用jwt中间件" |
| 224 | + global.GVA_LOG.Error(errStr) |
| 225 | + response.FailWithMessage(errStr, c) |
| 226 | + } else { |
| 227 | + waitUse := claims.(*request.CustomClaims) |
| 228 | + err, wfms := service.GetMyNeed(waitUse.ID, waitUse.AuthorityId) |
| 229 | + if err != nil { |
| 230 | + errStr := err.Error() |
| 231 | + global.GVA_LOG.Error(errStr) |
| 232 | + response.FailWithMessage(errStr, c) |
| 233 | + return |
| 234 | + } |
| 235 | + response.OkWithData(gin.H{"wfms": wfms}, c) |
| 236 | + } |
| 237 | +} |
| 238 | + |
| 239 | +// @Tags WorkflowProcess |
| 240 | +// @Summary 根据id获取当前节点详情和历史 |
| 241 | +// @Security ApiKeyAuth |
| 242 | +// @accept application/json |
| 243 | +// @Produce application/json |
| 244 | +// @Param data body request.GetById true "根据id获取当前节点详情和过往" |
| 245 | +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" |
| 246 | +// @Router /workflowProcess/getWorkflowMoveByID [get] |
| 247 | +func GetWorkflowMoveByID(c *gin.Context) { |
| 248 | + var req request.GetById |
| 249 | + _ = c.ShouldBindQuery(&req) |
| 250 | + err, move, moves, business := service.GetWorkflowMoveByID(req.Id) |
| 251 | + if err != nil { |
| 252 | + errStr := err.Error() |
| 253 | + global.GVA_LOG.Error(errStr) |
| 254 | + response.FailWithMessage(errStr, c) |
| 255 | + return |
| 256 | + } |
| 257 | + response.OkWithData(gin.H{"move": move, "moves": moves, "business": business}, c) |
| 258 | +} |
0 commit comments