feat(talk): 优化采集逻辑并移除冗余字典服务调用
- 移除了 talk.go 中对 dict 模块的依赖,直接使用配置中的 ItemID - 修改了 talkconfig.go 中的 ItemID 类型为 uint32,提升一致性 - 调整 talk.go 和 talkconfig.go 的缓存获取方式,增强性能 - 更新了 pet_fusion_material_service.go 中字典服务调用方法 - 修复 talk 模型中 TalkID 字段的唯一索引问题 - 日志记录由 Error 改为 Info,避免误导性
This commit is contained in:
@@ -3,7 +3,6 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/dict/service"
|
||||
)
|
||||
|
||||
type TalkService struct {
|
||||
@@ -30,6 +29,11 @@ func (s *TalkService) Cheak(mapid uint32, flag int) (int, bool) {
|
||||
var talks *model.Talk
|
||||
m1.Where("talk_id", flag).Scan(&talks)
|
||||
if talks == nil {
|
||||
talks = model.NewTalk()
|
||||
talks.PlayerID = uint64(s.userid)
|
||||
talks.TalkID = uint32(flag)
|
||||
s.GModel(s.Model).Data(talks).FieldsEx("id").Insert()
|
||||
|
||||
return 0, true //如果表里没有记载数据,那么就可以直接挖矿
|
||||
}
|
||||
|
||||
@@ -41,9 +45,12 @@ func (s *TalkService) Cheak(mapid uint32, flag int) (int, bool) {
|
||||
return int(talks.Count), true
|
||||
}
|
||||
|
||||
maps := service.DictInfoServiceS.DataRemark("mapid")
|
||||
//maps := service.DictInfoServiceS.DataRemark("mapid")
|
||||
if len(TalkConfigServiceS.GetCache(flag)) == 0 {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
if uint32(maps[mapid].ID) != TalkConfigServiceS.GetCache(flag)[0].MapID {
|
||||
if uint32(mapid) != TalkConfigServiceS.GetCache(flag)[0].MapID {
|
||||
return 0, false //没在地图
|
||||
}
|
||||
if talks.Count >= TalkConfigServiceS.GetCache(flag)[0].DailyCollectCount {
|
||||
@@ -57,10 +64,10 @@ func (s *TalkService) Update(flag int) {
|
||||
m1 := s.GModel(s.Model)
|
||||
|
||||
var talks model.Talk
|
||||
m1.Scan(&talks)
|
||||
m1.Where("talk_id", flag).Scan(&talks)
|
||||
|
||||
talks.PlayerID = uint64(s.userid)
|
||||
talks.TalkID = uint32(flag)
|
||||
//talks.PlayerID = uint64(s.userid)
|
||||
//talks.TalkID = uint32(flag)
|
||||
talks.Count += 1
|
||||
m1.Save(talks)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user