- 移除了 talk.go 中对 dict 模块的依赖,直接使用配置中的 ItemID - 修改了 talkconfig.go 中的 ItemID 类型为 uint32,提升一致性 - 调整 talk.go 和 talkconfig.go 的缓存获取方式,增强性能 - 更新了 pet_fusion_material_service.go 中字典服务调用方法 - 修复 talk 模型中 TalkID 字段的唯一索引问题 - 日志记录由 Error 改为 Info,避免误导性
36 lines
781 B
Go
36 lines
781 B
Go
package service
|
|
|
|
import (
|
|
"blazing/cool"
|
|
"blazing/modules/blazing/model"
|
|
"context"
|
|
|
|
"github.com/gogf/gf/v2/os/gcache"
|
|
)
|
|
|
|
type TalkConfigService struct {
|
|
*cool.Service
|
|
}
|
|
|
|
var TalkConfigServiceS = NewTalkConfigService()
|
|
|
|
func NewTalkConfigService() *TalkConfigService {
|
|
return &TalkConfigService{
|
|
|
|
Service: &cool.Service{Model: model.NewMineralCollectionConfig(),
|
|
Cache: gcache.New()},
|
|
}
|
|
|
|
}
|
|
|
|
func (s *TalkConfigService) GetCache(flag int) []model.MineralCollectionConfig {
|
|
|
|
ret, _ := s.Cache.GetOrSetFuncLock(context.Background(), flag, func(context.Context) (interface{}, error) {
|
|
var config []model.MineralCollectionConfig
|
|
cool.DBM(s.Model).Where("type", flag).Scan(&config)
|
|
return config, nil
|
|
}, 0)
|
|
return ret.Interface().([]model.MineralCollectionConfig)
|
|
|
|
}
|