feat(hero): 新增英雄相关接口和功能
- 新增英雄信息获取接口和相关逻辑 - 实现英雄列表和详情查询功能- 添加英雄相关数据结构和VO对象 - 更新项目结构,移除不必要的文件
This commit is contained in:
5
internal/controller/hero/hero.go
Normal file
5
internal/controller/hero/hero.go
Normal file
@@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package hero
|
||||
15
internal/controller/hero/hero_new.go
Normal file
15
internal/controller/hero/hero_new.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package hero
|
||||
|
||||
import (
|
||||
"epic/api/hero"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() hero.IHeroV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
45
internal/controller/hero/hero_v1.go
Normal file
45
internal/controller/hero/hero_v1.go
Normal file
@@ -0,0 +1,45 @@
|
||||
// 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{
|
||||
Data: detail,
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
Reference in New Issue
Block a user