优化表结构,重构模型,重新实现基于白银网关的提取节点流程

This commit is contained in:
2025-11-24 18:44:06 +08:00
parent 9a574f55cb
commit cb2a963a37
142 changed files with 6528 additions and 5808 deletions

View File

@@ -1,36 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameAdmin = "admin"
// Admin mapped from table <admin>
type Admin struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:管理员ID" json:"id"` // 管理员ID
Username string `gorm:"column:username;type:character varying(255);not null;comment:用户名" json:"username"` // 用户名
Password string `gorm:"column:password;type:character varying(255);not null;comment:密码" json:"password"` // 密码
Name *string `gorm:"column:name;type:character varying(255);comment:真实姓名" json:"name"` // 真实姓名
Avatar *string `gorm:"column:avatar;type:character varying(255);comment:头像URL" json:"avatar"` // 头像URL
Phone *string `gorm:"column:phone;type:character varying(255);comment:手机号码" json:"phone"` // 手机号码
Email *string `gorm:"column:email;type:character varying(255);comment:邮箱" json:"email"` // 邮箱
Status int32 `gorm:"column:status;type:integer;not null;default:1;comment:状态0-禁用1-正常" json:"status"` // 状态0-禁用1-正常
LastLogin *orm.LocalDateTime `gorm:"column:last_login;type:timestamp without time zone;comment:最后登录时间" json:"last_login"` // 最后登录时间
LastLoginHost *string `gorm:"column:last_login_host;type:character varying(45);comment:最后登录地址" json:"last_login_host"` // 最后登录地址
LastLoginAgent *string `gorm:"column:last_login_agent;type:character varying(255);comment:最后登录代理" json:"last_login_agent"` // 最后登录代理
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName Admin's table name
func (*Admin) TableName() string {
return TableNameAdmin
}

31
web/models/admin.go Normal file
View File

@@ -0,0 +1,31 @@
package models
import (
"time"
"platform/web/core"
"platform/web/globals/orm"
)
// Admin 管理员表
type Admin struct {
core.Model
Username string `json:"username" gorm:"column:username"` // 用户名
Password string `json:"password" gorm:"column:password"` // 密码
Name *string `json:"name" gorm:"column:name"` // 真实姓名
Avatar *string `json:"avatar" gorm:"column:avatar"` // 头像URL
Phone *string `json:"phone" gorm:"column:phone"` // 手机号码
Email *string `json:"email" gorm:"column:email"` // 邮箱
Status AdminStatus `json:"status" gorm:"column:status"` // 状态0-禁用1-正常
LastLogin *time.Time `json:"last_login" gorm:"column:last_login"` // 最后登录时间
LastLoginIP *orm.Inet `json:"last_login_ip" gorm:"column:last_login_ip"` // 最后登录地址
LastLoginUA *string `json:"last_login_ua" gorm:"column:last_login_ua"` // 最后登录代理
}
// AdminStatus 管理员状态枚举
type AdminStatus int
const (
AdminStatusDisabled AdminStatus = 0 // 禁用
AdminStatusEnabled AdminStatus = 1 // 正常
)

View File

@@ -1,30 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameAdminRole = "admin_role"
// AdminRole mapped from table <admin_role>
type AdminRole struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:管理员角色ID" json:"id"` // 管理员角色ID
Name string `gorm:"column:name;type:character varying(255);not null;comment:角色名称" json:"name"` // 角色名称
Description *string `gorm:"column:description;type:character varying(255);comment:角色描述" json:"description"` // 角色描述
Active *bool `gorm:"column:active;type:boolean;default:true;comment:是否激活" json:"active"` // 是否激活
Sort *int32 `gorm:"column:sort;type:integer;comment:排序" json:"sort"` // 排序
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName AdminRole's table name
func (*AdminRole) TableName() string {
return TableNameAdminRole
}

14
web/models/admin_role.go Normal file
View File

@@ -0,0 +1,14 @@
package models
import (
"platform/web/core"
)
// AdminRole 管理员角色表
type AdminRole struct {
core.Model
Name string `json:"name" gorm:"column:name"` // 角色名称
Description *string `json:"description" gorm:"column:description"` // 角色描述
Active bool `json:"active" gorm:"column:active"` // 是否激活
Sort int32 `json:"sort" gorm:"column:sort"` // 排序
}

View File

@@ -1,28 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameAdminRoleLink = "admin_role_link"
// AdminRoleLink mapped from table <admin_role_link>
type AdminRoleLink struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID
AdminID int32 `gorm:"column:admin_id;type:integer;not null;comment:管理员ID" json:"admin_id"` // 管理员ID
RoleID int32 `gorm:"column:role_id;type:integer;not null;comment:角色ID" json:"role_id"` // 角色ID
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName AdminRoleLink's table name
func (*AdminRoleLink) TableName() string {
return TableNameAdminRoleLink
}

View File

@@ -1,28 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameAdminRolePermissionLink = "admin_role_permission_link"
// AdminRolePermissionLink mapped from table <admin_role_permission_link>
type AdminRolePermissionLink struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID
RoleID int32 `gorm:"column:role_id;type:integer;not null;comment:角色ID" json:"role_id"` // 角色ID
PermissionID int32 `gorm:"column:permission_id;type:integer;not null;comment:权限ID" json:"permission_id"` // 权限ID
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName AdminRolePermissionLink's table name
func (*AdminRolePermissionLink) TableName() string {
return TableNameAdminRolePermissionLink
}

View File

@@ -1,32 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameAnnouncement = "announcement"
// Announcement mapped from table <announcement>
type Announcement struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:公告ID" json:"id"` // 公告ID
Title string `gorm:"column:title;type:character varying(255);not null;comment:公告标题" json:"title"` // 公告标题
Content *string `gorm:"column:content;type:text;comment:公告内容" json:"content"` // 公告内容
Type int32 `gorm:"column:type;type:integer;not null;default:1;comment:公告类型1-普通公告" json:"type"` // 公告类型1-普通公告
Pin bool `gorm:"column:pin;type:boolean;not null;comment:是否置顶" json:"pin"` // 是否置顶
Status int32 `gorm:"column:status;type:integer;not null;default:1;comment:公告状态0-禁用1-正常" json:"status"` // 公告状态0-禁用1-正常
Sort int32 `gorm:"column:sort;type:integer;not null;comment:公告排序" json:"sort"` // 公告排序
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName Announcement's table name
func (*Announcement) TableName() string {
return TableNameAnnouncement
}

View File

@@ -0,0 +1,31 @@
package models
import (
"platform/web/core"
)
// Announcement 公告表
type Announcement struct {
core.Model
Title string `json:"title" gorm:"column:title"` // 公告标题
Content *string `json:"content" gorm:"column:content"` // 公告内容
Type AnnouncementType `json:"type" gorm:"column:type"` // 公告类型1-普通公告
Pin bool `json:"pin" gorm:"column:pin"` // 是否置顶
Status AnnouncementStatus `json:"status" gorm:"column:status"` // 公告状态0-禁用1-正常
Sort int32 `json:"sort" gorm:"column:sort"` // 公告排序
}
// AnnouncementType 公告类型枚举
type AnnouncementType int
const (
AnnouncementTypeNormal AnnouncementType = 1 // 普通公告
)
// AnnouncementStatus 公告状态枚举
type AnnouncementStatus int
const (
AnnouncementStatusDisabled AnnouncementStatus = 0 // 禁用
AnnouncementStatusEnabled AnnouncementStatus = 1 // 正常
)

View File

@@ -1,38 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"github.com/shopspring/decimal"
"gorm.io/gorm"
)
const TableNameBill = "bill"
// Bill mapped from table <bill>
type Bill struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:账单ID" json:"id"` // 账单ID
UserID int32 `gorm:"column:user_id;type:integer;not null;comment:用户ID" json:"user_id"` // 用户ID
TradeID *int32 `gorm:"column:trade_id;type:integer;comment:订单ID" json:"trade_id"` // 订单ID
ResourceID *int32 `gorm:"column:resource_id;type:integer;comment:套餐ID" json:"resource_id"` // 套餐ID
RefundID *int32 `gorm:"column:refund_id;type:integer;comment:退款ID" json:"refund_id"` // 退款ID
BillNo string `gorm:"column:bill_no;type:character varying(255);not null;comment:易读账单号" json:"bill_no"` // 易读账单号
Info *string `gorm:"column:info;type:character varying(255);comment:产品可读信息" json:"info"` // 产品可读信息
Type int32 `gorm:"column:type;type:integer;not null;comment:账单类型1-消费2-退款3-充值" json:"type"` // 账单类型1-消费2-退款3-充值
Amount decimal.Decimal `gorm:"column:amount;type:numeric(12,2);not null;comment:账单金额" json:"amount"` // 账单金额
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
Trade *Trade `gorm:"foreignKey:TradeID" json:"trade"`
Refund *Refund `gorm:"foreignKey:RefundID" json:"refund"`
Resource *Resource `gorm:"foreignKey:ResourceID" json:"resource"`
}
// TableName Bill's table name
func (*Bill) TableName() string {
return TableNameBill
}

