2023-09-28 08:40:43 +08:00

53 lines
1.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}