修正返回目录
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
type AdminApiDto struct {
|
||||
APIID string `json:"api_id"` // 主键id
|
||||
APIName string `json:"api_name"` // api名称
|
||||
APIPath string `json:"api_path"` // 接口路径(全路径 id为:id)
|
||||
APIMethod string `json:"api_method"` // 请求类型
|
||||
IsAuth int `json:"is_auth"` // 是否验证权限(0:否 1:是)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
func GetAdminApiDto(m *model.AdminAPI) *AdminApiDto {
|
||||
return &AdminApiDto{
|
||||
APIID: fmt.Sprintf("%d", m.APIID),
|
||||
APIName: m.APIName,
|
||||
APIPath: m.APIPath,
|
||||
APIMethod: m.APIMethod,
|
||||
IsAuth: m.IsAuth,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func GetAdminApiListDto(m []*model.AdminAPI) []AdminApiDto {
|
||||
// 处理返回值
|
||||
responses := make([]AdminApiDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := AdminApiDto{
|
||||
APIID: fmt.Sprintf("%d", v.APIID),
|
||||
APIName: v.APIName,
|
||||
APIPath: v.APIPath,
|
||||
APIMethod: v.APIMethod,
|
||||
IsAuth: v.IsAuth,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
Reference in New Issue
Block a user