models

package
v0.0.0-...-b8d1666 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: MIT Imports: 7 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 AddCategory

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

func AddComment

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

func AddTag

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

func AddUser

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

func DeleteArticleByIds

func DeleteArticleByIds(ids []int) error

func DeleteCategoryByIds

func DeleteCategoryByIds(ids []int) error

func DeleteCommentByArticleIds

func DeleteCommentByArticleIds(articleIds []int) error

func DeleteCommentByIds

func DeleteCommentByIds(ids []int) error

func DeleteCommentByUserIds

func DeleteCommentByUserIds(userIds []int) error

func DeleteOwnCommentByIds

func DeleteOwnCommentByIds(userId int, ids []int) error

func DeleteTagByIds

func DeleteTagByIds(ids []int) error

func DeleteUserByIds

func DeleteUserByIds(ids []int) error

func ExistArticleByIds

func ExistArticleByIds(ids []int) (bool, error)

func ExistByMail

func ExistByMail(mail string) (bool, error)

func ExistCategoryByIds

func ExistCategoryByIds(ids []int) (bool, error)

func ExistCommentByIds

func ExistCommentByIds(ids []int) (bool, error)

func ExistTagByIds

func ExistTagByIds(ids []int) (bool, error)

func ExistUserByIds

func ExistUserByIds(ids []int) (bool, error)

func GeCommentTotal

func GeCommentTotal(userId int, maps interface{}) (int, error)

func GetArticleTotal

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

func GetCategoryTotal

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

func GetTagTotal

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

func GetUserTotal

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

func SetUp

func SetUp()

func UpdArticle

func UpdArticle(id int, data map[string]interface{}) error

func UpdArticleViews

func UpdArticleViews(id int, views int) error

func UpdCategory

func UpdCategory(id int, data map[string]interface{}) error

func UpdCurrentUser

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

func UpdTag

func UpdTag(id int, data map[string]interface{}) error

func UpdUser

func UpdUser(id int, data map[string]interface{}) error

Types

type Article

type Article struct {
	Model

	Title   string `json:"title"`
	Desc    string `json:"description" gorm:"column:description"`
	Content string `json:"content"`
	Cover   string `json:"cover"`
	State   int    `json:"state"`
	Views   int    `json:"views" gorm:"default:0"`

	CategoryId int      `json:"-" gorm:"index"`
	Category   Category `json:"category"`
	Tags       []*Tag   `json:"tag" gorm:"many2many:article_tag"`
}

func GetArticle

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

func PageArticles

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

type Category

type Category struct {
	Model

	Name  string `json:"name"`
	State int    `json:"state"`
}

func GetCategories

func GetCategories(maps interface{}) ([]*Category, error)

func GetCategory

func GetCategory(id int) (*Category, error)

func PageCategories

func PageCategories(pageNum int, pageSize int, maps interface{}) ([]*Category, error)

type Comment

type Comment struct {
	Model

	Content string `json:"content"`

	ProfileId int     `json:"-" gorm:"index"`
	Profile   Profile `json:"profile"`
	ArticleId int     `json:"-"`
}

func GetComment

func GetComment(id int) (*Comment, error)

func GetComments

func GetComments(maps interface{}) ([]*Comment, error)

func PageComments

func PageComments(pageNum int, pageSize int, userId int, maps interface{}) ([]*Comment, error)

type Model

type Model struct {
	ID        int        `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt *time.Time `json:"updated_at"`
	DeletedAt *time.Time `sql:"index" json:"-"`
}

type Profile

type Profile struct {
	Model

	Nickname string `json:"nickname"`
	Avatar   string `json:"avatar"`
}

type Role

type Role struct {
	Model

	Name  string `json:"name"`
	Level int    `json:"level"`
}

type Tag

type Tag struct {
	Model

	Name  string `json:"name"`
	State int    `json:"state"`
}

func GetTag

func GetTag(id int) (*Tag, error)

func GetTagList

func GetTagList(maps interface{}) ([]*Tag, error)

func GetTags

func GetTags(maps interface{}) ([]*Tag, error)

func PageTags

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

type User

type User struct {
	Model
	Mail     string `json:"mail"`
	Password string `json:"-"`

	RoleId int  `json:"-" gorm:"index"`
	Role   Role `json:"role"`

	ProfileId int     `json:"-" gorm:"index"`
	Profile   Profile `json:"profile"`
}

func CheckAuth

func CheckAuth(mail, password string) (*User, error)

CheckAuth checks if authentication information exists

func GetUser

func GetUser(data map[string]interface{}) (*User, error)

func GetUsers

func GetUsers(maps interface{}) ([]*User, error)

func PageUsers

func PageUsers(pageNum int, pageSize int, maps interface{}) ([]*User, error)

Jump to

Keyboard shortcuts

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