Documentation ¶
Index ¶
- Variables
- func GetIntSetting(key string, defaultVal int) int
- func GetSettingByName(name string) string
- func GetSettingByNameFromTx(tx *gorm.DB, name string) string
- func GetSettingByNameWithDefault(name, fallback string) string
- func GetSettingByNames(names ...string) map[string]string
- func GetSettingByType(types []string) map[string]string
- func Init()
- func IsTrue(value string) bool
- type DonateInfo
- type Setting
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *gorm.DB
DB 数据库链接单例
Functions ¶
func GetIntSetting ¶
GetIntSetting 获取整形设置值,如果转换失败则返回默认值defaultVal
func GetSettingByNameFromTx ¶
GetSettingByNameFromTx 用 Name 获取设置值,使用事务
func GetSettingByNameWithDefault ¶
GetSettingByNameWithDefault 用 Name 获取设置值, 取不到时使用缺省值
func GetSettingByNames ¶
GetSettingByNames 用多个 Name 获取设置值
func GetSettingByType ¶
GetSettingByType 获取一个或多个分组的所有设置值
Types ¶
type DonateInfo ¶
type DonateInfo struct { gorm.Model Name string `gorm:"not null;index" json:"name"` // Name 昵称 Payment string `gorm:"not null" json:"payment"` // Payment 支付方式 Url string `gorm:"not null" json:"url"` // Url 支付链接 Comment string `gorm:"size:256" json:"comment"` // Comment 留言 Author uint `gorm:"default:0;not null;index" json:"author"` // Author 作者用户ID }
DonateInfo 捐赠信息
type User ¶
type User struct { gorm.Model Username string `json:"username" gorm:"not null;unique;uniqueIndex"` // Username 用户名 不可变/登陆凭据/唯一 Nickname string `json:"nickname" gorm:"not null"` // Nickname 昵称 可变 Email string `json:"email" gorm:"not null;unique;uniqueIndex"` // Email 用户邮箱 Password string `json:"-" gorm:"not null"` // Password 哈希加密 Description string `json:"description" gorm:"size:256"` // Description 用户简介 Role int `json:"role" gorm:"not null;default:0"` // Role 0:user, 1:admin }
User 用户信息
Click to show internal directories.
Click to hide internal directories.