daShangDao_psiServer/models/response/Employee.go

121 lines
4.4 KiB
Go

package response
import (
"psi/models"
)
// LoginResponse 登录响应
type LoginResponse struct {
ID int64 `json:"id"` // 员工ID
EmployeeID string `json:"employee_id"` // 工号
Fid int64 `json:"fid"` // 父级ID
AboutId string `json:"about_id"` // 租户ID
Username string `json:"username"` // 用户名
Name string `json:"name"` // 姓名
Role int64 `json:"role"` // 角色
Score int64 `json:"score"` // 积分
From string `json:"from"`
Token string `json:"token"` // 令牌
ExpireIn int `json:"expire_in"` // 过期时间(小时)
LevelInfo *EmployeeLevelInfo `json:"level_info"` // 等级信息
}
// EmployeeLevelInfo 员工等级信息
type EmployeeLevelInfo struct {
Level int8 `json:"level"` // 等级
MaxNum int64 `json:"max_num"` // 最大数量
ExpireTime int64 `json:"expire_time"` // 到期时间
PayTime int64 `json:"pay_time"` // 支付时间
}
// EmployeeListResponse 员工列表响应
type EmployeeListResponse struct {
List []EmployeeItem `json:"list"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
}
// AddEmployeeResponse 添加员工响应
type AddEmployeeResponse struct {
EmployeeID string `json:"employee_id"`
Username string `json:"username"`
Name string `json:"name"`
}
// EmployeeItem 员工列表项
type EmployeeItem struct {
ID int64 `json:"id"`
EmployeeIDStr string `json:"employee_id"`
Fid int64 `json:"fid"` // 父级ID
AboutId int64 `json:"about_id"` // 租户ID
Code string `json:"code"` // 机械码
Username string `json:"username"`
Name string `json:"name"`
Phone string `json:"phone"`
Role int64 `json:"role"`
Score int64 `json:"score"`
Status int8 `json:"status"`
From string `json:"from"`
LastLoginAt int64 `json:"last_login_at"`
CreatedAt int64 `json:"created_at"`
ExpireTime int64 `json:"expire_time"`
LevelInfo *EmployeeLevelInfo `json:"level_info"` // 等级信息
Settings models.EmployeeSettingsConfig `json:"settings"`
UserType *UserTypeInfo `json:"user_type"`
}
type UserTypeInfo struct {
ID int64 `json:"id"`
Name string `json:"name"`
Icon string `json:"icon"`
}
// ConvertEmployeeToItem 将员工模型转换为响应项
func ConvertEmployeeToItem(emp models.Employee) EmployeeItem {
return EmployeeItem{
ID: emp.ID,
EmployeeIDStr: emp.EmployeeIDStr,
Fid: emp.Fid,
AboutId: emp.AboutId,
Code: emp.Code,
Username: emp.Username,
Name: emp.Name,
Phone: emp.Phone,
Role: emp.Role,
Score: emp.Score,
From: emp.From,
Status: emp.Status,
LastLoginAt: emp.LastLoginAt,
CreatedAt: emp.CreatedAt,
ExpireTime: emp.ExpireTime,
}
}
// EmployeeLevelConfigResponse 员工等级配置响应
type EmployeeLevelConfigResponse struct {
Level int8 `json:"level"` // 等级
MaxNum int64 `json:"max_num"` // 最大子账号数量
Price int64 `json:"price"` // 价格(单位:分)
LevelName string `json:"level_name"` // 等级名称
}
// UserListItem 用户列表项
type UserListItem struct {
ID int64 `json:"id"`
EmployeeIDStr string `json:"employee_id_str"`
Username string `json:"username"`
Name string `json:"name"`
Role int64 `json:"role"`
Status int8 `json:"status"`
SplitAccountConfigId int64 `json:"split_account_config_id"`
}
// GetUserListResponse 用户列表响应
type GetUserListResponse struct {
List []UserListItem `json:"list"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}