models

package
v0.0.0-...-8adfce3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USER_STATUS_INACTIVE = iota
	USER_STATUS_ACTIVATED
	USER_STATUS_DISABLE
)

Variables

View Source
var (
	Smtp          SmtpType
	QiniuScope    string
	QiniuDomain   string
	CachePageSize int // 允许缓存前几页数据
)
View Source
var (
	Avatars = []string{
		"gopher_teal.jpg",
		"gopher_aqua.jpg",
		"gopher_brown.jpg",
		"gopher_strawberry_bg.jpg",
		"gopher_strawberry.jpg",
	}
	DefaultAvatar = Avatars[0]
)

Functions

func EncryptPassword

func EncryptPassword(password, salt string) string

加密密码,转成md5

func GetEngine

func GetEngine() *xorm.Engine

func Init

func Init()

Types

type Category

type Category struct {
	Id      int64
	Name    string
	Intro   string
	Created time.Time `xorm:"created"`
}

func (Category) HasName

func (c Category) HasName() bool

func (Category) Validate

func (category Category) Validate(v *revel.Validation)

type Permissions

type Permissions struct {
	Id     int64
	UserId int64
	Perm   int
}

type Product

type Product struct {
	Id          int64
	Name        string
	Site        string
	Author      string
	Repository  string
	Description string `xorm:"text"`
	Image       string
	User        User      `xorm:"user_id bigint"`
	Created     time.Time `xorm:"created"`
	Updated     time.Time `xorm:"updated"`
}

func (Product) GetImage

func (p Product) GetImage() string

func (Product) Validate

func (product Product) Validate(v *revel.Validation)

type Reply

type Reply struct {
	Id      int64
	Topic   Topic     `xorm:"topic_id bigint"`
	User    User      `xorm:"user_id bigint"`
	Content string    `xorm:"text"`
	Created time.Time `xorm:"created"`
}

type SmtpType

type SmtpType struct {
	Username string
	Password string
	Host     string
	Address  string
	From     string
}

type Topic

type Topic struct {
	Id       int64
	Title    string
	Content  string   `xorm:"text"`
	Category Category `xorm:"category_id bigint"`
	User     User     `xorm:"user_id bigint"`
	Hits     int
	Replies  int
	Good     bool
	Created  time.Time `xorm:"created"`
	Updated  time.Time `xorm:"updated"`
}

func (Topic) Validate

func (topic Topic) Validate(v *revel.Validation)

type User

type User struct {
	Id              int64
	Name            string
	Email           string
	HashedPassword  string
	Salt            string
	Type            int // 1管理员,2普通用户
	Avatar          string
	ValidateCode    string
	Status          int
	Created         time.Time   `xorm:"created"`
	Updated         time.Time   `xorm:"updated"`
	Password        string      `xorm:"-"`
	ConfirmPassword string      `xorm:"-"`
	Permissions     map[int]int `xorm:"-"`
}

func (User) AvatarImgSrc

func (u User) AvatarImgSrc() string

头像的图片地址

func (User) GetPermissions

func (u User) GetPermissions() map[int]int

func (User) HasEmail

func (u User) HasEmail() bool

func (User) HasName

func (u User) HasName() bool

func (User) IsActive

func (u User) IsActive() bool

func (User) IsAdmin

func (u User) IsAdmin() bool

func (User) IsCustomAvatar

func (u User) IsCustomAvatar() bool

func (User) IsDefaultAvatar

func (u User) IsDefaultAvatar(avatar string) bool

是否是默认头像

func (User) Validate

func (user User) Validate(v *revel.Validation)

Jump to

Keyboard shortcuts

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