Commit ef401a035d474b571ffb2e4e9e7bc121d9226cf1

Authored by 王家文
1 parent 74be11b7
Exists in master and in 1 other branch dev-wjw

feat✨:房间排行活动基本框架

configs/feat-api.go
@@ -16,18 +16,18 @@ type ApiGameConfig struct { @@ -16,18 +16,18 @@ type ApiGameConfig struct {
16 Name string `gorm:"column:name"` 16 Name string `gorm:"column:name"`
17 } 17 }
18 18
19 -func (c *ApiGameConfig) RedisInfo(gameId string) *svredis.RedisInfo { 19 +func (c *ApiGameConfig) RedisInfo(suffix string) *svredis.RedisInfo {
20 tableName := "s_game_config" 20 tableName := "s_game_config"
21 return &svredis.RedisInfo{ 21 return &svredis.RedisInfo{
22 - CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, gameId), 22 + CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, suffix),
23 CacheTime: 300, 23 CacheTime: 300,
24 } 24 }
25 } 25 }
26 26
27 -func (c *ApiGameConfig) MysqlInfo(gameId string) *svmysql.MysqlInfo { 27 +func (c *ApiGameConfig) MysqlInfo(suffix string) *svmysql.MysqlInfo {
28 tableName := "s_game_config" 28 tableName := "s_game_config"
29 return &svmysql.MysqlInfo{ 29 return &svmysql.MysqlInfo{
30 - DbMysql: svconst.DbApi.Where("gameid = ?", gameId), 30 + DbMysql: svconst.DbApi.Where("gameid = ?", suffix),
31 TableName: tableName, 31 TableName: tableName,
32 } 32 }
33 } 33 }
configs/feat-cardholder.go
@@ -30,10 +30,10 @@ type CardActivityConfig struct { @@ -30,10 +30,10 @@ type CardActivityConfig struct {
30 GameId string // 所属游戏ID 30 GameId string // 所属游戏ID
31 } 31 }
32 32
33 -func (c *CardActivityConfig) RedisInfo(gameId string) *svredis.RedisInfo { 33 +func (c *CardActivityConfig) RedisInfo(suffix string) *svredis.RedisInfo {
34 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG 34 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG
35 return &svredis.RedisInfo{ 35 return &svredis.RedisInfo{
36 - CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, gameId), 36 + CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, suffix),
37 CacheTime: 300, 37 CacheTime: 300,
38 } 38 }
39 } 39 }
@@ -58,11 +58,11 @@ type CardActivityConfigRaw struct { @@ -58,11 +58,11 @@ type CardActivityConfigRaw struct {
58 UpdateTime int64 // 修改时间戳 58 UpdateTime int64 // 修改时间戳
59 } 59 }
60 60
61 -func (c *CardActivityConfigRaw) MysqlInfo(gameId string) *svmysql.MysqlInfo { 61 +func (c *CardActivityConfigRaw) MysqlInfo(suffix string) *svmysql.MysqlInfo {
62 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG 62 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG
63 return &svmysql.MysqlInfo{ 63 return &svmysql.MysqlInfo{
64 DbMysql: svconst.DbConfig.Where("status = ?", 1), 64 DbMysql: svconst.DbConfig.Where("status = ?", 1),
65 - TableName: tableName + gameId, 65 + TableName: tableName + suffix,
66 } 66 }
67 } 67 }
68 68
configs/feat-roomrank.go
@@ -17,10 +17,10 @@ type RoomRankConfig struct { @@ -17,10 +17,10 @@ type RoomRankConfig struct {
17 GameId string // 所属游戏ID 17 GameId string // 所属游戏ID
18 } 18 }
19 19
20 -func (c *RoomRankConfig) RedisInfo(gameId string) *svredis.RedisInfo { 20 +func (c *RoomRankConfig) RedisInfo(suffix string) *svredis.RedisInfo {
21 tableName := svconst.MYSQL_TABLE_S_ROOMRANK_CONFIG 21 tableName := svconst.MYSQL_TABLE_S_ROOMRANK_CONFIG
22 return &svredis.RedisInfo{ 22 return &svredis.RedisInfo{
23 - CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, gameId), 23 + CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, suffix),
24 CacheTime: 300, 24 CacheTime: 300,
25 } 25 }
26 } 26 }
@@ -45,11 +45,11 @@ type RoomRankConfigRaw struct { @@ -45,11 +45,11 @@ type RoomRankConfigRaw struct {
45 UpdateTime int64 // 修改时间戳 45 UpdateTime int64 // 修改时间戳
46 } 46 }
47 47
48 -func (c *RoomRankConfigRaw) MysqlInfo(gameId string) *svmysql.MysqlInfo { 48 +func (c *RoomRankConfigRaw) MysqlInfo(suffix string) *svmysql.MysqlInfo {
49 tableName := svconst.MYSQL_TABLE_S_ROOMRANK_CONFIG 49 tableName := svconst.MYSQL_TABLE_S_ROOMRANK_CONFIG
50 return &svmysql.MysqlInfo{ 50 return &svmysql.MysqlInfo{
51 DbMysql: svconst.DbConfig.Where("status = ?", 1), 51 DbMysql: svconst.DbConfig.Where("status = ?", 1),
52 - TableName: tableName + gameId, 52 + TableName: tableName + suffix,
53 } 53 }
54 } 54 }
55 55
service-common/svmysql/dto.go
@@ -6,8 +6,8 @@ import ( @@ -6,8 +6,8 @@ import (
6 "strings" 6 "strings"
7 ) 7 )
8 8
9 -func Insert(obj IMysqlData, gameId string) (err error) {  
10 - info := obj.MysqlInfo(gameId) 9 +func Insert(obj IMysqlData, suffix string) (err error) {
  10 + info := obj.MysqlInfo(suffix)
11 db := info.DbMysql 11 db := info.DbMysql
12 stmt := db.Session(&gorm.Session{DryRun: true}).Create(obj).Statement 12 stmt := db.Session(&gorm.Session{DryRun: true}).Create(obj).Statement
13 stmtSQL := stmt.SQL.String() 13 stmtSQL := stmt.SQL.String()
@@ -15,14 +15,14 @@ func Insert(obj IMysqlData, gameId string) (err error) { @@ -15,14 +15,14 @@ func Insert(obj IMysqlData, gameId string) (err error) {
15 result := db.Exec(sql, stmt.Vars...) 15 result := db.Exec(sql, stmt.Vars...)
16 err = result.Error 16 err = result.Error
17 if err != nil { 17 if err != nil {
18 - lxalilog.Errors(err, gameId) 18 + lxalilog.Errors(err, suffix)
19 return 19 return
20 } 20 }
21 return 21 return
22 } 22 }
23 23
24 -func Updates(obj IMysqlData, gameId string) (err error) {  
25 - info := obj.MysqlInfo(gameId) 24 +func Updates(obj IMysqlData, suffix string) (err error) {
  25 + info := obj.MysqlInfo(suffix)
26 db := info.DbMysql 26 db := info.DbMysql
27 stmt := db.Session(&gorm.Session{DryRun: true}).Updates(obj).Statement 27 stmt := db.Session(&gorm.Session{DryRun: true}).Updates(obj).Statement
28 stmtSQL := stmt.SQL.String() 28 stmtSQL := stmt.SQL.String()
@@ -30,14 +30,14 @@ func Updates(obj IMysqlData, gameId string) (err error) { @@ -30,14 +30,14 @@ func Updates(obj IMysqlData, gameId string) (err error) {
30 result := db.Exec(sql, stmt.Vars...) 30 result := db.Exec(sql, stmt.Vars...)
31 err = result.Error 31 err = result.Error
32 if err != nil { 32 if err != nil {
33 - lxalilog.Errors(err, gameId) 33 + lxalilog.Errors(err, suffix)
34 return 34 return
35 } 35 }
36 return 36 return
37 } 37 }
38 38
39 -func Save(obj IMysqlData, gameId string) (err error) {  
40 - info := obj.MysqlInfo(gameId) 39 +func Save(obj IMysqlData, suffix string) (err error) {
  40 + info := obj.MysqlInfo(suffix)
41 db := info.DbMysql 41 db := info.DbMysql
42 stmt := db.Session(&gorm.Session{DryRun: true}).Save(obj).Statement 42 stmt := db.Session(&gorm.Session{DryRun: true}).Save(obj).Statement
43 stmtSQL := stmt.SQL.String() 43 stmtSQL := stmt.SQL.String()
@@ -45,14 +45,14 @@ func Save(obj IMysqlData, gameId string) (err error) { @@ -45,14 +45,14 @@ func Save(obj IMysqlData, gameId string) (err error) {
45 result := db.Exec(sql, stmt.Vars...) 45 result := db.Exec(sql, stmt.Vars...)
46 err = result.Error 46 err = result.Error
47 if err != nil { 47 if err != nil {
48 - lxalilog.Errors(err, gameId) 48 + lxalilog.Errors(err, suffix)
49 return 49 return
50 } 50 }
51 return 51 return
52 } 52 }
53 53
54 -func First(obj IMysqlData, gameId string) (has bool, err error) {  
55 - info := obj.MysqlInfo(gameId) 54 +func First(obj IMysqlData, suffix string) (has bool, err error) {
  55 + info := obj.MysqlInfo(suffix)
56 db := info.DbMysql 56 db := info.DbMysql
57 stmt := db.Session(&gorm.Session{DryRun: true}).First(obj).Statement 57 stmt := db.Session(&gorm.Session{DryRun: true}).First(obj).Statement
58 stmtSQL := stmt.SQL.String() 58 stmtSQL := stmt.SQL.String()
@@ -61,14 +61,14 @@ func First(obj IMysqlData, gameId string) (has bool, err error) { @@ -61,14 +61,14 @@ func First(obj IMysqlData, gameId string) (has bool, err error) {
61 has = result.RowsAffected != 0 61 has = result.RowsAffected != 0
62 err = result.Error 62 err = result.Error
63 if err != nil { 63 if err != nil {
64 - lxalilog.Errors(err, gameId) 64 + lxalilog.Errors(err, suffix)
65 return 65 return
66 } 66 }
67 return 67 return
68 } 68 }
69 69
70 -func Find(obj IMysqlData, gameId string) (has bool, err error) {  
71 - info := obj.MysqlInfo(gameId) 70 +func Find(obj IMysqlData, suffix string) (has bool, err error) {
  71 + info := obj.MysqlInfo(suffix)
72 db := info.DbMysql 72 db := info.DbMysql
73 stmt := db.Session(&gorm.Session{DryRun: true}).Find(obj).Statement 73 stmt := db.Session(&gorm.Session{DryRun: true}).Find(obj).Statement
74 stmtSQL := stmt.SQL.String() 74 stmtSQL := stmt.SQL.String()
@@ -77,7 +77,7 @@ func Find(obj IMysqlData, gameId string) (has bool, err error) { @@ -77,7 +77,7 @@ func Find(obj IMysqlData, gameId string) (has bool, err error) {
77 has = result.RowsAffected != 0 77 has = result.RowsAffected != 0
78 err = result.Error 78 err = result.Error
79 if err != nil { 79 if err != nil {
80 - lxalilog.Errors(err, gameId) 80 + lxalilog.Errors(err, suffix)
81 return 81 return
82 } 82 }
83 return 83 return
service-common/svmysql/interface.go
@@ -11,5 +11,5 @@ type MysqlInfo struct { @@ -11,5 +11,5 @@ type MysqlInfo struct {
11 // IMysqlData mysql存储对象 11 // IMysqlData mysql存储对象
12 type IMysqlData interface { 12 type IMysqlData interface {
13 // MysqlInfo mysql存储信息 13 // MysqlInfo mysql存储信息
14 - MysqlInfo(gameId string) *MysqlInfo 14 + MysqlInfo(suffix string) *MysqlInfo
15 } 15 }
service-common/svredis/interface.go
@@ -9,5 +9,5 @@ type RedisInfo struct { @@ -9,5 +9,5 @@ type RedisInfo struct {
9 // IRedisData redis存储对象 9 // IRedisData redis存储对象
10 type IRedisData interface { 10 type IRedisData interface {
11 // RedisInfo redis存储信息 11 // RedisInfo redis存储信息
12 - RedisInfo(gameId string) *RedisInfo 12 + RedisInfo(suffix string) *RedisInfo
13 } 13 }
service/cardholder/dto-game.go
@@ -20,11 +20,11 @@ type DataCardHolder struct { @@ -20,11 +20,11 @@ type DataCardHolder struct {
20 UpdateTime int64 `gorm:"comment:修改时间戳"` 20 UpdateTime int64 `gorm:"comment:修改时间戳"`
21 } 21 }
22 22
23 -func (d *DataCardHolder) MysqlInfo(gameId string) *svmysql.MysqlInfo { 23 +func (d *DataCardHolder) MysqlInfo(suffix string) *svmysql.MysqlInfo {
24 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_DATA 24 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_DATA
25 return &svmysql.MysqlInfo{ 25 return &svmysql.MysqlInfo{
26 DbMysql: svconst.DbCommon, 26 DbMysql: svconst.DbCommon,
27 - TableName: tableName + gameId, 27 + TableName: tableName + suffix,
28 } 28 }
29 } 29 }
30 30
service/cardholder/dto-record.go
@@ -39,11 +39,11 @@ type RecordCardHolderOpen struct { @@ -39,11 +39,11 @@ type RecordCardHolderOpen struct {
39 CardList string `gorm:"type:varchar(255);comment:开卡内容"` 39 CardList string `gorm:"type:varchar(255);comment:开卡内容"`
40 } 40 }
41 41
42 -func (d *RecordCardHolderOpen) MysqlInfo(gameId string) *svmysql.MysqlInfo { 42 +func (d *RecordCardHolderOpen) MysqlInfo(suffix string) *svmysql.MysqlInfo {
43 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_OPEN 43 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_OPEN
44 return &svmysql.MysqlInfo{ 44 return &svmysql.MysqlInfo{
45 DbMysql: svconst.DbCommon, 45 DbMysql: svconst.DbCommon,
46 - TableName: tableName + gameId, 46 + TableName: tableName + suffix,
47 } 47 }
48 } 48 }
49 49
@@ -64,11 +64,11 @@ type RecordCardHolderRewardAlbum struct { @@ -64,11 +64,11 @@ type RecordCardHolderRewardAlbum struct {
64 Award string `gorm:"type:varchar(255);comment:奖励内容"` 64 Award string `gorm:"type:varchar(255);comment:奖励内容"`
65 } 65 }
66 66
67 -func (d *RecordCardHolderRewardAlbum) MysqlInfo(gameId string) *svmysql.MysqlInfo { 67 +func (d *RecordCardHolderRewardAlbum) MysqlInfo(suffix string) *svmysql.MysqlInfo {
68 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_REWARDALBUM 68 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_REWARDALBUM
69 return &svmysql.MysqlInfo{ 69 return &svmysql.MysqlInfo{
70 DbMysql: svconst.DbCommon, 70 DbMysql: svconst.DbCommon,
71 - TableName: tableName + gameId, 71 + TableName: tableName + suffix,
72 } 72 }
73 } 73 }
74 74
@@ -87,11 +87,11 @@ type RecordCardHolderRewardRound struct { @@ -87,11 +87,11 @@ type RecordCardHolderRewardRound struct {
87 Award string `gorm:"type:varchar(255);comment:奖励内容"` 87 Award string `gorm:"type:varchar(255);comment:奖励内容"`
88 } 88 }
89 89
90 -func (d *RecordCardHolderRewardRound) MysqlInfo(gameId string) *svmysql.MysqlInfo { 90 +func (d *RecordCardHolderRewardRound) MysqlInfo(suffix string) *svmysql.MysqlInfo {
91 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_REWARDROUND 91 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_REWARDROUND
92 return &svmysql.MysqlInfo{ 92 return &svmysql.MysqlInfo{
93 DbMysql: svconst.DbCommon, 93 DbMysql: svconst.DbCommon,
94 - TableName: tableName + gameId, 94 + TableName: tableName + suffix,
95 } 95 }
96 } 96 }
97 97
service/roomrank/dto-game.go
@@ -21,11 +21,11 @@ type DataRoomRank struct { @@ -21,11 +21,11 @@ type DataRoomRank struct {
21 UpdateTime int64 `gorm:"comment:修改时间戳"` 21 UpdateTime int64 `gorm:"comment:修改时间戳"`
22 } 22 }
23 23
24 -func (d *DataRoomRank) MysqlInfo(gameId string) *svmysql.MysqlInfo { 24 +func (d *DataRoomRank) MysqlInfo(suffix string) *svmysql.MysqlInfo {
25 tableName := svconst.MYSQL_TABLE_S_ROOMRANK_DATA 25 tableName := svconst.MYSQL_TABLE_S_ROOMRANK_DATA
26 return &svmysql.MysqlInfo{ 26 return &svmysql.MysqlInfo{
27 DbMysql: svconst.DbCommon, 27 DbMysql: svconst.DbCommon,
28 - TableName: tableName + gameId, 28 + TableName: tableName + suffix,
29 } 29 }
30 } 30 }
31 31