chance_reserve_type.go
1.3 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
package models
import (
"time"
"github.com/astaxie/beego/orm"
)
type ChanceReserveType struct {
Id int `orm:"column(id);auto" json:"id"`
Name string `orm:"column(name);size(50)" description:"储备类型名称" json:"name"`
CompanyId int `orm:"column(company_id)" description:"表company.id 公司编号" json:"-"`
SortNum int `orm:"column(sort_num);null" description:"序号 " json:"-"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间 " json:"-"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间 " json:"-"`
}
func (t *ChanceReserveType) TableName() string {
return "chance_reserve_type"
}
func init() {
orm.RegisterModel(new(ChanceReserveType))
}
// GetChanceReserveTypeById retrieves ChanceReserveType by Id. Returns error if
// Id doesn't exist
func GetChanceReserveTypeById(id int) (v *ChanceReserveType, err error) {
o := orm.NewOrm()
v = &ChanceReserveType{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
func GetChanceReserveTypes(cid int64) (v []*ChanceReserveType, err error) {
o := orm.NewOrm()
sql := "select * from chance_reserve_type where company_id=? order by sort_num,id"
if _, err = o.Raw(sql, cid).QueryRows(&v); err == nil {
return
}
return
}