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

feat(game): 宠物融合系统添加物品消耗异常处理

- 在宠物融合过程中添加物品扣除失败的错误检查
- 当物品不足时返回ErrInsufficientItems错误码

fix(pet): 宠物仓库管理功能增加数据库操作错误处理

- 在宠物释放到仓库和从仓库取出时验证数据库更新结果
- 添加宠物背包切换功能的错误检查机制

feat(fight):
This commit is contained in:
昔念
2026-03-19 14:50:11 +08:00
parent e2ac5a6325
commit b558f46d7a
10 changed files with 142 additions and 63 deletions

View File

@@ -24,23 +24,23 @@ func (s *ItemService) Get(min, max uint32) []model.Item {
return ttt
}
func (s *ItemService) UPDATE(id uint32, count int) {
func (s *ItemService) UPDATE(id uint32, count int) error {
if cool.Config.ServerInfo.IsVip != 0 && count < 0 {
return
return nil
}
if id == 0 {
return
return nil
}
m := s.dbm(s.Model)
ok, err := m.Where("item_id", id).Exist()
if err != nil {
panic(err)
return err
}
if ok {
_, err := s.dbm(s.Model).Where("item_id", id).Increment("item_cnt", count)
if err != nil {
panic(err)
return err
}
} else {
@@ -52,9 +52,10 @@ func (s *ItemService) UPDATE(id uint32, count int) {
"is_vip": cool.Config.ServerInfo.IsVip,
}
m.Data(data).Insert()
_, err := m.Data(data).Insert()
return err
}
return nil
}
// func (s *ItemService) UPDATEM(ids map[uint32]int) {