添加分区逻辑代码

This commit is contained in:
kongyuebin
2021-05-19 13:46:49 +08:00
parent f7a7eb737d
commit 706a95317d
34 changed files with 629 additions and 73 deletions

View File

@@ -55,6 +55,7 @@ func initLegend() {
orm.RegisterModel(new(legend.ScalePresent))
orm.RegisterModel(new(legend.ScaleTemplate))
orm.RegisterModel(new(legend.Group))
orm.RegisterModel(new(legend.Area))
logs.Info("init legend success ......")

View File

@@ -11,8 +11,7 @@ type AnyMoney struct {
GameMoneyName string
GameMoneyScale int
LimitLow float64
UpdateTime string
CreateTime string
BaseDao
}
const ANYMONEY = "legend_any_money"

View File

@@ -0,0 +1,92 @@
package legend
import (
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
)
type Area struct {
Id int `orm:"pk;column(id)"`
AreaName string
Uid string
GroupName string
TemplateName string
NotifyUrl string
AttachParams string
BaseDao
}
const AREA = "legend_area"
func (c *Area) TableName() string {
return AREA
}
func InsertArea(area *Area) bool {
o := orm.NewOrm()
if _, err := o.Insert(area); err != nil {
logs.Error("insert area err: ", err)
return false
}
return true
}
func GetAreaByName(name string) *Area {
o := orm.NewOrm()
area := new(Area)
if _, err := o.QueryTable(AREA).Filter("area_name", name).Limit(1).All(area); err != nil {
logs.Error("get area by name err", err)
}
return area
}
func GetAreaAllCount() int {
o := orm.NewOrm()
count, err := o.QueryTable(AREA).Count()
if err != nil {
logs.Error("get area all count err", err)
}
return int(count)
}
func GetAreaList(offset, limit int) []Area {
o := orm.NewOrm()
var areas []Area
if _, err := o.QueryTable(AREA).Limit(limit, offset).OrderBy("-create_time").All(&areas); err != nil {
logs.Error(" get area list err", err)
}
return areas
}
func GetAreaByUid(uid string) *Area {
o := orm.NewOrm()
area := new(Area)
if _, err := o.QueryTable(AREA).Filter("uid", uid).Limit(1).All(area); err != nil {
logs.Error(" get area by uid err : ", err)
}
return area
}
func UpdateArea(area *Area) bool {
o := orm.NewOrm()
if _, err := o.Update(area); err != nil {
logs.Error("update area err", err)
return false
}
return true
}
func DeleteAreaByUid(uid string) bool {
o := orm.NewOrm()
if _, err := o.QueryTable(AREA).Filter("uid", uid).Delete(); err != nil {
logs.Error(" delete area by uid err", err)
return false
}
return true
}

View File

@@ -0,0 +1,6 @@
package legend
type BaseDao struct {
UpdateTime string
CreateTime string
}

View File

@@ -13,8 +13,7 @@ type FixMoney struct {
GoodsName string
GoodsNo string
BuyTimes int
UpdateTime string
CreateTime string
BaseDao
}
const FIXMONEY = "legend_fix_money"

View File

@@ -11,8 +11,7 @@ type FixPresent struct {
TemplateName string
Money float64
PresentMoney float64
UpdateTime string
CreateTime string
BaseDao
}
const FIXPRESENT = "legend_fix_present"

View File

@@ -6,11 +6,10 @@ import (
)
type Group struct {
Id int `orm:"pk;column(id)"`
GroupName string
Uid string
UpdateTime string
CreateTime string
Id int `orm:"pk;column(id)"`
GroupName string
Uid string
BaseDao
}
const GROUP = "legend_group"

View File

@@ -11,8 +11,7 @@ type ScalePresent struct {
TemplateName string
Money float64
PresentScale float64
UpdateTime string
CreateTime string
BaseDao
}
const SCALEPRESENT = "legend_scale_present"

View File

@@ -13,8 +13,7 @@ type ScaleTemplate struct {
UserWarn string
MoneyType string
PresentType string
UpdateTime string
CreateTime string
BaseDao
}
const SCALETMPLETE = "legend_scale_template"