model

package
v0.0.0-...-544fd76 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserNotBindSecretError = errors.New("user not bind error")
View Source
var UserSecretNotMatchError = errors.New("user secret not match error")

Functions

func Archive

func Archive(tag string, t string) (map[string][]Post, int)

func DeletePost

func DeletePost(idList []string) bool

删除文章

func GetAllPostId

func GetAllPostId() []string

获取所有文章的id

func GetSettings

func GetSettings() map[string]string

获取所有设置

func InsertPost

func InsertPost(article_form ArticleForm, uid int64) (int64, error)

插入文章

func SetAdmin

func SetAdmin() (string, error)

func UpdateCommentCount

func UpdateCommentCount(id int, count int) int64

更新评论数量

func UpdatePost

func UpdatePost(aid int, article_form ArticleForm) error

Types

type ArticleForm

type ArticleForm struct {
	Title       string   `json:"title" form:"title" binding:"required"`
	CategoryId  string   `json:"category_id" form:"category" binding:"required,gt=0"`
	Content     string   `json:"content" form:"content"`
	PublishedAt string   `json:"published_at" form:"published_at"`
	Summary     string   `json:"abstract" form:"abstract"`
	Tags        []string `json:"tags" form:"tags[]"`
	Status      string   `json:"status" form:"status"`
}

type Category

type Category struct {
	Id          int    `json:"id" form:"id"`
	Name        string `json:"name" form:"name"`
	Description string `json:"description" form:"name"`
	EnName      string `json:"en_name" form:"en_name"`
	PostCount   int    `json:"post_count"`
}

栏目

func GetCategories

func GetCategories() []Category

获取所有栏目

type Friends

type Friends struct {
	Id   int    `json:"id" form:"id"`
	Name string `json:"name" form:"name"`
	Url  string `json:"url" form:"url"`
}

func GetFriends

func GetFriends() []Friends

获取所有友情链接

type Post

type Post struct {
	Id           int    `json:"id" form:"id"`
	Title        string `json:"title" form:"title"`
	Content      string `json:"content" form:"content"`
	ContentHtml  template.HTML
	Status       int            `json:"status" form:"status"`
	AuthorId     int            `json:"author_id" form:"author_id"`
	CatId        int            `json:"cat_id" form:"cat_id"`
	PublishedAt  time.Time      `json:"published_at" form:"published_at"`
	CreatedAt    time.Time      `json:"created_at" form:"created_at"`
	UpdatedAt    time.Time      `json:"updated_at" form:"updated_at"`
	Abstract     string         `json:"abstract" form:"abstract"`
	CommentCount uint64         `json:"comments_count" form:"comments_count"`
	TagImg       string         `json:"tag_img" form:"tag_img"`
	TagName      sql.NullString `json:"tag_name"`
	CName        string         `json:"name" form:"name"`
	CEnName      string         `json:"en_name" form:"en_name"`
	Tags         []Tag          `json:"tag"`
}

文章

func GetPost

func GetPost(id int, filterStatus bool) (Post, error)

获取单篇文章

func GetPosts

func GetPosts(offset int, limit int, status string) ([]Post, int)

获取文章列表

func SearchPosts

func SearchPosts(keyword string, offset int, limit int) ([]Post, int)

搜索文章

type Setting

type Setting struct {
	Key   string `json:"key" form:"key"`
	Value string `json:"value" form:"value"`
}

站点配置

type Tag

type Tag struct {
	Id        sql.NullInt64 `json:"id" form:"id"`
	Name      string        `json:"name" form:"name"`
	PostCount int           `json:"post_count"`
	WeightCss int           `json:"weight_css"`
}

func GetTags

func GetTags() []Tag

获取所有tag

type User

type User struct {
	Id            int       `json:"id"`
	Nickname      string    `json:"nickname"`
	Username      string    `json:"username"`
	Secret        string    `json:"secret"`
	BindSecret    int       `json:"bind_secret"`
	Email         string    `json:"email"`
	Password      string    `json:"password"`
	RememberToken string    `json:"remember_token"`
	CreatedAt     time.Time `json:"created_at"`
	LastLoginAt   time.Time `json:"last_login_at"`
	LastLoginIp   int       `json:"last_login_ip"`
}

func Auth

func Auth(username string, password string, authenticatorCode string, clientIp int64) (User, error)

Jump to

Keyboard shortcuts

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