model

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Index

Constants

View Source
const (
	HelpStatusInActive HelpStatus = -1        // 未启用的状态
	HelpStatusActive   HelpStatus = 1         // 启用的状态
	HelpTypeArticle    HelpType   = "article" // 普通文章
	HelpTypeClass      HelpType   = "class"   // 分类
)
View Source
const (
	LoginLogTypeUserName         LoginLogType    = 0 // 用户名登陆
	LoginLogTypeTel                                  // 手机登陆
	LoginLogTypeEmail                                // 邮箱登陆
	LoginLogTypeThird                                // 第三方登陆
	LoginLogTypeWechat                               // 微信登陆
	LoginLogTypeQRCode                               // 扫码登录
	LoginLogCommandLoginSuccess  LoginLogCommand = 0 // 登陆成功
	LoginLogCommandLogoutSuccess                     // 登出成功
	LoginLogCommandLoginFail                         // 登陆失败
	LoginLogCommandLogoutFail                        // 登出失败
)
View Source
const (
	NewsTypeNews         NewsType = "news"         // 新闻资讯
	NewsTypeAnnouncement NewsType = "announcement" // 官方公告

	NewsStatusInActive NewsStatus = -1 // 未启用的状态
	NewsStatusActive   NewsStatus = 0  // 启用的状态
)
View Source
const (
	// 用户状态
	UserStatusBanned      UserStatus = -100 // 账号被禁用
	UserStatusInactivated UserStatus = -1   // 账号未激活
	UserStatusInit        UserStatus = 1    // 初始化状态

	// 用户性别
	GenderUnknown Gender = 0 // 未知性别
	GenderMale    Gender = 1 // 男
	GenderFemale  Gender = 2 // 女
)

Variables

View Source
var (
	ConfigFieldNamePhone     = ConfigField{Field: "phone", Description: "手机相关的配置"}
	ConfigFieldNameSMTP      = ConfigField{Field: "smtp", Description: "SMTP 邮件服务的配置"}
	ConfigFieldNameWechatApp = ConfigField{Field: "wechat_app", Description: "微信小程序的相关配置"}
	ConfigFields             = []ConfigField{ConfigFieldNamePhone, ConfigFieldNameSMTP, ConfigFieldNameWechatApp}
)
View Source
var (
	ReportTypeBug        ReportType = "bug"        // BUG 反馈
	ReportTypeFeature    ReportType = "feature"    // 新功能请求
	ReportTypeSuggestion ReportType = "suggestion" // 建议
	ReportTypeOther      ReportType = "other"      // 其他
	ReportTypes                     = []ReportTypeDetail{
		{
			Type:        ReportTypeBug,
			Description: "BUG 反馈",
		},
		{
			Type:        ReportTypeFeature,
			Description: "新功能请求",
		},
		{
			Type:        ReportTypeSuggestion,
			Description: "建议",
		},
		{
			Type:        ReportTypeOther,
			Description: "其他",
		},
	}

	ReportStatusPending ReportStatus = 0 // 初始状态
	ReportStatusResolve ReportStatus = 1 // 已解决
	ReportStatuses                   = []ReportStatus{ReportStatusPending, ReportStatusResolve}
)
View Source
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{},
	}
)
View Source
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,
	}
)

Functions

func IsValidNewsType

func IsValidNewsType(t NewsType) bool

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(2)" json:"province_code"`          // 省份代码
	CityCode     string  `gorm:"not null;index;type:varchar(4)" json:"city_code"`              // 城市代码
	AreaCode     string  `gorm:"not null;index;type:varchar(6)" json:"area_code"`              // 地区代码
	StreetCode   string  `gorm:"not null;index;type:varchar(9)" json:"street_code"`            // 街道代码
	Address      string  `gorm:"not null;index;type:varchar(32)" json:"address"`               // 详细地址
	IsDefault    bool    `gorm:"not null;index;" json:"is_default"`                            // 是否为默认地址, 跟 UID 联合唯一
	Note         *string `gorm:"null;index;type:varchar(12)" json:"note"`                      // 备注, 通常备注是 家/公司/学校 等
	CreatedAt    time.Time
	UpdatedAt    time.Time
	DeletedAt    *time.Time `sql:"index"`
}

func (*Address) BeforeCreate

func (news *Address) BeforeCreate(scope *gorm.Scope) error

func (*Address) TableName

func (news *Address) TableName() string

type Admin

type Admin struct {
	Id        string         `gorm:"primary_key;not null;unique;index;type:varchar(32)" 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"`
}

func (*Admin) BeforeCreate

func (news *Admin) BeforeCreate(scope *gorm.Scope) error

func (*Admin) TableName

func (news *Admin) TableName() string

type AdminStatus