34
web/models/bill.go Normal file
View File

@@ -0,0 +1,34 @@
package models
import (
"platform/web/core"
"github.com/shopspring/decimal"
)
// Bill 账单表
type Bill struct {
core.Model
UserID int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
TradeID *int32 `json:"trade_id" gorm:"column:trade_id"` // 订单ID
ResourceID *int32 `json:"resource_id" gorm:"column:resource_id"` // 套餐ID
RefundID *int32 `json:"refund_id" gorm:"column:refund_id"` // 退款ID
BillNo string `json:"bill_no" gorm:"column:bill_no"` // 易读账单号
Info *string `json:"info" gorm:"column:info"` // 产品可读信息
Type BillType `json:"type" gorm:"column:type"` // 账单类型1-消费2-退款3-充值
Amount decimal.Decimal `json:"amount" gorm:"column:amount"` // 账单金额
User *User `json:"user" gorm:"foreignKey:UserID"`
Trade *Trade `json:"trade" gorm:"foreignKey:TradeID"`
Resource *Resource `json:"resource" gorm:"foreignKey:ResourceID"`
Refund *Refund `json:"refund" gorm:"foreignKey:RefundID"`
}
// BillType 账单类型枚举
type BillType int
const (
BillTypeConsume BillType = 1 // 消费
BillTypeRefund BillType = 2 // 退款
BillTypeRecharge BillType = 3 // 充值
)

View File

@@ -1,40 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameChannel = "channel"
// Channel mapped from table <channel>
type Channel struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:通道ID" json:"id"` // 通道ID
UserID int32 `gorm:"column:user_id;type:integer;not null;comment:用户ID" json:"user_id"` // 用户ID
ProxyID int32 `gorm:"column:proxy_id;type:integer;not null;comment:代理ID" json:"proxy_id"` // 代理ID
EdgeID *int32 `gorm:"column:edge_id;type:integer;comment:节点ID" json:"edge_id"` // 节点ID
ResourceID int32 `gorm:"column:resource_id;type:integer;not null;comment:套餐ID" json:"resource_id"` // 套餐ID
ProxyHost string `gorm:"column:proxy_host;type:character varying(255);not null;comment:代理地址" json:"proxy_host"` // 代理地址
ProxyPort int32 `gorm:"column:proxy_port;type:integer;not null;comment:转发端口" json:"proxy_port"` // 转发端口
EdgeHost *string `gorm:"column:edge_host;type:character varying(255);comment:节点地址" json:"edge_host"` // 节点地址
Protocol *int32 `gorm:"column:protocol;type:integer;comment:协议类型1-http2-https3-socks5" json:"protocol"` // 协议类型1-http2-https3-socks5
AuthIP bool `gorm:"column:auth_ip;type:boolean;not null;comment:IP认证" json:"auth_ip"` // IP认证
Whitelists *string `gorm:"column:whitelists;type:text;comment:IP白名单逗号分隔" json:"whitelists"` // IP白名单逗号分隔
AuthPass bool `gorm:"column:auth_pass;type:boolean;not null;comment:密码认证" json:"auth_pass"` // 密码认证
Username *string `gorm:"column:username;type:character varying(255);comment:用户名" json:"username"` // 用户名
Password *string `gorm:"column:password;type:character varying(255);comment:密码" json:"password"` // 密码
Expiration orm.LocalDateTime `gorm:"column:expiration;type:timestamp without time zone;not null;comment:过期时间" json:"expiration"` // 过期时间
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName Channel's table name
func (*Channel) TableName() string {
return TableNameChannel
}

31
web/models/channel.go Normal file
View File

@@ -0,0 +1,31 @@
package models
import (
"platform/web/core"
"platform/web/globals/orm"
"time"
)
// Channel 通道表
type Channel struct {
core.Model
UserID int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
ResourceID int32 `json:"resource_id" gorm:"column:resource_id"` // 套餐ID
ProxyID int32 `json:"proxy_id" gorm:"column:proxy_id"` // 代理ID
BatchNo string `json:"batch_no" gorm:"column:batch_no"` // 批次编号
Port uint16 `json:"port" gorm:"column:port"` // 代理端口
EdgeID *int32 `json:"edge_id" gorm:"column:edge_id"` // 节点ID手动配置
FilterISP *EdgeISP `json:"filter_isp" gorm:"column:filter_isp"` // 运营商过滤(自动配置):参考 edge.isp
FilterProv *string `json:"filter_prov" gorm:"column:filter_prov"` // 省份过滤(自动配置)
FilterCity *string `json:"filter_city" gorm:"column:filter_city"` // 城市过滤(自动配置)
IP *orm.Inet `json:"ip" gorm:"column:ip"` // 节点地址
Whitelists *orm.Slice[string] `json:"whitelists" gorm:"column:whitelists"` // IP白名单逗号分隔
Username *string `json:"username" gorm:"column:username"` // 用户名
Password *string `json:"password" gorm:"column:password"` // 密码
ExpiredAt time.Time `json:"expired_at" gorm:"column:expired_at"` // 过期时间
User User `json:"user" gorm:"foreignKey:UserID"`
Resource Resource `json:"resource" gorm:"foreignKey:ResourceID"`
Proxy Proxy `json:"proxy" gorm:"foreignKey:ProxyID"`
Edge *Edge `json:"edge" gorm:"foreignKey:EdgeID"`
}

View File

@@ -1,34 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameClient = "client"
// Client mapped from table <client>
type Client struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:客户端ID" json:"id"` // 客户端ID
ClientID string `gorm:"column:client_id;type:character varying(255);not null;comment:OAuth2客户端标识符" json:"client_id"` // OAuth2客户端标识符
ClientSecret string `gorm:"column:client_secret;type:character varying(255);not null;comment:OAuth2客户端密钥" json:"client_secret"` // OAuth2客户端密钥
RedirectURI *string `gorm:"column:redirect_uri;type:character varying(255);comment:OAuth2 重定向URI" json:"redirect_uri"` // OAuth2 重定向URI
Spec int32 `gorm:"column:spec;type:integer;not null;comment:安全规范1-native2-browser3-web4-api" json:"spec"` // 安全规范1-native2-browser3-web4-api
Name string `gorm:"column:name;type:character varying(255);not null;comment:名称" json:"name"` // 名称
Icon *string `gorm:"column:icon;type:character varying(255);comment:图标URL" json:"icon"` // 图标URL
Status int32 `gorm:"column:status;type:integer;not null;default:1;comment:状态0-禁用1-正常" json:"status"` // 状态0-禁用1-正常
Type int32 `gorm:"column:type;type:integer;not null;comment:类型0-普通1-官方" json:"type"` // 类型0-普通1-官方
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName Client's table name
func (*Client) TableName() string {
return TableNameClient
}

44
web/models/client.go Normal file
View File

@@ -0,0 +1,44 @@
package models
import (
"platform/web/core"
)
// Client 客户端表
type Client struct {
core.Model
ClientID string `json:"client_id" gorm:"column:client_id"` // OAuth2客户端标识符
ClientSecret string `json:"client_secret" gorm:"column:client_secret"` // OAuth2客户端密钥
RedirectURI *string `json:"redirect_uri" gorm:"column:redirect_uri"` // OAuth2 重定向URI
Spec ClientSpec `json:"spec" gorm:"column:spec"` // 安全规范1-native2-browser3-web4-api
Name string `json:"name" gorm:"column:name"` // 名称
Icon *string `json:"icon" gorm:"column:icon"` // 图标URL
Status ClientStatus `json:"status" gorm:"column:status"` // 状态0-禁用1-正常
Type ClientType `json:"type" gorm:"column:type"` // 类型0-普通1-官方
}
// ClientSpec 客户端安全规范枚举
type ClientSpec int
const (
ClientSpecNative ClientSpec = 1 // native
ClientSpecBrowser ClientSpec = 2 // browser
ClientSpecWeb ClientSpec = 3 // web
ClientSpecAPI ClientSpec = 4 // api
)
// ClientStatus 客户端状态枚举
type ClientStatus int
const (
ClientStatusDisabled ClientStatus = 0 // 禁用
ClientStatusEnabled ClientStatus = 1 // 正常
)
// ClientType 客户端类型枚举
type ClientType int
const (
ClientTypeNormal ClientType = 0 // 普通
ClientTypeOfficial ClientType = 1 // 官方
)

