- refactor model register.

This commit is contained in:
gazebo
2018-07-24 09:46:30 +08:00
parent 3439ef3669
commit de21819f71
14 changed files with 40 additions and 39 deletions

View File

@@ -1,8 +1,8 @@
package controllers
import (
"git.rosy.net.cn/jx-callback/business/legacymodel"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/legacy/models"
"github.com/astaxie/beego/orm"
)
@@ -17,7 +17,7 @@ func OnNewOrder(orderID string, vendorID int, userMobile string, jxStoreID int,
if db == nil {
db = orm.NewOrm()
}
user := &models.BlackClient{
user := &legacymodel.BlackClient{
Mobile: userMobile,
}
if err := db.Read(user, "Mobile"); err != nil {

View File

@@ -1,8 +0,0 @@
package models
type Config struct {
Id int
Thirdparty string `orm:"size(20);unique"`
Token string `orm:"size(300)"`
Date string `orm:"size(30)"`
}

View File

@@ -1,26 +1,13 @@
package models
import (
"time"
elmmodels "git.rosy.net.cn/jx-callback/legacy/elm/models"
jdmodels "git.rosy.net.cn/jx-callback/legacy/jd/models"
"github.com/astaxie/beego/orm"
)
type BlackClient struct {
ID int `orm:"column(id)"`
Mobile string `orm:"size(16);unique"`
Name string `orm:"size(8)"`
Note string `orm:"size(256)"`
CreatedAt time.Time `orm:"auto_now_add;type(datetime);null"`
UpdatedAt time.Time `orm:"auto_now;type(datetime);null"`
}
func RegisterModels() {
// register model
orm.RegisterModel(new(jdmodels.Jdorder))
orm.RegisterModel(new(elmmodels.ELMOrder))
orm.RegisterModel(new(Config))
orm.RegisterModel(new(BlackClient))
}

View File

@@ -4,13 +4,13 @@ import (
"fmt"
"time"
"git.rosy.net.cn/jx-callback/business/legacymodel"
"git.rosy.net.cn/jx-callback/globals/api"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/legacy/freshfood"
"git.rosy.net.cn/jx-callback/legacy/models"
"github.com/astaxie/beego/orm"
)
@@ -37,7 +37,7 @@ func RefreshConfig(configKey string, expiresTime time.Duration, configGetter fun
sleepGap = maxRefreshGap
}
refreshFunc := func() (string, error) {
curConfig := &models.Config{
curConfig := &legacymodel.Config{
Thirdparty: configKey,
}
db := orm.NewOrm()