新增几大中心功能

This commit is contained in:
Administrator
2026-04-23 15:29:07 +08:00
parent 5c2a146a44
commit c6354ee065
123 changed files with 13074 additions and 229 deletions

View File

@@ -0,0 +1,67 @@
package admin
// DashboardStats 与 web-admin `DashboardStats` 对齐,供 /admin/dashboard/stats 返回。
// 当前为占位实现:各统计为零,列表为空;后续可按业务表聚合替换。
type DashboardStats struct {
Users DashboardUserStats `json:"users"`
Characters DashboardCharacterStats `json:"characters"`
Creators DashboardCreatorStats `json:"creators"`
Feedback DashboardFeedbackStats `json:"feedback"`
System DashboardSystemStats `json:"system"`
}
type DashboardUserStats struct {
Total int `json:"total"`
CreatorCount int `json:"creatorCount"`
OnlineCount int `json:"onlineCount"`
TodayNew int `json:"todayNew"`
WeekNew int `json:"weekNew"`
TotalMessages int `json:"totalMessages"`
TotalChats int `json:"totalChats"`
}
type DashboardCharacterStats struct {
Total int `json:"total"`
Published int `json:"published"`
PendingReview int `json:"pendingReview"`
TodayNew int `json:"todayNew"`
WeekNew int `json:"weekNew"`
}
type DashboardTopCreator struct {
UserId int `json:"userId"`
NickName string `json:"nickName"`
Avatar string `json:"avatar"`
CharCount int `json:"charCount"`
TotalUseCount int `json:"totalUseCount"`
}
type DashboardCreatorStats struct {
Total int `json:"total"`
Contracted int `json:"contracted"`
TodayNew int `json:"todayNew"`
WeekNew int `json:"weekNew"`
PendingApplications int `json:"pendingApplications"`
TopCreators []DashboardTopCreator `json:"topCreators"`
}
type DashboardFeedbackPendingItem struct {
ID int `json:"id"`
Title string `json:"title"`
UserNickname string `json:"userNickname"`
UserAvatar string `json:"userAvatar"`
UnreadCount int `json:"unreadCount"`
CreatedAt string `json:"createdAt"`
}
type DashboardFeedbackStats struct {
Total int `json:"total"`
Open int `json:"open"`
AdminUnread int `json:"adminUnread"`
ClosedToday int `json:"closedToday"`
PendingItems []DashboardFeedbackPendingItem `json:"pendingItems"`
}
type DashboardSystemStats struct {
TotalConversations int `json:"totalConversations"`
}

View File

@@ -0,0 +1,35 @@
package app
import "time"
type AppAssetType string
const (
AppAssetTypeAccount AppAssetType = "account"
AppAssetTypeGameCoin AppAssetType = "game_coin"
)
type AppRechargeType string
const (
AppRechargeTypeOffline AppRechargeType = "offline"
AppRechargeTypeOnlineNotArrived AppRechargeType = "online_not_arrived"
AppRechargeTypeActivitySubsidy AppRechargeType = "activity_subsidy"
AppRechargeTypeManualAdjustment AppRechargeType = "manual_adjustment"
)
// AppAssetTransaction 玩家资产流水(金额单位:厘)
type AppAssetTransaction struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"index;not null"`
AssetType AppAssetType `json:"assetType" gorm:"type:varchar(16);index;not null"`
RechargeType AppRechargeType `json:"rechargeType" gorm:"type:varchar(32);index;not null;default:'manual_adjustment'"`
DeltaLi int64 `json:"deltaLi" gorm:"not null;comment:变动(厘)"`
BeforeLi int64 `json:"beforeLi" gorm:"not null"`
AfterLi int64 `json:"afterLi" gorm:"not null"`
Reason string `json:"reason" gorm:"size:255;not null"`
OperatorUserID uint `json:"operatorUserId" gorm:"index;not null;comment:后台操作人ID"`
CreatedAt time.Time `json:"createdAt"`
}
func (AppAssetTransaction) TableName() string { return "app_asset_transactions" }

View File

@@ -0,0 +1,30 @@
package app
import "time"
type InviteCodeStatus string
const (
InviteCodeStatusUnused InviteCodeStatus = "unused"
InviteCodeStatusUsed InviteCodeStatus = "used"
InviteCodeStatusRevoked InviteCodeStatus = "revoked"
InviteCodeStatusExpired InviteCodeStatus = "expired"
)
// AppInviteCode 玩家邀请码(明文不落库,仅保存 hash
type AppInviteCode struct {
ID uint `json:"id" gorm:"primaryKey"`
CreatedByUserID uint `json:"createdByUserId" gorm:"index;not null"`
CodeHash string `json:"-" gorm:"uniqueIndex;size:64;not null"`
CodeLast4 string `json:"codeLast4" gorm:"size:8"`
Status InviteCodeStatus `json:"status" gorm:"type:varchar(16);index;not null"`
ExpiresAt *time.Time `json:"expiresAt" gorm:"index"`
UsedByUserID *uint `json:"usedByUserId" gorm:"index"`
UsedAt *time.Time `json:"usedAt"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppInviteCode) TableName() string {
return "app_invite_codes"
}

