39 lines
1.0 KiB
Go
Raw Normal View History

2025-04-24 20:39:31 +08:00
package smdl
import (
"admin/apps/game/domain/entity"
"admin/internal/errcode"
2025-05-16 15:17:10 +08:00
"admin/internal/model/dto"
2025-04-24 20:39:31 +08:00
"admin/lib/httpclient"
)
type Items struct {
}
func (items *Items) GetItems(projectInfo *entity.Project) ([]*dto.CommonDtoFieldChoice, error) {
2025-05-07 15:03:19 +08:00
//return []*dto.CommonDtoFieldChoice{
// {Desc: "黄金战甲", Value: 123, Type: 1},
// {Desc: "黄金头盔", Value: 234, Type: 1},
// {Desc: "黄金大刀", Value: 346, Type: 1},
// {Desc: "白银大刀", Value: 346, Type: 1},
//}, nil
2025-04-24 20:39:31 +08:00
alisrvAddr := projectInfo.GetApiAddr()
if alisrvAddr == "" {
2025-04-30 15:46:14 +08:00
return nil, errcode.New(errcode.ServerError, "项目%v没有配置api服务器地址", projectInfo.Po.Name)
2025-04-24 20:39:31 +08:00
}
type RspData struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
List []*dto.CommonDtoFieldChoice `json:"list"`
} `json:"data"`
}
rsp := &RspData{}
err := httpclient.Request(alisrvAddr+"/items", "get", nil, rsp)
if err != nil {
2025-05-16 15:51:22 +08:00
return make([]*dto.CommonDtoFieldChoice, 0), nil
2025-04-24 20:39:31 +08:00
}
return rsp.Data.List, nil
}