Documentation
¶
Index ¶
- Constants
- Variables
- func InitModel()
- func LoadCache()
- func SyncDB() error
- type Admin
- func (a *Admin) AdminSuperUserCount() int
- func (a *Admin) ChangePasswd(oldPwd, newPwd string) (bool, string)
- func (a *Admin) DeleteAdmin(id int64)
- func (a *Admin) GetUserByID(id int64) (*Admin, error)
- func (a *Admin) Group() string
- func (a *Admin) List() ([]Admin, error)
- func (a *Admin) New() (int64, string)
- func (a *Admin) SignIn(request *revel.Request) (*Admin, string)
- func (a *Admin) UpdateAdmin(id int64, u *Admin) (bool, string)
- type AdminRole
- type Blog
- func (b *Blog) Auther() *Admin
- func (b *Blog) BatchDel(ids []int64) (bool, string)
- func (b *Blog) BlogTags() []Tag
- func (b *Blog) BlogTagsJSON() string
- func (b *Blog) Category() *Category
- func (b *Blog) DeleteAllBlogTags() error
- func (b *Blog) FindByCategory(categoryID int64) (*[]Blog, error)
- func (b *Blog) FindById() (*Blog, error)
- func (b *Blog) FindByIdent() (*Blog, error)
- func (b *Blog) FindList() ([]Blog, error)
- func (b *Blog) GetBlogByPage(page int, pageSize int) ([]Blog, error)
- func (b *Blog) GetBlogByPageAND(uid, category int64, page int, pageSize int) ([]Blog, error)
- func (b *Blog) GetBlogCount() int64
- func (b *Blog) GetHotBlog(n int) []Blog
- func (b *Blog) GetLatestBlog(n int) []Blog
- func (b *Blog) GetSummary() string
- func (b *Blog) IsMD() bool
- func (b *Blog) MainURL() string
- func (b *Blog) New() (int64, error)
- func (b *Blog) RenderContent() string
- func (b *Blog) Update() (bool, error)
- func (b *Blog) UpdateView(id int64)
- type BlogTag
- type Category
- func (c *Category) AddOrUpdate(id int64, name, ident string, parent int64, desc string) (int64, error)
- func (c *Category) Delete(id int64)
- func (c *Category) FindAll() *[]Category
- func (c *Category) GetByID(id int64) (*Category, error)
- func (c *Category) GetByIdent(ident string) int64
- func (c *Category) RelatedBlogCount() int
- type Comment
- type Setting
- func (s *Setting) FindAll() ([]Setting, string)
- func (s *Setting) Get() (string, error)
- func (s *Setting) GetSiteInfo() (*SiteInfo, string)
- func (s *Setting) InsertAndModify(key, value string) error
- func (s *Setting) NewSiteInfo(title, subtitle, url, seo, reg, foot, statistics, status, comment string) error
- func (s *Setting) Put() (bool, error)
- func (s *Setting) Update() (bool, error)
- type SiteInfo
- type Tag
- func (t *Tag) Delete(ids []string)
- func (t *Tag) FindBlogByTag(ident string) []Blog
- func (b *Tag) GetByID(id int64) (*Tag, error)
- func (b *Tag) GetByIdent(ident string) (*Tag, error)
- func (b *Tag) ListAll() ([]Tag, error)
- func (b *Tag) New() (int64, error)
- func (b *Tag) NewTagByName(name string) (int64, error)
- func (t *Tag) QueryTags(str string) ([]map[string][]byte, error)
- func (t *Tag) Update() bool
Constants ¶
const ( ADMIN_SUPER = 1001 ADMIN_WRITER = 1002 )
const ( BLOG_STATUS_NORMAL = 0 // 正常状态 BLOG_STATUS_PENDING = 1 // 审核状态 BLOG_TYPE_MD = 0 BLOG_TYPE_HTML = 1 PAGE_SIZE = 10 )
Variables ¶
var TABLE_BLOG string
var TABLE_BLOG_TAG string
var TABLE_CATEGORY string
var TABLE_TAG string
Functions ¶
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) ChangePasswd ¶
Admin change password.
func (*Admin) GetUserByID ¶
GetUserByID just as you see
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
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) FindByCategory ¶
FindByCategory . 查找某个分类下的博客
func (*Blog) FindByIdent ¶
FindByIdent to find blogger by ident. 通过 id 查找博客
func (*Blog) GetBlogByPage ¶
GetBlogByPage . 根据页面获取博客
func (*Blog) GetBlogByPageAND ¶
GetBlogByPage . 根据页面获取博客 FIXME:Laily 这里顺便查出作者,否则页面显示的时候再查询作者信息效率太差
func (*Blog) GetSummary ¶
GetSummary to cut out a part of blog content 获取一篇博客的摘要 如果没有摘要则截取文章开头 300 个字符
func (*Blog) RenderContent ¶
type BlogTag ¶
type BlogTag struct { Id int64 `xorm:"not null pk autoincr INT(11)"` Blogid int64 `xorm:"INT(11)"` Tagid int64 `xorm:"INT(11)"` }
标签关联表
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) GetByIdent ¶
GetByIdent get category by category ident 通过 ident 获取分类
func (*Category) RelatedBlogCount ¶
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.
type Setting ¶
type Setting struct { Key string `xorm:"not null pk VARCHAR(20)"` Value string `xorm:"not null TEXT"` }
Setting model
func (*Setting) GetSiteInfo ¶
Query site setting info.
func (*Setting) InsertAndModify ¶
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
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) FindBlogByTag ¶
FindBlogCount to get count of blog related to this tag 查询标签关联的文章数目