View File

@@ -0,0 +1,18 @@
package app
import "time"
// AppLoginLog 玩家登录日志(用于审计)
type AppLoginLog struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"index;comment:玩家ID(失败时可为0)"`
Username string `json:"username" gorm:"index;size:64;not null;comment:用户名"`
IP string `json:"ip" gorm:"size:64;not null;comment:请求IP"`
Referer string `json:"referer" gorm:"size:2048;comment:参考地址(Referer)"`
UserAgent string `json:"userAgent" gorm:"size:2048;comment:客户端信息(User-Agent)"`
Status bool `json:"status" gorm:"index;not null;comment:登录状态"`
ErrorMessage string `json:"errorMessage" gorm:"size:255;comment:失败原因"`
CreatedAt time.Time `json:"createdAt" gorm:"index"`
}
func (AppLoginLog) TableName() string { return "app_login_logs" }

View File

@@ -0,0 +1,19 @@
package app
import "time"
// AppRiskTag 风险标签(人工版)
type AppRiskTag struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"size:64;uniqueIndex;not null;comment:标签名"`
Level int `json:"level" gorm:"index;not null;default:1;comment:风险级别(1-5)"`
Color string `json:"color" gorm:"size:32;comment:颜色(前端展示)"`
Desc string `json:"desc" gorm:"size:255;comment:说明"`
CreatedAt time.Time `json:"createdAt" gorm:"index"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppRiskTag) TableName() string { return "app_risk_tags" }

View File

@@ -0,0 +1,23 @@
package app
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type AppUser struct {
ID uint `json:"id" gorm:"primaryKey"`
UUID uuid.UUID `json:"uuid" gorm:"index;not null;comment:用户UUID"`
Username string `json:"username" gorm:"uniqueIndex;size:64;not null"`
Password string `json:"-" gorm:"not null"`
Enable int `json:"enable" gorm:"default:1;comment:1正常 2禁用"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppUser) TableName() string {
return "app_users"
}

View File

@@ -0,0 +1,16 @@
package app
import "time"
// AppUserActivity 玩家登录与活跃信息
type AppUserActivity struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"uniqueIndex;not null"`
LastLoginAt *time.Time `json:"lastLoginAt" gorm:"index"`
LastActiveAt *time.Time `json:"lastActiveAt" gorm:"index"`
LastActiveIP string `json:"lastActiveIp" gorm:"size:64"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppUserActivity) TableName() string { return "app_user_activity" }

View File

@@ -0,0 +1,16 @@
package app
import "time"
// AppUserAsset 玩家资产(金额单位:厘)
type AppUserAsset struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"uniqueIndex;not null"`
AccountBalanceLi int64 `json:"accountBalanceLi" gorm:"not null;default:0;comment:账户余额(厘)"`
AccountFrozenLi int64 `json:"accountFrozenLi" gorm:"not null;default:0;comment:账户余额冻结(厘)"`
GameCoinBalanceLi int64 `json:"gameCoinBalanceLi" gorm:"not null;default:0;comment:游戏币余额(厘)"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppUserAsset) TableName() string { return "app_user_assets" }

View File

@@ -0,0 +1,15 @@
package app
import "time"
type AppUserInviteRelation struct {
ID uint `json:"id" gorm:"primaryKey"`
InviterUserID uint `json:"inviterUserId" gorm:"index;not null"`
InviteeUserID uint `json:"inviteeUserId" gorm:"uniqueIndex;not null"`
InviteCodeID uint `json:"inviteCodeId" gorm:"index;not null"`
CreatedAt time.Time `json:"createdAt"`
}
func (AppUserInviteRelation) TableName() string {
return "app_user_invite_relations"
}

View File

