38 lines
754 B
Go
38 lines
754 B
Go
package dto
|
|
|
|
import (
|
|
"fmt"
|
|
"hospital-admin-api/api/model"
|
|
)
|
|
|
|
type AdminMenuApiDto struct {
|
|
ApiId string `json:"api_id"` // 接口id
|
|
ApiName string `json:"api_name"` // 接口名称
|
|
}
|
|
|
|
func GetAdminMenuApiDto(m *model.AdminMenuApi) *AdminMenuApiDto {
|
|
return &AdminMenuApiDto{
|
|
ApiId: fmt.Sprintf("%d", m.ApiId),
|
|
ApiName: m.API.APIName,
|
|
}
|
|
}
|
|
|
|
func GetAdminMenuApiListDto(m []*model.AdminMenuApi) []*AdminMenuApiDto {
|
|
// 处理返回值
|
|
responses := make([]*AdminMenuApiDto, len(m))
|
|
|
|
if len(m) > 0 {
|
|
for i, v := range m {
|
|
response := &AdminMenuApiDto{
|
|
ApiId: fmt.Sprintf("%d", v.ApiId),
|
|
ApiName: v.API.APIName,
|
|
}
|
|
|
|
// 将转换后的结构体添加到新切片中
|
|
responses[i] = response
|
|
}
|
|
}
|
|
|
|
return responses
|
|
}
|