新增岗位接口
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package postResponse
|
||||
|
||||
import (
|
||||
"hospital-admin-api/api/model"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// getPostPage 获取岗位列表-分页
|
||||
type getPostPage struct {
|
||||
PostId string `json:"post_id"` // 主键id
|
||||
PostName string `json:"post_name"` // 岗位名称
|
||||
DeptStatus int `json:"dept_status"` // 岗位状态(1:正常 2:删除)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
// GetPost 岗位详情
|
||||
type GetPost struct {
|
||||
PostId string `json:"post_id"` // 主键id
|
||||
PostName string `json:"post_name"` // 岗位名称
|
||||
DeptStatus int `json:"dept_status"` // 岗位状态(1:正常 2:删除)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
// GetPostPageResponse 获取接口列表-分页
|
||||
func GetPostPageResponse(adminPost []*model.AdminPost) []getPostPage {
|
||||
// 处理返回值
|
||||
getPostPageResponses := make([]getPostPage, len(adminPost))
|
||||
|
||||
if len(adminPost) > 0 {
|
||||
for i, v := range adminPost {
|
||||
// 将原始结构体转换为新结构体
|
||||
getPostPageResponse := getPostPage{
|
||||
PostId: strconv.Itoa(int(v.PostId)),
|
||||
PostName: v.PostName,
|
||||
DeptStatus: v.PostStatus,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
getPostPageResponses[i] = getPostPageResponse
|
||||
}
|
||||
}
|
||||
|
||||
return getPostPageResponses
|
||||
}
|
||||
|
||||
// GetPostResponse 部门详情
|
||||
func GetPostResponse(adminPost *model.AdminPost) *GetPost {
|
||||
return &GetPost{
|
||||
PostId: strconv.Itoa(int(adminPost.PostId)),
|
||||
PostName: adminPost.PostName,
|
||||
DeptStatus: adminPost.PostStatus,
|
||||
CreatedAt: adminPost.CreatedAt,
|
||||
UpdatedAt: adminPost.UpdatedAt,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user