From dfed6b4782fa4df9e5347f30f8dea94e3127f8a6 Mon Sep 17 00:00:00 2001 From: 王家文 Date: Thu, 18 Apr 2024 15:36:03 +0800 Subject: [PATCH] feat✨:游戏功能配置 --- configs/confbase/index.go | 15 +++++++++++++++ configs/confcardholder/get.go | 16 ++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 configs/confbase/index.go diff --git a/configs/confbase/index.go b/configs/confbase/index.go new file mode 100644 index 0000000..f2c1677 --- /dev/null +++ b/configs/confbase/index.go @@ -0,0 +1,15 @@ +package confbase + +import ( + "apigame/service-common/svmysql" + "apigame/util/util-lx/lxtime" +) + +func FindDuringTime(obj svmysql.IMysqlData, gameId string) (has bool) { + info := obj.MysqlInfo(gameId) + db := info.DbMysql + timeNow := lxtime.NowUninx() + result := db.Table(info.TableName).Where("start_time <= ? AND end_time >= ?", timeNow, timeNow).First(obj) + has = result.RowsAffected != 0 + return +} diff --git a/configs/confcardholder/get.go b/configs/confcardholder/get.go index 8e8fd96..cd2584f 100644 --- a/configs/confcardholder/get.go +++ b/configs/confcardholder/get.go @@ -1,6 +1,7 @@ package confcardholder import ( + "apigame/configs/confbase" "apigame/service-common/svconst" "apigame/service-common/svmysql" "apigame/service-common/svredis" @@ -22,15 +23,15 @@ func GetCurrent(gameId string) (conf *ActivityConfig, has bool) { confRaw := new(ActivityConfigRaw) hasFind := false if currentId == 0 { - hasFind = FindCurrent(confRaw, gameId) + hasFind = confbase.FindDuringTime(confRaw, gameId) } else { conf, has = GetConfig(gameId, currentId) if has { if timeNow < conf.StartTime || timeNow > conf.EndTime { - hasFind = FindCurrent(confRaw, gameId) + hasFind = confbase.FindDuringTime(confRaw, gameId) } } else { - hasFind = FindCurrent(confRaw, gameId) + hasFind = confbase.FindDuringTime(confRaw, gameId) } } if hasFind { @@ -44,15 +45,6 @@ func GetCurrent(gameId string) (conf *ActivityConfig, has bool) { return } -func FindCurrent(confRaw *ActivityConfigRaw, gameId string) (has bool) { - info := confRaw.MysqlInfo(gameId) - db := info.DbMysql - timeNow := lxtime.NowUninx() - result := db.Table(info.TableName).Where("start_time <= ? AND end_time >= ?", timeNow, timeNow).First(confRaw) - has = result.RowsAffected != 0 - return -} - // GetConfig 获取 配置根据Id func GetConfig(gameId string, confId int64) (conf *ActivityConfig, has bool) { var err error -- libgit2 0.21.0