feat(pet): 优化宠物仓库和背包功能的数据库操作

- 使用copier.CopyWithOption替代直接赋值,确保深拷贝操作
- 移除冗余的model导入,简化代码结构
- 重构PetReleaseToWarehouse和PetRetrieveFromWarehouse方法,
  直接调用UPdateFree方法更新宠物状态
- 优化TogglePetBagWarehouse方法中的宠物数据更新逻辑
- 添加
This commit is contained in:
2025-12-31 01:35:20 +08:00
parent b86ab8d5a9
commit be70f50939
4 changed files with 34 additions and 46 deletions

View File

@@ -53,8 +53,10 @@ func (h Controller) UsePetItemOutOfFight(data *item.C2S_USE_PET_ITEM_OUT_OF_FIGH
oldPetCatchTime := currentPet.CatchTime
oldPet := c.Service.Pet.PetInfo_One_Unscoped(currentPet.OldCatchTime)
println(c.Info.UserID, "还原", len(c.Info.PetList), currentPet.ID, oldPet.Data.ID)
currentPet = &oldPet.Data
copier.CopyWithOption(currentPet, oldPet.Data, copier.Option{DeepCopy: true})
currentPet.CatchTime = oldPetCatchTime
println(c.Info.UserID, "还原后", len(c.Info.PetList), currentPet.ID, oldPet.Data.ID)
} else {
handler := item.PetItemRegistry.GetHandler(data.ItemID)
if handler == nil {