新增角色列表,岗位列表
This commit is contained in:
@@ -14,6 +14,15 @@ type getPostPage struct {
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
// getPostList 获取岗位列表
|
||||
type getPostList 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"` // 修改时间
|
||||
}
|
||||
|
||||
// GetPost 岗位详情
|
||||
type GetPost struct {
|
||||
PostId string `json:"post_id"` // 主键id
|
||||
@@ -57,3 +66,27 @@ func GetPostResponse(adminPost *model.AdminPost) *GetPost {
|
||||
UpdatedAt: adminPost.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// GetPostListResponse 获取角色列表
|
||||
func GetPostListResponse(adminPost []*model.AdminPost) []getPostList {
|
||||
// 处理返回值
|
||||
getPostListResponses := make([]getPostList, len(adminPost))
|
||||
|
||||
if len(adminPost) > 0 {
|
||||
for i, v := range adminPost {
|
||||
// 将原始结构体转换为新结构体
|
||||
getPostListResponse := getPostList{
|
||||
PostId: strconv.Itoa(int(v.PostId)),
|
||||
PostName: v.PostName,
|
||||
PostStatus: v.PostStatus,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
getPostListResponses[i] = getPostListResponse
|
||||
}
|
||||
}
|
||||
|
||||
return getPostListResponses
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user