model

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

DB 数据库链接单例

Functions

func GetIntSetting

func GetIntSetting(key string, defaultVal int) int

GetIntSetting 获取整形设置值,如果转换失败则返回默认值defaultVal

func GetSettingByName

func GetSettingByName(name string) string

GetSettingByName 用 Name 获取设置值

func GetSettingByNameFromTx

func GetSettingByNameFromTx(tx *gorm.DB, name string) string

GetSettingByNameFromTx 用 Name 获取设置值,使用事务

func GetSettingByNameWithDefault

func GetSettingByNameWithDefault(name, fallback string) string

GetSettingByNameWithDefault 用 Name 获取设置值, 取不到时使用缺省值

func GetSettingByNames

func GetSettingByNames(names ...string) map[string]string

GetSettingByNames 用多个 Name 获取设置值

func GetSettingByType

func GetSettingByType(types []string) map[string]string

GetSettingByType 获取一个或多个分组的所有设置值

func Init

func Init()

Init 初始化 MySQL 链接

func IsTrue

func IsTrue(value string) bool

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 Setting

type Setting struct {
	Name  string `gorm:"not null;unique;uniqueIndex;primaryKey" json:"name"`
	Type  string `gorm:"not null" json:"type"`
	Value string `gorm:"size:256" json:"value"`
}

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 用户信息

Jump to

Keyboard shortcuts

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