View File

@@ -1,28 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameClientPermissionLink = "client_permission_link"
// ClientPermissionLink mapped from table <client_permission_link>
type ClientPermissionLink struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID
ClientID int32 `gorm:"column:client_id;type:integer;not null;comment:客户端ID" json:"client_id"` // 客户端ID
PermissionID int32 `gorm:"column:permission_id;type:integer;not null;comment:权限ID" json:"permission_id"` // 权限ID
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName ClientPermissionLink's table name
func (*ClientPermissionLink) TableName() string {
return TableNameClientPermissionLink
}

View File

@@ -1,34 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"github.com/shopspring/decimal"
"gorm.io/gorm"
)
const TableNameCoupon = "coupon"
// Coupon mapped from table <coupon>
type Coupon struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:优惠券ID" json:"id"` // 优惠券ID
UserID *int32 `gorm:"column:user_id;type:integer;comment:用户ID" json:"user_id"` // 用户ID
Code string `gorm:"column:code;type:character varying(255);not null;comment:优惠券代码" json:"code"` // 优惠券代码
Remark *string `gorm:"column:remark;type:character varying(255);comment:优惠券备注" json:"remark"` // 优惠券备注
Amount decimal.Decimal `gorm:"column:amount;type:numeric(12,2);not null;comment:优惠券金额" json:"amount"` // 优惠券金额
MinAmount decimal.Decimal `gorm:"column:min_amount;type:numeric(12,2);not null;comment:最低消费金额" json:"min_amount"` // 最低消费金额
Status int32 `gorm:"column:status;type:integer;not null;comment:优惠券状态0-未使用1-已使用2-已过期" json:"status"` // 优惠券状态0-未使用1-已使用2-已过期
ExpireAt *orm.LocalDateTime `gorm:"column:expire_at;type:timestamp without time zone;comment:过期时间" json:"expire_at"` // 过期时间
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName Coupon's table name
func (*Coupon) TableName() string {
return TableNameCoupon
}

29
web/models/coupon.go Normal file
View File

@@ -0,0 +1,29 @@
package models
import (
"platform/web/core"
"time"
"github.com/shopspring/decimal"
)
// Coupon 优惠券表
type Coupon struct {
core.Model
UserID *int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
Code string `json:"code" gorm:"column:code"` // 优惠券代码
Remark *string `json:"remark" gorm:"column:remark"` // 优惠券备注
Amount decimal.Decimal `json:"amount" gorm:"column:amount"` // 优惠券金额
MinAmount decimal.Decimal `json:"min_amount" gorm:"column:min_amount"` // 最低消费金额
Status CouponStatus `json:"status" gorm:"column:status"` // 优惠券状态0-未使用1-已使用2-已过期
ExpireAt *time.Time `json:"expire_at" gorm:"column:expire_at"` // 过期时间
}
// CouponStatus 优惠券状态枚举
type CouponStatus int
const (
CouponStatusUnused CouponStatus = 0 // 未使用
CouponStatusUsed CouponStatus = 1 // 已使用
CouponStatusExpired CouponStatus = 2 // 已过期
)

View File

@@ -1,38 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameEdge = "edge"
// Edge mapped from table <edge>
type Edge struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:节点ID" json:"id"` // 节点ID
ProxyID *int32 `gorm:"column:proxy_id;type:integer;comment:代理ID" json:"proxy_id"` // 代理ID
Type int32 `gorm:"column:type;type:integer;not null;comment:节点类型1-自建" json:"type"` // 节点类型1-自建
Version int32 `gorm:"column:version;type:integer;not null;comment:节点版本" json:"version"` // 节点版本
Name string `gorm:"column:name;type:character varying(255);not null;comment:节点名称" json:"name"` // 节点名称
Host string `gorm:"column:host;type:character varying(255);not null;comment:节点地址" json:"host"` // 节点地址
Isp int32 `gorm:"column:isp;type:integer;not null;comment:运营商0-未知1-电信2-联通3-移动" json:"isp"` // 运营商0-未知1-电信2-联通3-移动
Prov string `gorm:"column:prov;type:character varying(255);not null;comment:省份" json:"prov"` // 省份
City string `gorm:"column:city;type:character varying(255);not null;comment:城市" json:"city"` // 城市
ProxyPort *int32 `gorm:"column:proxy_port;type:integer;comment:代理端口" json:"proxy_port"` // 代理端口
Status int32 `gorm:"column:status;type:integer;not null;comment:节点状态0-离线1-正常" json:"status"` // 节点状态0-离线1-正常
Rtt *int32 `gorm:"column:rtt;type:integer;comment:最近平均延迟" json:"rtt"` // 最近平均延迟
Loss *int32 `gorm:"column:loss;type:integer;comment:最近丢包率" json:"loss"` // 最近丢包率
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName Edge's table name
func (*Edge) TableName() string {
return TableNameEdge
}

65
web/models/edge.go Normal file
View File

@@ -0,0 +1,65 @@
package models
import (
"platform/web/core"
"platform/web/globals/orm"
)
// Edge 节点表
type Edge struct {
core.Model
Type EdgeType `json:"type" gorm:"column:type"` // 节点类型1-自建
Version int32 `json:"version" gorm:"column:version"` // 节点版本
Mac string `json:"mac" gorm:"column:mac"` // 节点 mac 地址
IP orm.Inet `json:"ip" gorm:"column:ip;not null"` // 节点地址
ISP EdgeISP `json:"isp" gorm:"column:isp"` // 运营商0-未知1-电信2-联通3-移动
Prov string `json:"prov" gorm:"column:prov"` // 省份
City string `json:"city" gorm:"column:city"` // 城市
Status EdgeStatus `json:"status" gorm:"column:status"` // 节点状态0-离线1-正常
RTT int32 `json:"rtt" gorm:"column:rtt"` // 最近平均延迟
Loss int32 `json:"loss" gorm:"column:loss"` // 最近丢包率
}
// EdgeType 节点类型枚举
type EdgeType int
const (
EdgeTypeSelfBuilt EdgeType = 1 // 自建
)
// EdgeStatus 节点状态枚举
type EdgeStatus int
const (
EdgeStatusOffline EdgeStatus = 0 // 离线
EdgeStatusNormal EdgeStatus = 1 // 正常
)
// EdgeISP 运营商枚举
type EdgeISP int
const (
EdgeISPTelecom EdgeISP = 1 // 电信
EdgeISPUnicom EdgeISP = 2 // 联通
EdgeISPMobile EdgeISP = 3 // 移动
)
func (isp *EdgeISP) String() string {
if isp == nil {
return ""
}
switch *isp {
case EdgeISPTelecom:
return "电信"
case EdgeISPUnicom:
return "联通"
case EdgeISPMobile:
return "移动"
default:
return ""
}
}
func ToEdgeISP(i int) EdgeISP {
return EdgeISP(i)
}

View File

@@ -0,0 +1,8 @@
package models
// LinkAdminRole 管理员角色关联表
type LinkAdminRole struct {
ID int32 `json:"id" gorm:"column:id"` // 关联ID
AdminID int32 `json:"admin_id" gorm:"column:admin_id"` // 管理员ID
RoleID int32 `json:"role_id" gorm:"column:role_id"` // 角色ID
}

View File

@@ -0,0 +1,8 @@
package models
// LinkAdminRolePermission 管理员角色权限关联表
type LinkAdminRolePermission struct {
ID int32 `json:"id" gorm:"column:id"` // 关联ID
RoleID int32 `json:"role_id" gorm:"column:role_id"` // 角色ID
PermissionID int32 `json:"permission_id" gorm:"column:permission_id"` // 权限ID
}

View File

@@ -0,0 +1,8 @@
package models
// LinkClientPermission 客户端权限关联表
type LinkClientPermission struct {
ID int32 `json:"id" gorm:"column:id"` // 关联ID
ClientID int32 `json:"client_id" gorm:"column:client_id"` // 客户端ID
PermissionID int32 `json:"permission_id" gorm:"column:permission_id"` // 权限ID
}

