config-load.go 1.55 KB
package cardholder

import (
	"apigame/common/svconst"
)

// Init1 初始化
func Init1() {

	NewConfigs()

	TryUpdateConfigs()
}

// TryUpdateConfigs 尝试更新配置表
func TryUpdateConfigs() {
	LoadConfigs()
}

// LoadConfigs 读取mysql配置
func LoadConfigs() {
	for _, gameId := range svconst.GameListCardHolder {
		LoadConfig(gameId)
	}
}

// TryUpdateConfig 尝试更新配置表
func TryUpdateConfig(gameId string) (config *CardActivityConfig, has bool) {
	LoadConfig(gameId)
	return GetConfig(gameId)
}

// LoadConfig 读取mysql配置
func LoadConfig(gameId string) {
	//// 找到当前开放的活动
	//configOpen := CardActivityUpdateConfig{Id: 0}
	//{
	//	conf := make([]CardActivityUpdateConfig, 0)
	//	_, err := svdto.Find(&conf, new(CardActivityUpdateConfig), gameId)
	//	if err != nil {
	//		return
	//	}
	//	for _, config := range conf {
	//		if config.Status != 0 {
	//			configOpen = config
	//			continue
	//		}
	//	}
	//	fmt.Println(configOpen)
	//}
	//// 没有开放的活动
	//if configOpen.Id == 0 {
	//	return
	//}
	//// 判断是否需要更新
	//needUpdate := false
	//configOld, hasConfigOld := GetConfig(gameId)
	//if hasConfigOld {
	//	if configOpen.Id != configOld.Raw.Id || configOpen.UpdateTime != configOld.Raw.UpdateTime {
	//		needUpdate = true
	//	}
	//} else {
	//	needUpdate = true
	//}
	//// 更新数据
	//if needUpdate {
	//	confNew := &CardActivityConfigRaw{}
	//	hasConfNew, err := svdto.First(confNew, gameId)
	//	if err != nil {
	//		return
	//	}
	//	if !hasConfNew {
	//		return
	//	}
	//	ConfigDecode(gameId, confNew)
	//}
}