models

package
v0.0.0-...-928417b Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Users []User

Functions

func AddArticle

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

func AddTag

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

add tag

func CheckAuth

func CheckAuth(email, password string) (bool, string)

func CleanAllArticle

func CleanAllArticle() bool

func CleanAllTag

func CleanAllTag() (bool, error)

func CloseDB

func CloseDB()

关闭db连接

func DeleteArticle

func DeleteArticle(id int) bool

func DeleteTag

func DeleteTag(id int) bool

delete tag

func EditArticle

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

func EditTag

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

edit tag

func ExistArticleById

func ExistArticleById(id int) (bool, error)

func ExistTagByID

func ExistTagByID(id int) bool

func ExistTagByName

func ExistTagByName(name string) bool

if exists

func GetArticleTotal

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

func GetTagTotal

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

func GetUsers

func GetUsers(page, pageSize int)

func Setup

func Setup()

初始化

Types

type Article

type Article struct {
	Model

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

	CategoryId    int    `json:"category_id"`
	Title         string `json:"title"`
	Desc          string `json:"desc"`
	Content       string `json:"content"`
	State         int    `json:"state"`
	CoverImageUrl string `json:"cover_image_url"`
	CreatedAt     string `json:"created_at"`
	UpdatedAt     string `json:"updated_at"`
}

func GetArticle

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

func GetArticles

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

type Auth

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

type Model

type Model struct {
	ID        int `gorm:"primary_key" json:"id"`
	CreatedAt int `json:"created_at"`
	UpdatedAt int `json:"updated_at"`
	DeletedAt int `json:"deleted_at"`
}

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)

type User

type User struct {
	Model

	Id        int64  `json:"id"`
	UserName  string `json:"user_name"`
	Email     string `json:"email"`
	Password  string `json:"password"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

func (*User) Destroy

func (user *User) Destroy(id int64) (Result User, err error)

func (User) Insert

func (user User) Insert() (id int64, err error)

func (*User) Users

func (user *User) Users() (users []User, err error)

Jump to

Keyboard shortcuts

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