rank_range_data.go
1.7 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
package models
import (
"github.com/astaxie/beego/orm"
)
type RankRangeData struct {
Id int64 `orm:"column(id);auto"`
RankRangeId int64 `orm:"column(rank_range_id)"`
RangeType int8 `orm:"column(range_type);" description:"类型"`
RelationId int64 `orm:"column(relation_id);"`
RankTypeId int64 `orm:"column(rank_type_id)"`
}
func (t *RankRangeData) TableName() string {
return "rank_range_data"
}
func init() {
orm.RegisterModel(new(RankRangeData))
}
// AddRankRangeData insert a new RankRangeData into database and returns
// last inserted Id on success.
func AddRankRangeDataMulti(m []RankRangeData, om ...orm.Ormer) (successNums int64, err error) {
var o orm.Ormer
if len(om) > 0 {
o = om[0]
} else {
o = orm.NewOrm()
}
successNums, err = o.InsertMulti(20, m)
return
}
// GetRankRangeDataById retrieves RankRangeData by Id. Returns error if
// Id doesn't exist
func GetRankRangeDataById(id int64) (v *RankRangeData, err error) {
o := orm.NewOrm()
v = &RankRangeData{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
// DeleteRankRangeData deletes RankRangeData by Id and returns error if
// the record to be deleted doesn't exist
func DeleteRankRangeData(id []int64, om orm.Ormer) (err error) {
_, err = om.QueryTable(&RankRangeData{}).
Filter("id__in", id).
Delete()
return err
}
func GetRankRangeDataByRangeId(id int64) ([]RankRangeData, error) {
var (
data = make([]RankRangeData, 0)
err error
)
o := orm.NewOrm()
_, err = o.QueryTable(&RankRangeData{}).
Filter("rank_range_id", id).
All(&data)
if err == orm.ErrNoRows {
return data, nil
}
if err != nil {
return nil, err
}
return data, nil
}