View File

@@ -0,0 +1,8 @@
package models
// LinkUserRole 用户角色关联表
type LinkUserRole struct {
ID int32 `json:"id" gorm:"column:id"` // 关联ID
UserID int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
RoleID int32 `json:"role_id" gorm:"column:role_id"` // 角色ID
}

View File

@@ -0,0 +1,8 @@
package models
// LinkUserRolePermission 用户角色权限关联表
type LinkUserRolePermission struct {
ID int32 `json:"id" gorm:"column:id"` // 关联ID
RoleID int32 `json:"role_id" gorm:"column:role_id"` // 角色ID
PermissionID int32 `json:"permission_id" gorm:"column:permission_id"` // 权限ID
}

View File

@@ -1,26 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import "platform/web/globals/orm"
const TableNameLogsLogin = "logs_login"
// LogsLogin mapped from table <logs_login>
type LogsLogin struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:登录日志ID" json:"id"` // 登录日志ID
IP string `gorm:"column:ip;type:character varying(45);not null;comment:IP地址" json:"ip"` // IP地址
UA string `gorm:"column:ua;type:character varying(255);not null;comment:用户代理" json:"ua"` // 用户代理
GrantType string `gorm:"column:grant_type;type:character varying(255);not null;comment:授权类型authorization_code-授权码模式client_credentials-客户端凭证模式refresh_token-刷新令牌模式password-密码模式" json:"grant_type"` // 授权类型authorization_code-授权码模式client_credentials-客户端凭证模式refresh_token-刷新令牌模式password-密码模式
PasswordGrantType string `gorm:"column:password_grant_type;type:character varying(255);not null;comment:密码模式子授权类型password-账号密码phone_code-手机验证码email_code-邮箱验证码" json:"password_grant_type"` // 密码模式子授权类型password-账号密码phone_code-手机验证码email_code-邮箱验证码
Success bool `gorm:"column:success;type:boolean;not null;comment:登录是否成功" json:"success"` // 登录是否成功
UserID *int32 `gorm:"column:user_id;type:integer;comment:用户ID" json:"user_id"` // 用户ID
Time orm.LocalDateTime `gorm:"column:time;type:timestamp without time zone;not null;comment:登录时间" json:"time"` // 登录时间
}
// TableName LogsLogin's table name
func (*LogsLogin) TableName() string {
return TableNameLogsLogin
}

39
web/models/logs_login.go Normal file
View File

@@ -0,0 +1,39 @@
package models
import (
"platform/web/globals/orm"
"time"
)
// LogsLogin 登录日志表
type LogsLogin struct {
ID int32 `json:"id" gorm:"column:id"` // 登录日志ID
IP orm.Inet `json:"ip" gorm:"column:ip;not null"` // IP地址
UA string `json:"ua" gorm:"column:ua"` // 用户代理
GrantType GrantType `json:"grant_type" gorm:"column:grant_type"` // 授权类型
PasswordType PasswordType `json:"password_type" gorm:"column:password_type"` // 密码模式子授权类型
Success bool `json:"success" gorm:"column:success"` // 登录是否成功
UserID *int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
Time time.Time `json:"time" gorm:"column:time"` // 登录时间
User *User `json:"user" gorm:"foreignKey:UserID"`
}
// GrantType 授权类型枚举
type GrantType string
const (
GrantTypeAuthorizationCode GrantType = "authorization_code" // 授权码模式
GrantTypeClientCredentials GrantType = "client_credentials" // 客户端凭证模式
GrantTypeRefreshToken GrantType = "refresh_token" // 刷新令牌模式
GrantTypePassword GrantType = "password" // 密码模式
)
// PasswordType 密码模式子授权类型枚举
type PasswordType string
const (
PasswordTypePassword PasswordType = "password" // 账号密码
PasswordTypePhoneCode PasswordType = "phone_code" // 手机验证码
PasswordTypeEmailCode PasswordType = "email_code" // 邮箱验证码
)

View File

@@ -1,29 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import "platform/web/globals/orm"
const TableNameLogsRequest = "logs_request"
// LogsRequest mapped from table <logs_request>
type LogsRequest struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:访问日志ID" json:"id"` // 访问日志ID
IP string `gorm:"column:ip;type:character varying(45);not null;comment:IP地址" json:"ip"` // IP地址
UA string `gorm:"column:ua;type:character varying(255);not null;comment:用户代理" json:"ua"` // 用户代理
UserID *int32 `gorm:"column:user_id;type:integer;comment:用户ID" json:"user_id"` // 用户ID
ClientID *int32 `gorm:"column:client_id;type:integer;comment:客户端ID" json:"client_id"` // 客户端ID
Method string `gorm:"column:method;type:character varying(10);not null;comment:请求方法" json:"method"` // 请求方法
Path string `gorm:"column:path;type:character varying(255);not null;comment:请求路径" json:"path"` // 请求路径
Status int32 `gorm:"column:status;type:integer;not null;comment:响应状态码" json:"status"` // 响应状态码
Error *string `gorm:"column:error;type:text;comment:错误信息" json:"error"` // 错误信息
Time orm.LocalDateTime `gorm:"column:time;type:timestamp without time zone;not null;comment:请求时间" json:"time"` // 请求时间
Latency string `gorm:"column:latency;type:character varying(255);not null;comment:请求延迟" json:"latency"` // 请求延迟
}
// TableName LogsRequest's table name
func (*LogsRequest) TableName() string {
return TableNameLogsRequest
}

View File

@@ -0,0 +1,24 @@
package models
import (
"platform/web/globals/orm"
"time"
)
// LogsRequest 访问日志表
type LogsRequest struct {
ID int32 `json:"id" gorm:"column:id"` // 访问日志ID
IP orm.Inet `json:"ip" gorm:"column:ip;not null"` // IP地址
UA string `json:"ua" gorm:"column:ua"` // 用户代理
UserID *int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
ClientID *int32 `json:"client_id" gorm:"column:client_id"` // 客户端ID
Method string `json:"method" gorm:"column:method"` // 请求方法
Path string `json:"path" gorm:"column:path"` // 请求路径
Status int16 `json:"status" gorm:"column:status"` // 响应状态码
Error *string `json:"error" gorm:"column:error"` // 错误信息
Time time.Time `json:"time" gorm:"column:time"` // 请求时间
Latency string `json:"latency" gorm:"column:latency"` // 请求延迟
User *User `json:"user" gorm:"foreignKey:UserID"`
Client *Client `json:"client" gorm:"foreignKey:ClientID"`
}

View File

@@ -1,22 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import "platform/web/globals/orm"
const TableNameLogsUserBandwidth = "logs_user_bandwidth"
// LogsUserBandwidth mapped from table <logs_user_bandwidth>
type LogsUserBandwidth struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:日志ID" json:"id"` // 日志ID
UserID int32 `gorm:"column:user_id;type:integer;not null;comment:用户ID" json:"user_id"` // 用户ID
Bandwidth int32 `gorm:"column:bandwidth;type:integer;not null;comment:带宽使用量(KB)" json:"bandwidth"` // 带宽使用量(KB)
Time orm.LocalDateTime `gorm:"column:time;type:timestamp without time zone;not null;comment:记录时间" json:"time"` // 记录时间
}
// TableName LogsUserBandwidth's table name
func (*LogsUserBandwidth) TableName() string {
return TableNameLogsUserBandwidth
}

View File

@@ -0,0 +1,13 @@
package models
import (
"time"
)
// LogsUserBandwidth 用户带宽日志表
type LogsUserBandwidth struct {
ID int32 `json:"id" gorm:"column:id;not null"` // 日志ID
UserID int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
Bandwidth int32 `json:"bandwidth" gorm:"column:bandwidth"` // 带宽使用量(KB)
Time time.Time `json:"time" gorm:"column:time"` // 记录时间
}

View File

@@ -1,27 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import "platform/web/globals/orm"
const TableNameLogsUserUsage = "logs_user_usage"
// LogsUserUsage mapped from table <logs_user_usage>
type LogsUserUsage struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:日志ID" json:"id"` // 日志ID
UserID int32 `gorm:"column:user_id;type:integer;not null;comment:用户ID" json:"user_id"` // 用户ID
ResourceID int32 `gorm:"column:resource_id;type:integer;not null;comment:套餐ID" json:"resource_id"` // 套餐ID
Count_ int32 `gorm:"column:count;type:integer;not null;comment:数量" json:"count"` // 数量
Prov *string `gorm:"column:prov;type:character varying(255);comment:省份" json:"prov"` // 省份
City *string `gorm:"column:city;type:character varying(255);comment:城市" json:"city"` // 城市
Isp *string `gorm:"column:isp;type:character varying(255);comment:运营商" json:"isp"` // 运营商
IP string `gorm:"column:ip;type:character varying(45);not null;comment:IP地址" json:"ip"` // IP地址
Time orm.LocalDateTime `gorm:"column:time;type:timestamp without time zone;not null;comment:提取时间" json:"time"` // 提取时间
}
// TableName LogsUserUsage's table name
func (*LogsUserUsage) TableName() string {
return TableNameLogsUserUsage
}

