新增后台用户管理
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
"hepa-calc-admin-api/utils"
|
||||
)
|
||||
|
||||
// AdminUserDto 后台-用户表
|
||||
type AdminUserDto struct {
|
||||
UserId string `json:"user_id"` // 主键id
|
||||
Access string `json:"access"` // 账号
|
||||
Password string `json:"password"` // 密码
|
||||
Salt string `json:"salt"` // 密码掩码
|
||||
NickName string `json:"nick_name"` // 昵称
|
||||
IsAdmin int `json:"is_admin"` // 是否管理员(0:否 1:是)
|
||||
Status int `json:"status"` // 状态(1:正常 2:审核中 3:审核失败)
|
||||
IsDeleted int `json:"is_deleted"` // 是否被删除(0:否 1:是)
|
||||
IsDisabled int `json:"is_disabled"` // 是否被禁用(0:否 1:是)
|
||||
Phone string `json:"phone"` // 手机号
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
Sex int `json:"sex"` // 性别(1:男 2:女)
|
||||
Email string `json:"email"` // 邮箱
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
Token string `json:"token"` // token
|
||||
}
|
||||
|
||||
// GetAdminUserListDto 列表
|
||||
func GetAdminUserListDto(m []*model.AdminUser) []*AdminUserDto {
|
||||
// 处理返回值
|
||||
responses := make([]*AdminUserDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &AdminUserDto{
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
Access: v.Access,
|
||||
NickName: v.NickName,
|
||||
IsAdmin: v.IsAdmin,
|
||||
Status: v.Status,
|
||||
IsDeleted: v.IsDeleted,
|
||||
IsDisabled: v.IsDisabled,
|
||||
Phone: v.Phone,
|
||||
Avatar: utils.AddOssDomain(v.Avatar),
|
||||
Sex: v.Sex,
|
||||
Email: v.Email,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
Reference in New Issue
Block a user