refactor: 简化玩家称号获取逻辑,直接返回ID列表
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -2,7 +2,6 @@ package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
dict "blazing/modules/dict/service"
|
||||
"blazing/modules/player/service"
|
||||
"context"
|
||||
|
||||
@@ -32,33 +31,31 @@ type GetReq struct {
|
||||
|
||||
func (c *TitleController) Get(ctx context.Context, req *GetReq) (res *cool.BaseRes, err error) {
|
||||
res = &cool.BaseRes{}
|
||||
var ret []TitleRes
|
||||
//var ret []TitleRes
|
||||
var (
|
||||
admin = cool.GetAdmin(ctx)
|
||||
//r = g.RequestFromCtx(ctx)
|
||||
)
|
||||
alltitile := service.NewUserService(uint32(admin.UserId)).Title.Get()
|
||||
titles := dict.NewDictInfoService().GetData("achieve")
|
||||
for _, v := range alltitile {
|
||||
tt := TitleRes{
|
||||
//titles := dict.NewDictInfoService().GetData("achieve")
|
||||
// tt := []uint32{}
|
||||
// for _, v := range alltitile {
|
||||
|
||||
ID: v,
|
||||
}
|
||||
info := titles[v]
|
||||
if info.Remark != nil {
|
||||
tt.Desc = *info.Remark
|
||||
}
|
||||
tt.Name = info.Name
|
||||
ret = append(ret, tt)
|
||||
}
|
||||
// //info := titles[v]
|
||||
// // if info.Remark != nil {
|
||||
// // tt.Desc = *info.Remark
|
||||
// // }
|
||||
// // tt.Name = info.Name
|
||||
// tt = append(tt, v.)
|
||||
// }
|
||||
|
||||
res.Data = ret
|
||||
res.Data = alltitile
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
type TitleRes struct {
|
||||
ID uint32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Desc string `json:"desc"`
|
||||
}
|
||||
// type TitleRes struct {
|
||||
// ID uint32 `json:"id"`
|
||||
// Name string `json:"name"`
|
||||
// Desc string `json:"desc"`
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user