models

package
v0.0.0-...-4440387 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2021 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{}) bool

func AddTag

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

添加新标签

func CheckAuth

func CheckAuth(username, password string) bool

func CloseDB

func CloseDB()

func DeleteArticle

func DeleteArticle(id int) bool

func DeleteTag

func DeleteTag(id int) bool

删除标签

func EditArticle

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

func EditTag

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

更新标签

func ExistArticleByID

func ExistArticleByID(id int) bool

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{}) (count int)

查询文章标签的总数

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"`
}

func GetArticle

func GetArticle(id int) (article Article)

func GetArticles

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

func (*Article) BeforCreate

func (article *Article) BeforCreate(scope *gorm.Scope) error

func (*Article) BeforeUpdate

func (article *Article) BeforeUpdate(scope *gorm.Scope) error

type Auth

type Auth struct {
	ID       int    `gorm:"primary_key" 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"`
}

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{}) (tags []Tag)

查询文章标签

func (*Tag) BeforeCreate

func (tag *Tag) BeforeCreate(scope *gorm.Scope) error

gorm的Callback

func (*Tag) BeforeUpdate

func (tag *Tag) BeforeUpdate(scope *gorm.Scope) error

gorm的Callback

Jump to

Keyboard shortcuts

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