108 lines
5.2 KiB
Go
108 lines
5.2 KiB
Go
package entity
|
|
|
|
import "time"
|
|
|
|
// AccountUser 账号(用户)。
|
|
type AccountUser struct {
|
|
Model
|
|
Username string `gorm:"size:64;uniqueIndex:uk_username;not null" json:"username"`
|
|
PasswordHash string `gorm:"size:128;not null" json:"-"`
|
|
RealName string `gorm:"size:64" json:"real_name"`
|
|
RealIDCard string `gorm:"size:64" json:"-"` // Day 28:证件号(详情接口脱敏输出,JSON 不直接暴露)
|
|
RealnameStatus int8 `gorm:"default:0" json:"realname_status"` // Day 28:0 待审核/1 通过/2 驳回
|
|
Role string `gorm:"size:32;index:idx_role_status,priority:1;default:customer" json:"role"`
|
|
ParentID int64 `gorm:"index:idx_parent;default:0" json:"parent_id"`
|
|
Path string `gorm:"size:512;index:idx_path" json:"path"` // Day 28:物化路径 "/1/5/9/",切换上级级联重写
|
|
IsStarred int8 `gorm:"default:0" json:"is_starred"` // Day 28:标星(列表置顶)
|
|
Status int8 `gorm:"index:idx_role_status,priority:2;default:1" json:"status"`
|
|
IPBind string `gorm:"size:256" json:"ip_bind"`
|
|
Balance int64 `json:"balance"`
|
|
CreditBalance int64 `json:"credit_balance"`
|
|
RebateRate float64 `gorm:"type:decimal(5,4);default:0" json:"rebate_rate"` // v20:代理返点率(小数,0.1200=12%;0=无返点;上级对直线下级结算额的分成)
|
|
SvcTeam string `gorm:"size:64" json:"svc_team"`
|
|
ExpiredAt *time.Time `json:"expired_at"`
|
|
LastLoginAt *time.Time `json:"last_login_at"`
|
|
LastLoginIP string `gorm:"size:45" json:"last_login_ip"`
|
|
Remark string `gorm:"size:255" json:"remark"`
|
|
}
|
|
|
|
func (AccountUser) TableName() string { return "account_user" }
|
|
|
|
// AccountConfig 账号业务配置(每账号每业务一行)。
|
|
type AccountConfig struct {
|
|
Model
|
|
AccountID int64 `gorm:"uniqueIndex:uk_account_biz,priority:1;not null" json:"account_id"`
|
|
Business string `gorm:"size:16;uniqueIndex:uk_account_biz,priority:2;default:sms" json:"business"`
|
|
AuditMode int8 `json:"audit_mode"` // 0免审 1人工审核 2自动审核(黑词)
|
|
SmsType string `gorm:"size:32" json:"sms_type"`
|
|
FeeMode int8 `json:"fee_mode"`
|
|
FailRefund int8 `gorm:"default:1" json:"fail_refund"`
|
|
DayLimit int `json:"day_limit"`
|
|
SpeedLimit int `json:"speed_limit"`
|
|
ExtCode string `gorm:"size:32" json:"ext_code"`
|
|
ApiSecret string `gorm:"size:64" json:"-"` // Day 46:接口密钥(存 MD5(secret) 32hex;明文仅开通时返回一次)
|
|
SignLimit string `gorm:"size:512" json:"sign_limit"`
|
|
ReportURL string `gorm:"size:255" json:"report_url"`
|
|
UplinkURL string `gorm:"size:255" json:"uplink_url"`
|
|
Protocol string `gorm:"size:16;default:http" json:"protocol"`
|
|
|
|
CmppMaxConns int `json:"cmpp_max_conns"` // Day 62:CMPP 每账号最大连接数(0=系统默认)
|
|
CmppSpeed int `json:"cmpp_speed"` // Day 62:CMPP 单链提交限速 条/s(0=系统默认)
|
|
}
|
|
|
|
func (AccountConfig) TableName() string { return "account_config" }
|
|
|
|
// AccountPrice 用户分时单价。
|
|
type AccountPrice struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
AccountID int64 `gorm:"index:idx_account_biz_time,priority:1" json:"account_id"`
|
|
Business string `gorm:"size:16;index:idx_account_biz_time,priority:2;default:sms" json:"business"`
|
|
Price float64 `gorm:"type:decimal(10,4)" json:"price"`
|
|
EffectiveAt time.Time `gorm:"index:idx_account_biz_time,priority:3" json:"effective_at"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
}
|
|
|
|
func (AccountPrice) TableName() string { return "account_price" }
|
|
|
|
// AccountRole 角色。
|
|
type AccountRole struct {
|
|
Model
|
|
Code string `gorm:"size:32;uniqueIndex:uk_role_code" json:"code"`
|
|
Name string `gorm:"size:64" json:"name"`
|
|
IsBuiltIn int8 `gorm:"default:0" json:"is_built_in"`
|
|
}
|
|
|
|
func (AccountRole) TableName() string { return "account_role" }
|
|
|
|
// AccountPermission 权限点(resource:action)。
|
|
type AccountPermission struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
Code string `gorm:"size:64;uniqueIndex:uk_permission_code" json:"code"`
|
|
Name string `gorm:"size:64" json:"name"`
|
|
}
|
|
|
|
func (AccountPermission) TableName() string { return "account_permission" }
|
|
|
|
// AccountRolePermission 角色-权限关联。
|
|
type AccountRolePermission struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
RoleID int64 `gorm:"uniqueIndex:uk_role_perm,priority:1" json:"role_id"`
|
|
PermissionID int64 `gorm:"uniqueIndex:uk_role_perm,priority:2" json:"permission_id"`
|
|
}
|
|
|
|
func (AccountRolePermission) TableName() string { return "account_role_permission" }
|
|
|
|
// AccountBalanceLog 余额变动日志(充值/扣费/返还/调整)。
|
|
type AccountBalanceLog struct {
|
|
LogModel
|
|
AccountID int64 `gorm:"index:idx_account_time,priority:1" json:"account_id"`
|
|
BizType string `gorm:"size:16" json:"biz_type"` // recharge/credit/deduct/refund/adjust
|
|
Amount int64 `json:"amount"` // 正负
|
|
BalanceAfter int64 `json:"balance_after"`
|
|
RefID string `gorm:"size:64" json:"ref_id"`
|
|
Operator string `gorm:"size:64" json:"operator"`
|
|
Remark string `gorm:"size:255" json:"remark"`
|
|
}
|
|
|
|
func (AccountBalanceLog) TableName() string { return "account_balance_log" }
|