View File

@@ -0,0 +1,19 @@
package models
import (
"platform/web/globals/orm"
"time"
)
// LogsUserUsage 用户使用日志表
type LogsUserUsage struct {
ID int32 `json:"id" gorm:"column:id"` // 日志ID
UserID int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
ResourceID int32 `json:"resource_id" gorm:"column:resource_id"` // 套餐ID
Count int32 `json:"count" gorm:"column:count"` // 数量
Prov *string `json:"prov" gorm:"column:prov"` // 省份
City *string `json:"city" gorm:"column:city"` // 城市
ISP *string `json:"isp" gorm:"column:isp"` // 运营商
IP orm.Inet `json:"ip" gorm:"column:ip"` // IP地址
Time time.Time `json:"time" gorm:"column:time"` // 提取时间
}

View File

@@ -1,29 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNamePermission = "permission"
// Permission mapped from table <permission>
type Permission struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:权限ID" json:"id"` // 权限ID
ParentID *int32 `gorm:"column:parent_id;type:integer;comment:父权限ID" json:"parent_id"` // 父权限ID
Name string `gorm:"column:name;type:character varying(255);not null;comment:权限名称" json:"name"` // 权限名称
Description *string `gorm:"column:description;type:character varying(255);comment:权限描述" json:"description"` // 权限描述
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName Permission's table name
func (*Permission) TableName() string {
return TableNamePermission
}

14
web/models/permission.go Normal file
View File

@@ -0,0 +1,14 @@
package models
import "platform/web/core"
// Permission 权限表
type Permission struct {
core.Model
ParentID *int32 `json:"parent_id" gorm:"column:parent_id"` // 父权限ID
Name string `json:"name" gorm:"column:name"` // 权限名称
Description *string `json:"description" gorm:"column:description"` // 权限描述
Parent *Permission `json:"parent" gorm:"foreignKey:ParentID"`
Children []*Permission `json:"children" gorm:"foreignKey:ParentID"`
}

View File

@@ -1,31 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameProduct = "product"
// Product mapped from table <product>
type Product struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:产品ID" json:"id"` // 产品ID
Code string `gorm:"column:code;type:character varying(255);not null;comment:产品代码" json:"code"` // 产品代码
Name string `gorm:"column:name;type:character varying(255);not null;comment:产品名称" json:"name"` // 产品名称
Description *string `gorm:"column:description;type:character varying(255);comment:产品描述" json:"description"` // 产品描述
Sort int32 `gorm:"column:sort;type:integer;not null;comment:排序" json:"sort"` // 排序
Status int32 `gorm:"column:status;type:integer;not null;default:1;comment:产品状态0-禁用1-正常" json:"status"` // 产品状态0-禁用1-正常
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName Product's table name
func (*Product) TableName() string {
return TableNameProduct
}

23
web/models/product.go Normal file
View File

@@ -0,0 +1,23 @@
package models
import (
"platform/web/core"
)
// Product 产品表
type Product struct {
core.Model
Code string `json:"code" gorm:"column:code"` // 产品代码
Name string `json:"name" gorm:"column:name"` // 产品名称
Description *string `json:"description" gorm:"column:description"` // 产品描述
Sort int32 `json:"sort" gorm:"column:sort"` // 排序
Status ProductStatus `json:"status" gorm:"column:status"` // 产品状态0-禁用1-正常
}
// ProductStatus 产品状态枚举
type ProductStatus int
const (
ProductStatusDisabled ProductStatus = 0 // 禁用
ProductStatusEnabled ProductStatus = 1 // 正常
)

View File

@@ -1,33 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameProxy = "proxy"
// Proxy mapped from table <proxy>
type Proxy struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:代理服务ID" json:"id"` // 代理服务ID
Version int32 `gorm:"column:version;type:integer;not null;comment:代理服务版本" json:"version"` // 代理服务版本
Name string `gorm:"column:name;type:character varying(255);not null;comment:代理服务名称" json:"name"` // 代理服务名称
Host string `gorm:"column:host;type:character varying(255);not null;comment:代理服务地址" json:"host"` // 代理服务地址
Secret *string `gorm:"column:secret;type:character varying(255);comment:代理服务密钥" json:"secret"` // 代理服务密钥
Type int32 `gorm:"column:type;type:integer;not null;comment:代理服务类型1-三方2-自有" json:"type"` // 代理服务类型1-三方2-自有
Status int32 `gorm:"column:status;type:integer;not null;comment:代理服务状态0-离线1-在线" json:"status"` // 代理服务状态0-离线1-在线
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
Edges []Edge `gorm:"foreignKey:ProxyID;references:ID" json:"edges"`
}
// TableName Proxy's table name
func (*Proxy) TableName() string {
return TableNameProxy
}

38
web/models/proxy.go Normal file
View File

@@ -0,0 +1,38 @@
package models
import (
"platform/web/core"
"platform/web/globals/orm"
"gorm.io/datatypes"
)
// Proxy 代理服务表
type Proxy struct {
core.Model
Version int32 `json:"version" gorm:"column:version"` // 代理服务版本
Mac string `json:"mac" gorm:"column:mac"` // 代理服务名称
IP orm.Inet `json:"ip" gorm:"column:ip;not null"` // 代理服务地址
Secret *string `json:"secret" gorm:"column:secret"` // 代理服务密钥
Type ProxyType `json:"type" gorm:"column:type"` // 代理服务类型1-自有2-白银
Status ProxyStatus `json:"status" gorm:"column:status"` // 代理服务状态0-离线1-在线
Meta *datatypes.JSONType[any] `json:"meta" gorm:"column:meta"` // 代理服务元信息
Channels []Channel `json:"channels" gorm:"foreignkey:ProxyID"`
}
// ProxyType 代理服务类型枚举
type ProxyType int
const (
ProxyTypeSelfHosted ProxyType = 1 // 自有
ProxyTypeBaiYin ProxyType = 2 // 白银
)
// ProxyStatus 代理服务状态枚举
type ProxyStatus int
const (
ProxyStatusOffline ProxyStatus = 0 // 离线
ProxyStatusOnline ProxyStatus = 1 // 在线
)

View File

@@ -1,32 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"github.com/shopspring/decimal"
"gorm.io/gorm"
)
const TableNameRefund = "refund"
// Refund mapped from table <refund>
type Refund struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:退款ID" json:"id"` // 退款ID
TradeID int32 `gorm:"column:trade_id;type:integer;not null;comment:订单ID" json:"trade_id"` // 订单ID
ProductID *int32 `gorm:"column:product_id;type:integer;comment:产品ID" json:"product_id"` // 产品ID
Amount decimal.Decimal `gorm:"column:amount;type:numeric(12,2);not null;comment:退款金额" json:"amount"` // 退款金额
Reason *string `gorm:"column:reason;type:character varying(255);comment:退款原因" json:"reason"` // 退款原因
Status int32 `gorm:"column:status;type:integer;not null;comment:退款状态0-待处理1-已退款2-已拒绝" json:"status"` // 退款状态0-待处理1-已退款2-已拒绝
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName Refund's table name
func (*Refund) TableName() string {
return TableNameRefund
}

26
web/models/refund.go Normal file
View File

@@ -0,0 +1,26 @@
package models
import (
"platform/web/core"
"github.com/shopspring/decimal"
)
// Refund 退款记录表
type Refund struct {
core.Model
TradeID int32 `json:"trade_id" gorm:"column:trade_id"` // 订单ID
ProductID *int32 `json:"product_id" gorm:"column:product_id"` // 产品ID
Amount decimal.Decimal `json:"amount" gorm:"column:amount"` // 退款金额
Reason *string `json:"reason" gorm:"column:reason"` // 退款原因
Status RefundStatus `json:"status" gorm:"column:status"` // 退款状态0-待处理1-已退款2-已拒绝
}
// RefundStatus 退款状态枚举
type RefundStatus int
const (
RefundStatusPending RefundStatus = 0 // 待处理
RefundStatusRefunded RefundStatus = 1 // 已退款
RefundStatusRejected RefundStatus = 2 // 已拒绝
)

