refactor(pet): 重构精灵信息获取逻辑并丰富精灵简要信息
- 使用 copier 库简化精灵信息复制过程 - 在 PetShortInfo 结构体中添加更多精灵属性: - ID - Level - SkinID - Shiny - 优化 GetPetList 函数返回值结构
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
|||||||
"blazing/logic/service/pet"
|
"blazing/logic/service/pet"
|
||||||
"blazing/modules/blazing/service"
|
"blazing/modules/blazing/service"
|
||||||
blservice "blazing/modules/blazing/service"
|
blservice "blazing/modules/blazing/service"
|
||||||
|
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 获取精灵信息
|
// 获取精灵信息
|
||||||
@@ -30,13 +32,11 @@ func (h *Controller) GetPetList(
|
|||||||
tt := blservice.NewUserService(c.Info.UserID).GetPetList(0) //获得未放生的精灵
|
tt := blservice.NewUserService(c.Info.UserID).GetPetList(0) //获得未放生的精灵
|
||||||
result.ShortInfoList = make([]pet.PetShortInfo, len(tt))
|
result.ShortInfoList = make([]pet.PetShortInfo, len(tt))
|
||||||
for i, v := range tt {
|
for i, v := range tt {
|
||||||
result.ShortInfoList[i] = pet.PetShortInfo{
|
|
||||||
|
|
||||||
TypeId: v.ID,
|
copier.Copy(&result.ShortInfoList[i], &v)
|
||||||
CatchTime: v.CatchTime,
|
|
||||||
}
|
}
|
||||||
}
|
return result, 0
|
||||||
return
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ type GetPetListOutboundInfo struct {
|
|||||||
|
|
||||||
// PetShortInfo 精灵简要信息结构体
|
// PetShortInfo 精灵简要信息结构体
|
||||||
type PetShortInfo struct {
|
type PetShortInfo struct {
|
||||||
TypeId uint32 // 精灵类型ID
|
ID uint32 // 精灵类型ID(对应Java中的id)
|
||||||
CatchTime uint32 // 精灵生成时间
|
CatchTime uint32 // 精灵生成时间
|
||||||
|
Level uint32 // 精灵等级
|
||||||
|
SkinID uint32 // 精灵皮肤ID
|
||||||
|
Shiny uint32 // 精灵是否闪光(0=否,1=是)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user