@@ -0,0 +1,18 @@
package app
import "time"
type AppUserProfile struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"uniqueIndex;not null"`
WelcomePhrase string `json:"welcomePhrase" gorm:"type:varchar(255);comment:安全欢迎词"`
NickName string `json:"nickName" gorm:"type:varchar(64)"`
Avatar string `json:"avatar" gorm:"type:varchar(255)"`
Channel string `json:"channel" gorm:"type:varchar(64)"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppUserProfile) TableName() string {
return "app_user_profiles"
}

View File

@@ -0,0 +1,19 @@
package app
import "time"
// AppUserRiskTag 玩家风险标签关系(人工版)
type AppUserRiskTag struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"index;not null"`
TagID uint `json:"tagId" gorm:"index;not null"`
OperatorUserID uint `json:"operatorUserId" gorm:"index;not null;comment:后台操作人ID"`
Remark string `json:"remark" gorm:"size:255;comment:备注"`
CreatedAt time.Time `json:"createdAt" gorm:"index"`
}
func (AppUserRiskTag) TableName() string { return "app_user_risk_tags" }

View File

@@ -0,0 +1,48 @@
package app
import "time"
type AppWithdrawOrderStatus string
const (
AppWithdrawOrderStatusPending AppWithdrawOrderStatus = "pending" // 已提交,待审核
AppWithdrawOrderStatusApproved AppWithdrawOrderStatus = "approved" // 已审核通过,待打款
AppWithdrawOrderStatusRejected AppWithdrawOrderStatus = "rejected" // 审核拒绝(已解冻)
AppWithdrawOrderStatusPaid AppWithdrawOrderStatus = "paid" // 已打款(余额已扣减)
AppWithdrawOrderStatusFailed AppWithdrawOrderStatus = "failed" // 打款失败(已解冻)
)
// AppWithdrawOrder 提现订单(金额单位:厘)
type AppWithdrawOrder struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"index;not null;comment:玩家ID"`
Username string `json:"username" gorm:"size:64;index;not null;comment:用户名快照"`
AmountLi int64 `json:"amountLi" gorm:"not null;comment:提现金额(厘)"`
FeeLi int64 `json:"feeLi" gorm:"not null;default:0;comment:手续费(厘)"`
NetLi int64 `json:"netLi" gorm:"not null;comment:实际打款金额(厘)"`
Status AppWithdrawOrderStatus `json:"status" gorm:"type:varchar(16);index;not null;default:'pending'"`
Channel string `json:"channel" gorm:"size:32;comment:打款渠道(预留)"`
PayeeAccount string `json:"payeeAccount" gorm:"size:128;comment:收款账号(脱敏/快照)"`
PayeeRealName string `json:"payeeRealName" gorm:"size:64;comment:收款人(快照)"`
ApplyRemark string `json:"applyRemark" gorm:"size:255;comment:申请备注(预留)"`
AuditRemark string `json:"auditRemark" gorm:"size:255;comment:审核备注"`
RejectReason string `json:"rejectReason" gorm:"size:255;comment:拒绝原因"`
FailureReason string `json:"failureReason" gorm:"size:255;comment:打款失败原因"`
ExternalTxID string `json:"externalTxId" gorm:"size:128;index;comment:外部流水号(预留)"`
OperatorUserID uint `json:"operatorUserId" gorm:"index;not null;comment:创建/最近操作人ID"`
ApprovedBy uint `json:"approvedBy" gorm:"index;comment:审核人ID"`
ApprovedAt *time.Time `json:"approvedAt" gorm:"index"`
PaidBy uint `json:"paidBy" gorm:"index;comment:打款确认人ID"`
PaidAt *time.Time `json:"paidAt" gorm:"index"`
CreatedAt time.Time `json:"createdAt" gorm:"index"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppWithdrawOrder) TableName() string { return "app_withdraw_orders" }

View File

@@ -0,0 +1,8 @@
package request
type Login struct {
Username string `json:"username" binding:"required"`
Password string `json:"password" binding:"required"`
Captcha string `json:"captcha"`
CaptchaId string `json:"captchaId"`
}

View File

@@ -0,0 +1,12 @@
package request
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"`
Captcha string `json:"captcha"`
CaptchaId string `json:"captchaId"`
InviteCode string `json:"inviteCode"`
}

View 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"`
}

View 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"
}

View 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"`
}

View File

@@ -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;"`
}

View 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"`
}

View 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" }

View File

@@ -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 {

View 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"
}