forked from zileyuan/goflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.go
55 lines (49 loc) · 1.77 KB
/
process.go
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
package goflow
import "time"
//流程定义实体类
type Process struct {
Id string `xorm:"varchar(36) pk notnull"` //主键ID
Version int `xorm:"tinyint"` //版本
Name string `xorm:"varchar(100) index"` //流程定义名称
DisplayName string `xorm:"varchar(200)"` //流程定义显示名称
InstanceAction string `xorm:"varchar(200)"` //当前流程的实例Action,(Web为URL,一般为流程第一步的URL;APP需要自定义),该字段可以直接打开流程申请的表单
State FLOW_STATUS `xorm:"tinyint"` //状态
CreateTime time.Time `xorm:"datetime"` //创建时间
Creator string `xorm:"varchar(36)"` //创建人
Content string `xorm:"text"` //流程定义XML
Model *ProcessModel `xorm:"-"` //Model对象
}
//根据ID得到Process
func (p *Process) GetProcessById(id string) bool {
p.Id = id
success, err := orm.Get(p)
PanicIf(err, "fail to GetProcessById")
return success
}
//根据Process本身条件得到Process
func (p *Process) GetProcess() bool {
success, err := orm.Get(p)
PanicIf(err, "fail to GetProcess")
return success
}
//设定Model对象
func (p *Process) SetModel(model *ProcessModel) {
p.Model = model
p.Name = model.Name
p.DisplayName = model.DisplayName
p.InstanceAction = model.InstanceAction
}
//得到最新的Process
func GetLatestProcess(name string) *Process {
process := &Process{
Name: name,
}
processes := make([]*Process, 0)
err := orm.Desc("Version").Find(&processes, process)
PanicIf(err, "fail to GetLatestProcess")
if len(processes) > 0 {
return processes[0]
} else {
return nil
}
}