Commit dfed6b4782fa4df9e5347f30f8dea94e3127f8a6

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

feat✨:游戏功能配置

configs/confbase/index.go 0 → 100644
@@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
  1 +package confbase
  2 +
  3 +import (
  4 + "apigame/service-common/svmysql"
  5 + "apigame/util/util-lx/lxtime"
  6 +)
  7 +
  8 +func FindDuringTime(obj svmysql.IMysqlData, gameId string) (has bool) {
  9 + info := obj.MysqlInfo(gameId)
  10 + db := info.DbMysql
  11 + timeNow := lxtime.NowUninx()
  12 + result := db.Table(info.TableName).Where("start_time <= ? AND end_time >= ?", timeNow, timeNow).First(obj)
  13 + has = result.RowsAffected != 0
  14 + return
  15 +}
configs/confcardholder/get.go
1 package confcardholder 1 package confcardholder
2 2
3 import ( 3 import (
  4 + "apigame/configs/confbase"
4 "apigame/service-common/svconst" 5 "apigame/service-common/svconst"
5 "apigame/service-common/svmysql" 6 "apigame/service-common/svmysql"
6 "apigame/service-common/svredis" 7 "apigame/service-common/svredis"
@@ -22,15 +23,15 @@ func GetCurrent(gameId string) (conf *ActivityConfig, has bool) { @@ -22,15 +23,15 @@ func GetCurrent(gameId string) (conf *ActivityConfig, has bool) {
22 confRaw := new(ActivityConfigRaw) 23 confRaw := new(ActivityConfigRaw)
23 hasFind := false 24 hasFind := false
24 if currentId == 0 { 25 if currentId == 0 {
25 - hasFind = FindCurrent(confRaw, gameId) 26 + hasFind = confbase.FindDuringTime(confRaw, gameId)
26 } else { 27 } else {
27 conf, has = GetConfig(gameId, currentId) 28 conf, has = GetConfig(gameId, currentId)
28 if has { 29 if has {
29 if timeNow < conf.StartTime || timeNow > conf.EndTime { 30 if timeNow < conf.StartTime || timeNow > conf.EndTime {
30 - hasFind = FindCurrent(confRaw, gameId) 31 + hasFind = confbase.FindDuringTime(confRaw, gameId)
31 } 32 }
32 } else { 33 } else {
33 - hasFind = FindCurrent(confRaw, gameId) 34 + hasFind = confbase.FindDuringTime(confRaw, gameId)
34 } 35 }
35 } 36 }
36 if hasFind { 37 if hasFind {
@@ -44,15 +45,6 @@ func GetCurrent(gameId string) (conf *ActivityConfig, has bool) { @@ -44,15 +45,6 @@ func GetCurrent(gameId string) (conf *ActivityConfig, has bool) {
44 return 45 return
45 } 46 }
46 47
47 -func FindCurrent(confRaw *ActivityConfigRaw, gameId string) (has bool) {  
48 - info := confRaw.MysqlInfo(gameId)  
49 - db := info.DbMysql  
50 - timeNow := lxtime.NowUninx()  
51 - result := db.Table(info.TableName).Where("start_time <= ? AND end_time >= ?", timeNow, timeNow).First(confRaw)  
52 - has = result.RowsAffected != 0  
53 - return  
54 -}  
55 -  
56 // GetConfig 获取 配置根据Id 48 // GetConfig 获取 配置根据Id
57 func GetConfig(gameId string, confId int64) (conf *ActivityConfig, has bool) { 49 func GetConfig(gameId string, confId int64) (conf *ActivityConfig, has bool) {
58 var err error 50 var err error