新增获取接口列表

This commit is contained in:
2023-06-30 18:14:24 +08:00
parent 9d94e367b3
commit 2e6df8c974
5 changed files with 74 additions and 26 deletions
+27
View File
@@ -16,6 +16,12 @@ type getApiPage struct {
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
}
// getApiList 获取接口列表
type getApiList struct {
APIID string `json:"api_id"` // 主键id
APIName string `json:"api_name"` // api名称
}
// 接口详情
type getApi struct {
APIID string `json:"api_id"` // 主键id
@@ -53,6 +59,27 @@ func GetApiPageResponse(adminApi []*model.AdminAPI) []getApiPage {
return getApiPageResponses
}
// GetApiListResponse 获取接口列表
func GetApiListResponse(adminApi []*model.AdminAPI) []getApiList {
// 处理返回值
getApiListResponses := make([]getApiList, len(adminApi))
if len(adminApi) > 0 {
for i, v := range adminApi {
// 将原始结构体转换为新结构体
getApiListResponse := getApiList{
APIID: strconv.Itoa(int(v.APIID)),
APIName: v.APIName,
}
// 将转换后的结构体添加到新切片中
getApiListResponses[i] = getApiListResponse
}
}
return getApiListResponses
}
// GetApiResponse 接口详情
func GetApiResponse(adminApi *model.AdminAPI) *getApi {
return &getApi{