```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

refactor(pet): 重构宠物服务方法命名和优化数据库操作

- 统一PetService中方法命名规范,将驼峰命名改为标准驼峰格式
- 修复拼写错误:UPdate -> Update, UPdateFree -> UpdateFree等
- 重命名查询方法:PetInfo_One -> PetInfoOneByCatchTime,
  PetInfo_One_ID -> PetInfoOneByID, PetInfo_One_ohter -> PetInfoOneOther
- 优化BuyPet方法中的事务处理逻辑,使用
This commit is contained in:
昔念
2026-03-26 04:51:36 +08:00
parent 5b655c8287
commit 619e4b50ca
7 changed files with 136 additions and 185 deletions

View File

@@ -79,7 +79,7 @@ func (h Controller) handleNeuronItem(currentPet *model.PetInfo, c *player.Player
}
originalCatchTime := currentPet.CatchTime
oldPet := c.Service.Pet.PetInfo_One_Unscoped(currentPet.OldCatchTime)
oldPet := c.Service.Pet.PetInfoOneUnscoped(currentPet.OldCatchTime)
if oldPet == nil {
return errorcode.ErrorCodes.ErrCannotRevertSpirit
}

View File

@@ -26,7 +26,7 @@ func (h Controller) GetPetInfo(
}
return result, 0
}
ret := player.Service.Pet.PetInfo_One(data.CatchTime)
ret := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
if ret == nil {
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
}
@@ -85,7 +85,7 @@ func (h Controller) PetReleaseToWarehouse(
return nil, errorcode.ErrorCodes.ErrCannotReleaseNonWarehouse
}
if !player.Service.Pet.UPdateFree(data.CatchTime, 1) {
if !player.Service.Pet.UpdateFree(data.CatchTime, 1) {
return nil, errorcode.ErrorCodes.ErrSystemError
}
return nil, err
@@ -98,7 +98,7 @@ func (h Controller) PetRetrieveFromWarehouse(
//如果背包没找到,再放入背包
if _, _, ok := player.FindPet(data.CatchTime); !ok {
if !player.Service.Pet.UPdateFree(data.CatchTime, 0) {
if !player.Service.Pet.UpdateFree(data.CatchTime, 0) {
return nil, errorcode.ErrorCodes.ErrSystemError
}
@@ -133,7 +133,7 @@ func (h Controller) TogglePetBagWarehouse(
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
}
if !player.Service.Pet.UPdate(*pet) {
if !player.Service.Pet.Update(*pet) {
return result, errorcode.ErrorCodes.ErrSystemError
}
@@ -148,7 +148,7 @@ func (h Controller) TogglePetBagWarehouse(
//如果背包没找到,再放入背包
if !ok {
r := player.Service.Pet.PetInfo_One(data.CatchTime)
r := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
if r == nil {
return result, errorcode.ErrorCodes.ErrPokemonNotExists
}

View File

@@ -34,7 +34,7 @@ func (h Controller) GetRoomPetShowInfo(data *room.PetRoomListInboundInfo, c *pla
result.Pets = make([]pet.PetShortInfo, 0)
roomInfo := c.Service.Room.Get(data.TargetUserID)
for _, catchTime := range roomInfo.ShowPokemon {
petInfo := c.Service.Pet.PetInfo_One_ohter(data.TargetUserID, catchTime)
petInfo := c.Service.Pet.PetInfoOneOther(data.TargetUserID, catchTime)
if petInfo.Data.ID == 0 {
continue
}
@@ -76,7 +76,7 @@ func (h Controller) GetAllFurniture(data *room.FitmentAllInboundEmpty, c *player
// c: 当前玩家对象
// 返回: 精灵详细信息和错误码
func (h Controller) GetRoomPetInfo(data *room.C2S_RoomPetInfo, c *player.Player) (result *pet.RoomPetInfo, err errorcode.ErrorCode) {
petInfo := c.Service.Pet.PetInfo_One_ohter(data.UserID, data.CatchTime)
petInfo := c.Service.Pet.PetInfoOneOther(data.UserID, data.CatchTime)
result = &pet.RoomPetInfo{}
copier.CopyWithOption(result, &petInfo.Data, copier.Option{DeepCopy: true})
result.OwnerId = data.UserID

View File

@@ -34,7 +34,7 @@ func (h Controller) SetPet(data *room.C2S_PET_ROOM_SHOW, c *player.Player) (resu
result = &room.S2C_PET_ROOM_SHOW{}
result.PetShowList = make([]pet.PetShortInfo, len(showPetCatchTimes))
for _, catchTime := range showPetCatchTimes {
petInfo := c.Service.Pet.PetInfo_One(catchTime)
petInfo := c.Service.Pet.PetInfoOneByCatchTime(catchTime)
if petInfo == nil {
continue
}