chance_self_check.go
2.2 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
package models
import (
"fmt"
"time"
"github.com/astaxie/beego/orm"
)
type ChanceSelfCheck struct {
Id int64 `orm:"column(id);pk" description:"编号"`
UserCompanyId int64 `orm:"column(user_company_id);null" description:"提交人"`
ChanceId int64 `orm:"column(chanceId);null" description:"机会编号"`
RelateId int64 `orm:"column(relateId)" description:"关联编号 机会编号 / 审核流程编号"`
CheckItem string `orm:"column(checkItem);size(50)" description:"检查项"`
GroupId int64 `orm:"column(groupId)" description:"分组编号(audit_check.id/pid)"`
Answer string `orm:"column(answer);size(50);null" description:"回答"`
Reason string `orm:"column(reason);size(200);null" description:"理由"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"`
Enable int8 `orm:"column(enable);size(200);null" description:"是否有效【0:无效】【1:有效】"`
}
func (t *ChanceSelfCheck) TableName() string {
return "chance_self_check"
}
func init() {
orm.RegisterModel(new(ChanceSelfCheck))
}
// AddChanceSelfCheck insert a new ChanceSelfCheck into database and returns
// last inserted Id on success.
func AddChanceSelfCheck(m *ChanceSelfCheck) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
// GetChanceSelfCheckById retrieves ChanceSelfCheck by Id. Returns error if
// Id doesn't exist
func GetChanceSelfCheckById(id int64) (v *ChanceSelfCheck, err error) {
o := orm.NewOrm()
v = &ChanceSelfCheck{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
// UpdateChanceSelfCheck updates ChanceSelfCheck by Id and returns error if
// the record to be updated doesn't exist
func UpdateChanceSelfCheckById(m *ChanceSelfCheck) (err error) {
o := orm.NewOrm()
v := ChanceSelfCheck{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
}