View File

@@ -1,32 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameResource = "resource"
// Resource mapped from table <resource>
type Resource struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:套餐ID" json:"id"` // 套餐ID
UserID int32 `gorm:"column:user_id;type:integer;not null;comment:用户ID" json:"user_id"` // 用户ID
ResourceNo *string `gorm:"column:resource_no;type:character varying(255);comment:套餐编号" json:"resource_no"` // 套餐编号
Active bool `gorm:"column:active;type:boolean;not null;default:true;comment:套餐状态" json:"active"` // 套餐状态
Type int32 `gorm:"column:type;type:integer;not null;comment:套餐类型1-短效动态2-长效动态" json:"type"` // 套餐类型1-短效动态2-长效动态
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
Short *ResourceShort `gorm:"foreignKey:ResourceID;references:ID" json:"short"`
Long *ResourceLong `gorm:"foreignKey:ResourceID;references:ID" json:"long"`
}
// TableName Resource's table name
func (*Resource) TableName() string {
return TableNameResource
}

34
web/models/resource.go Normal file
View File

@@ -0,0 +1,34 @@
package models
import (
"platform/web/core"
)
// Resource 套餐表
type Resource struct {
core.Model
UserID int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
ResourceNo *string `json:"resource_no" gorm:"column:resource_no"` // 套餐编号
Active bool `json:"active" gorm:"column:active"` // 套餐状态
Type ResourceType `json:"type" gorm:"column:type"` // 套餐类型1-短效动态2-长效动态
User User `json:"user" gorm:"foreignKey:UserID"`
Short *ResourceShort `json:"short" gorm:"foreignKey:ResourceID"`
Long *ResourceLong `json:"long" gorm:"foreignKey:ResourceID"`
}
// ResourceType 套餐类型枚举
type ResourceType int
const (
ResourceTypeShort ResourceType = 1 // 短效动态
ResourceTypeLong ResourceType = 2 // 长效动态
)
// ResourceLongType 套餐计费模式枚举
type ResourceMode int
const (
ResourceModeTime ResourceMode = 1 // 包时
ResourceModeQuota ResourceMode = 2 // 包量
)

View File

@@ -1,28 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import "platform/web/globals/orm"
const TableNameResourceLong = "resource_long"
// ResourceLong mapped from table <resource_long>
type ResourceLong struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:ID" json:"id"` // ID
ResourceID int32 `gorm:"column:resource_id;type:integer;not null;comment:套餐ID" json:"resource_id"` // 套餐ID
Type int32 `gorm:"column:type;type:integer;not null;comment:套餐类型1-包时2-包量" json:"type"` // 套餐类型1-包时2-包量
Live int32 `gorm:"column:live;type:integer;not null;comment:可用时长(天)" json:"live"` // 可用时长(天)
Expire *orm.LocalDateTime `gorm:"column:expire;type:timestamp without time zone;comment:过期时间" json:"expire"` // 过期时间
Quota *int32 `gorm:"column:quota;type:integer;comment:配额数量" json:"quota"` // 配额数量
Used int32 `gorm:"column:used;type:integer;not null;comment:已用数量" json:"used"` // 已用数量
DailyLimit int32 `gorm:"column:daily_limit;type:integer;not null;comment:每日限制" json:"daily_limit"` // 每日限制
DailyUsed int32 `gorm:"column:daily_used;type:integer;not null;comment:今日已用数量" json:"daily_used"` // 今日已用数量
DailyLast *orm.LocalDateTime `gorm:"column:daily_last;type:timestamp without time zone;comment:今日最后使用时间" json:"daily_last"` // 今日最后使用时间
}
// TableName ResourceLong's table name
func (*ResourceLong) TableName() string {
return TableNameResourceLong
}

View File

@@ -0,0 +1,19 @@
package models
import (
"time"
)
// ResourceLong 长效动态套餐表
type ResourceLong struct {
ID int32 `json:"id" gorm:"column:id"` // ID
ResourceID int32 `json:"resource_id" gorm:"column:resource_id"` // 套餐ID
Type ResourceMode `json:"type" gorm:"column:type"` // 套餐类型1-包时2-包量
Live int32 `json:"live" gorm:"column:live"` // 可用时长(天)
Expire *time.Time `json:"expire" gorm:"column:expire"` // 过期时间
Quota *int32 `json:"quota" gorm:"column:quota"` // 配额数量
Used int32 `json:"used" gorm:"column:used"` // 已用数量
DailyLimit int32 `json:"daily_limit" gorm:"column:daily_limit"` // 每日限制
DailyUsed int32 `json:"daily_used" gorm:"column:daily_used"` // 今日已用数量
DailyLast *time.Time `json:"daily_last" gorm:"column:daily_last"` // 今日最后使用时间
}

View File

@@ -1,28 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import "platform/web/globals/orm"
const TableNameResourceShort = "resource_short"
// ResourceShort mapped from table <resource_short>
type ResourceShort struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:ID" json:"id"` // ID
ResourceID int32 `gorm:"column:resource_id;type:integer;not null;comment:套餐ID" json:"resource_id"` // 套餐ID
Type int32 `gorm:"column:type;type:integer;not null;comment:套餐类型1-包时2-包量" json:"type"` // 套餐类型1-包时2-包量
Live int32 `gorm:"column:live;type:integer;not null;comment:可用时长(秒)" json:"live"` // 可用时长(秒)
Expire *orm.LocalDateTime `gorm:"column:expire;type:timestamp without time zone;comment:过期时间" json:"expire"` // 过期时间
Quota *int32 `gorm:"column:quota;type:integer;comment:配额数量" json:"quota"` // 配额数量
Used int32 `gorm:"column:used;type:integer;not null;comment:已用数量" json:"used"` // 已用数量
DailyLimit int32 `gorm:"column:daily_limit;type:integer;not null;comment:每日限制" json:"daily_limit"` // 每日限制
DailyUsed int32 `gorm:"column:daily_used;type:integer;not null;comment:今日已用数量" json:"daily_used"` // 今日已用数量
DailyLast *orm.LocalDateTime `gorm:"column:daily_last;type:timestamp without time zone;comment:今日最后使用时间" json:"daily_last"` // 今日最后使用时间
}
// TableName ResourceShort's table name
func (*ResourceShort) TableName() string {
return TableNameResourceShort
}

View File

@@ -0,0 +1,19 @@
package models
import (
"time"
)
// ResourceShort 短效动态套餐表
type ResourceShort struct {
ID int32 `json:"id" gorm:"column:id"` // ID
ResourceID int32 `json:"resource_id" gorm:"column:resource_id"` // 套餐ID
Type ResourceMode `json:"type" gorm:"column:type"` // 套餐类型1-包时2-包量
Live int32 `json:"live" gorm:"column:live"` // 可用时长(秒)
Expire *time.Time `json:"expire" gorm:"column:expire"` // 过期时间
Quota *int32 `json:"quota" gorm:"column:quota"` // 配额数量
Used int32 `json:"used" gorm:"column:used"` // 已用数量
DailyLimit int32 `json:"daily_limit" gorm:"column:daily_limit"` // 每日限制
DailyUsed int32 `json:"daily_used" gorm:"column:daily_used"` // 今日已用数量
DailyLast *time.Time `json:"daily_last" gorm:"column:daily_last"` // 今日最后使用时间
}

View File

@@ -1,39 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameSession = "session"
// Session mapped from table <session>
type Session struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:会话ID" json:"id"` // 会话ID
UserID *int32 `gorm:"column:user_id;type:integer;comment:用户ID" json:"user_id"` // 用户ID
AdminID *int32 `gorm:"column:admin_id;type:integer;comment:管理员ID" json:"admin_id"` // 管理员ID
ClientID *int32 `gorm:"column:client_id;type:integer;comment:客户端ID" json:"client_id"` // 客户端ID
IP *string `gorm:"column:ip;type:character varying(45);comment:IP地址" json:"ip"` // IP地址
UA *string `gorm:"column:ua;type:character varying(255);comment:用户代理" json:"ua"` // 用户代理
AccessToken string `gorm:"column:access_token;type:character varying(255);not null;comment:访问令牌" json:"access_token"` // 访问令牌
AccessTokenExpires orm.LocalDateTime `gorm:"column:access_token_expires;type:timestamp without time zone;not null;comment:访问令牌过期时间" json:"access_token_expires"` // 访问令牌过期时间
RefreshToken *string `gorm:"column:refresh_token;type:character varying(255);comment:刷新令牌" json:"refresh_token"` // 刷新令牌
RefreshTokenExpires *orm.LocalDateTime `gorm:"column:refresh_token_expires;type:timestamp without time zone;comment:刷新令牌过期时间" json:"refresh_token_expires"` // 刷新令牌过期时间
Scopes_ *string `gorm:"column:scopes;type:character varying(255);comment:权限范围" json:"scopes"` // 权限范围
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
User *User `gorm:"foreignKey:UserID" json:"user"`
Admin *Admin `gorm:"foreignKey:UserID" json:"admin"`
Client *Client `gorm:"belongsTo:ID;foreignKey:ClientID" json:"client"`
}
// TableName Session's table name
func (*Session) TableName() string {
return TableNameSession
}

