- 新增英雄详情接口,包含60级属性、套装平均属性、套装占比、神器占比等信息- 优化数据处理逻辑,提高查询效率 - 增加缓存机制,减少数据库访问- 新增数据传输对象HeroSetData和HeroSetItem,用于处理套装数据
46 lines
993 B
Go
46 lines
993 B
Go
// internal/controller/hero/hero_v1.go
|
|
package hero
|
|
|
|
import (
|
|
"context"
|
|
"epic/api/hero/v1"
|
|
"epic/internal/service"
|
|
)
|
|
|
|
func (c *ControllerV1) GetOne(ctx context.Context, req *v1.GetOneReq) (res *v1.GetOneRes, err error) {
|
|
hero, err := service.Hero().GetHeroByCode(ctx, req.Code)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
res = &v1.GetOneRes{
|
|
EpicHeroInfo: hero,
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
func (c *ControllerV1) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) {
|
|
// 获取 VO 列表
|
|
list, err := service.Hero().GetHeroList(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// 构造响应
|
|
res = &v1.GetListRes{
|
|
Records: list, // ✅ 正确赋值字段
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
func (c *ControllerV1) GetDetail(ctx context.Context, req *v1.GetDetailReq) (res *v1.GetDetailRes, err error) {
|
|
detail, err := service.Hero().GetHeroDetailByCode(ctx, req.Code)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
res = &v1.GetDetailRes{
|
|
HeroDetailVO: detail,
|
|
}
|
|
return res, nil
|
|
}
|