models

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2017 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ADMIN_SUPER  = 1001
	ADMIN_WRITER = 1002
)
View Source
const (
	BLOG_STATUS_NORMAL  = 0 // 正常状态
	BLOG_STATUS_PENDING = 1 // 审核状态
	BLOG_TYPE_MD        = 0
	BLOG_TYPE_HTML      = 1
	PAGE_SIZE           = 10
)

Variables

View Source
var TABLE_BLOG string
View Source
var TABLE_BLOG_TAG string
View Source
var TABLE_CATEGORY string
View Source
var TABLE_TAG string

Functions

func InitModel

func InitModel()

func LoadCache

func LoadCache()

Loaded setting info to cache.

func SyncDB

func SyncDB() error

Types

type Admin

type Admin struct {
	Id        int64     `xorm:"not null pk autoincr INT(11)"`
	Name      string    `xorm:"not null VARCHAR(15)"`
	Nickname  string    `xorm:"VARCHAR(20)"`
	Passwd    string    `xorm:"not null VARCHAR(64)"`
	Email     string    `xorm:"VARCHAR(45)"`
	Skey      string    `xorm:"not null VARCHAR(64)"`
	Lock      int       `xorm:"default 0 INT(11)"`
	RoleId    int64     `xorm:"default 1001 INT(11)"`
	LastIp    string    `xorm:"default '0.0.0.0' VARCHAR(20)"`
	LastLogin time.Time `xorm:"created TIMESTAMP"`
}

Admin model

func (*Admin) AdminSuperUserCount

func (a *Admin) AdminSuperUserCount() int

统计 admin_super 用户数目

func (*Admin) ChangePasswd

func (a *Admin) ChangePasswd(oldPwd, newPwd string) (bool, string)

Admin change password.

func (*Admin) DeleteAdmin

func (a *Admin) DeleteAdmin(id int64)

DeleteAdmin .

func (*Admin) GetUserByID

func (a *Admin) GetUserByID(id int64) (*Admin, error)

GetUserByID just as you see

func (*Admin) Group

func (a *Admin) Group() string

Group show user's admin Group

func (*Admin) List

func (a *Admin) List() ([]Admin, error)

List all user TODO:Laily need to spilit for page

func (*Admin) New

func (a *Admin) New() (int64, string)

Add new admin user.

func (*Admin) SignIn

func (a *Admin) SignIn(request *revel.Request) (*Admin, string)

Admin sign in/login. 用户登录验证

func (*Admin) UpdateAdmin

func (a *Admin) UpdateAdmin(id int64, u *Admin) (bool, string)

type AdminRole

type AdminRole struct {
	Id       int64  `xorm:"not null pk autoincr INT(11)"`
	RoleDes  string `xorm:"VARCHAR(20)"`
	RoleType int    `xorm:"INT(11)"`
}

AdminRole model

func (*AdminRole) FindByType

func (a *AdminRole) FindByType(id int) (*AdminRole, string)

find role data for type

type Blog

type Blog struct {
	Id            int64     `xorm:"not null pk autoincr INT(11)"`
	Ident         string    `xorm:"not null VARCHAR(255)`
	Title         string    `xorm:"not null default '' VARCHAR(250)"`
	ContentHTML   string    `xorm:"not null TEXT 'content_html'"`
	CategoryId    int64     `xorm:"INT(11)"`
	Passwd        string    `xorm:"VARCHAR(64)"`
	CreateTime    time.Time `xorm:"TIMESTAMP"`
	CreateBy      int64     `xorm:"not null INT(11)"`
	ReadCount     int64     `xorm:"default 0 BIGINT(20)"`
	LeaveCount    int64     `xorm:"default 0 BIGINT(20)"`
	UpdateTime    time.Time `xorm:"TIMESTAMP" updated`
	BackgroundPic string    `xorm:"VARCHAR(255)"`
	Type          int       `xorm:"INT(1)"`
	Status        int       `xorm:"INT(11)"`
	ContentMD     string    `xorm:"TEXT 'content_md'"`
	Summary       string    `xorm:"VARCHAR(255)"`
	Pic           string    `xorm:"VARCHAR(200)"`
	IsDeleted     int       `xorm:"default 0 TINYINT(1)"`
}

