models

package
v0.0.0-...-1c779d3 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 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{}) 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, maps 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

func ExistTagByName

func ExistTagByName(name string) bool

func GetArticleTotal

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

func GetRoles

func GetRoles(username string) []string

func GetTagTotal

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

func GetUserID

func GetUserID(username string) string

Types

type Article

type Article struct {
	Model

	State         int    `json:"state"`
	TagId         int    `json:"tag_id"`
	Title         string `json:"title"`
	Desc          string `json:"desc"`
	Content       string `json:"Content"`
	CoverImageUrl string `json:"cover_image_url"`
	CreatedBy     string `json:"created_by"`
	Tag           Tag    `json:"tag"`
}

func GetArticle

func GetArticle(id int) (article Article)

func GetArticles

func GetArticles(PageNum int, PageSize int, maps interface{}) (article []Article)

func (*Article) BeforeCreate

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

func (*Article) BeforeUpdate

func (tag *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"`
	Avatar   string `json:"avatar"`
}

type Claims

type Claims struct {
	ID     int    `gorm:"primary_key" json:"claim_id"`
	AuthID int    `json:"auth_id"`
	Type   string `json:"type"`
	Value  string `json:"value"`
}

func GetUserClaims

func GetUserClaims(userName string) (claims []Claims)

type Model

type Model struct {
	ID         int       `gorm:"primary_key" json:"id"`
	CreatedOn  time.Time `json:"created_on"`
	ModifiedOn time.Time `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

func (*Tag) BeforeUpdate

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

type User

type User struct {
	UserName   string
	UserClaims []Claims
}

User demo

Jump to

Keyboard shortcuts

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