Skip to content

Commit 10a05e1

Browse files
committed
根据流程ID查询流程
1 parent e680050 commit 10a05e1

File tree

4 files changed

+48
-5
lines changed

4 files changed

+48
-5
lines changed

workflow-controller/processController.go

+21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package controller
33
import (
44
"fmt"
55
"net/http"
6+
"strconv"
67

78
"github.com/go-workflow/go-workflow/workflow-engine/model"
89

@@ -213,3 +214,23 @@ func MoveFinishedProcInstToHistory(writer http.ResponseWriter, request *http.Req
213214
}
214215
util.ResponseOk(writer)
215216
}
217+
218+
// FindProcInstByID 根据流程ID查询流程
219+
func FindProcInstByID(writer http.ResponseWriter, request *http.Request) {
220+
request.ParseForm()
221+
if len(request.Form["id"]) == 0 {
222+
util.ResponseErr(writer, "字段 id 不能为空")
223+
return
224+
}
225+
id, err := strconv.Atoi(request.Form["id"][0])
226+
if err != nil {
227+
util.ResponseErr(writer, err)
228+
return
229+
}
230+
data, err := service.FindProcInstByID(id)
231+
if err != nil {
232+
util.ResponseErr(writer, err)
233+
return
234+
}
235+
util.Response(writer, data, true)
236+
}

workflow-engine/model/ACT_HI_PROCINST.go

+10
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ func StartByMyself(userID, company string, pageIndex, pageSize int) ([]*ProcInst
6666
return findProcInsts(maps, pageIndex, pageSize)
6767
}
6868

69+
// FindProcInstByID FindProcInstByID
70+
func FindProcInstByID(id int) (*ProcInst, error) {
71+
var data = ProcInst{}
72+
err := db.Where("id=?", id).Find(&data).Error
73+
if err != nil {
74+
return nil, err
75+
}
76+
return &data, nil
77+
}
78+
6979
// FindProcNotify 查询抄送我的流程
7080
func FindProcNotify(userID, company string, groups []string, pageIndex, pageSize int) ([]*ProcInst, int, error) {
7181
var datas []*ProcInst

workflow-engine/service/procInstService.go

+16-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
// ProcessReceiver 接收页面传递参数
1616
type ProcessReceiver struct {
1717
UserID string `json:"userId"`
18+
ProcInstID string `json:"procInstID"`
1819
Username string `json:"username"`
1920
Company string `json:"company"`
2021
ProcName string `json:"procName"`
@@ -29,11 +30,12 @@ type ProcessPageReceiver struct {
2930
// 我分管的部门
3031
Departments []string `json:"departments"`
3132
// 我所属于的用户组或者角色
32-
Groups []string `josn:"groups"`
33-
UserID string `json:"userID"`
34-
Username string `json:"username"`
35-
Company string `json:"company"`
36-
ProcName string `json:"procName"`
33+
Groups []string `josn:"groups"`
34+
UserID string `json:"userID"`
35+
Username string `json:"username"`
36+
Company string `json:"company"`
37+
ProcName string `json:"procName"`
38+
ProcInstID string `json:"procInstID"`
3739
}
3840

3941
var copyLock sync.Mutex
@@ -51,6 +53,15 @@ func findAll(pr *ProcessPageReceiver) ([]*model.ProcInst, int, error) {
5153
return model.FindProcInsts(pr.UserID, pr.ProcName, pr.Company, pr.Groups, pr.Departments, pr.PageIndex, pr.PageSize)
5254
}
5355

56+
// FindProcInstByID FindProcInstByID
57+
func FindProcInstByID(id int) (string, error) {
58+
data, err := model.FindProcInstByID(id)
59+
if err != nil {
60+
return "", err
61+
}
62+
return util.ToJSONStr(data)
63+
}
64+
5465
// FindAllPageAsJSON FindAllPageAsJSON
5566
func FindAllPageAsJSON(pr *ProcessPageReceiver) (string, error) {
5667
datas, count, err := findAll(pr)

workflow-router/router.go

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func setMux() {
3636
Mux.HandleFunc("/api/v1/workflow/process/start", intercept(controller.StartProcessInstance)) // 启动流程
3737
Mux.HandleFunc("/api/v1/workflow/process/startByToken", intercept(controller.StartProcessInstanceByToken)) // 启动流程
3838
Mux.HandleFunc("/api/v1/workflow/process/findTask", intercept(controller.FindMyProcInstPageAsJSON)) // 查询需要我审批的流程
39+
Mux.HandleFunc("/api/v1/workflow/process/findById", intercept(controller.FindProcInstByID)) // 根据id查询流程实例
3940
Mux.HandleFunc("/api/v1/workflow/process/findTaskByToken", intercept(controller.FindMyProcInstByToken))
4041
Mux.HandleFunc("/api/v1/workflow/process/startByMyself", intercept(controller.StartByMyself)) // 查询我启动的流程
4142
Mux.HandleFunc("/api/v1/workflow/process/FindProcNotify", intercept(controller.FindProcNotify)) // 查询抄送我的流程

0 commit comments

Comments
 (0)