Blogger model. 博客实体

func (*Blog) Auther

func (b *Blog) Auther() *Admin

Auther to get blog auther 获取作者

func (*Blog) BatchDel

func (b *Blog) BatchDel(ids []int64) (bool, string)

BatchDel to delete a batch of blog 删除一批博客

func (*Blog) BlogTags

func (b *Blog) BlogTags() []Tag

获取博客的标签

func (*Blog) BlogTagsJSON

func (b *Blog) BlogTagsJSON() string

获取博客的标签并转换成 json

func (*Blog) Category

func (b *Blog) Category() *Category

func (*Blog) DeleteAllBlogTags

func (b *Blog) DeleteAllBlogTags() error

删除该博客关联的所有标签

func (*Blog) FindByCategory

func (b *Blog) FindByCategory(categoryID int64) (*[]Blog, error)

FindByCategory . 查找某个分类下的博客

func (*Blog) FindById

func (b *Blog) FindById() (*Blog, error)

FindById to find blogger by id. 通过 id 查找博客

func (*Blog) FindByIdent

func (b *Blog) FindByIdent() (*Blog, error)

FindByIdent to find blogger by ident. 通过 id 查找博客

func (*Blog) FindList

func (b *Blog) FindList() ([]Blog, error)

FindList to Get blogger list. 获取所有博客

func (*Blog) GetBlogByPage

func (b *Blog) GetBlogByPage(page int, pageSize int) ([]Blog, error)

GetBlogByPage . 根据页面获取博客

func (*Blog) GetBlogByPageAND

func (b *Blog) GetBlogByPageAND(uid, category int64, page int, pageSize int) ([]Blog, error)

GetBlogByPage . 根据页面获取博客 FIXME:Laily 这里顺便查出作者,否则页面显示的时候再查询作者信息效率太差

func (*Blog) GetBlogCount

func (b *Blog) GetBlogCount() int64

GetBlogCount . 获取博客总数

func (*Blog) GetHotBlog

func (b *Blog) GetHotBlog(n int) []Blog

GetLatestBlog . 获取最热门的博客

func (*Blog) GetLatestBlog

func (b *Blog) GetLatestBlog(n int) []Blog

GetLatestBlog . 获取最新的博客

func (*Blog) GetSummary

func (b *Blog) GetSummary() string

GetSummary to cut out a part of blog content 获取一篇博客的摘要 如果没有摘要则截取文章开头 300 个字符

func (*Blog) IsMD

func (b *Blog) IsMD() bool

IsMD to judge it is written by Markdown 判断这篇博客是否由 markdown 书写

func (*Blog) MainURL

func (b *Blog) MainURL() string

MainURL return the url of the blog 博客的链接

func (*Blog) New

func (b *Blog) New() (int64, error)

New to Add new blogger. 新建一个博客

func (*Blog) RenderContent

func (b *Blog) RenderContent() string

func (*Blog) Update

func (b *Blog) Update() (bool, error)

Update blogger. 更新博客

func (*Blog) UpdateView

func (b *Blog) UpdateView(id int64)

更新浏览次数

type BlogTag

type BlogTag struct {
	Id     int64 `xorm:"not null pk autoincr INT(11)"`
	Blogid int64 `xorm:"INT(11)"`
	Tagid  int64 `xorm:"INT(11)"`
}

标签关联表

func (*BlogTag) AddTagRef

func (bt *BlogTag) AddTagRef(tagid, blogid int64)

type Category

type Category struct {
	Id     int64  `xorm:"not null pk autoincr INT(11)"`
	Name   string `xorm:"not null VARCHAR(20)"`
	Ident  string `xorm:"VARCHAR(30)"`
	Parent int64  `xorm:"default 0 INT(11)"`
	Desc   string `xorm:"VARCHAR(255)"`
}

Category . 博客分类实体

func (*Category) AddOrUpdate

func (c *Category) AddOrUpdate(id int64, name, ident string, parent int64, desc string) (int64, error)

AddOrUpdate is a function to save or update a category 添加或者更新一个分类

