Commit 2e7e26fd6d6accdc996b894dad7014928fe6f527
1 parent
658bcbb7
Exists in
master
and in
1 other branch
refactor♻️:项目目录重构
Showing
17 changed files
with
292 additions
and
176 deletions
Show diff stats
common/svconst/vars.go
| @@ -0,0 +1,64 @@ | @@ -0,0 +1,64 @@ | ||
| 1 | +package svdto | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "apigame/util/utdto" | ||
| 5 | + "apigame/util/util-lx/lxalilog" | ||
| 6 | + "gorm.io/gorm" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +func InitTable(db *gorm.DB, tb IDtoData, gameId string) { | ||
| 10 | + tableName := tb.GetTableName(gameId) | ||
| 11 | + utdto.InitTable(db, tb, tableName) | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +func Insert(db *gorm.DB, data IDtoData, gameId string) (err error) { | ||
| 15 | + result := utdto.Insert(db, data, data.GetTableName(gameId)) | ||
| 16 | + err = result.Error | ||
| 17 | + if err != nil { | ||
| 18 | + lxalilog.Errors(err, gameId) | ||
| 19 | + return | ||
| 20 | + } | ||
| 21 | + return | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func Update(db *gorm.DB, data IDtoData, gameId string) (err error) { | ||
| 25 | + result := utdto.Update(db, data, data.GetTableName(gameId)) | ||
| 26 | + err = result.Error | ||
| 27 | + if err != nil { | ||
| 28 | + lxalilog.Errors(err, gameId) | ||
| 29 | + return | ||
| 30 | + } | ||
| 31 | + return | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +func Save(db *gorm.DB, data IDtoData, gameId string) (err error) { | ||
| 35 | + result := utdto.Save(db, data, data.GetTableName(gameId)) | ||
| 36 | + err = result.Error | ||
| 37 | + if err != nil { | ||
| 38 | + lxalilog.Errors(err, gameId) | ||
| 39 | + return | ||
| 40 | + } | ||
| 41 | + return | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +func First(db *gorm.DB, data IDtoData, gameId string) (has bool, err error) { | ||
| 45 | + result := utdto.First(db, data, data.GetTableName(gameId)) | ||
| 46 | + has = result.RowsAffected != 0 | ||
| 47 | + err = result.Error | ||
| 48 | + if err != nil { | ||
| 49 | + lxalilog.Errors(err, gameId) | ||
| 50 | + return | ||
| 51 | + } | ||
| 52 | + return | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +func Find(db *gorm.DB, data any, tableName string) (has bool, err error) { | ||
| 56 | + result := utdto.Find(db, data, tableName) | ||
| 57 | + has = result.RowsAffected != 0 | ||
| 58 | + err = result.Error | ||
| 59 | + if err != nil { | ||
| 60 | + lxalilog.Errors(err, tableName) | ||
| 61 | + return | ||
| 62 | + } | ||
| 63 | + return | ||
| 64 | +} |
| @@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
| 1 | +package svdto | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "apigame/common/svconst" | ||
| 5 | + "apigame/dto" | ||
| 6 | + "apigame/service/constd" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +func Init() { | ||
| 10 | + | ||
| 11 | + // create table | ||
| 12 | + // 卡牌卡包 | ||
| 13 | + for _, gameId := range constd.GameListCardHolder { | ||
| 14 | + InitTable(svconst.DbCommon, new(dto.CardHolderData), gameId) | ||
| 15 | + InitTable(svconst.DbCommon, new(dto.CardHolderRecordOpen), gameId) | ||
| 16 | + InitTable(svconst.DbCommon, new(dto.CardHolderRecordRewardAlbum), gameId) | ||
| 17 | + InitTable(svconst.DbCommon, new(dto.CardHolderRecordRewardRound), gameId) | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | +} |
common/svmysql/index.go
| 1 | package svmysql | 1 | package svmysql |
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "apigame/common/svconst" | ||
| 5 | + "apigame/service/constd" | ||
| 6 | + "apigame/util/utdto" | ||
| 7 | + "fmt" | ||
| 8 | + "github.com/astaxie/beego" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +func Init() bool { | ||
| 12 | + | ||
| 13 | + // ConnectMySQL | ||
| 14 | + if db, err := utdto.ConnectMySQL(beego.AppConfig.String("mysql::" + constd.MYSQL_DBAPI)); err == nil { | ||
| 15 | + svconst.DbApi = db | ||
| 16 | + } else { | ||
| 17 | + fmt.Println("svmysql.Init DbApi Error::" + err.Error()) | ||
| 18 | + return false | ||
| 19 | + } | ||
| 20 | + if db, err := utdto.ConnectMySQL(beego.AppConfig.String("mysql::mergecommon")); err == nil { | ||
| 21 | + svconst.DbCommon = db | ||
| 22 | + } else { | ||
| 23 | + fmt.Println("svmysql.Init DbCommon Error::" + err.Error()) | ||
| 24 | + return false | ||
| 25 | + } | ||
| 26 | + if db, err := utdto.ConnectMySQL(beego.AppConfig.String("mysql::" + constd.MYSQL_MERGECONFIG)); err == nil { | ||
| 27 | + svconst.DbConfig = db | ||
| 28 | + } else { | ||
| 29 | + fmt.Println("svmysql.Init DbConfig Error::" + err.Error()) | ||
| 30 | + return false | ||
| 31 | + } | ||
| 32 | + return true | ||
| 33 | + | ||
| 34 | +} |
| @@ -0,0 +1,119 @@ | @@ -0,0 +1,119 @@ | ||
| 1 | +package thinkingdata | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "crypto/tls" | ||
| 5 | + "encoding/json" | ||
| 6 | + "errors" | ||
| 7 | + "fmt" | ||
| 8 | + "gitee.com/lxgow/lxconv" | ||
| 9 | + "github.com/astaxie/beego" | ||
| 10 | + "github.com/astaxie/beego/httplib" | ||
| 11 | + lconv "github.com/lixu-any/go-tools/conv" | ||
| 12 | + "time" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +// index | ||
| 16 | +// 创建时间:2023/10/23 10:06 | ||
| 17 | +// 创建人:lixu | ||
| 18 | + | ||
| 19 | +// index 数数科技 | ||
| 20 | +// 创建时间:2023/7/18 16:03 | ||
| 21 | +// 创建人:lixu | ||
| 22 | + | ||
| 23 | +// GetNowDateTime 当前日期时间 | ||
| 24 | +func GetNowDateTime() string { | ||
| 25 | + tim := time.Unix(time.Now().Unix(), 0).Format("2006-01-02 15:04:05") | ||
| 26 | + return fmt.Sprintf("%s", tim) | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +type MThinkDataConfig struct { | ||
| 30 | + Url string `json:"url"` | ||
| 31 | + Debug int `json:"debug"` | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +type MRespData struct { | ||
| 35 | + Msg string `json:"Msg"` | ||
| 36 | + Code int `json:"code"` | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +var THINKINGDATACONFIG MThinkDataConfig | ||
| 40 | + | ||
| 41 | +// InitThinkData 初始化数数 | ||
| 42 | +func InitThinkData() (err error) { | ||
| 43 | + thinkingdata, _ := beego.AppConfig.GetSection("thinkingdata") | ||
| 44 | + THINKINGDATACONFIG.Url = thinkingdata["url"] | ||
| 45 | + THINKINGDATACONFIG.Debug = lxconv.ParseInt(thinkingdata["debug"]) | ||
| 46 | + return | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +// AddOneData 数据上报 | ||
| 50 | +func AddOneData(appid, account_id, distinct_id string, event string, data map[string]interface{}, typ string) (resp MRespData, err error) { | ||
| 51 | + | ||
| 52 | + _data := map[string]interface{}{ | ||
| 53 | + "#type": typ, | ||
| 54 | + //"#event_name": event, | ||
| 55 | + "#time": GetNowDateTime(), | ||
| 56 | + "#account_id": account_id, | ||
| 57 | + "#distinct_id": distinct_id, | ||
| 58 | + "properties": data, | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + if typ == "track" && event != "" { | ||
| 62 | + _data["#event_name"] = event | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + postdata := map[string]interface{}{ | ||
| 66 | + "appid": appid, | ||
| 67 | + "debug": THINKINGDATACONFIG.Debug, | ||
| 68 | + "data": _data, | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + req := httplib.Post(THINKINGDATACONFIG.Url + "/sync_json") | ||
| 72 | + | ||
| 73 | + req.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) | ||
| 74 | + | ||
| 75 | + _, err = req.JSONBody(&postdata) | ||
| 76 | + if err != nil { | ||
| 77 | + err = errors.New("thinkingdata-AddOneData req.JSONBody() error::" + err.Error() + "::" + lconv.JsonEncode(postdata)) | ||
| 78 | + return | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + var ( | ||
| 82 | + bytes []byte | ||
| 83 | + ) | ||
| 84 | + | ||
| 85 | + bytes, err = req.Bytes() | ||
| 86 | + if err != nil { | ||
| 87 | + err = errors.New("thinkingdata-AddOneData req.Bytes() error::" + err.Error() + "::" + lconv.JsonEncode(postdata) + "::" + string(bytes)) | ||
| 88 | + return | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + _ = json.Unmarshal(bytes, &resp) | ||
| 92 | + | ||
| 93 | + if resp.Code != 0 { | ||
| 94 | + err = errors.New("thinkingdata-AddOneData resp.Code error:: " + lconv.JsonEncode(postdata) + "::" + string(bytes)) | ||
| 95 | + return | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + return | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +// TrackOne 向事件表传入一个事件 | ||
| 102 | +func TrackOne(appid, account_id string, event string, data map[string]interface{}) (resp MRespData, err error) { | ||
| 103 | + return AddOneData(appid, account_id, "", event, data, "track") | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +// UserSet 对用户表进行操作,覆盖一个或多个用户属性,如果该属性已有值存在,覆盖先前值 | ||
| 107 | +func UserSet(appid, account_id string, data map[string]interface{}) (resp MRespData, err error) { | ||
| 108 | + return AddOneData(appid, account_id, "", "", data, "user_set") | ||
| 109 | +} | ||
| 110 | + | ||
| 111 | +// UserSetOnce 对用户表进行操作,初始化一个或多个用户属性,如果该属性已有值存在,则忽略本次操作 | ||
| 112 | +func UserSetOnce(appid, account_id string, data map[string]interface{}) (resp MRespData, err error) { | ||
| 113 | + return AddOneData(appid, account_id, "", "", data, "user_setOnce") | ||
| 114 | +} | ||
| 115 | + | ||
| 116 | +// UserAdd 对用户表进行操作,为一个或多个数值型用户属性做累加计算 | ||
| 117 | +func UserAdd(appid, account_id string, data map[string]interface{}) (resp MRespData, err error) { | ||
| 118 | + return AddOneData(appid, account_id, "", "", data, "user_add") | ||
| 119 | +} |
dto/dto.go
| @@ -1,64 +0,0 @@ | @@ -1,64 +0,0 @@ | ||
| 1 | -package dto | ||
| 2 | - | ||
| 3 | -import ( | ||
| 4 | - "apigame/util/utdto" | ||
| 5 | - "apigame/util/util-lx/lxalilog" | ||
| 6 | - "gorm.io/gorm" | ||
| 7 | -) | ||
| 8 | - | ||
| 9 | -func InitTable(db *gorm.DB, tb IDtoData, gameId string) { | ||
| 10 | - tableName := tb.GetTableName(gameId) | ||
| 11 | - utdto.InitTable(db, tb, tableName) | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | -func Insert(db *gorm.DB, data IDtoData, gameId string) (err error) { | ||
| 15 | - result := utdto.Insert(db, data, data.GetTableName(gameId)) | ||
| 16 | - err = result.Error | ||
| 17 | - if err != nil { | ||
| 18 | - lxalilog.Errors(err, gameId) | ||
| 19 | - return | ||
| 20 | - } | ||
| 21 | - return | ||
| 22 | -} | ||
| 23 | - | ||
| 24 | -func Update(db *gorm.DB, data IDtoData, gameId string) (err error) { | ||
| 25 | - result := utdto.Update(db, data, data.GetTableName(gameId)) | ||
| 26 | - err = result.Error | ||
| 27 | - if err != nil { | ||
| 28 | - lxalilog.Errors(err, gameId) | ||
| 29 | - return | ||
| 30 | - } | ||
| 31 | - return | ||
| 32 | -} | ||
| 33 | - | ||
| 34 | -func Save(db *gorm.DB, data IDtoData, gameId string) (err error) { | ||
| 35 | - result := utdto.Save(db, data, data.GetTableName(gameId)) | ||
| 36 | - err = result.Error | ||
| 37 | - if err != nil { | ||
| 38 | - lxalilog.Errors(err, gameId) | ||
| 39 | - return | ||
| 40 | - } | ||
| 41 | - return | ||
| 42 | -} | ||
| 43 | - | ||
| 44 | -func First(db *gorm.DB, data IDtoData, gameId string) (has bool, err error) { | ||
| 45 | - result := utdto.First(db, data, data.GetTableName(gameId)) | ||
| 46 | - has = result.RowsAffected != 0 | ||
| 47 | - err = result.Error | ||
| 48 | - if err != nil { | ||
| 49 | - lxalilog.Errors(err, gameId) | ||
| 50 | - return | ||
| 51 | - } | ||
| 52 | - return | ||
| 53 | -} | ||
| 54 | - | ||
| 55 | -func Find(db *gorm.DB, data any, tableName string) (has bool, err error) { | ||
| 56 | - result := utdto.Find(db, data, tableName) | ||
| 57 | - has = result.RowsAffected != 0 | ||
| 58 | - err = result.Error | ||
| 59 | - if err != nil { | ||
| 60 | - lxalilog.Errors(err, tableName) | ||
| 61 | - return | ||
| 62 | - } | ||
| 63 | - return | ||
| 64 | -} |
dto/init-dto.go
| @@ -1,39 +0,0 @@ | @@ -1,39 +0,0 @@ | ||
| 1 | -package dto | ||
| 2 | - | ||
| 3 | -import ( | ||
| 4 | - "apigame/service/constd" | ||
| 5 | - "apigame/util/utdto" | ||
| 6 | - "fmt" | ||
| 7 | - "github.com/astaxie/beego" | ||
| 8 | - "gorm.io/gorm" | ||
| 9 | -) | ||
| 10 | - | ||
| 11 | -var ( | ||
| 12 | - DbCommon *gorm.DB | ||
| 13 | - DbConfig *gorm.DB | ||
| 14 | -) | ||
| 15 | - | ||
| 16 | -func InitDto() { | ||
| 17 | - | ||
| 18 | - // ConnectMySQL | ||
| 19 | - if db, err := utdto.ConnectMySQL(beego.AppConfig.String("mysql::mergecommon")); err == nil { | ||
| 20 | - DbCommon = db | ||
| 21 | - } else { | ||
| 22 | - fmt.Println(" InitMysqls Error::" + err.Error()) | ||
| 23 | - } | ||
| 24 | - if db, err := utdto.ConnectMySQL(beego.AppConfig.String("mysql::" + constd.MYSQL_MERGECONFIG)); err == nil { | ||
| 25 | - DbConfig = db | ||
| 26 | - } else { | ||
| 27 | - | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | - // create table | ||
| 31 | - // 卡牌卡包 | ||
| 32 | - for _, gameId := range constd.GameListCardHolder { | ||
| 33 | - InitTable(DbCommon, new(CardHolderData), gameId) | ||
| 34 | - InitTable(DbCommon, new(CardHolderRecordOpen), gameId) | ||
| 35 | - InitTable(DbCommon, new(CardHolderRecordRewardAlbum), gameId) | ||
| 36 | - InitTable(DbCommon, new(CardHolderRecordRewardRound), gameId) | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | -} |
dto/inits.go
| @@ -1,46 +0,0 @@ | @@ -1,46 +0,0 @@ | ||
| 1 | -package dto | ||
| 2 | - | ||
| 3 | -import ( | ||
| 4 | - "apigame/service/constd" | ||
| 5 | - "apigame/util/util-lx/lxmysql" | ||
| 6 | - "fmt" | ||
| 7 | - "github.com/astaxie/beego" | ||
| 8 | -) | ||
| 9 | - | ||
| 10 | -func Inits() (err error) { | ||
| 11 | - | ||
| 12 | - appname := beego.AppConfig.String("appname") | ||
| 13 | - | ||
| 14 | - //初始化MYSQL | ||
| 15 | - var conns []lxmysql.MapMysqlConn | ||
| 16 | - | ||
| 17 | - //默认数据库 | ||
| 18 | - conns = append(conns, lxmysql.MapMysqlConn{ | ||
| 19 | - Name: constd.MYSQL_DEFAULT, | ||
| 20 | - SqlCon: beego.AppConfig.String("mysql::mergecommon"), | ||
| 21 | - }) | ||
| 22 | - | ||
| 23 | - conns = append(conns, lxmysql.MapMysqlConn{ | ||
| 24 | - Name: constd.MYSQL_MERGECONFIG, | ||
| 25 | - SqlCon: beego.AppConfig.String("mysql::" + constd.MYSQL_MERGECONFIG), | ||
| 26 | - }) | ||
| 27 | - | ||
| 28 | - err = lxmysql.InitMysqls(conns, beego.AppConfig.String("redis::cachedb")) | ||
| 29 | - if err != nil { | ||
| 30 | - fmt.Println(" InitMysqls Error::" + err.Error()) | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - for _, conn := range conns { | ||
| 34 | - fmt.Println(appname + " dbs::" + conn.Name + " init success") | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - //// 初始化数数打点 | ||
| 38 | - //_ = thinkingdata.InitThinkData() | ||
| 39 | - // | ||
| 40 | - //_ = config.InitLxLimit() | ||
| 41 | - | ||
| 42 | - // dto | ||
| 43 | - InitDto() | ||
| 44 | - | ||
| 45 | - return | ||
| 46 | -} |
dto/interface.go
dto/record.go
main.go
| @@ -2,9 +2,10 @@ package main | @@ -2,9 +2,10 @@ package main | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "apigame/common/svconst" | 4 | "apigame/common/svconst" |
| 5 | + "apigame/common/svdto" | ||
| 5 | "apigame/common/svlog" | 6 | "apigame/common/svlog" |
| 7 | + "apigame/common/svmysql" | ||
| 6 | "apigame/common/svredis" | 8 | "apigame/common/svredis" |
| 7 | - "apigame/dto" | ||
| 8 | _ "apigame/routers" | 9 | _ "apigame/routers" |
| 9 | "apigame/service/cardholder" | 10 | "apigame/service/cardholder" |
| 10 | "github.com/astaxie/beego" | 11 | "github.com/astaxie/beego" |
| @@ -47,7 +48,16 @@ func Init() { | @@ -47,7 +48,16 @@ func Init() { | ||
| 47 | return | 48 | return |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | - _ = dto.Inits() | 51 | + if !svmysql.Init() { |
| 52 | + return | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + //// 初始化数数打点 | ||
| 56 | + //_ = thinkingdata.InitThinkData() | ||
| 57 | + // | ||
| 58 | + //_ = config.InitLxLimit() | ||
| 59 | + | ||
| 60 | + svdto.Init() | ||
| 51 | 61 | ||
| 52 | // 初始化配置 | 62 | // 初始化配置 |
| 53 | cardholder.Init() | 63 | cardholder.Init() |
service/cardholder/config-load.go
| 1 | package cardholder | 1 | package cardholder |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | - "apigame/dto" | 4 | + "apigame/common/svconst" |
| 5 | + "apigame/common/svdto" | ||
| 5 | "apigame/service/constd" | 6 | "apigame/service/constd" |
| 6 | "fmt" | 7 | "fmt" |
| 7 | ) | 8 | ) |
| @@ -38,7 +39,7 @@ func LoadConfig(gameId string) { | @@ -38,7 +39,7 @@ func LoadConfig(gameId string) { | ||
| 38 | configOpen := CardActivityUpdateConfig{Id: 0} | 39 | configOpen := CardActivityUpdateConfig{Id: 0} |
| 39 | { | 40 | { |
| 40 | conf := make([]CardActivityUpdateConfig, 0) | 41 | conf := make([]CardActivityUpdateConfig, 0) |
| 41 | - _, err := dto.Find(dto.DbConfig, &conf, new(CardActivityUpdateConfig).GetTableName(gameId)) | 42 | + _, err := svdto.Find(svconst.DbConfig, &conf, new(CardActivityUpdateConfig).GetTableName(gameId)) |
| 42 | if err != nil { | 43 | if err != nil { |
| 43 | return | 44 | return |
| 44 | } | 45 | } |
| @@ -67,7 +68,7 @@ func LoadConfig(gameId string) { | @@ -67,7 +68,7 @@ func LoadConfig(gameId string) { | ||
| 67 | // 更新数据 | 68 | // 更新数据 |
| 68 | if needUpdate { | 69 | if needUpdate { |
| 69 | confNew := &CardActivityConfigRaw{} | 70 | confNew := &CardActivityConfigRaw{} |
| 70 | - hasConfNew, err := dto.First(dto.DbConfig, confNew, gameId) | 71 | + hasConfNew, err := svdto.First(svconst.DbConfig, confNew, gameId) |
| 71 | if err != nil { | 72 | if err != nil { |
| 72 | return | 73 | return |
| 73 | } | 74 | } |
service/cardholder/logic.go
| 1 | package cardholder | 1 | package cardholder |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "apigame/common/svconst" | ||
| 5 | + "apigame/common/svdto" | ||
| 4 | "apigame/dto" | 6 | "apigame/dto" |
| 5 | "apigame/models" | 7 | "apigame/models" |
| 6 | "apigame/service/constd" | 8 | "apigame/service/constd" |
| @@ -16,12 +18,12 @@ func SaveData(gameId string, d *dto.CardHolderData) { | @@ -16,12 +18,12 @@ func SaveData(gameId string, d *dto.CardHolderData) { | ||
| 16 | d.UpdateTime = lxtime.NowUninx() | 18 | d.UpdateTime = lxtime.NowUninx() |
| 17 | d.Encode() | 19 | d.Encode() |
| 18 | 20 | ||
| 19 | - dto.Save(dto.DbCommon, d, gameId) | 21 | + svdto.Save(svconst.DbCommon, d, gameId) |
| 20 | } | 22 | } |
| 21 | 23 | ||
| 22 | func _LoadData(gameId string, uid int64) (d *dto.CardHolderData) { | 24 | func _LoadData(gameId string, uid int64) (d *dto.CardHolderData) { |
| 23 | d = dto.NewCardHolderData(uid) | 25 | d = dto.NewCardHolderData(uid) |
| 24 | - has, err := dto.First(dto.DbCommon, d, gameId) | 26 | + has, err := svdto.First(svconst.DbCommon, d, gameId) |
| 25 | if err != nil { | 27 | if err != nil { |
| 26 | return | 28 | return |
| 27 | } | 29 | } |
| @@ -29,7 +31,7 @@ func _LoadData(gameId string, uid int64) (d *dto.CardHolderData) { | @@ -29,7 +31,7 @@ func _LoadData(gameId string, uid int64) (d *dto.CardHolderData) { | ||
| 29 | d.Decode() | 31 | d.Decode() |
| 30 | } else { | 32 | } else { |
| 31 | d.Init(uid) | 33 | d.Init(uid) |
| 32 | - dto.Insert(dto.DbCommon, d, gameId) | 34 | + svdto.Insert(svconst.DbCommon, d, gameId) |
| 33 | } | 35 | } |
| 34 | return | 36 | return |
| 35 | } | 37 | } |
| @@ -228,7 +230,7 @@ func DoOpen(gameId string, | @@ -228,7 +230,7 @@ func DoOpen(gameId string, | ||
| 228 | // 记录开卡包日志 | 230 | // 记录开卡包日志 |
| 229 | { | 231 | { |
| 230 | recordBase := dto.NewCardHolderRecordBase(gameData.Uid, sequenceId, cohort, config.Id, gameData.Details.Round) | 232 | recordBase := dto.NewCardHolderRecordBase(gameData.Uid, sequenceId, cohort, config.Id, gameData.Details.Round) |
| 231 | - dto.SaveRecord(gameId, dto.NewCardHolderRecordOpen(recordBase, | 233 | + svdto.SaveRecord(gameId, dto.NewCardHolderRecordOpen(recordBase, |
| 232 | openMode, utstring.StringToInt(confCardholder.Id), zjson.Str(newCards))) | 234 | openMode, utstring.StringToInt(confCardholder.Id), zjson.Str(newCards))) |
| 233 | } | 235 | } |
| 234 | 236 | ||
| @@ -276,7 +278,7 @@ func DoOpenCheckAward(gameId string, | @@ -276,7 +278,7 @@ func DoOpenCheckAward(gameId string, | ||
| 276 | { | 278 | { |
| 277 | // 记录日志 | 279 | // 记录日志 |
| 278 | recordBase := dto.NewCardHolderRecordBase(gameData.Uid, sequenceId, cohort, config.Id, gameData.Details.Round) | 280 | recordBase := dto.NewCardHolderRecordBase(gameData.Uid, sequenceId, cohort, config.Id, gameData.Details.Round) |
| 279 | - dto.SaveRecord(gameId, dto.NewCardHolderRecordRewardAlbum(recordBase, | 281 | + svdto.SaveRecord(gameId, dto.NewCardHolderRecordRewardAlbum(recordBase, |
| 280 | albumId, award)) | 282 | albumId, award)) |
| 281 | } | 283 | } |
| 282 | } | 284 | } |
| @@ -287,7 +289,7 @@ func DoOpenCheckAward(gameId string, | @@ -287,7 +289,7 @@ func DoOpenCheckAward(gameId string, | ||
| 287 | 289 | ||
| 288 | // 记录日志 | 290 | // 记录日志 |
| 289 | recordBase := dto.NewCardHolderRecordBase(gameData.Uid, sequenceId, cohort, config.Id, gameData.Details.Round) | 291 | recordBase := dto.NewCardHolderRecordBase(gameData.Uid, sequenceId, cohort, config.Id, gameData.Details.Round) |
| 290 | - dto.SaveRecord(gameId, dto.NewCardHolderRecordRewardRound(recordBase, | 292 | + svdto.SaveRecord(gameId, dto.NewCardHolderRecordRewardRound(recordBase, |
| 291 | awardRound)) | 293 | awardRound)) |
| 292 | 294 | ||
| 293 | // 处理轮次完成 | 295 | // 处理轮次完成 |
service/constd/mysql.go
| @@ -6,6 +6,7 @@ package constd | @@ -6,6 +6,7 @@ package constd | ||
| 6 | 6 | ||
| 7 | const ( | 7 | const ( |
| 8 | MYSQL_DEFAULT = "default" | 8 | MYSQL_DEFAULT = "default" |
| 9 | + MYSQL_DBAPI = "api" | ||
| 9 | MYSQL_MERGECOMMON = "merge_common" | 10 | MYSQL_MERGECOMMON = "merge_common" |
| 10 | MYSQL_MERGECONFIG = "merge_config" | 11 | MYSQL_MERGECONFIG = "merge_config" |
| 11 | MYSQL_DEFAULT_QUERY_MAXCOUNT = 100 | 12 | MYSQL_DEFAULT_QUERY_MAXCOUNT = 100 |