✨ 新增几大中心功能
This commit is contained in:
32
server/model/system/invite_code.go
Normal file
32
server/model/system/invite_code.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type InviteCodeStatus string
|
||||
|
||||
const (
|
||||
InviteCodeStatusUnused InviteCodeStatus = "unused"
|
||||
InviteCodeStatusUsed InviteCodeStatus = "used"
|
||||
InviteCodeStatusRevoked InviteCodeStatus = "revoked"
|
||||
InviteCodeStatusExpired InviteCodeStatus = "expired"
|
||||
)
|
||||
|
||||
// InviteCode 邀请码(明文不落库,仅保存 hash)
|
||||
type InviteCode struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
CreatedByUserID uint `json:"createdByUserId" gorm:"index;not null;comment:邀请码生成者用户ID"`
|
||||
CodeHash string `json:"-" gorm:"uniqueIndex;size:64;not null;comment:邀请码hash(sha256 hex)"`
|
||||
CodeLast4 string `json:"codeLast4" gorm:"size:8;comment:邀请码末尾4位(展示)"`
|
||||
Status InviteCodeStatus `json:"status" gorm:"type:varchar(16);index;not null;comment:状态"`
|
||||
ExpiresAt *time.Time `json:"expiresAt" gorm:"index;comment:过期时间"`
|
||||
UsedByUserID *uint `json:"usedByUserId" gorm:"index;comment:使用者用户ID"`
|
||||
UsedAt *time.Time `json:"usedAt" gorm:"comment:使用时间"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (InviteCode) TableName() string {
|
||||
return "invite_codes"
|
||||
}
|
||||
15
server/model/system/request/public_register.go
Normal file
15
server/model/system/request/public_register.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package request
|
||||
|
||||
// PublicRegister 用户前端注册请求(public)
|
||||
type PublicRegister struct {
|
||||
Username string `json:"username" binding:"required,min=3,max=64"`
|
||||
Password string `json:"password" binding:"required,min=6,max=128"`
|
||||
WelcomePhrase string `json:"welcomePhrase" binding:"required,min=1,max=255"`
|
||||
|
||||
// 当 auth.register_require_captcha=1 时必填
|
||||
Captcha string `json:"captcha"`
|
||||
CaptchaId string `json:"captchaId"`
|
||||
|
||||
// 当 auth.register_mode=invite 时必填
|
||||
InviteCode string `json:"inviteCode"`
|
||||
}
|
||||
@@ -50,13 +50,13 @@ type SetUserAuthorities struct {
|
||||
}
|
||||
|
||||
type ChangeUserInfo struct {
|
||||
ID uint `gorm:"primarykey"` // 主键ID
|
||||
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
|
||||
Phone string `json:"phone" gorm:"comment:用户手机号"` // 用户手机号
|
||||
AuthorityIds []uint `json:"authorityIds" gorm:"-"` // 角色ID
|
||||
Email string `json:"email" gorm:"comment:用户邮箱"` // 用户邮箱
|
||||
HeaderImg string `json:"headerImg" gorm:"default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像"` // 用户头像
|
||||
Enable int `json:"enable" gorm:"comment:冻结用户"` //冻结用户
|
||||
ID uint `gorm:"primarykey"` // 主键ID
|
||||
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
|
||||
Phone string `json:"phone" gorm:"comment:用户手机号"` // 用户手机号
|
||||
AuthorityIds []uint `json:"authorityIds" gorm:"-"` // 角色ID
|
||||
Email string `json:"email" gorm:"comment:用户邮箱"` // 用户邮箱
|
||||
HeaderImg string `json:"headerImg" gorm:"default:https://gravatar.com/avatar/00000000000000000000000000000000?d=mp&f=y;comment:用户头像"` // 用户头像
|
||||
Enable int `json:"enable" gorm:"comment:冻结用户"` //冻结用户
|
||||
Authorities []system.SysAuthority `json:"-" gorm:"many2many:sys_user_authority;"`
|
||||
}
|
||||
|
||||
|
||||
16
server/model/system/response/register_status.go
Normal file
16
server/model/system/response/register_status.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package response
|
||||
|
||||
type RegisterMode string
|
||||
|
||||
const (
|
||||
RegisterModeClosed RegisterMode = "closed"
|
||||
RegisterModeOpen RegisterMode = "open"
|
||||
RegisterModeInvite RegisterMode = "invite"
|
||||
)
|
||||
|
||||
type RegisterStatusResponse struct {
|
||||
Mode RegisterMode `json:"mode"`
|
||||
RequireCaptcha bool `json:"requireCaptcha"`
|
||||
InviteExpireHours int `json:"inviteExpireHours,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
25
server/model/system/sys_param_change_log.go
Normal file
25
server/model/system/sys_param_change_log.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package system
|
||||
|
||||
import "time"
|
||||
|
||||
type SysParamChangeAction string
|
||||
|
||||
const (
|
||||
SysParamChangeActionCreate SysParamChangeAction = "create"
|
||||
SysParamChangeActionUpdate SysParamChangeAction = "update"
|
||||
SysParamChangeActionDelete SysParamChangeAction = "delete"
|
||||
)
|
||||
|
||||
// SysParamChangeLog 参数变更审计(策略/开关等都落在 sys_params)
|
||||
type SysParamChangeLog struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
ParamID uint `json:"paramId" gorm:"index;not null"`
|
||||
Key string `json:"key" gorm:"index;size:191;not null"`
|
||||
Action SysParamChangeAction `json:"action" gorm:"type:varchar(16);index;not null"`
|
||||
OldValue string `json:"oldValue" gorm:"type:text"`
|
||||
NewValue string `json:"newValue" gorm:"type:text"`
|
||||
OperatorUserID uint `json:"operatorUserId" gorm:"index;not null"`
|
||||
CreatedAt time.Time `json:"createdAt" gorm:"index"`
|
||||
}
|
||||
|
||||
func (SysParamChangeLog) TableName() string { return "sys_param_change_logs" }
|
||||
@@ -19,18 +19,19 @@ var _ Login = new(SysUser)
|
||||
|
||||
type SysUser struct {
|
||||
global.GVA_MODEL
|
||||
UUID uuid.UUID `json:"uuid" gorm:"index;comment:用户UUID"` // 用户UUID
|
||||
Username string `json:"userName" gorm:"index;comment:用户登录名"` // 用户登录名
|
||||
Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码
|
||||
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
|
||||
HeaderImg string `json:"headerImg" gorm:"default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像"` // 用户头像
|
||||
AuthorityId uint `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID
|
||||
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"` // 用户角色
|
||||
Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"` // 多用户角色
|
||||
Phone string `json:"phone" gorm:"comment:用户手机号"` // 用户手机号
|
||||
Email string `json:"email" gorm:"comment:用户邮箱"` // 用户邮箱
|
||||
Enable int `json:"enable" gorm:"default:1;comment:用户是否被冻结 1正常 2冻结"` //用户是否被冻结 1正常 2冻结
|
||||
OriginSetting common.JSONMap `json:"originSetting" form:"originSetting" gorm:"type:text;default:null;column:origin_setting;comment:配置;"` //配置
|
||||
UUID uuid.UUID `json:"uuid" gorm:"index;comment:用户UUID"` // 用户UUID
|
||||
Username string `json:"userName" gorm:"index;comment:用户登录名"` // 用户登录名
|
||||
Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码
|
||||
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
|
||||
HeaderImg string `json:"headerImg" gorm:"default:https://gravatar.com/avatar/00000000000000000000000000000000?d=mp&f=y;comment:用户头像"` // 用户头像
|
||||
WelcomePhrase string `json:"welcomePhrase" gorm:"type:varchar(255);default:'';comment:欢迎词"` // 欢迎词
|
||||
AuthorityId uint `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID
|
||||
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"` // 用户角色
|
||||
Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"` // 多用户角色
|
||||
Phone string `json:"phone" gorm:"comment:用户手机号"` // 用户手机号
|
||||
Email string `json:"email" gorm:"comment:用户邮箱"` // 用户邮箱
|
||||
Enable int `json:"enable" gorm:"default:1;comment:用户是否被冻结 1正常 2冻结"` //用户是否被冻结 1正常 2冻结
|
||||
OriginSetting common.JSONMap `json:"originSetting" form:"originSetting" gorm:"type:text;default:null;column:origin_setting;comment:配置;"` //配置
|
||||
}
|
||||
|
||||
func (SysUser) TableName() string {
|
||||
|
||||
16
server/model/system/user_invite_relation.go
Normal file
16
server/model/system/user_invite_relation.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package system
|
||||
|
||||
import "time"
|
||||
|
||||
// UserInviteRelation 邀请关系(inviter -> invitee)
|
||||
type UserInviteRelation struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
InviterUserID uint `json:"inviterUserId" gorm:"index;not null;comment:邀请人用户ID"`
|
||||
InviteeUserID uint `json:"inviteeUserId" gorm:"uniqueIndex;not null;comment:被邀请人用户ID(唯一)"`
|
||||
InviteCodeID uint `json:"inviteCodeId" gorm:"index;not null;comment:邀请码ID"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
|
||||
func (UserInviteRelation) TableName() string {
|
||||
return "user_invite_relations"
|
||||
}
|
||||
Reference in New Issue
Block a user