func (*Category) Delete

func (c *Category) Delete(id int64)

Delete to delete a category 删除分类

func (*Category) FindAll

func (c *Category) FindAll() *[]Category

FindAll to find all categorys 查询所有的分类

func (*Category) GetByID

func (c *Category) GetByID(id int64) (*Category, error)

通过 ident 获取分类

func (*Category) GetByIdent

func (c *Category) GetByIdent(ident string) int64

GetByIdent get category by category ident 通过 ident 获取分类

func (*Category) RelatedBlogCount

func (c *Category) RelatedBlogCount() int

RelatedBlogCount get how many blog that related to the category 获取该分类下的文章数目

type Comment

type Comment struct {
	Id         int64     `xorm:"not null pk autoincr INT(11)"`
	Content    string    `xorm:"TEXT"`
	Name       string    `xorm:"VARCHAR(200)"`
	Email      string    `xorm:"VARVHAR(200)"`
	BlogId     int64     `xorm:"INT(11)"`
	CommentId  int64     `xorm:"INT(11)"`
	CreateTime time.Time `xorm:"DATETIME"`
	Status     int       `xorm:"INT(1)"`
}

Comment model.

func (*Comment) NewComment

func (c *Comment) NewComment() error

New comment.

type Setting

type Setting struct {
	Key   string `xorm:"not null pk VARCHAR(20)"`
	Value string `xorm:"not null TEXT"`
}

Setting model

func (*Setting) FindAll

func (s *Setting) FindAll() ([]Setting, string)

find all setting info.

func (*Setting) Get

func (s *Setting) Get() (string, error)

Get setting value for key.

func (*Setting) GetSiteInfo

func (s *Setting) GetSiteInfo() (*SiteInfo, string)

Query site setting info.

func (*Setting) InsertAndModify

func (s *Setting) InsertAndModify(key, value string) error

Add new setting info or update

func (*Setting) NewSiteInfo

func (s *Setting) NewSiteInfo(title, subtitle, url, seo, reg, foot,
	statistics, status, comment string) error

Add new site info

func (*Setting) Put

func (s *Setting) Put() (bool, error)

Put setting K,V in cache and db.

func (*Setting) Update

func (s *Setting) Update() (bool, error)

Update value for key.

type SiteInfo

type SiteInfo struct {
	Title      string
	SubTitle   string
	Url        string
	Seo        string
	Reg        string
	Foot       string
	Statistics string
	Status     string
	Comment    string
}

SiteInfo model

var SiteInfos *SiteInfo

type Tag

type Tag struct {
	Id     int64  `xorm:"not null pk autoincr INT(11)" json:"id"`
	Type   int    `xorm:"not null INT(11)"`
	Name   string `xorm:"not null VARCHAR(20)" json:"name"`
	Parent int64  `xorm:"default 0 INT(11)"`
	Ident  string `xorm:"VARCHAR(255)" json:"ident"`
}

BloggerTag model 标签表

func (*Tag) Delete

func (t *Tag) Delete(ids []string)

删除标签

func (*Tag) FindBlogByTag

func (t *Tag) FindBlogByTag(ident string) []Blog

FindBlogCount to get count of blog related to this tag 查询标签关联的文章数目

func (*Tag) GetByID

func (b *Tag) GetByID(id int64) (*Tag, error)

根据 id 获取标签

func (*Tag) GetByIdent

func (b *Tag) GetByIdent(ident string) (*Tag, error)

根据 ident 获取标签

func (*Tag) ListAll

func (b *Tag) ListAll() ([]Tag, error)

Query all tag 查找所有 tag

func (*Tag) New

func (b *Tag) New() (int64, error)

New to Add a new tag 新增一个标签

func (*Tag) NewTagByName

func (b *Tag) NewTagByName(name string) (int64, error)

根据名字创建一个标签

func (*Tag) QueryTags

func (t *Tag) QueryTags(str string) ([]map[string][]byte, error)

QueryTags to Search for tag 根据用户输入的单词匹配 tag

func (*Tag) Update

func (t *Tag) Update() bool

更新标签

Jump to

Keyboard shortcuts

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