```
feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
This commit is contained in:
61
modules/player/service/user.go
Normal file
61
modules/player/service/user.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
)
|
||||
|
||||
type BaseService struct {
|
||||
userid uint32
|
||||
*cool.Service
|
||||
}
|
||||
type UserService struct {
|
||||
Talk *TalkService //挖矿
|
||||
Task *TaskService //任务
|
||||
Info *InfoService //信息
|
||||
Pet *PetService //精灵
|
||||
Item *ItemService //物品
|
||||
Done *DoneService //完成
|
||||
Room *RoomService
|
||||
Barge *BargeService
|
||||
Title *TitleService
|
||||
Cdk *CdkService
|
||||
}
|
||||
|
||||
func NewUserService(id uint32) *UserService {
|
||||
return &UserService{
|
||||
|
||||
Task: NewTaskService(id),
|
||||
Info: NewInfoService(id),
|
||||
Pet: NewPetService(id),
|
||||
Item: NewItemService(id),
|
||||
Talk: NewTalkService(id),
|
||||
Done: NewDoneService(id),
|
||||
Room: NewRoomService(id),
|
||||
Barge: NewBargeService(id),
|
||||
Title: NewTitleService(id),
|
||||
Cdk: NewCdkService(id),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *BaseService) TestModel(m cool.IModel) *gdb.Model {
|
||||
m1 := cool.DBM(m)
|
||||
if s.userid != 0 {
|
||||
m1.Where("player_id", s.userid)
|
||||
}
|
||||
m1.Where("is_vip", cool.Config.ServerInfo.IsVip)
|
||||
|
||||
return m1
|
||||
|
||||
}
|
||||
func (s *BaseService) PModel(m cool.IModel) *gdb.Model {
|
||||
m1 := cool.DBM(m)
|
||||
if s.userid != 0 {
|
||||
m1.Where("player_id", s.userid)
|
||||
}
|
||||
|
||||
return m1
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user