26
web/models/session.go Normal file
View File

@@ -0,0 +1,26 @@
package models
import (
"platform/web/core"
"platform/web/globals/orm"
"time"
)
// Session 会话表
type Session struct {
core.Model
UserID *int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
AdminID *int32 `json:"admin_id" gorm:"column:admin_id"` // 管理员ID
ClientID *int32 `json:"client_id" gorm:"column:client_id"` // 客户端ID
IP *orm.Inet `json:"ip" gorm:"column:ip"` // IP地址
UA *string `json:"ua" gorm:"column:ua"` // 用户代理
AccessToken string `json:"access_token" gorm:"column:access_token"` // 访问令牌
AccessTokenExpires time.Time `json:"access_token_expires" gorm:"column:access_token_expires"` // 访问令牌过期时间
RefreshToken *string `json:"refresh_token" gorm:"column:refresh_token"` // 刷新令牌
RefreshTokenExpires *time.Time `json:"refresh_token_expires" gorm:"column:refresh_token_expires"` // 刷新令牌过期时间
Scopes *string `json:"scopes" gorm:"column:scopes"` // 权限范围
User *User `json:"user" gorm:"foreignKey:UserID"`
Admin *Admin `json:"admin" gorm:"foreignKey:AdminID"`
Client *Client `json:"client" gorm:"foreignKey:ClientID;belongsTo:ID"`
}

View File

@@ -1,43 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"github.com/shopspring/decimal"
"gorm.io/gorm"
)
const TableNameTrade = "trade"
// Trade mapped from table <trade>
type Trade struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:订单ID" json:"id"` // 订单ID
UserID int32 `gorm:"column:user_id;type:integer;not null;comment:用户ID" json:"user_id"` // 用户ID
InnerNo string `gorm:"column:inner_no;type:character varying(255);not null;comment:内部订单号" json:"inner_no"` // 内部订单号
OuterNo *string `gorm:"column:outer_no;type:character varying(255);comment:外部订单号" json:"outer_no"` // 外部订单号
Type int32 `gorm:"column:type;type:integer;not null;comment:订单类型1-购买产品2-充值余额" json:"type"` // 订单类型1-购买产品2-充值余额
Subject string `gorm:"column:subject;type:character varying(255);not null;comment:订单主题" json:"subject"` // 订单主题
Remark *string `gorm:"column:remark;type:character varying(255);comment:订单备注" json:"remark"` // 订单备注
Amount decimal.Decimal `gorm:"column:amount;type:numeric(12,2);not null;comment:订单总金额" json:"amount"` // 订单总金额
Payment decimal.Decimal `gorm:"column:payment;type:numeric(12,2);not null;comment:实际支付金额" json:"payment"` // 实际支付金额
Method int32 `gorm:"column:method;type:integer;not null;comment:支付方式1-支付宝2-微信3-商福通4-商福通渠道支付宝5-商福通渠道微信" json:"method"` // 支付方式1-支付宝2-微信3-商福通4-商福通渠道支付宝5-商福通渠道微信
Platform int32 `gorm:"column:platform;type:integer;not null;comment:支付平台1-电脑网站2-手机网站" json:"platform"` // 支付平台1-电脑网站2-手机网站
Acquirer *int32 `gorm:"column:acquirer;type:integer;comment:收单机构1-支付宝2-微信3-银联" json:"acquirer"` // 收单机构1-支付宝2-微信3-银联
Status int32 `gorm:"column:status;type:integer;not null;comment:订单状态0-待支付1-已支付2-已取消" json:"status"` // 订单状态0-待支付1-已支付2-已取消
Refunded bool `gorm:"column:refunded;type:boolean;not null" json:"refunded"`
PaymentURL *string `gorm:"column:payment_url;type:text;comment:支付链接" json:"payment_url"` // 支付链接
CompletedAt *orm.LocalDateTime `gorm:"column:completed_at;type:timestamp without time zone;comment:支付时间" json:"completed_at"` // 支付时间
CanceledAt *orm.LocalDateTime `gorm:"column:canceled_at;type:timestamp without time zone;comment:取消时间" json:"canceled_at"` // 取消时间
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName Trade's table name
func (*Trade) TableName() string {
return TableNameTrade
}

74
web/models/trade.go Normal file
View File

@@ -0,0 +1,74 @@
package models
import (
"platform/web/core"
"time"
"github.com/shopspring/decimal"
)
// Trade 订单表
type Trade struct {
core.Model
UserID int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
InnerNo string `json:"inner_no" gorm:"column:inner_no"` // 内部订单号
OuterNo *string `json:"outer_no" gorm:"column:outer_no"` // 外部订单号
Type TradeType `json:"type" gorm:"column:type"` // 订单类型1-购买产品2-充值余额
Subject string `json:"subject" gorm:"column:subject"` // 订单主题
Remark *string `json:"remark" gorm:"column:remark"` // 订单备注
Amount decimal.Decimal `json:"amount" gorm:"column:amount"` // 订单总金额
Payment decimal.Decimal `json:"payment" gorm:"column:payment"` // 实际支付金额
Method TradeMethod `json:"method" gorm:"column:method"` // 支付方式1-支付宝2-微信3-商福通4-商福通渠道支付宝5-商福通渠道微信
Platform TradePlatform `json:"platform" gorm:"column:platform"` // 支付平台1-电脑网站2-手机网站
Acquirer *TradeAcquirer `json:"acquirer" gorm:"column:acquirer"` // 收单机构1-支付宝2-微信3-银联
Status TradeStatus `json:"status" gorm:"column:status"` // 订单状态0-待支付1-已支付2-已取消
Refunded bool `json:"refunded" gorm:"column:refunded"` // 是否已退款
PaymentURL *string `json:"payment_url" gorm:"column:payment_url"` // 支付链接
CompletedAt *time.Time `json:"completed_at" gorm:"column:completed_at"` // 支付时间
CanceledAt *time.Time `json:"canceled_at" gorm:"column:canceled_at"` // 取消时间
}
// TradeType 订单类型枚举
type TradeType int
const (
TradeTypePurchase TradeType = 1 // 购买产品
TradeTypeRecharge TradeType = 2 // 充值余额
)
// TradeMethod 支付方式枚举
type TradeMethod int
const (
TradeMethodAlipay TradeMethod = 1 // 支付宝
TradeMethodWechat TradeMethod = 2 // 微信
TradeMethodSft TradeMethod = 3 // 商福通
TradeMethodSftAlipay TradeMethod = 4 // 商福通渠道支付宝
TradeMethodSftWechat TradeMethod = 5 // 商福通渠道微信
)
// TradePlatform 支付平台枚举
type TradePlatform int
const (
TradePlatformPC TradePlatform = 1 // 电脑网站
TradePlatformMobile TradePlatform = 2 // 手机网站
)
// TradeAcquirer 收单机构枚举
type TradeAcquirer int
const (
TradeAcquirerAlipay TradeAcquirer = 1 // 支付宝
TradeAcquirerWechat TradeAcquirer = 2 // 微信
TradeAcquirerUnionPay TradeAcquirer = 3 // 银联
)
// TradeStatus 订单状态枚举
type TradeStatus int
const (
TradeStatusPending TradeStatus = 0 // 待支付
TradeStatusSuccess TradeStatus = 1 // 已支付
TradeStatusCanceled TradeStatus = 2 // 已取消
)

View File

