models

package
v0.0.0-...-c7ddeeb Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddArticle

func AddArticle(data map[string]interface{}) error

* 添加文章

func AddTag

func AddTag(name string, state int, createdBy string) error

* 添加标签

func CheckAuth

func CheckAuth(username, password string) bool

* 验证 token

func CleanAllArticle

func CleanAllArticle() error

* 删除所有文章

func CleanAllTag

func CleanAllTag() (bool, error)

* 清除所有tag

func CloseDB

func CloseDB()

CloseDB closes database connection (unnecessary)

func DeleteArticle

func DeleteArticle(id int) error

* 删除文章

func DeleteTag

func DeleteTag(id int) (bool, error)

* 删除标签

func EditArticle

func EditArticle(id int, data interface{}) error

* 编辑文章

func EditTag

func EditTag(id int, data interface{}) (bool, error)

* 编辑标签

func ExistArticleByID

func ExistArticleByID(id int) bool

* 通过id查询文章

func ExistTagByID

func ExistTagByID(id int) bool

* 通过id判断用户是否存在

func ExistTagByName

func ExistTagByName(name string) bool

* 判断标签名是否存在

func GetArticleTotal

func GetArticleTotal(maps interface{}) (count int)

* 获取文章总数

func GetTagTotal

func GetTagTotal(maps interface{}) (int, error)

* 获取标签总数

func Setup

func Setup()

Types

type Article

type Article struct {
	Model

	TagID int `json:"tag_id" gorm:"index"`
	Tag   Tag `json:"tag"`

	Title         string `json:"title"`
	Desc          string `json:"desc"`
	Content       string `json:"content"`
	CreatedBy     string `json:"created_by"`
	ModifiedBy    string `json:"modified_by"`
	State         int    `json:"state"`
	CoverImageUrl string `json:"cover_image_url"`
}

func GetArticle

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

* 获取文章,关联标签

func GetArticles

func GetArticles(pageNum int, pageSize int, maps interface{}) ([]*Article, error)

* 获取文章列表

type Auth

type Auth struct {
	ID       int    `json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type Model

type Model struct {
	ID         int `gorm:"primary_key" json:"id"`
	CreatedOn  int `json:"created_on"`
	ModifiedOn int `json:"modified_on"`
	DeleteOn   int `json:"delete_on"`
}

type Tag

type Tag struct {
	Model

	Name       string `json:"name"`
	CreatedBy  string `json:"created_by"`
	ModifiedBy string `json:"modified_by"`
	State      int    `json:"state"`
}

func GetTags

func GetTags(pageNum int, pageSize int, maps interface{}) ([]Tag, error)

* 获取标签

Jump to

Keyboard shortcuts

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