174 lines
9.2 KiB
Go
174 lines
9.2 KiB
Go
package response
|
|
|
|
import (
|
|
"encoding/json"
|
|
"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"` // 员工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"` // 用户类型ID
|
|
Name string `json:"name"` // 用户类型名称
|
|
Icon string `json:"icon"` // 用户类型图标
|
|
}
|
|
|
|
// ConvertEmployeeToItem 将员工模型转换为响应项
|
|
func ConvertEmployeeToItem(emp models.Employee) EmployeeItem {
|
|
return EmployeeItem{
|
|
ID: emp.ID, // 员工ID
|
|
EmployeeIDStr: emp.EmployeeIDStr, // 工号
|
|
Fid: emp.Fid, // 父级ID
|
|
AboutId: emp.AboutId, // 租户ID
|
|
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"` // 用户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"` // 分账配置ID
|
|
SplitAccountConfig *SplitAccountConfigInfo `json:"split_account_config,omitempty"` // 分账配置详情
|
|
AboutId int64 `json:"about_id"` // 租户ID
|
|
Phone string `json:"phone"` // 手机号
|
|
From string `json:"from"` // 来源
|
|
LastLoginIp string `json:"last_login_ip"` // 最后登录IP
|
|
LastLoginAt int64 `json:"last_login_at"` // 最后登录时间
|
|
Code string `json:"code"` // 机械码
|
|
ExpireTime int64 `json:"expire_time"` // 到期时间
|
|
}
|
|
|
|
// GetUserListResponse 用户列表响应
|
|
type GetUserListResponse struct {
|
|
List []UserListItem `json:"list"` // 用户列表
|
|
Total int64 `json:"total"` // 总数
|
|
Page int `json:"page"` // 当前页
|
|
PageSize int `json:"page_size"` // 每页数量
|
|
}
|
|
|
|
// UpdateEmployeeSplitAccountConfigResponse 更新员工分账配置响应
|
|
type UpdateEmployeeSplitAccountConfigResponse struct {
|
|
ID int64 `json:"id"` // 员工分账配置ID
|
|
EmployeeIDStr string `json:"employee_id_str"` // 工号
|
|
Username string `json:"username"` // 用户名
|
|
Name string `json:"name"` // 姓名
|
|
Phone string `json:"phone"` // 手机号
|
|
AboutId int64 `json:"about_id"` // 租户ID
|
|
SplitAccountConfigId int64 `json:"split_account_config_id"` // 分账配置ID
|
|
Status int8 `json:"status"` // 状态
|
|
UpdatedAt int64 `json:"updated_at"` // 更新时间
|
|
}
|
|
|
|
// CurrentUserResponse 当前用户信息响应(包含分账配置)
|
|
type CurrentUserResponse struct {
|
|
ID int64 `json:"id"` // 员工ID
|
|
EmployeeIDStr string `json:"employee_id_str"` // 工号
|
|
Username string `json:"username"` // 用户名
|
|
Name string `json:"name"` // 姓名
|
|
Phone string `json:"phone"` // 手机号
|
|
Role int64 `json:"role"` // 角色
|
|
Fid int64 `json:"fid"` // 父级ID
|
|
AboutId int64 `json:"about_id"` // 租户ID
|
|
Status int8 `json:"status"` // 状态
|
|
Score int64 `json:"score"` // 积分
|
|
SplitAccountConfigId int64 `json:"split_account_config_id"` // 分账配置ID
|
|
SplitAccountConfig *SplitAccountConfigInfo `json:"split_account_config,omitempty"` // 分账配置详情
|
|
CreatedAt int64 `json:"created_at"` // 创建时间
|
|
UpdatedAt int64 `json:"updated_at"` // 更新时间
|
|
}
|
|
|
|
// SplitAccountConfigInfo 分账配置信息
|
|
type SplitAccountConfigInfo struct {
|
|
ID int64 `json:"id"` // 分账配置ID
|
|
RuleName string `json:"rule_name"` // 规则名称
|
|
RuleValue json.RawMessage `json:"rule_value"` // 规则值
|
|
Status int8 `json:"status"` // 状态
|
|
Description string `json:"description"` // 描述
|
|
CreatedBy string `json:"created_by"` // 创建人
|
|
UpdatedBy string `json:"updated_by"` // 更新人
|
|
CreatedAt int64 `json:"created_at"` // 创建时间
|
|
UpdatedAt int64 `json:"updated_at"` // 更新时间
|
|
}
|