type AdminStatus int32
const (
	AdminStatusBanned      AdminStatus = -100 // 账号被禁用
	AdminStatusInactivated AdminStatus = -1   // 账号未激活
	AdminStatusInit        AdminStatus = 0    // 初始化状态
)
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"`
}

func (*Banner) BeforeCreate

func (news *Banner) BeforeCreate(scope *gorm.Scope) (err error)

func (*Banner) TableName

func (news *Banner) TableName() string

type BannerPlatform

type BannerPlatform string
const (
	BannerPlatformPc  BannerPlatform = "pc"  // PC 端的 Banner
	BannerPlatformApp BannerPlatform = "app" // APP 端的 Banner
)

type Config added in v0.4.0

type Config struct {
	Name      string `gorm:"primary_key;unique;not null;type:varchar(32);index;" json:"name"` // 配置名称
	Fields    string `gorm:"not null;type:text" json:"fields"`                                // 配置对应的字段
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func (*Config) BeforeCreate added in v0.4.0

func (config *Config) BeforeCreate(scope *gorm.Scope) error

func (*Config) IsValidConfigField added in v0.4.0

func (config *Config) IsValidConfigField() error

校验配置字段是否正确

func (*Config) IsValidConfigName added in v0.4.0

func (config *Config) IsValidConfigName() error

校验配置名是否正确

func (*Config) TableName added in v0.4.0

func (config *Config) TableName() string

type ConfigField added in v0.4.0

type ConfigField struct {
	Field       string `json:"field"`       // 字段名称
	Description string `json:"description"` // 配置描述
}

type ConfigFieldPhone added in v0.4.0

type ConfigFieldPhone struct {
	Provider string `json:"provider"` // 短信服务提供商, 可选 aliyun/tencent
}

type ConfigFieldSMTP added in v0.4.0

type ConfigFieldSMTP struct {
	Server    string `json:"server" validate:"required" comment:"服务器地址"`            // SMTP 服务器地址(域名)
	Port      int    `json:"port" validate:"required,min=1,max=65535" comment:"端口"` // SMTP 服务器端口
	Username  string `json:"username" validate:"required" comment:"用户名"`            // SMTP 用户名
	Password  string `json:"password" validate:"required" comment:"密码"`             // SMTP 密码
	FromName  string `json:"from_name" validate:"required" comment:"发送者名字"`         // 邮件发送者的名字
	FromEmail string `json:"from_email" validate:"required,email" comment:"发送者地址"`  // 邮件发送者的邮箱地址
}

type ConfigFieldWechatApp added in v0.4.0

type ConfigFieldWechatApp struct {
	AppID  string `json:"app_id" validate:"required" comment:"微信小程序APPID"`  // 微信小程序的 APP ID
	Secret string `json:"secret" validate:"required" comment:"微信小程序Secret"` // 微信小程序的密钥
}

type CustomerSession added in v0.6.0

type CustomerSession 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"`                   // 用户ID
	User      User                  `gorm:"foreignkey:Uid" json:"user"`                                   // **外键**
	WaiterID  string                `gorm:"not null;index;type:varchar(32)" json:"waiter_id"`             // 客服 ID
	Waiter    User                  `gorm:"foreignkey:WaiterID" json:"waiter"`                            //  **外键**
	Items     []CustomerSessionItem `gorm:"foreignkey:SessionID" json:"items"`                            //  **外键**
	ClosedAt  *time.Time            `gorm:"null;index;" json:"closed_at"`                                 // 会话关闭时间
	Rate      *uint                 `gorm:"null;index;" json:"rate"`                                      // 用户对于本次会话的评分
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

客服聊天的会话记录

func (*CustomerSession) BeforeCreate added in v0.6.0

func (c *CustomerSession) BeforeCreate(scope *gorm.Scope) error

func (*CustomerSession) TableName added in v0.6.0

func (c *CustomerSession) TableName() string

type CustomerSessionItem added in v0.6.0

type CustomerSessionItem struct {
	Id         string          `gorm:"primary_key;not null;unique;index;type:varchar(32)" json:"id"` // 消息 ID
	SessionID  string          `gorm:"not null;index;type:varchar(32)" json:"session_id"`            // 会话 ID
	Session    CustomerSession `gorm:"foreignkey:SessionID" json:"session"`                          // **外键**
	Type       SessionType     `gorm:"not null;index;type:varchar(32)" json:"type"`                  // 会话类型
	SenderID   string          `gorm:"not null;index;type:varchar(32)" json:"sender_id"`             // 发送者 ID
	Sender     User            `gorm:"foreignkey:SenderID" json:"sender"`                            // **外键**
	ReceiverID string          `gorm:"not null;index;type:varchar(32)" json:"receiver_id"`           // 接受者的 ID
	Receiver   User            `gorm:"foreignkey:ReceiverID" json:"receiver"`                        // **外键**
	Payload    string          `gorm:"not null;index;type:text" json:"payload"`                      // 数据
	CreatedAt  time.Time
	UpdatedAt  time.Time
	DeletedAt  *time.Time `sql:"index"`
}

客服聊天的会话记录

func (*CustomerSessionItem) BeforeCreate added in v0.6.0

func (c *CustomerSessionItem) BeforeCreate(scope *gorm.Scope) error

func (*CustomerSessionItem) IsValidType added in v0.6.0

func (c *CustomerSessionItem) IsValidType() bool

func (*CustomerSessionItem) TableName added in v0.6.0

func (c *CustomerSessionItem) TableName() string

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 Gender

type Gender int

type Help

type Help struct {
	Id        string         `gorm:"primary_key;unique;not null;index;type:varchar(32)" json:"id"` // 帮助文章ID
	Title     string         `gorm:"not null;index;type:varchar(32)" json:"title"`                 // 帮助文章标题
	Content   string         `gorm:"not null;type:text" json:"content"`                            // 帮助文章内容
	Tags      pq.StringArray `gorm:"type:varchar(32)[]" json:"tags"`                               // 帮助文章的标签
	Status    HelpStatus     `gorm:"not null;type:integer" json:"status"`                          // 帮助文章状态
	Type      HelpType       `gorm:"not null;type:varchar(32)" json:"type"`                        // 帮助文章的类型
	ParentId  *string        `gorm:"null;index;type:varchar(32)" json:"parent_id"`                 // 父级 ID,如果有的话                                    // 父级 ID
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func (*Help) BeforeCreate

func (news *Help) BeforeCreate(scope *gorm.Scope) error

func (*Help) TableName

func (news *Help) TableName() string

type HelpStatus

type HelpStatus int

type HelpType

type HelpType string

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
	User      User            `gorm:"foreignkey:Uid" json:"user"`                            // **外键**
	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"`
}

func (*LoginLog) BeforeCreate

func (news *LoginLog) BeforeCreate(scope *gorm.Scope) error

func (*LoginLog) TableName

func (news *LoginLog) TableName() string

type LoginLogCommand

type LoginLogCommand int

type LoginLogType

type LoginLogType int
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"`
}
func (menu *Menu) BeforeCreate(scope *gorm.Scope) error
func (menu *Menu) TableName() string

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

