models

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

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

Go to latest
Published: Oct 9, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Filter_Create        = "created"
	Filter_Update        = "updated"
	Filter_ViewCount     = "view_count"
	Filter_LastReplyTime = "last_reply_time"
	Filter_UserName      = "author"

	ArticlePerPageLimit = 10
)

文章字段过滤器

View Source
const (
	Filter_Category_Create       = "created"
	Filter_Category_ArticleCount = "article_count"
)

分类字段过滤器

View Source
const UserTokenPeriod_s = 60 * 24 * 60 * 60

登陆有效期60天 day hour min sec

Variables

View Source
var UserTokenPrefix string

Functions

func AddArticle

func AddArticle(article Article, tagsrt []string) error

func AddCategory

func AddCategory(category Category) error

func AddReply

func AddReply(reply *Reply) error

func AddTag

func AddTag(tag Tag) error

func DelUserToken

func DelUserToken(token string) error

func DeleteArticle

func DeleteArticle(id int64) error

func DeleteArticleTag

func DeleteArticleTag(articleId int64) (err error)

func DeleteCategory

func DeleteCategory(Id int64, name string) error

func DeleteReply

func DeleteReply(Id int64) error

func DeleteTag

func DeleteTag(tagId int64) error

func GetTotalArticleCount

func GetTotalArticleCount() int64

func GetUserAvatar

func GetUserAvatar(uid int64) (path string, err error)

func GetUserNameById

func GetUserNameById(uid int) (string, error)

func ModifyArticle

func ModifyArticle(article *Article, raw_former_tag string, raw_tags string) error

func ModifyCategory

func ModifyCategory(former_category, category_name string) error

func ModifyUserInfo

func ModifyUserInfo(uid int64, username string, pwd string) error

func RemoveDuplicates

func RemoveDuplicates(articles *[]*Article)

func RenameTag

func RenameTag(tagId int64, tagName string) error

func SaveArticleTag

func SaveArticleTag(article_id, tag_id int64) error

func SaveUserAvatar

func SaveUserAvatar(uid int64, path string) error

func SetupTotalArticleCount

func SetupTotalArticleCount() (err error)

Types

type Article

type Article struct {
	Id              int64
	Title           string    `form:"title"`
	Subtitle        string    `form:"subtitle"`
	Content         string    `orm:"size(10000)" form:"content"`
	Author          *User     `orm:"rel(fk)"`
	Category        string    `form:"category"`
	Created         time.Time `orm:"index"`
	Updated         time.Time `orm:"index"`
	ViewCount       int64     `orm:"index"`
	ReplyCount      int64
	LastReplyTime   time.Time `orm:"index"`
	LastReplyUserId int64
}

func FindArticles

func FindArticles(key string, byTitle bool, bySubtitle bool, byCategory bool, byTag bool) (articles []*Article, err error)

func GetArticle

func GetArticle(id int64) (*Article, error)

func GetArticles

func GetArticles(order_key string, category, tag string, uid int64, inverted bool, page int) (articles []*Article, article_count int, err error)

func GetArticlesAccroingTagId

func GetArticlesAccroingTagId(tagId int64) (articles []Article, count int64, err error)

func GetArticlesAccroingTagName

func GetArticlesAccroingTagName(name string) (articles []Article, count int64, err error)

type ArticleTag

type ArticleTag struct {
	Id        int64
	ArticleId int64
	TagId     int64
}

type Category

type Category struct {
	Id           int64
	Name         string
	Created      time.Time `orm:"index"`
	ArticleCount int64     `orm:"index"`
}

func GetCategories

func GetCategories(order_key string, inverted bool) ([]*Category, error)

type Reply

type Reply struct {
	Id           int64
	ArticleId    int64
	UserName     string
	Content      string `orm:"size(500)"`
	Time         time.Time
	LikeCount    int64
	QuoteReplyId int64
}

func GetAdminReplies

func GetAdminReplies() ([]*Reply, error)

func GetReplies

func GetReplies(aid int64) ([]*Reply, error)

func GetReplyById

func GetReplyById(rid int64) (Reply, error)

type Tag

type Tag struct {
	Id   int64
	Name string
}

func FindTags

func FindTags(key string) ([]Tag, error)

func GetArticleTag

func GetArticleTag(articleId int64) ([]*Tag, error)

func GetTagAccroingAritcle

func GetTagAccroingAritcle(articleId int64) (tags []Tag, count int64, err error)

func GetTags

func GetTags() ([]Tag, error)

type User

type User struct {
	Id     int    `form:"_" json:"id" redis:"id"`
	Name   string `orm:"size(16);unique" form:"name" json:"name" valid:"Required" redis:"name"`
	Pwd    string `orm:"size(32)" form:"pwd" json:"_" valid:"MinSize(8);MaxSize(32)" redis:"pwd"`
	Avatar string
}

func GetUserByToken

func GetUserByToken(token string) (user *User, err error)

根据Token取得User

func GetUserFromContext

func GetUserFromContext(ctx *context.Context) (user *User, err error)

func (*User) Login

func (u *User) Login() (token string, err error)

用户登录

func (*User) New

func (u *User) New() error

新建用户

func (*User) ReadById

func (u *User) ReadById() error

从仅有Id的User中读出Name, Pwd

Jump to

Keyboard shortcuts

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