修正返回目录
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
type AdminPostDto struct {
|
||||
PostId string `json:"post_id"` // 主键id
|
||||
PostName string `json:"post_name"` // 岗位名称
|
||||
PostStatus int `json:"post_status"` // 岗位状态(1:正常 2:删除)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
func GetAdminPostDto(m *model.AdminPost) *AdminPostDto {
|
||||
return &AdminPostDto{
|
||||
PostId: fmt.Sprintf("%d", m.PostId),
|
||||
PostName: m.PostName,
|
||||
PostStatus: m.PostStatus,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func GetAdminPostListDto(m []*model.AdminPost) []AdminPostDto {
|
||||
// 处理返回值
|
||||
responses := make([]AdminPostDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := AdminPostDto{
|
||||
PostId: fmt.Sprintf("%d", v.PostId),
|
||||
PostName: v.PostName,
|
||||
PostStatus: v.PostStatus,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
Reference in New Issue
Block a user