54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
// Code scaffolded by goctl. Safe to edit.
|
|
// goctl 1.10.1
|
|
|
|
package config
|
|
|
|
import (
|
|
"context"
|
|
|
|
"sundynix-micro-go/app/plant/api/internal/svc"
|
|
"sundynix-micro-go/app/plant/api/internal/types"
|
|
"sundynix-micro-go/app/plant/rpc/plant"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetLevelConfigListLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
// 等级配置列表
|
|
func NewGetLevelConfigListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLevelConfigListLogic {
|
|
return &GetLevelConfigListLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetLevelConfigListLogic) GetLevelConfigList(req *types.LevelConfigListReq) (interface{}, error) {
|
|
result, err := l.svcCtx.PlantRpc.GetLevelConfigList(l.ctx, &plant.PageReq{
|
|
Current: int32(req.Current),
|
|
PageSize: int32(req.PageSize),
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resList := make([]map[string]interface{}, 0, len(result.List))
|
|
for _, item := range result.List {
|
|
resList = append(resList, map[string]interface{}{
|
|
"id": item.Id,
|
|
"level": item.Level,
|
|
"title": item.Title,
|
|
"minSunlight": item.MinSunlight, // Explicitly keep 0 values in JSON
|
|
"perks": item.Perks,
|
|
})
|
|
}
|
|
|
|
return map[string]interface{}{
|
|
"list": resList,
|
|
}, nil
|
|
}
|