Skip to content

Commit 34e6ccc

Browse files
committed
Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev
2 parents e957e5e + e102f82 commit 34e6ccc

File tree

143 files changed

+9531
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+9531
-257
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ swag init
320320

321321
- [ ] 导入,导出Excel
322322
- [ ] Echart图表支持
323-
- [ ] 工作流,任务交接功能开发
324323
- [ ] 单独前端使用模式以及数据模拟
325324

326325
## 7. 知识库

server/api/v1/sys_work_flow.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

server/api/v1/wk_process.go

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
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+
}

server/cmd/datas/apis.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ var Apis = []model.SysApi{
7777
{global.GVA_MODEL{ID: 65, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserInfo", "设置用户信息", "user", "PUT"},
7878
{global.GVA_MODEL{ID: 66, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getServerInfo", "获取服务器信息", "system", "POST"},
7979
{global.GVA_MODEL{ID: 67, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/email/emailTest", "发送测试邮件", "email", "POST"},
80+
{global.GVA_MODEL{ID: 68, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/createWorkflowProcess", "新建工作流", "workflowProcess", "POST"},
81+
{global.GVA_MODEL{ID: 69, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/deleteWorkflowProcess", "删除工作流", "workflowProcess", "DELETE"},
82+
{global.GVA_MODEL{ID: 70, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/deleteWorkflowProcessByIds", "批量删除工作流", "workflowProcess", "DELETE"},
83+
{global.GVA_MODEL{ID: 71, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/updateWorkflowProcess", "更新工作流", "workflowProcess", "PUT"},
84+
{global.GVA_MODEL{ID: 72, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/findWorkflowProcess", "根据ID获取工作流", "workflowProcess", "GET"},
85+
{global.GVA_MODEL{ID: 73, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/getWorkflowProcessList", "获取工作流", "workflowProcess", "GET"},
86+
{global.GVA_MODEL{ID: 74, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/findWorkflowStep", "获取工作流步骤", "workflowProcess", "GET"},
87+
{global.GVA_MODEL{ID: 75, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/startWorkflow", "启动工作流", "workflowProcess", "POST"},
88+
{global.GVA_MODEL{ID: 76, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/getMyStated", "获取我发起的工作流", "workflowProcess", "GET"},
89+
{global.GVA_MODEL{ID: 77, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/getMyNeed", "获取我的待办", "workflowProcess", "GET"},
90+
{global.GVA_MODEL{ID: 78, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/getWorkflowMoveByID", "根据id获取当前节点详情和历史", "workflowProcess", "GET"},
91+
{global.GVA_MODEL{ID: 79, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/completeWorkflowMove", "提交工作流", "workflowProcess", "POST"},
8092
}
8193

8294
func InitSysApi(db *gorm.DB) {

server/cmd/datas/authority_menus.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ var AuthorityMenus = []SysAuthorityMenus{
3939
{"888", 25},
4040
{"888", 26},
4141
{"888", 27},
42+
{"888", 28},
43+
{"888", 29},
44+
{"888", 30},
45+
{"888", 31},
46+
{"888", 32},
47+
{"888", 33},
4248
{"8881", 1},
4349
{"8881", 2},
4450
{"8881", 8},

server/cmd/datas/casbins.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ var Carbines = []gormadapter.CasbinRule{
7575
{PType: "p", V0: "888", V1: "/simpleUploader/upload", V2: "POST"},
7676
{PType: "p", V0: "888", V1: "/simpleUploader/checkFileMd5", V2: "GET"},
7777
{PType: "p", V0: "888", V1: "/simpleUploader/mergeFileMd5", V2: "GET"},
78+
{PType: "p", V0: "888", V1: "/workflowProcess/createWorkflowProcess", V2: "POST"},
79+
{PType: "p", V0: "888", V1: "/workflowProcess/deleteWorkflowProcess", V2: "DELETE"},
80+
{PType: "p", V0: "888", V1: "/workflowProcess/deleteWorkflowProcessByIds", V2: "DELETE"},
81+
{PType: "p", V0: "888", V1: "/workflowProcess/updateWorkflowProcess", V2: "PUT"},
82+
{PType: "p", V0: "888", V1: "/workflowProcess/findWorkflowProcess", V2: "GET"},
83+
{PType: "p", V0: "888", V1: "/workflowProcess/getWorkflowProcessList", V2: "GET"},
84+
{PType: "p", V0: "888", V1: "/workflowProcess/findWorkflowStep", V2: "GET"},
85+
{PType: "p", V0: "888", V1: "/workflowProcess/startWorkflow", V2: "POST"},
86+
{PType: "p", V0: "888", V1: "/workflowProcess/completeWorkflowMove", V2: "POST"},
87+
{PType: "p", V0: "888", V1: "/workflowProcess/getMyStated", V2: "GET"},
88+
{PType: "p", V0: "888", V1: "/workflowProcess/getMyNeed", V2: "GET"},
89+
{PType: "p", V0: "888", V1: "/workflowProcess/getWorkflowMoveByID", V2: "GET"},
7890
{PType: "p", V0: "8881", V1: "/base/login", V2: "POST"},
7991
{PType: "p", V0: "8881", V1: "/user/register", V2: "POST"},
8092
{PType: "p", V0: "8881", V1: "/api/createApi", V2: "POST"},

server/cmd/datas/init.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func InitMysqlData(db *gorm.DB) {
2121
InitSysDataAuthorityId(db)
2222
InitSysDictionaryDetail(db)
2323
InitExaFileUploadAndDownload(db)
24+
InitWkProcess(db)
2425
}
2526

2627
func InitMysqlTables(db *gorm.DB) {
@@ -34,21 +35,24 @@ func InitMysqlTables(db *gorm.DB) {
3435
model.ExaFile{},
3536
model.ExaCustomer{},
3637
model.SysBaseMenu{},
37-
model.SysWorkflow{},
3838
model.SysAuthority{},
3939
model.JwtBlacklist{},
4040
model.ExaFileChunk{},
4141
model.SysDictionary{},
4242
model.ExaSimpleUploader{},
4343
model.SysOperationRecord{},
44-
model.SysWorkflowStepInfo{},
4544
model.SysDictionaryDetail{},
4645
model.SysBaseMenuParameter{},
4746
model.ExaFileUploadAndDownload{},
47+
model.WorkflowProcess{},
48+
model.WorkflowNode{},
49+
model.WorkflowEdge{},
50+
model.WorkflowStartPoint{},
51+
model.WorkflowEndPoint{},
4852
)
4953
if err != nil {
5054
color.Warn.Printf("[Mysql]-->初始化数据表失败,err: %v\n", err)
5155
os.Exit(0)
5256
}
5357
color.Info.Println("[Mysql]-->初始化数据表成功")
54-
}
58+
}

0 commit comments

Comments
 (0)