func (*Message) BeforeCreate

func (news *Message) BeforeCreate(scope *gorm.Scope) error

func (*Message) TableName

func (news *Message) TableName() string

type MessageStatus

type MessageStatus int
const (
	MessageStatusActive MessageStatus = 0 // 默认状态
)

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

func (*News) BeforeCreate

func (news *News) BeforeCreate(scope *gorm.Scope) error

func (*News) TableName

func (news *News) TableName() string

type NewsStatus

type NewsStatus int

type NewsType

type NewsType string

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 OAuth

type OAuth struct {
	Id       string        `gorm:"primary_key;unique;not null;index;type:varchar(32)" json:"id"`    // ID
	Provider OAuthProvider `gorm:"not null;index;unique(user_id);type:varchar(32)" json:"provider"` // 绑定的服务提供商
	Uid      string        `gorm:"not null;index;unique(provider);type:varchar(32)" json:"uid"`     // 对应的平台 UID

	// 以下是 oAuth 返回的字段
	UserID            string    `gorm:"not null;type:varchar(255);index" json:"user_id"` // 用户 ID
	Name              string    `gorm:"not null;type:varchar(32)" json:"name"`           // 用户名
	FirstName         string    `gorm:"not null;type:varchar(32)" json:"first_name"`     // 姓
	LastName          string    `gorm:"not null;type:varchar(32)" json:"last_name"`      // 名
	Nickname          string    `gorm:"not null;type:varchar(32)" json:"nickname"`       // 昵称
	Description       string    `gorm:"not null;type:varchar(255)" json:"description"`   // 描述
	Email             string    `gorm:"not null;type:varchar(255)" json:"email"`         // 邮箱
	AvatarURL         string    `gorm:"not null;type:varchar(255)" json:"avatar_url"`    // 头像 URL
	Location          string    `gorm:"not null;type:varchar(255)" json:"location"`      // 地址
	AccessToken       string    `gorm:"not null;" json:"access_token"`                   // Access Token
	AccessTokenSecret string    `gorm:"not null;" json:"access_token_secret"`            // Access Token Secret
	RefreshToken      string    `gorm:"not null;" json:"refresh_token"`                  // Refresh Token
	ExpiresAt         time.Time `gorm:"not null;" json:"expires_at"`                     // 过期时间

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func (*OAuth) BeforeCreate

func (o *OAuth) BeforeCreate(scope *gorm.Scope) (err error)

func (*OAuth) IsValidProvider

func (o *OAuth) IsValidProvider() bool

func (*OAuth) TableName

func (o *OAuth) TableName() string

type OAuthProvider

type OAuthProvider string
var (
	ProviderGithub   OAuthProvider = "github"
	ProviderGitlab   OAuthProvider = "gitlab"
	ProviderTwitter  OAuthProvider = "twitter"
	ProviderFacebook OAuthProvider = "facebook"
	ProviderGoogle   OAuthProvider = "google"
)

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(255)[]" json:"screenshots"`                       // 反馈的截图
	Locked      bool           `gorm:"not null;" json:"locked"`                                      // 是否已锁定,锁定之后用户不能再更改状态
	CreatedAt   time.Time
	UpdatedAt   time.Time
	DeletedAt   *time.Time `sql:"index"`
}

