Documentation
¶
Overview ¶
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Copyright 2019 Axetroy. All rights reserved. MIT license.
Index ¶
- Constants
- Variables
- func IsValidNewsType(t NewsType) bool
- func IsValidReportType(t ReportType) bool
- type Address
- type Admin
- type AdminStatus
- type Banner
- type BannerPlatform
- type FinanceLog
- type FinanceLogCny
- type FinanceLogCoin
- type FinanceLogUsd
- type FinanceType
- type Gender
- type InviteHistory
- type InviteStatus
- type LoginLog
- type LoginLogCommand
- type LoginLogType
- type Menu
- type Message
- type MessageStatus
- type News
- type NewsStatus
- type NewsType
- type Notification
- type NotificationMark
- type NotificationStatus
- type Report
- type ReportStatus
- type ReportType
- type Role
- type TransferLog
- type TransferLogCny
- type TransferLogCoin
- type TransferLogUsd
- type TransferStatus
- type User
- type UserStatus
- type Wallet
- type WalletCny
- type WalletCoin
- type WalletUsd
Constants ¶
const ( LoginLogTypeUserName LoginLogType = 0 // 用户名登陆 LoginLogTypeTel // 手机登陆 LoginLogTypeEmail // 邮箱登陆 LoginLogTypeThird // 第三方登陆 LoginLogCommandLoginSuccess LoginLogCommand = 0 // 登陆成功 LoginLogCommandLogoutSuccess // 登出成功 LoginLogCommandLoginFail // 登陆失败 LoginLogCommandLogoutFail // 登出失败 )
const ( NewsTypeNews NewsType = "news" // 新闻资讯 NewsTypeAnnouncement NewsType = "announcement" // 官方公告 NewsStatusInActive NewsStatus = -1 // 未启用的状态 NewsStatusActive // 启用的状态 )
const ( // 用户状态 UserStatusBanned UserStatus = -100 // 账号被禁用 UserStatusInactivated UserStatus = -1 // 账号未激活 UserStatusInit UserStatus = 0 // 初始化状态 // 用户性别 GenderUnknown Gender = 0 // 未知性别 GenderMale // 男 GenderFemmale // 女 )
Variables ¶
var ( ReportTypeBug ReportType = "bug" // BUG 反馈 ReportTypeFeature ReportType = "feature" // 新功能请求 ReportTypeSuggestion ReportType = "suggestion" // 建议 ReportTypeOther ReportType = "other" // 其他 ReportStatusPending ReportStatus = 0 // 初始状态 ReportStatusResolve ReportStatus = 1 // 已解决 ReportTypes = []ReportType{ReportTypeBug, ReportTypeFeature, ReportTypeSuggestion, ReportTypeOther} )
var ( TransferStatusReject TransferStatus = -1 // 收款方拒接接受 TransferStatusWaitForConfirm TransferStatus = 0 // 等待收款方确认 TransferStatusConfirmed TransferStatus = 1 // 收款方已确认 TransferLogCnyTableName = transferLogTablePrefix + strings.ToLower(WalletCNY) // 人民币表名 TransferLogUsdTableName = transferLogTablePrefix + strings.ToLower(WalletUSD) // 美元表名 TransferLogCoinTableName = transferLogTablePrefix + strings.ToLower(WalletCOIN) // 积分表名 TransferTableNames = []string{ TransferLogCnyTableName, TransferLogUsdTableName, TransferLogCoinTableName, } TransferLogMap = map[string]interface{}{ WalletCNY: TransferLogCny{}, WalletUSD: TransferLogUsd{}, WalletCOIN: TransferLogCoin{}, } )
var ( WalletCNY = "CNY" WalletUSD = "USD" WalletCOIN = "COIN" Wallets = []string{WalletCNY, WalletUSD, WalletCOIN} WalletCnyTableName = walletTablePrefix + strings.ToLower(WalletCNY) // 人民币表名 WalletUsdTableName = walletTablePrefix + strings.ToLower(WalletUSD) // 美元表名 WalletCoinTableName = walletTablePrefix + strings.ToLower(WalletCOIN) // 积分表名 WalletTableNames = []string{ WalletCnyTableName, WalletUsdTableName, WalletCoinTableName, } )
var ( DefaultUser = role.New("user", "普通用户", []accession.Accession{ *accession.ProfileUpdate, *accession.Password2Set, *accession.Password2Reset, *accession.Password2Update, *accession.PasswordUpdate, *accession.DoTransfer, }) )
var (
NewsTypes = []NewsType{NewsTypeNews, NewsTypeAnnouncement}
)
Functions ¶
func IsValidNewsType ¶
Types ¶
type Address ¶
type Address struct {
Id string `gorm:"primary_key;unique;not null;index;type:varchar(32)" json:"id"` // 地址ID
Uid string `gorm:"not null;index;type:varchar(32)" json:"uid"` // 用户ID, 与默认地址联合唯一,用户只能有一个唯一的收货地址
Name string `gorm:"not null;index;type:varchar(32)" json:"name"` // 收货人
Phone string `gorm:"not null;index;type:varchar(32)" json:"phone"` // 收货人电话
ProvinceCode string `gorm:"not null;index;type:varchar(6)" json:"province_code"` // 省份代码
CityCode string `gorm:"not null;index;type:varchar(6)" json:"city_code"` // 城市代码
AreaCode string `gorm:"not null;index;type:varchar(6)" json:"area_code"` // 地区代码
Address string `gorm:"not null;index;type:varchar(32)" json:"address"` // 详细地址
IsDefault bool `gorm:"not null;index;" json:"is_default"` // 是否为默认地址, 跟 UID 联合唯一
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
type Admin ¶
type Admin struct {
Id string `gorm:"primary_key;not null;unique;index" json:"id"` // 用户ID
Username string `gorm:"not null;unique;index;type:varchar(36)" json:"username"` // 用户名, 用于登陆
Name string `gorm:"not null;index;type:varchar(36)" json:"Name"` // 管理员名
Password string `gorm:"not null;type:varchar(36)" json:"password"` // 登陆密码
Accession pq.StringArray `gorm:"not null;type:varchar(64)[]" json:"accession"` // 管理员的权限, 超级管理员不依赖于这个字段
IsSuper bool `gorm:"not null;" json:"is_super"` // 是否是超级管理员, 超级管理员全站应该只有一个
Status AdminStatus `gorm:"not null;" json:"status"` // 状态
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
type AdminStatus ¶
type AdminStatus int32
const ( AdminStatusBanned AdminStatus = -100 // 账号被禁用 AdminStatusInactivated AdminStatus = -1 // 账号未激活 AdminStatusInit AdminStatus = 0 // 初始化状态 )
type Banner ¶
type Banner struct {
Id string `gorm:"primary_key;unique;not null;index;type:varchar(32)" json:"id"` // ID
Image string `gorm:"not null;index;type:varchar(255)" json:"image"` // 图片
Href string `gorm:"not null;index;type:varchar(255)" json:"href"` // 图片连接
Platform BannerPlatform `gorm:"not null;index;type:varchar(32)" json:"platform"` // 用于哪个平台
Description *string `gorm:"null;index;type:varchar(255)" json:"description"` // Banner 描述
Priority *int `gorm:"null;index;" json:"priority"` // 优先级,主要用于排序
Identifier *string `gorm:"null;index;type:varchar(32)" json:"identifier"` // 标识符, 用于 APP 跳转页面的标识符
FallbackUrl *string `gorm:"null;index;type:varchar(255)" json:"fallback_url"` // fallback 的 url, 当 APP 没有 `Identifier` 对应的页面时,这个就是 fallback 的页面
Active bool `gorm:"not null;default:true;index;" json:"active"` // 是否激活
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
type BannerPlatform ¶
type BannerPlatform string
const ( BannerPlatformPc BannerPlatform = "pc" // PC 端的 Banner BannerPlatformApp BannerPlatform = "app" // APP 端的 Banner )
type FinanceLog ¶
type FinanceLog struct {
Id string `gorm:"primary_key;unique;not null;index;type:varchar(32)" json:"id"` // 流水ID
Currency string `gorm:"not null;index;type:varchar(16)" json:"currency"` // 对应的币种流水
OrderId string `gorm:"null;index;type:varchar(32)" json:"order_id"` // 对应的订单id, 系统产生的流水可能不会存在orderId
Uid string `gorm:"not null;index;type:varchar(32)" json:"uid"` // 对应的用户
BeforeBalance float64 `gorm:"not null;" json:"before_balance"` // 这条流水前的余额
BalanceMutation float64 `gorm:"not null;" json:"balance_mutation"` // 可用余额的变动,正数则为加,负数为减
AfterBalance float64 `gorm:"not null" json:"after_balance"` // 这条流水后的余额
BeforeFrozen float64 `gorm:"not null" json:"before_frozen"` // 这条流水前的冻结余额
FrozenMutation float64 `gorm:"not null" json:"frozen_mutation"` // 冻结余额的变动,正数则为加,负数为减
AfterFrozen float64 `gorm:"not null" json:"after_frozen"` // 这条流水后的冻结余额
Type FinanceType `gorm:"not null" json:"status"` // 流水类型
Note *string `gorm:"null;type:varchar(128)" json:"note"` // 流水备注
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index" json:"-"`
}
func (*FinanceLog) BeforeCreate ¶
func (news *FinanceLog) BeforeCreate(scope *gorm.Scope) error
type FinanceLogCny ¶
type FinanceLogCny struct {
FinanceLog
}
func (*FinanceLogCny) BeforeCreate ¶
func (news *FinanceLogCny) BeforeCreate(scope *gorm.Scope) error
func (*FinanceLogCny) TableName ¶
func (news *FinanceLogCny) TableName() string
type FinanceLogCoin ¶
type FinanceLogCoin struct {
FinanceLog
}
func (*FinanceLogCoin) BeforeCreate ¶
func (news *FinanceLogCoin) BeforeCreate(scope *gorm.Scope) error
func (*FinanceLogCoin) TableName ¶
func (news *FinanceLogCoin) TableName() string
type FinanceLogUsd ¶
type FinanceLogUsd struct {
FinanceLog
}
func (*FinanceLogUsd) BeforeCreate ¶
func (news *FinanceLogUsd) BeforeCreate(scope *gorm.Scope) error
func (*FinanceLogUsd) TableName ¶
func (news *FinanceLogUsd) TableName() string
type FinanceType ¶
type FinanceType string
var ( FinanceTypeTransferIn FinanceType = "transfer_in" // 转入 FinanceTypeTransferOut FinanceType = "transfer_out" // 转出 FinanceLogMap = map[string]interface{}{ "cny": FinanceLogCny{}, "usd": FinanceLogUsd{}, "coin": FinanceLogCoin{}, } )
type InviteHistory ¶
type InviteHistory struct {
Id string `gorm:"primary_key;notnull;unique;index" json:"id"`
Inviter string `gorm:"not null;index;type:varchar(32)" json:"inviter"` // 邀请人
Invitee string `gorm:"not null;unique;index;type:varchar(32)" json:"invitee"` // 受邀请人, 只有唯一的一个
Status InviteStatus `gorm:"not null;" json:"status"` // 受邀请人的激活状态
RewardSettled bool `gorm:"not null;" json:"reward_settled"` // 是否已发放奖励, 包括邀请人和收邀请人的奖励
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
func (*InviteHistory) BeforeCreate ¶
func (news *InviteHistory) BeforeCreate(scope *gorm.Scope) error
func (*InviteHistory) TableName ¶
func (news *InviteHistory) TableName() string
type InviteStatus ¶
type InviteStatus int
const ( StatusInviteRegistered InviteStatus = 0 // 被邀请人刚注册 StatusInviteAuth InviteStatus = 10 // 被邀请人进行了实名认证 StatusInvitePay InviteStatus = 50 // 被邀请人已进行了一笔支付 )
type LoginLog ¶
type LoginLog struct {
Id string `gorm:"primary_key;not null;index;type:varchar(32)" json:"id"` // 数据ID
Uid string `gorm:"not null;index;type:varchar(32)" json:"uid"` // 用户ID
Type LoginLogType `gorm:"not null;type:int" json:"type"` // 登陆类型(用什么方式登陆)
Command LoginLogCommand `gorm:"not null;type:int" json:"command"` // 登陆的状态(成功, 失败)
LastIp string `gorm:"not null;type:varchar(15)" json:"last_ip"` // 本次登陆IP
Client string `gorm:"not null;type:varchar(255)" json:"client"` // 登陆的客户端
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
type LoginLogCommand ¶
type LoginLogCommand int
type LoginLogType ¶
type LoginLogType int
type Menu ¶
type Menu struct {
Id string `gorm:"primary_key;unique;not null;index;type:varchar(32)" json:"id"` // 菜单 ID
ParentId string `gorm:"not null;index;type:varchar(32)" json:"parent_id"` // 该菜单的父级 ID
Name string `gorm:"not null;index;type:varchar(32)" json:"name"` // 菜单名
Url string `gorm:"not null;index;type:varchar(255)" json:"url"` // 菜单链接的 URL 地址
Icon string `gorm:"not null;index;type:varchar(64)" json:"icon"` // 菜单的图标
Accession pq.StringArray `gorm:"not null;index;type:varchar(64)[]" json:"accession"` // 该菜单所需要的权限
Sort int `gorm:"not null;index;" json:"sort"` // 菜单排序, 越大的越靠前
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
type Message ¶
type Message struct {
Id string `gorm:"primary_key;not null;unique;index;type:varchar(32)" json:"id"` // 消息ID
Uid string `gorm:"not null;index;type:varchar(32)" json:"uid"` // 这条消息的所有者
Title string `gorm:"not null;index;type:varchar(32)" json:"title"` // 消息标题
Content string `gorm:"not null;type:text" json:"content"` // 消息内容
Read bool `gorm:"not null" json:"read"` // 是否已读
ReadAt *time.Time `json:"read_at"` // 已读时间
Status MessageStatus `gorm:"not null" json:"status"` // 消息状态
Note *string `gorm:"null;type:varchar(255)" json:"note"` // 这条通知的备注
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
type News ¶
type News struct {
Id string `gorm:"primary_key;unique;not null;index;type:varchar(32)" json:"id"` // 新闻公告类ID
Author string `gorm:"not null;index;type:varchar(32)" json:"author"` // 公告的作者ID
Title string `gorm:"not null;index;type:varchar(32)" json:"title"` // 公告标题
Content string `gorm:"not null;type:text" json:"content"` // 公告内容
Type NewsType `gorm:"not null;type:varchar(32)" json:"type"` // 公告类型
Tags pq.StringArray `gorm:"type:varchar(32)[]" json:"tags"` // 公告的标签
Status NewsStatus `gorm:"not null;type:integer" json:"status"` // 公告状态
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
type NewsStatus ¶
type NewsStatus int
type Notification ¶
type Notification struct {
Id string `gorm:"primary_key;not null;unique;index;type:varchar(32)" json:"id"` // 通知ID
Author string `gorm:"not null;index;type:varchar(32)" json:"Author"` // 发布这则公告的作者
Title string `gorm:"not null;index;type:varchar(32)" json:"title"` // 公告标题
Content string `gorm:"not null;type:text" json:"content"` // 公告内容
Status NotificationStatus `gorm:"not null" json:"status"` // 公告状态
Note *string `gorm:"null;type:varchar(255)" json:"note"` // 这条通知的备注
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
func (*Notification) BeforeCreate ¶
func (news *Notification) BeforeCreate(scope *gorm.Scope) error
func (*Notification) TableName ¶
func (news *Notification) TableName() string
type NotificationMark ¶
type NotificationMark struct {
Id string `gorm:"primary_key;not null;unique(uid);index;type:varchar(32)" json:"id"` // 通知ID, 通知 ID 和 UID 为联合唯一
Uid string `gorm:"not null;index;unique(id);type:varchar(32)" json:"uid"` // 对应的用户ID, 联合通知ID唯一
Read bool `gorm:"not null" json:"read"` // 是否已读
Notification Notification `gorm:"foreign_key:Id;association_foreign_key:Id" json:"notification"` // 关联外键
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
func (*NotificationMark) BeforeCreate ¶
func (news *NotificationMark) BeforeCreate(scope *gorm.Scope) error
func (*NotificationMark) TableName ¶
func (news *NotificationMark) TableName() string
type NotificationStatus ¶
type NotificationStatus int
const ( NotificationStatusInActive NotificationStatus = -1 // 未启用的状态 NotificationStatusActive NotificationStatus = 0 // 启用的状态 )
type Report ¶
type Report struct {
Id string `gorm:"primary_key;unique;not null;index;type:varchar(32)" json:"id"` // 反馈ID
Uid string `gorm:"not null;index;type:varchar(32)" json:"uid"` // 反馈的作者ID
Title string `gorm:"not null;index;type:varchar(32)" json:"title"` // 反馈标题
Content string `gorm:"not null;type:text" json:"content"` // 反馈内容
Type ReportType `gorm:"not null;type:varchar(32)" json:"type"` // 反馈类型
Status ReportStatus `gorm:"not null;" json:"status"` // 当前报告的处理状态
Screenshots pq.StringArray `gorm:"type:varchar(256)[]" json:"screenshots"` // 反馈的截图
Locked bool `gorm:"not null;" json:"locked"` // 是否已锁定,锁定之后用户不能再更改状态
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
type ReportStatus ¶
type ReportStatus int
type ReportType ¶
type ReportType string
type Role ¶
type Role struct {
Name string `gorm:"primary_key;unique;not null;index;type:varchar(64)" json:"name"` // 角色名, 作为主建而且唯一
Description string `gorm:"not null;index;type:varchar(64)" json:"description"` // 角色描述
Accession pq.StringArray `gorm:"not null;index;type:varchar(64)[]" json:"accession"` // 改角色拥有的权限
BuildIn bool `gorm:"not null;index;" json:"build_in"` // 是否是内建的角色,该角色通常是不可改的
Note *string `gorm:"null;index;type:varchar(64)" json:"note"` // 备注
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
type TransferLog ¶
type TransferLog struct {
Id string `gorm:"primary_key;unique;not null;index;type:varchar(32)" json:"id"` // 转账ID
Currency string `gorm:"not null;index;" json:"currency"` // 转账币种
From string `gorm:"not null;index;type:varchar(32)" json:"from"` // 汇款人
To string `gorm:"not null;index;type:varchar(32)" json:"to"` // 收款人
Amount string `gorm:"not null;type:numeric" json:"amount"` // 转账数量
Status TransferStatus `gorm:"not null" json:"status"` // 转账状态
Note *string `gorm:"null;type:varchar(128)" json:"note"` // 转账备注
SnapshotFrom *string `gorm:"null" json:"-"` // 转账者的钱包快照
SnapshotTo *string `gorm:"null" json:"-"` // 收款人的钱包快照
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index" json:"-"`
}
func (*TransferLog) BeforeCreate ¶
func (news *TransferLog) BeforeCreate(scope *gorm.Scope) error
type TransferLogCny ¶
type TransferLogCny struct {
TransferLog
}
func (*TransferLogCny) TableName ¶
func (news *TransferLogCny) TableName() string
type TransferLogCoin ¶
type TransferLogCoin struct {
TransferLog
}
func (*TransferLogCoin) TableName ¶
func (news *TransferLogCoin) TableName() string
type TransferLogUsd ¶
type TransferLogUsd struct {
TransferLog
}
func (*TransferLogUsd) TableName ¶
func (news *TransferLogUsd) TableName() string
type TransferStatus ¶
type TransferStatus int
type User ¶
type User struct {
Id string `gorm:"primary_key;not null;unique;index;type:varchar(32)" json:"id"` // 用户ID
Username string `gorm:"not null;unique;index" json:"username"` // 用户名
Password string `gorm:"not null;type:varchar(36);index" json:"password"` // 登陆密码
PayPassword *string `gorm:"null;type:varchar(36)" json:"pay_password"` // 支付密码
Nickname *string `gorm:"null;type:varchar(36)" json:"nickname"` // 昵称
Phone *string `gorm:"null;type:varchar(16);index" json:"phone"` // 手机号
Email *string `gorm:"null;type:varchar(36);index" json:"email"` // 邮箱
Status UserStatus `gorm:"not null" json:"status"` // 状态
Role pq.StringArray `gorm:"not null;type:varchar(36)[]" json:"role"` // 角色, 用户可以拥有多个角色
Avatar string `gorm:"not null;type:varchar(128)" json:"avatar"` // 头像
Level int32 `gorm:"default(1)" json:"level"` // 用户等级
Gender Gender `gorm:"default(0)" json:"gender"` // 性别
EnableTOTP bool `gorm:"not null;" json:"enable_totp"` // 是否启用双重身份认证
Secret string `gorm:"not null;type:varchar(32)" json:"secret"` // 用户自己的密钥
InviteCode string `gorm:"not null;unique;type:varchar(8)" json:"invite_code"` // 用户的邀请码,邀请码唯一
OauthGoogleId *string `gorm:"null;unique;type:varchar(255)" json:"oauth_google_id"` // 用户的GoogleAuth唯一标识符
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
type UserStatus ¶
type UserStatus int32
type Wallet ¶
type Wallet struct {
Id string `gorm:"primary_key;unique;notnull;index;type:varchar(32)" json:"id"` // 用户ID
Currency string `gorm:"not null;type:varchar(12)" json:"currency"` // 钱包币种
Balance float64 `gorm:"not null;type:numeric" json:"balance"` // 可用余额
Frozen float64 `gorm:"not null;type:numeric" json:"frozen"` // 冻结余额
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
type WalletCoin ¶
type WalletCoin struct {
Wallet
}
我们平台自己的币
func (*WalletCoin) TableName ¶
func (news *WalletCoin) TableName() string