@@ -1,44 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"github.com/shopspring/decimal"
"gorm.io/gorm"
)
const TableNameUser = "user"
// User mapped from table <user>
type User struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:用户ID" json:"id"` // 用户ID
AdminID *int32 `gorm:"column:admin_id;type:integer;comment:管理员ID" json:"admin_id"` // 管理员ID
Phone string `gorm:"column:phone;type:character varying(255);not null;comment:手机号码" json:"phone"` // 手机号码
Username *string `gorm:"column:username;type:character varying(255);comment:用户名" json:"username"` // 用户名
Email *string `gorm:"column:email;type:character varying(255)" json:"email"`
Password *string `gorm:"column:password;type:character varying(255);comment:用户密码" json:"password"` // 用户密码
Name *string `gorm:"column:name;type:character varying(255);comment:真实姓名" json:"name"` // 真实姓名
Avatar *string `gorm:"column:avatar;type:character varying(255);comment:头像URL" json:"avatar"` // 头像URL
Status int32 `gorm:"column:status;type:integer;not null;default:1;comment:用户状态0-禁用1-正常" json:"status"` // 用户状态0-禁用1-正常
Balance decimal.Decimal `gorm:"column:balance;type:numeric(12,2);not null;comment:账户余额" json:"balance"` // 账户余额
IDType int32 `gorm:"column:id_type;type:integer;not null;comment:认证类型0-未认证1-个人认证2-企业认证" json:"id_type"` // 认证类型0-未认证1-个人认证2-企业认证
IDNo *string `gorm:"column:id_no;type:character varying(255);comment:身份证号或营业执照号" json:"id_no"` // 身份证号或营业执照号
IDToken *string `gorm:"column:id_token;type:character varying(255);comment:身份验证标识" json:"id_token"` // 身份验证标识
ContactQQ *string `gorm:"column:contact_qq;type:character varying(255);comment:QQ联系方式" json:"contact_qq"` // QQ联系方式
ContactWechat *string `gorm:"column:contact_wechat;type:character varying(255);comment:微信联系方式" json:"contact_wechat"` // 微信联系方式
LastLogin *orm.LocalDateTime `gorm:"column:last_login;type:timestamp without time zone;comment:最后登录时间" json:"last_login"` // 最后登录时间
LastLoginHost *string `gorm:"column:last_login_host;type:character varying(45);comment:最后登录地址" json:"last_login_host"` // 最后登录地址
LastLoginAgent *string `gorm:"column:last_login_agent;type:character varying(255);comment:最后登录代理" json:"last_login_agent"` // 最后登录代理
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName User's table name
func (*User) TableName() string {
return TableNameUser
}

50
web/models/user.go Normal file
View File

@@ -0,0 +1,50 @@
package models
import (
"platform/web/core"
"platform/web/globals/orm"
"time"
"github.com/shopspring/decimal"
)
// User 用户表
type User struct {
core.Model
AdminID *int32 `json:"admin_id" gorm:"column:admin_id"` // 管理员ID
Phone string `json:"phone" gorm:"column:phone"` // 手机号码
Username *string `json:"username" gorm:"column:username"` // 用户名
Email *string `json:"email" gorm:"column:email"` // 邮箱
Password *string `json:"password" gorm:"column:password"` // 用户密码
Name *string `json:"name" gorm:"column:name"` // 真实姓名
Avatar *string `json:"avatar" gorm:"column:avatar"` // 头像URL
Status UserStatus `json:"status" gorm:"column:status"` // 用户状态0-禁用1-正常
Balance decimal.Decimal `json:"balance" gorm:"column:balance"` // 账户余额
IDType UserIDType `json:"id_type" gorm:"column:id_type"` // 认证类型0-未认证1-个人认证2-企业认证
IDNo *string `json:"id_no" gorm:"column:id_no"` // 身份证号或营业执照号
IDToken *string `json:"id_token" gorm:"column:id_token"` // 身份验证标识
ContactQQ *string `json:"contact_qq" gorm:"column:contact_qq"` // QQ联系方式
ContactWechat *string `json:"contact_wechat" gorm:"column:contact_wechat"` // 微信联系方式
LastLogin *time.Time `json:"last_login" gorm:"column:last_login"` // 最后登录时间
LastLoginIP *orm.Inet `json:"last_login_ip" gorm:"column:last_login_ip"` // 最后登录地址
LastLoginUA *string `json:"last_login_ua" gorm:"column:last_login_ua"` // 最后登录代理
Admin Admin `json:"admin" gorm:"foreignKey:AdminID"`
}
// UserStatus 用户状态枚举
type UserStatus int
const (
UserStatusDisabled UserStatus = 0 // 禁用
UserStatusEnabled UserStatus = 1 // 正常
)
// UserIDType 用户认证类型枚举
type UserIDType int
const (
UserIDTypeUnverified UserIDType = 0 // 未认证
UserIDTypePersonal UserIDType = 1 // 个人认证
UserIDTypeEnterprise UserIDType = 2 // 企业认证
)

View File

@@ -1,30 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameUserRole = "user_role"
// UserRole mapped from table <user_role>
type UserRole struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:角色ID" json:"id"` // 角色ID
Name string `gorm:"column:name;type:character varying(255);not null;comment:角色名称" json:"name"` // 角色名称
Description *string `gorm:"column:description;type:character varying(255);comment:角色描述" json:"description"` // 角色描述
Active *bool `gorm:"column:active;type:boolean;default:true;comment:是否激活" json:"active"` // 是否激活
Sort *int32 `gorm:"column:sort;type:integer;comment:排序" json:"sort"` // 排序
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName UserRole's table name
func (*UserRole) TableName() string {
return TableNameUserRole
}

14
web/models/user_role.go Normal file
View File

@@ -0,0 +1,14 @@
package models
import (
"platform/web/core"
)
// UserRole 用户角色表
type UserRole struct {
core.Model
Name string `json:"name" gorm:"column:name"` // 角色名称
Description *string `json:"description" gorm:"column:description"` // 角色描述
Active bool `json:"active" gorm:"column:active"` // 是否激活
Sort int32 `json:"sort" gorm:"column:sort"` // 排序
}

View File

@@ -1,28 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameUserRoleLink = "user_role_link"
// UserRoleLink mapped from table <user_role_link>
type UserRoleLink struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID
UserID int32 `gorm:"column:user_id;type:integer;not null;comment:用户ID" json:"user_id"` // 用户ID
RoleID int32 `gorm:"column:role_id;type:integer;not null;comment:角色ID" json:"role_id"` // 角色ID
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName UserRoleLink's table name
func (*UserRoleLink) TableName() string {
return TableNameUserRoleLink
}

View File

@@ -1,28 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameUserRolePermissionLink = "user_role_permission_link"
// UserRolePermissionLink mapped from table <user_role_permission_link>
type UserRolePermissionLink struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID
RoleID int32 `gorm:"column:role_id;type:integer;not null;comment:角色ID" json:"role_id"` // 角色ID
PermissionID int32 `gorm:"column:permission_id;type:integer;not null;comment:权限ID" json:"permission_id"` // 权限ID
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName UserRolePermissionLink's table name
func (*UserRolePermissionLink) TableName() string {
return TableNameUserRolePermissionLink
}

View File

@@ -1,29 +0,0 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package models
import (
"platform/web/globals/orm"
"gorm.io/gorm"
)
const TableNameWhitelist = "whitelist"
// Whitelist mapped from table <whitelist>
type Whitelist struct {
ID int32 `gorm:"column:id;type:integer;primaryKey;autoIncrement:true;comment:白名单ID" json:"id"` // 白名单ID
UserID int32 `gorm:"column:user_id;type:integer;not null;comment:用户ID" json:"user_id"` // 用户ID
Host string `gorm:"column:host;type:character varying(45);not null;comment:IP地址" json:"host"` // IP地址
Remark *string `gorm:"column:remark;type:character varying(255);comment:备注" json:"remark"` // 备注
CreatedAt *orm.LocalDateTime `gorm:"column:created_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt *orm.LocalDateTime `gorm:"column:updated_at;type:timestamp without time zone;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp without time zone;comment:删除时间" json:"deleted_at"` // 删除时间
}
// TableName Whitelist's table name
func (*Whitelist) TableName() string {
return TableNameWhitelist
}

14
web/models/whitelist.go Normal file
View File

@@ -0,0 +1,14 @@
package models
import (
"platform/web/core"
"platform/web/globals/orm"
)
// Whitelist 白名单表
type Whitelist struct {
core.Model
UserID int32 `json:"user_id" gorm:"column:user_id"` // 用户ID
IP orm.Inet `json:"ip" gorm:"column:ip;not null"` // IP地址
Remark *string `json:"remark" gorm:"column:remark"` // 备注
}