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

47 lines
1.1 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 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
}