package service import ( "blazing/cool" "blazing/modules/player/model" "context" ) func (s *RoomService) Get(userid uint32) model.BaseHouseEx { //todo待测试 var ttt model.BaseHouseEx s.dbm(s.Model).Scan(&ttt) return ttt } func (s *RoomService) Set(id []model.FitmentShowInfo) { //todo待测试 if cool.Config.ServerInfo.IsVip != 0 { return } var ttt model.BaseHouseEx m := s.dbm(s.Model) m.Scan(&ttt) ttt.PlacedItems = id ttt.UsedItems = make(map[uint32]uint32) for _, ids := range id { _, ok := ttt.UsedItems[ids.Id] if !ok { ttt.UsedItems[ids.Id] = 1 } else { ttt.UsedItems[ids.Id] = ttt.UsedItems[ids.Id] + 1 } } ttt.PlayerID = uint64(s.userid) m.Save(ttt) } func (s *RoomService) Show(cactime []uint32) { //todo待测试 var ttt model.BaseHouseEx m := s.dbm(s.Model) m.Scan(&ttt) 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}, } }, }}, }, } }