修正返回目录

This commit is contained in:
2023-09-28 08:40:43 +08:00
parent aedf61c31b
commit 70c35e0ce6
84 changed files with 3579 additions and 2007 deletions
+52
View File
@@ -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
}