audit_flow_config.go
3.5 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package models
import (
"fmt"
"time"
"github.com/astaxie/beego/orm"
)
type AuditFlowConfig struct {
Id int `orm:"column(id);pk" description:"唯一编号"`
AuditTemplateId int64 `orm:"column(audit_template_id)" description:"表audit_template.id 所属审批模板编号"`
AuditGroupId int64 `orm:"column(audit_group_id)" description:"审核组id (同一个审批批次)"`
Level int `orm:"column(level)" description:"审批层级顺序,审批步骤 第几步"`
AuditFlowType int `orm:"column(audit_flow_type)" description:"审核流类型 1.部门长 2.指定成员 3.指定角色 4.特殊审核人 "`
FromSpecialUser string `orm:"column(from_special_user)" description:"特殊指定的审批单发起人"`
ToRole string `orm:"column(to_role);null" description:"指定角色"`
ToUser string `orm:"column(to_user);null" description:"指定人"`
FlowType int `orm:"column(flow_type)" description:"审批类型 1:正常审核 2:特殊审核"`
ActionType uint `orm:"column(action_type)" description:"审批执行方式【1:or】【2:and】"`
CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
}
func (t *AuditFlowConfig) TableName() string {
return "audit_flow_config"
}
func init() {
orm.RegisterModel(new(AuditFlowConfig))
}
// AddAuditFlowConfig insert a new AuditFlowConfig into database and returns
// last inserted Id on success.
func AddAuditFlowConfig(m *AuditFlowConfig) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
// GetAuditFlowConfigById retrieves AuditFlowConfig by Id. Returns error if
// Id doesn't exist
func GetAuditFlowConfigById(id int) (v *AuditFlowConfig, err error) {
o := orm.NewOrm()
v = &AuditFlowConfig{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
// UpdateAuditFlowConfig updates AuditFlowConfig by Id and returns error if
// the record to be updated doesn't exist
func UpdateAuditFlowConfigById(m *AuditFlowConfig) (err error) {
o := orm.NewOrm()
v := AuditFlowConfig{Id: m.Id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Update(m); err == nil {
fmt.Println("Number of records updated in database:", num)
}
}
return
}
// DeleteAuditFlowConfig deletes AuditFlowConfig by Id and returns error if
// the record to be deleted doesn't exist
func DeleteAuditFlowConfig(id int) (err error) {
o := orm.NewOrm()
v := AuditFlowConfig{Id: id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Delete(&AuditFlowConfig{Id: id}); err == nil {
fmt.Println("Number of records deleted in database:", num)
}
}
return
}
func GetAuditFlowConfigs(auditTemplateId int64, groupId int64) (v []*AuditFlowConfig, err error) {
o := orm.NewOrm()
sql := "select * from audit_flow_config where audit_template_id=? and audit_group_id=? order by level"
if _, err = o.Raw(sql, auditTemplateId, groupId).QueryRows(&v); err == nil {
return
}
return
}
func GetAuditFlowConfigsLevel(auditTemplateId int64, level int) (v []*AuditFlowConfig, err error) {
o := orm.NewOrm()
sql := "select * from audit_flow_config where audit_template_id=? and level=?"
if _, err = o.Raw(sql, auditTemplateId, level).QueryRows(&v); err == nil {
return
}
return
}