feat(room): 移除旧版房间控制器逻辑并重构家具展示信息结构

移除了 logic/controller/room.go 中已废弃的房间相关控制器方法,包括获取基地物品、展示精灵及房间家具的方法。同时,在 logic/service/room/FitmentShowInfo.go 中对家具展示信息结构进行了重构,引入了 model.FitmentShowInfo 并新增 SET_FITMENT 和 NullInfo 结构体以支持新的数据协议。另外,在 pet.go 中增加 PetInfo_One_ohter 方法用于查询指定用户的宠物信息,并在 user.go 中为 UserService 添加 RoomService 支持。
This commit is contained in:
2025-12-13 22:51:39 +08:00
parent fe89620efb
commit d198e7446a
11 changed files with 329 additions and 18 deletions

View File

@@ -62,6 +62,15 @@ func (s *PetService) PetInfo_One(cachetime uint32) model.PetEX {
tt.Data.CatchTime = tt.CatchTime
return tt
}
func (s *PetService) PetInfo_One_ohter(userid, cachetime uint32) model.PetEX {
m := cool.DBM(s.Model).Where("player_id", userid).Where("catch_time", cachetime)
var tt model.PetEX
m.Scan(&tt)
tt.Data.CatchTime = tt.CatchTime
return tt
}
func (s *PetService) PetInfo_One_Unscoped(cachetime uint32) model.PetEX {
m := cool.DBM(s.Model).Where("player_id", s.userid).Where("catch_time", cachetime).Unscoped()

View File

@@ -0,0 +1,89 @@
package service
import (
"blazing/cool"
"blazing/modules/blazing/model"
"context"
)
func (s *RoomService) Get(userid uint32) model.BaseHouseEx {
//todo待测试
var ttt model.BaseHouseEx
cool.DBM(s.Model).Where("player_id", userid).Scan(&ttt)
return ttt
}
func (s *RoomService) Add(id, count uint32) {
//todo待测试
var ttt model.BaseHouseEx
m := s.GModel(s.Model)
m.Scan(&ttt)
if ttt.OwnedItems == nil {
ttt.OwnedItems = make(map[uint32]uint32)
}
t, ok := ttt.OwnedItems[id]
if ok {
ttt.OwnedItems[id] = t + count
} else {
ttt.OwnedItems[id] = count
}
ttt.PlayerID = uint64(s.userid)
m.Save(ttt)
}
func (s *RoomService) Set(id []model.FitmentShowInfo) {
//todo待测试
var ttt model.BaseHouseEx
m := s.GModel(s.Model)
m.Scan(&ttt)
ttt.PlacedItems = id
ttt.PlayerID = uint64(s.userid)
m.Save(ttt)
}
func (s *RoomService) Show(cactime uint32) {
//todo待测试
var ttt model.BaseHouseEx
m := s.GModel(s.Model)
m.Scan(&ttt)
ttt.ShowPokemon = append(ttt.ShowPokemon, cactime)
ttt.PlayerID = uint64(s.userid)
m.Save(ttt)
}
// /添加进来的物品一定是保证存在的
type RoomService struct {
BaseService
}
func NewRoomService(id uint32) *RoomService {
return &RoomService{
BaseService: BaseService{userid: id,
Service: &cool.Service{Model: model.NewBaseHouse(), UniqueKey: map[string]string{
"player_id": "角色名称不能重复",
}, PageQueryOp: &cool.QueryOp{
KeyWordField: []string{"player_id"},
Where: func(ctx context.Context) [][]interface{} {
var (
//admin = cool.GetAdmin(ctx)
//userId = admin.UserId
)
return [][]interface{}{
// {"player_id", userId, true},
// {"free", 0, true},
}
},
}},
},
}
}

View File

@@ -17,6 +17,7 @@ type UserService struct {
Pet *PetService //精灵
Item *ItemService //物品
Done *DoneService //完成
Room *RoomService
}
func NewUserService(id uint32) *UserService {
@@ -28,6 +29,7 @@ func NewUserService(id uint32) *UserService {
Item: NewItemService(id),
Talk: NewTalkService(id),
Done: NewDoneService(id),
Room: NewRoomService(id),
}
}