```
feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
This commit is contained in:
60
modules/player/service/Barge.go
Normal file
60
modules/player/service/Barge.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/player/model"
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type BargeService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
func NewBargeService(id uint32) *BargeService {
|
||||
return &BargeService{
|
||||
|
||||
BaseService: BaseService{userid: id,
|
||||
|
||||
Service: &cool.Service{Model: model.NewPetBargeListInfo()},
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *BargeService) Update(petid uint32, isskill bool) {
|
||||
|
||||
if cool.Config.ServerInfo.IsVip != 0 {
|
||||
cool.Logger.Info(context.TODO(), "测试服不消耗物品玩家数据", s.userid)
|
||||
return
|
||||
}
|
||||
if t, _ := s.PModel(s.Model).Where("pet_id", petid).Count(); t != 0 {
|
||||
if isskill {
|
||||
s.PModel(s.Model).Where("pet_id", petid).Increment("killed_count", 1)
|
||||
} else {
|
||||
s.PModel(s.Model).Where("pet_id", petid).Increment("catched_count", 1)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
r := g.Map{
|
||||
"player_id": s.userid,
|
||||
"pet_id": petid,
|
||||
}
|
||||
|
||||
if isskill {
|
||||
r["killed_count"] = 1
|
||||
} else {
|
||||
r["catched_count"] = 1
|
||||
}
|
||||
s.PModel(s.Model).Data(r).Insert()
|
||||
}
|
||||
|
||||
}
|
||||
func (s *BargeService) Get(start, end uint32) []model.PetBargeListInfo {
|
||||
var Barges []model.PetBargeListInfo
|
||||
s.PModel(s.Model).WhereBetween("pet_id", start, end).Scan(&Barges)
|
||||
return Barges
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user