refactor(item): 统一物品操作接口并优化金币处理逻辑

This commit is contained in:
1
2025-12-16 06:54:27 +00:00
parent 39dc79f706
commit 49b4c8cf2a
10 changed files with 47 additions and 28 deletions

View File

@@ -20,7 +20,7 @@ func (s *ItemService) Get(min, max uint32) []model.Item {
return ttt
}
func (s *ItemService) AddItem(id, count uint32) {
func (s *ItemService) UPDATE(id uint32, count int) {
if t, _ := s.GModel(s.Model).Where("item_id", id).Count(); t != 0 {
_, err := s.GModel(s.Model).Where("item_id", id).Increment("item_cnt", count)
if err != nil {
@@ -35,11 +35,7 @@ func (s *ItemService) AddItem(id, count uint32) {
}
}
func (s *ItemService) SubItem(id, count uint32) {
s.GModel(s.Model).Where("item_id", id).Decrement("item_cnt", count)
}
func (s *ItemService) CheakItem(id uint32) uint32 {
var ttt model.Item
s.GModel(s.Model).Where("item_id", id).Scan(&ttt)