func (*Report) BeforeCreate

func (r *Report) BeforeCreate(scope *gorm.Scope) (err error)

func (*Report) IsValidStatus added in v0.6.0

func (r *Report) IsValidStatus() bool

func (*Report) IsValidType added in v0.6.0

func (r *Report) IsValidType() bool

func (*Report) TableName

func (r *Report) TableName() string

type ReportStatus

type ReportStatus uint

type ReportType

type ReportType string

type ReportTypeDetail added in v0.6.0

type ReportTypeDetail struct {
	Type        ReportType `json:"type"`
	Description string     `json:"description"`
}

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

func (*Role) TableName

func (news *Role) TableName() string

type SessionType added in v0.6.0

type SessionType int
const (
	SessionTypeText  SessionType = 0 // 发送纯文本消息
	SessionTypeImage SessionType = 1 // 发送图片
)

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;type:varchar(36)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;unique;type:varchar(16);index" json:"phone"`              // 手机号
	Email                   *string        `gorm:"null;unique;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"`           // 用户的邀请码,邀请码唯一
	UsernameRenameRemaining int            `gorm:"not null;" json:"username_rename_remaining"`                   // 用户名还有几次重新更改的机会, 主要是如果用第三方注册登陆,则用户名随机生成,这里给用户一个重新命名的机会

	// 外键关联
	WechatOpenID *string       `gorm:"null;unique;type:varchar(255);index" json:"wechat_open_id"` // 绑定的微信帐号 open_id
	Wechat       *WechatOpenID `gorm:"foreignkey:wechatOpenID" json:"wechat"`                     // **外键**
	OAuth        []OAuth       `gorm:"foreignkey:Uid" json:"oauth"`                               // **外键**

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func (*User) BeforeCreate

func (u *User) BeforeCreate(scope *gorm.Scope) error

func (*User) CheckStatusValid

func (u *User) CheckStatusValid() error

检查用户状态是否正常

func (*User) TableName

func (u *User) TableName() string

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 WalletCny

type WalletCny struct {
	Wallet
}

人民币

func (*WalletCny) TableName

func (news *WalletCny) TableName() string

type WalletCoin

type WalletCoin struct {
	Wallet
}

我们平台自己的币

func (*WalletCoin) TableName

func (news *WalletCoin) TableName() string

type WalletUsd

type WalletUsd struct {
	Wallet
}

美元

func (*WalletUsd) TableName

func (news *WalletUsd) TableName() string

type WechatOpenID

type WechatOpenID struct {
	Id   string `gorm:"primary_key;not null;unique;index;type:varchar(32)" json:"id"` // 微信的 open ID
	Uid  string `gorm:"null;unique;index" json:"uid"`                                 // 对应的用户 ID, 如果为空,则说明没有关联帐号
	User User   `gorm:"foreignkey:Uid" json:"user"`                                   // **外键**

	// 微信相关字段 https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/UserInfo.html
	Nickname  *string `gorm:"null;" json:"nickname"`   // 微信昵称
	AvatarUrl *string `gorm:"null;" json:"avatar_url"` // 微信头像 URL
	Gender    *int    `gorm:"null;" json:"gender"`     // 微信性别 0: 未知 1: 男性 2: 女性
	Country   *string `gorm:"null;" json:"country"`    // 国家/地区
	Province  *string `gorm:"null;" json:"province"`   // 省份
	City      *string `gorm:"null;" json:"city"`       // 城市
	Language  *string `gorm:"null;" json:"language"`   // 语言

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func (*WechatOpenID) BeforeCreate

func (news *WechatOpenID) BeforeCreate(scope *gorm.Scope) error

func (*WechatOpenID) TableName

func (news *WechatOpenID) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL