39 lines
984 B
Go
Raw Normal View History

2025-04-24 20:39:31 +08:00
package smdl
import (
"admin/apps/game/domain/entity"
"admin/apps/game/model/dto"
"admin/internal/errcode"
"admin/lib/httpclient"
)
type Items struct {
}
func (items *Items) GetItems(projectInfo *entity.Project) ([]*dto.CommonDtoFieldChoice, error) {
2025-05-04 22:07:13 +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 {
return nil, err
}
return rsp.Data.List, nil
}