新增医生列表
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
package adminUserResponse
|
||||
|
||||
import (
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/config"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// getUserPage 获取用户列表-分页
|
||||
type getUserPage struct {
|
||||
UserID string `json:"user_id"` // 主键id
|
||||
Access string `json:"access"` // 账号
|
||||
Status int `json:"status"` // 状态(1:正常 2:审核中 3:审核失败)
|
||||
IsDeleted int `json:"is_deleted"` // 是否被删除(0:否 1:是)
|
||||
IsDisabled int `json:"is_disabled"` // 是否被禁用(0:否 1:是)
|
||||
NickName string `json:"nick_name"` // 昵称
|
||||
Phone string `json:"phone"` // 手机号
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
Sex int `json:"sex"` // 性别(1:男 2:女)
|
||||
Email string `json:"email"` // 邮箱
|
||||
RoleID string `json:"role_id"` // 角色id
|
||||
DeptID string `json:"dept_id"` // 部门id
|
||||
PostID string `json:"post_id"` // 岗位id
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
Role *getUserPageRole `json:"role"` // 角色
|
||||
Dept *getUserPageDept `json:"dept"` // 部门
|
||||
Post *getUserPagePost `json:"post"` // 岗位
|
||||
}
|
||||
|
||||
type getUserPageRole struct {
|
||||
RoleId string `json:"role_id"` // 角色id
|
||||
RoleName string `json:"role_name"` // 角色名称
|
||||
}
|
||||
|
||||
type getUserPageDept struct {
|
||||
DeptId string `json:"dept_id"` // 部门id
|
||||
DeptName string `json:"dept_name"` // 部门名称
|
||||
}
|
||||
|
||||
type getUserPagePost struct {
|
||||
PostId string `json:"post_id"` // 岗位id
|
||||
PostName string `json:"post_name"` // 岗位名称
|
||||
}
|
||||
|
||||
// getUser 用户详情
|
||||
type getUser struct {
|
||||
UserID string `json:"user_id"`
|
||||
Access string `json:"access"`
|
||||
Status int `json:"status"`
|
||||
IsDeleted int `json:"is_deleted"`
|
||||
IsDisabled int `json:"is_disabled"`
|
||||
NickName string `json:"nick_name"`
|
||||
Phone string `json:"phone"`
|
||||
Avatar string `json:"avatar"`
|
||||
Sex int `json:"sex"`
|
||||
Email string `json:"email"`
|
||||
RoleID string `json:"role_id"`
|
||||
DeptID string `json:"dept_id"`
|
||||
PostID string `json:"post_id"`
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
// GetUserPageResponse 获取用户列表-分页
|
||||
func GetUserPageResponse(adminUser []*model.AdminUser) []getUserPage {
|
||||
// 处理返回值
|
||||
getUserPageResponses := make([]getUserPage, len(adminUser))
|
||||
|
||||
if len(adminUser) > 0 {
|
||||
for i, v := range adminUser {
|
||||
var role *getUserPageRole
|
||||
if v.Role != nil {
|
||||
role = &getUserPageRole{
|
||||
RoleId: strconv.FormatInt(v.Role.RoleId, 10),
|
||||
RoleName: v.Role.RoleName,
|
||||
}
|
||||
}
|
||||
|
||||
var dept *getUserPageDept
|
||||
if v.Dept != nil {
|
||||
dept = &getUserPageDept{
|
||||
DeptId: strconv.FormatInt(v.Dept.DeptId, 10),
|
||||
DeptName: v.Dept.DeptName,
|
||||
}
|
||||
}
|
||||
|
||||
var post *getUserPagePost
|
||||
if v.Post != nil {
|
||||
post = &getUserPagePost{
|
||||
PostId: strconv.FormatInt(v.Post.PostId, 10),
|
||||
PostName: v.Post.PostName,
|
||||
}
|
||||
}
|
||||
|
||||
// 将原始结构体转换为新结构体
|
||||
getUserPageResponse := getUserPage{
|
||||
UserID: strconv.Itoa(int(v.UserID)),
|
||||
Access: v.Access,
|
||||
Status: v.Status,
|
||||
IsDeleted: v.IsDeleted,
|
||||
IsDisabled: v.IsDisabled,
|
||||
NickName: v.NickName,
|
||||
Phone: v.Phone,
|
||||
Avatar: config.C.Oss.OssCustomDomainName + "/" + v.Avatar,
|
||||
Sex: v.Sex,
|
||||
Email: v.Email,
|
||||
RoleID: strconv.Itoa(int(v.RoleID)),
|
||||
DeptID: strconv.Itoa(int(v.DeptID)),
|
||||
PostID: strconv.Itoa(int(v.PostID)),
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
Role: role,
|
||||
Dept: dept,
|
||||
Post: post,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
getUserPageResponses[i] = getUserPageResponse
|
||||
}
|
||||
}
|
||||
|
||||
return getUserPageResponses
|
||||
}
|
||||
|
||||
// GetUserResponse 用户详情
|
||||
func GetUserResponse(adminUser *model.AdminUser) *getUser {
|
||||
return &getUser{
|
||||
UserID: strconv.FormatInt(adminUser.UserID, 10),
|
||||
Access: adminUser.Access,
|
||||
Status: adminUser.Status,
|
||||
IsDeleted: adminUser.IsDeleted,
|
||||
IsDisabled: adminUser.IsDisabled,
|
||||
NickName: adminUser.NickName,
|
||||
Phone: adminUser.Phone,
|
||||
Avatar: config.C.Oss.OssCustomDomainName + "/" + adminUser.Avatar,
|
||||
Sex: adminUser.Sex,
|
||||
Email: adminUser.Email,
|
||||
RoleID: strconv.FormatInt(adminUser.RoleID, 10),
|
||||
DeptID: strconv.FormatInt(adminUser.DeptID, 10),
|
||||
PostID: strconv.FormatInt(adminUser.PostID, 10),
|
||||
CreatedAt: adminUser.CreatedAt,
|
||||
UpdatedAt: adminUser.UpdatedAt,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user