models

package
v0.0.0-...-2f3d8d3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

An open source project for personal blog website

An open source project for personal blog website

An open source project for personal blog website

An open source project for personal blog website

An open source project for personal blog website

An open source project for personal blog website

Index

Constants

View Source
const (
	MIN_PAGE_SIZE = 10  // 最小分页
	MAX_PAGE_SIZE = 100 // 最大分页
)

Variables

View Source
var (
	ErrCategoryNotExist    = errors.New("Category does not exist")
	ErrCategoryAlreadExist = errors.New("Category alread exist")
	ErrCategoryIsNull      = errors.New("Category is null")
)
View Source
var (
	ErrTopicNotExist = errors.New("Topic does not exist")
	ErrTopicIsNull   = errors.New("Topic is null")
)
View Source
var (
	ErrUserNotExist    = errors.New("User does not exist")
	ErrUserAlreadExist = errors.New("User alread exist")
	ErrUserIsNull      = errors.New("User is null")
)
View Source
var (
	ErrParameter = errors.New("Parameter is wrong")
)

Functions

func GetSession

func GetSession() *xorm.Session

func InitDatabase

func InitDatabase() error

Types

type Album

type Album struct {
	Id       int64
	Name     string    `xorm:"size(100)"`
	Cover    string    `xorm:"size(70)"`
	Posttime time.Time `xorm:"type(datetime);index"`
	Ishide   int8
	Rank     int8
	Photonum int64
}

相册表

func (*Album) Count

func (t *Album) Count() (int64, error)

func (*Album) Delete

func (m *Album) Delete() error

func (*Album) GetAlbums

func (t *Album) GetAlbums(offset int, size int) ([]*Album, error)

func (*Album) Insert

func (m *Album) Insert() error

func (*Album) Read

func (m *Album) Read(fields ...string) error

func (*Album) Update

func (m *Album) Update(fields ...string) error

type Category

type Category struct {
	Id         int64     `xorm:pk autoincr`
	Name       string    `xorm:"varchar(100) notnull"` // 分类名称
	Count      int64     `xorm:"int"`                  // 文章数量
	CreateTime time.Time `xorm:DateTime created`       // 创建时间
}

func (*Category) Delete

func (c *Category) Delete() error

func (*Category) Save

func (c *Category) Save() error

func (*Category) Update

func (c *Category) Update() error

type Pager

type Pager struct {
	Page     int64
	Totalnum int64
	Pagesize int64
	// contains filtered or unexported fields
}

func NewPager

func NewPager(page, totalnum, pagesize int64, urlpath string) *Pager

func (*Pager) ToString

func (this *Pager) ToString() string

type Photo

type Photo struct {
	Id       int64     `xorm:int`
	Albumid  int64     `xorm:int`
	Des      string    `xorm:varchar(100)`
	Posttime time.Time `xorm:"DateTime created"`
	Url      string    `xorm:"varchar(70)"`
	Small    string    `xorm:"-"`
}

相册表

func (*Photo) Delete

func (m *Photo) Delete() error

func (*Photo) GetPhotos

func (t *Photo) GetPhotos(offset int, size int) ([]*Photo, error)

func (*Photo) Insert

func (m *Photo) Insert() error

func (*Photo) Read

func (m *Photo) Read(fields ...string) error

func (*Photo) Update

func (m *Photo) Update(fields ...string) error

type Topic

type Topic struct {
	Id          int64     `xorm:"pk autoincr"`
	Title       string    `xorm:"varchar(255) notnull"` // 标题
	TitleColor  string    `xorm:varchar(7)`             // 标题置顶颜色
	PreContent  string    `xorm:"varchar(255)"`         // 预读内容
	Content     string    `xorm:"text"`                 // 内容
	Tags        string    `xorm:"varchar(255)"`         // 标签:多个标签使用|分隔
	CategorieId int64     `xorm:index`                  // 分类ID
	Categorie   *Category `xorm:"- <- ->"`              // 分类
	AuthorId    int64     `xorm:index`                  // 作者ID
	Author      *User     `xorm:"- <- ->"`              // 作者
	Status      int8      `xorm:int`                    // 发布状态
	IsTop       int8      `xorm:int`                    // 是否致顶
	Cover       string    `xorm:varchar(100)`           // 封面图片
	Views       int64     `xorm:int`                    // 阅读数
	SourceFrom  string    `xorm:"varchar(255)"`         // 信息来源
	CreateTime  time.Time `xorm:"DateTime created"`     // 创建时间
	UpdateTime  time.Time `xorm:"DateTime updated"`     // 更新时间
}

func (*Topic) Count

func (t *Topic) Count() (int64, error)

func (*Topic) DeleteById

func (t *Topic) DeleteById(id int64) error

Delete topic with id

func (*Topic) GetTopicById

func (t *Topic) GetTopicById(id int64) error

Find a topic with id

func (*Topic) GetTopics

func (t *Topic) GetTopics(offset int, size int) ([]*Topic, error)

GetTopics method returns the topic list

func (*Topic) Save

func (t *Topic) Save() error

Save topic to db

func (*Topic) Update

func (t *Topic) Update() error

update topic

type User

type User struct {
	Id            int64     `xorm:"pk autoincr"`
	Name          string    `xorm:varchar(100)`         // `姓名`
	Email         string    `xorm:varchar(100)`         // `邮箱地址`
	Username      string    `xorm:varchar(100) notnull` // `用户名称`
	Password      string    `xorm:varchar(100) notnull` // `用户密码`
	LoginCount    int64     `xorm:int`                  // 登录次数
	Authkey       string    `xorm:varchar(10)"`
	Active        int8      `xorm:int`                // 是否激活
	CreateTime    time.Time `xorm:"DateTime created"` // `创建时间`
	LastLoginTime time.Time `xorm:"DateTime updated"` // `最后登录时间`
	LoginIp       string    `xorm:"varchar(100)"`     // `登录IP`
}

func (*User) AllUserCount

func (u *User) AllUserCount() (int64, error)

func (*User) Delete

func (u *User) Delete() error

func (*User) DisableUserCount

func (u *User) DisableUserCount() (int64, error)

func (*User) GetUserByEmail

func (u *User) GetUserByEmail(email string) error

Find user with e-mail address

func (*User) GetUserById

func (u *User) GetUserById(id int64) error

Find user with id

func (*User) GetUserByUsername

func (u *User) GetUserByUsername(username string) error

Find user with username

func (*User) GetUsers

func (u *User) GetUsers(offset int, size int) ([]*User, error)

GetUsers method returns the user list

func (*User) IsUserExist

func (u *User) IsUserExist() (bool, error)

Check user whether or not exist in db with the username

func (*User) SaveUser

func (u *User) SaveUser() error

Save user entity

func (*User) String

func (u *User) String() string

func (*User) UpdateUser

func (u *User) UpdateUser() error

Update user entity

Jump to

Keyboard shortcuts

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