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 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 20 tableName := "s_game_config"
21 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 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 28 tableName := "s_game_config"
29 29 return &svmysql.MysqlInfo{
30   - DbMysql: svconst.DbApi.Where("gameid = ?", gameId),
  30 + DbMysql: svconst.DbApi.Where("gameid = ?", suffix),
31 31 TableName: tableName,
32 32 }
33 33 }
... ...
configs/feat-cardholder.go
... ... @@ -30,10 +30,10 @@ type CardActivityConfig struct {
30 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 34 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG
35 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 37 CacheTime: 300,
38 38 }
39 39 }
... ... @@ -58,11 +58,11 @@ type CardActivityConfigRaw struct {
58 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 62 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG
63 63 return &svmysql.MysqlInfo{
64 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 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 21 tableName := svconst.MYSQL_TABLE_S_ROOMRANK_CONFIG
22 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 24 CacheTime: 300,
25 25 }
26 26 }
... ... @@ -45,11 +45,11 @@ type RoomRankConfigRaw struct {
45 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 49 tableName := svconst.MYSQL_TABLE_S_ROOMRANK_CONFIG
50 50 return &svmysql.MysqlInfo{
51 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 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 11 db := info.DbMysql
12 12 stmt := db.Session(&gorm.Session{DryRun: true}).Create(obj).Statement
13 13 stmtSQL := stmt.SQL.String()
... ... @@ -15,14 +15,14 @@ func Insert(obj IMysqlData, gameId string) (err error) {
15 15 result := db.Exec(sql, stmt.Vars...)
16 16 err = result.Error
17 17 if err != nil {
18   - lxalilog.Errors(err, gameId)
  18 + lxalilog.Errors(err, suffix)
19 19 return
20 20 }
21 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 26 db := info.DbMysql
27 27 stmt := db.Session(&gorm.Session{DryRun: true}).Updates(obj).Statement
28 28 stmtSQL := stmt.SQL.String()
... ... @@ -30,14 +30,14 @@ func Updates(obj IMysqlData, gameId string) (err error) {
30 30 result := db.Exec(sql, stmt.Vars...)
31 31 err = result.Error
32 32 if err != nil {
33   - lxalilog.Errors(err, gameId)
  33 + lxalilog.Errors(err, suffix)
34 34 return
35 35 }
36 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 41 db := info.DbMysql
42 42 stmt := db.Session(&gorm.Session{DryRun: true}).Save(obj).Statement
43 43 stmtSQL := stmt.SQL.String()
... ... @@ -45,14 +45,14 @@ func Save(obj IMysqlData, gameId string) (err error) {
45 45 result := db.Exec(sql, stmt.Vars...)
46 46 err = result.Error
47 47 if err != nil {
48   - lxalilog.Errors(err, gameId)
  48 + lxalilog.Errors(err, suffix)
49 49 return
50 50 }
51 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 56 db := info.DbMysql
57 57 stmt := db.Session(&gorm.Session{DryRun: true}).First(obj).Statement
58 58 stmtSQL := stmt.SQL.String()
... ... @@ -61,14 +61,14 @@ func First(obj IMysqlData, gameId string) (has bool, err error) {
61 61 has = result.RowsAffected != 0
62 62 err = result.Error
63 63 if err != nil {
64   - lxalilog.Errors(err, gameId)
  64 + lxalilog.Errors(err, suffix)
65 65 return
66 66 }
67 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 72 db := info.DbMysql
73 73 stmt := db.Session(&gorm.Session{DryRun: true}).Find(obj).Statement
74 74 stmtSQL := stmt.SQL.String()
... ... @@ -77,7 +77,7 @@ func Find(obj IMysqlData, gameId string) (has bool, err error) {
77 77 has = result.RowsAffected != 0
78 78 err = result.Error
79 79 if err != nil {
80   - lxalilog.Errors(err, gameId)
  80 + lxalilog.Errors(err, suffix)
81 81 return
82 82 }
83 83 return
... ...
service-common/svmysql/interface.go
... ... @@ -11,5 +11,5 @@ type MysqlInfo struct {
11 11 // IMysqlData mysql存储对象
12 12 type IMysqlData interface {
13 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 9 // IRedisData redis存储对象
10 10 type IRedisData interface {
11 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 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 24 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_DATA
25 25 return &svmysql.MysqlInfo{
26 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 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 43 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_OPEN
44 44 return &svmysql.MysqlInfo{
45 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 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 68 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_REWARDALBUM
69 69 return &svmysql.MysqlInfo{
70 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 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 91 tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_RECORD_REWARDROUND
92 92 return &svmysql.MysqlInfo{
93 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 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 25 tableName := svconst.MYSQL_TABLE_S_ROOMRANK_DATA
26 26 return &svmysql.MysqlInfo{
27 27 DbMysql: svconst.DbCommon,
28   - TableName: tableName + gameId,
  28 + TableName: tableName + suffix,
29 29 }
30 30 }
31 31  
... ...