feat(admin): 宠物管理功能优化 - 清理宠物控制器中的乱码字符 - 更新宠物获取请求结构体字段注释为英文描述 - 重构变量命名提高代码可读性 - 添加宠物存储信息服务方法 - 优化错误提示信息为英文 - 新增宠物等级
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package service
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
@@ -34,7 +34,7 @@ RETURNING max_ts;`, service.NewBaseSysUserService().Model.TableName())
|
||||
}
|
||||
arr := ret.Array()
|
||||
if len(arr) == 0 {
|
||||
return 0, fmt.Errorf("鐢熸垚鎹曟崏鏃堕棿澶辫触: 鏃犺繑鍥炴暟鎹?)
|
||||
return 0, fmt.Errorf("generate catch time failed: empty result")
|
||||
}
|
||||
return arr[0].Uint32(), nil
|
||||
}
|
||||
@@ -58,6 +58,16 @@ func (s *PetService) PetInfo(flag int) []model.Pet {
|
||||
return tt
|
||||
}
|
||||
|
||||
func (s *PetService) StorageInfo(isVip int) []model.Pet {
|
||||
var tt []model.Pet
|
||||
if err := s.dbm_fix(s.Model).Where("free", 0).Where("is_vip", isVip).Scan(&tt); err != nil {
|
||||
return nil
|
||||
}
|
||||
for i := range tt {
|
||||
tt[i].Data.CatchTime = tt[i].CatchTime
|
||||
}
|
||||
return tt
|
||||
}
|
||||
func (s *PetService) PetCount(flag int) int {
|
||||
ret, err := s.dbm(s.Model).Where("free", flag).Count()
|
||||
if err != nil {
|
||||
@@ -107,16 +117,16 @@ func (s *PetService) UpdatePrice(catchTime, price, free uint32) error {
|
||||
func (s *PetService) BuyPet(pid uint32) error {
|
||||
tt := NewPetService(0).PetInfoOneByID(pid)
|
||||
if tt == nil {
|
||||
return fmt.Errorf("娌℃湁姝ょ簿鐏?)
|
||||
return fmt.Errorf("pet not found")
|
||||
}
|
||||
if tt.IsVip != 0 {
|
||||
return fmt.Errorf("涓嶅厑璁镐氦鏄?)
|
||||
return fmt.Errorf("pet cannot be traded")
|
||||
}
|
||||
if tt.Free != 2 {
|
||||
return fmt.Errorf("鏈笂鏋?)
|
||||
return fmt.Errorf("pet is not on sale")
|
||||
}
|
||||
if tt.SalePrice == 0 {
|
||||
return fmt.Errorf("鏈缃环鏍?)
|
||||
return fmt.Errorf("pet sale price is not set")
|
||||
}
|
||||
if !tt.UpdateTime.AddDate(0, 0, 1).Before(gtime.Now()) {
|
||||
return fmt.Errorf("鏈埌璐拱鏃堕棿")
|
||||
@@ -285,4 +295,3 @@ func NewPetService(userid uint32) *PetService {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user