From ef401a035d474b571ffb2e4e9e7bc121d9226cf1 Mon Sep 17 00:00:00 2001 From: 王家文 Date: Wed, 17 Apr 2024 17:56:19 +0800 Subject: [PATCH] feat✨:房间排行活动基本框架 --- configs/feat-api.go | 8 ++++---- configs/feat-cardholder.go | 8 ++++---- configs/feat-roomrank.go | 8 ++++---- service-common/svmysql/dto.go | 30 +++++++++++++++--------------- service-common/svmysql/interface.go | 2 +- service-common/svredis/interface.go | 2 +- service/cardholder/dto-game.go | 4 ++-- service/cardholder/dto-record.go | 12 ++++++------ service/roomrank/dto-game.go | 4 ++-- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/configs/feat-api.go b/configs/feat-api.go index 3f1df05..3f33dfe 100644 --- a/configs/feat-api.go +++ b/configs/feat-api.go @@ -16,18 +16,18 @@ type ApiGameConfig struct { Name string `gorm:"column:name"` } -func (c *ApiGameConfig) RedisInfo(gameId string) *svredis.RedisInfo { +func (c *ApiGameConfig) RedisInfo(suffix string) *svredis.RedisInfo { tableName := "s_game_config" return &svredis.RedisInfo{ - CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, gameId), + CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, suffix), CacheTime: 300, } } -func (c *ApiGameConfig) MysqlInfo(gameId string) *svmysql.MysqlInfo { +func (c *ApiGameConfig) MysqlInfo(suffix string) *svmysql.MysqlInfo { tableName := "s_game_config" return &svmysql.MysqlInfo{ - DbMysql: svconst.DbApi.Where("gameid = ?", gameId), + DbMysql: svconst.DbApi.Where("gameid = ?", suffix), TableName: tableName, } } diff --git a/configs/feat-cardholder.go b/configs/feat-cardholder.go index 071c20e..1a238f7 100644 --- a/configs/feat-cardholder.go +++ b/configs/feat-cardholder.go @@ -30,10 +30,10 @@ type CardActivityConfig struct { GameId string // 所属游戏ID } -func (c *CardActivityConfig) RedisInfo(gameId string) *svredis.RedisInfo { +func (c *CardActivityConfig) RedisInfo(suffix string) *svredis.RedisInfo { tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG return &svredis.RedisInfo{ - CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, gameId), + CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, suffix), CacheTime: 300, } } @@ -58,11 +58,11 @@ type CardActivityConfigRaw struct { UpdateTime int64 // 修改时间戳 } -func (c *CardActivityConfigRaw) MysqlInfo(gameId string) *svmysql.MysqlInfo { +func (c *CardActivityConfigRaw) MysqlInfo(suffix string) *svmysql.MysqlInfo { tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG return &svmysql.MysqlInfo{ DbMysql: svconst.DbConfig.Where("status = ?", 1), - TableName: tableName + gameId, + TableName: tableName + suffix, } } diff --git a/configs/feat-roomrank.go b/configs/feat-roomrank.go index c39995a..6645e10 100644 --- a/configs/feat-roomrank.go +++ b/configs/feat-roomrank.go @@ -17,10 +17,10 @@ type RoomRankConfig struct { GameId string // 所属游戏ID } -func (c *RoomRankConfig) RedisInfo(gameId string) *svredis.RedisInfo { +func (c *RoomRankConfig) RedisInfo(suffix string) *svredis.RedisInfo { tableName := svconst.MYSQL_TABLE_S_ROOMRANK_CONFIG return &svredis.RedisInfo{ - CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, gameId), + CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, suffix), CacheTime: 300, } } @@ -45,11 +45,11 @@ type RoomRankConfigRaw struct { UpdateTime int64 // 修改时间戳 } -func (c *RoomRankConfigRaw) MysqlInfo(gameId string) *svmysql.MysqlInfo { +func (c *RoomRankConfigRaw) MysqlInfo(suffix string) *svmysql.MysqlInfo { tableName := svconst.MYSQL_TABLE_S_ROOMRANK_CONFIG return &svmysql.MysqlInfo{ DbMysql: svconst.DbConfig.Where("status = ?", 1), - TableName: tableName + gameId, + TableName: tableName + suffix, } } diff --git a/service-common/svmysql/dto.go b/service-common/svmysql/dto.go index d379890..97f1a89 100644 --- a/service-common/svmysql/dto.go +++ b/service-common/svmysql/dto.go @@ -6,8 +6,8 @@ import ( "strings" ) -func Insert(obj IMysqlData, gameId string) (err error) { - info := obj.MysqlInfo(gameId) +func Insert(obj IMysqlData, suffix string) (err error) { + info := obj.MysqlInfo(suffix) db := info.DbMysql stmt := db.Session(&gorm.Session{DryRun: true}).Create(obj).Statement stmtSQL := stmt.SQL.String() @@ -15,14 +15,14 @@ func Insert(obj IMysqlData, gameId string) (err error) { result := db.Exec(sql, stmt.Vars...) err = result.Error if err != nil { - lxalilog.Errors(err, gameId) + lxalilog.Errors(err, suffix) return } return } -func Updates(obj IMysqlData, gameId string) (err error) { - info := obj.MysqlInfo(gameId) +func Updates(obj IMysqlData, suffix string) (err error) { + info := obj.MysqlInfo(suffix) db := info.DbMysql stmt := db.Session(&gorm.Session{DryRun: true}).Updates(obj).Statement stmtSQL := stmt.SQL.String() @@ -30,14 +30,14 @@ func Updates(obj IMysqlData, gameId string) (err error) { result := db.Exec(sql, stmt.Vars...) err = result.Error if err != nil { - lxalilog.Errors(err, gameId) + lxalilog.Errors(err, suffix) return } return } -func Save(obj IMysqlData, gameId string) (err error) { - info := obj.MysqlInfo(gameId) +func Save(obj IMysqlData, suffix string) (err error) { + info := obj.MysqlInfo(suffix) db := info.DbMysql stmt := db.Session(&gorm.Session{DryRun: true}).Save(obj).Statement stmtSQL := stmt.SQL.String() @@ -45,14 +45,14 @@ func Save(obj IMysqlData, gameId string) (err error) { result := db.Exec(sql, stmt.Vars...) err = result.Error if err != nil { - lxalilog.Errors(err, gameId) + lxalilog.Errors(err, suffix) return } return } -func First(obj IMysqlData, gameId string) (has bool, err error) { - info := obj.MysqlInfo(gameId) +func First(obj IMysqlData, suffix string) (has bool, err error) { + info := obj.MysqlInfo(suffix) db := info.DbMysql stmt := db.Session(&gorm.Session{DryRun: true}).First(obj).Statement stmtSQL := stmt.SQL.String() @@ -61,14 +61,14 @@ func First(obj IMysqlData, gameId string) (has bool, err error) { has = result.RowsAffected != 0 err = result.Error if err != nil { - lxalilog.Errors(err, gameId) + lxalilog.Errors(err, suffix) return } return } -func Find(obj IMysqlData, gameId string) (has bool, err error) { - info := obj.MysqlInfo(gameId) +func Find(obj IMysqlData, suffix string) (has bool, err error) { + info := obj.MysqlInfo(suffix) db := info.DbMysql stmt := db.Session(&gorm.Session{DryRun: true}).Find(obj).Statement stmtSQL := stmt.SQL.String() @@ -77,7 +77,7 @@ func Find(obj IMysqlData, gameId string) (has bool, err error) { has = result.RowsAffected != 0 err = result.Error if err != nil { - lxalilog.Errors(err, gameId) + lxalilog.Errors(err, suffix) return } return diff --git a/service-common/svmysql/interface.go b/service-common/svmysql/interface.go index fba3d4d..4ec7795 100644 --- a/service-common/svmysql/interface.go +++ b/service-common/svmysql/interface.go @@ -11,5 +11,5 @@ type MysqlInfo struct { // IMysqlData mysql存储对象 type IMysqlData interface { // MysqlInfo mysql存储信息 - MysqlInfo(gameId string) *MysqlInfo + MysqlInfo(suffix string) *MysqlInfo } diff --git a/service-common/svredis/interface.go b/service-common/svredis/interface.go index 0c24d5d..cec4b43 100644 --- a/service-common/svredis/interface.go +++ b/service-common/svredis/interface.go @@ -9,5 +9,5 @@ type RedisInfo struct { // IRedisData redis存储对象 type IRedisData interface { // RedisInfo redis存储信息 - RedisInfo(gameId string) *RedisInfo + RedisInfo(suffix string) *RedisInfo } diff --git a/service/cardholder/dto-game.go b/service/cardholder/dto-game.go index e609812..1db795d 100644 --- a/service/cardholder/dto-game.go +++ b/service/cardholder/dto-game.go @@ -20,11 +20,11 @@ type DataCardHolder struct { UpdateTime int64 `gorm:"comment:修改时间戳"` } -func (d *DataCardHolder) MysqlInfo(gameId string) *svmysql.MysqlInfo { +func (d *DataCardHolder) MysqlInfo(suffix string) *svmysql.MysqlInfo { tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_DATA return &svmysql.MysqlInfo{ DbMysql: svconst.DbCommon, - TableName: tableName + gameId, + TableName: tableName + suffix, } } diff --git a/service/cardholder/dto-record.go b/service/cardholder/dto-record.go index 60bf9fe..c8efb61 100644 --- a/service/cardholder/dto-record.go +++ b/service/cardholder/dto-record.go @@ -39,11 +39,11 @@ type RecordCardHolderOpen struct { CardList string `gorm:"type:varchar(255);comment:开卡内容"` } -func (d *RecordCardHolderOpen) MysqlInfo(gameId string) *svmysql.MysqlInfo { +func (d *RecordCardHolderOpen) MysqlInfo(suffix string) *svmysql.MysqlInfo { tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_OPEN return &svmysql.MysqlInfo{ DbMysql: svconst.DbCommon, - TableName: tableName + gameId, + TableName: tableName + suffix, } } @@ -64,11 +64,11 @@ type RecordCardHolderRewardAlbum struct { Award string `gorm:"type:varchar(255);comment:奖励内容"` } -func (d *RecordCardHolderRewardAlbum) MysqlInfo(gameId string) *svmysql.MysqlInfo { +func (d *RecordCardHolderRewardAlbum) MysqlInfo(suffix string) *svmysql.MysqlInfo { tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_REWARDALBUM return &svmysql.MysqlInfo{ DbMysql: svconst.DbCommon, - TableName: tableName + gameId, + TableName: tableName + suffix, } } @@ -87,11 +87,11 @@ type RecordCardHolderRewardRound struct { Award string `gorm:"type:varchar(255);comment:奖励内容"` } -func (d *RecordCardHolderRewardRound) MysqlInfo(gameId string) *svmysql.MysqlInfo { +func (d *RecordCardHolderRewardRound) MysqlInfo(suffix string) *svmysql.MysqlInfo { tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_REWARDROUND return &svmysql.MysqlInfo{ DbMysql: svconst.DbCommon, - TableName: tableName + gameId, + TableName: tableName + suffix, } } diff --git a/service/roomrank/dto-game.go b/service/roomrank/dto-game.go index 4ed1fc8..a7e2274 100644 --- a/service/roomrank/dto-game.go +++ b/service/roomrank/dto-game.go @@ -21,11 +21,11 @@ type DataRoomRank struct { UpdateTime int64 `gorm:"comment:修改时间戳"` } -func (d *DataRoomRank) MysqlInfo(gameId string) *svmysql.MysqlInfo { +func (d *DataRoomRank) MysqlInfo(suffix string) *svmysql.MysqlInfo { tableName := svconst.MYSQL_TABLE_S_ROOMRANK_DATA return &svmysql.MysqlInfo{ DbMysql: svconst.DbCommon, - TableName: tableName + gameId, + TableName: tableName + suffix, } } -- libgit2 0.21.0