feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
package service
|
|
|
|
import (
|
|
"blazing/cool"
|
|
"blazing/modules/player/model"
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
)
|
|
|
|
type DoneService struct {
|
|
BaseService
|
|
}
|
|
|
|
func (s *DoneService) Exec(data model.EnumMilestone, id []uint32, fn func(*model.MilestoneEX) bool) {
|
|
if cool.Config.ServerInfo.IsVip != 0 {
|
|
cool.Logger.Info(context.TODO(), "测试服不消耗物品玩家数据", s.userid)
|
|
return
|
|
}
|
|
arss := strings.Join(gconv.Strings(id), "-")
|
|
m := s.PModel(s.Model).Where("done_type", data).Where("args", arss)
|
|
var tt *model.MilestoneEX
|
|
m.Scan(&tt)
|
|
if tt == nil {
|
|
tt = &model.MilestoneEX{
|
|
Milestone: model.Milestone{
|
|
DoneType: data,
|
|
Args: strings.Join(gconv.Strings(id), "-"),
|
|
//Count: 1,
|
|
},
|
|
}
|
|
}
|
|
|
|
tt.Args = id
|
|
ook := fn(tt)
|
|
if !ook { //不需要保存
|
|
return
|
|
}
|
|
tt.PlayerID = uint64(s.userid)
|
|
tt.Milestone.Args = strings.Join(gconv.Strings(id), "-")
|
|
|
|
_, err := m.Save(tt)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
}
|
|
func NewDoneService(id uint32) *DoneService {
|
|
return &DoneService{
|
|
|
|
BaseService: BaseService{userid: id,
|
|
|
|
Service: &cool.Service{Model: model.NewMilestone(), UniqueKey: map[string]string{
|
|
"player_id": "角色名称不能重复",
|
|
}},
|
|
},
|
|
}
|
|
|
|
}
|