model

package
v0.0.0-...-2926792 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

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 CleanAllArticle

func CleanAllArticle() bool

硬删除代码 要使用 Unscoped(),这是 GORM 的约定

func CleanAllCategory

func CleanAllCategory() bool

硬删除代码 要使用 Unscoped(),这是 GORM 的约定

func CleanAllTag

func CleanAllTag() bool

硬删除代码 要使用 Unscoped(),这是 GORM 的约定

func CloseDB

func CloseDB()

func DelCategory

func DelCategory(id uint) bool

删除分类

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

func ExistTagByName

func ExistTagByName(name string) bool

func GetArticleTotal

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

func GetTagTotal

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

func Open

func Open(host, port, username, password, name string) *gorm.DB

func SaveCategory

func SaveCategory(c Category) bool

添加分类

func UpdatePwd

func UpdatePwd(id uint, pwd string) int64

更新密码

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 Article)

gorm会通过类名+ID的方式去找到这两个类之间的关联关系

func GetArticles

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

type Auth

type Auth struct {
	Model
	Username string `json:"username"`
	Password string `json:"password"`
}

type Category

type Category struct {
	Model
	ID   uint   `gorm:"primary_key"`
	Name string `gorm:"size:20"`
}

type Model

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

type SysUsers

type SysUsers struct {
	ID        uint   `gorm:"primary_key"`
	Name      string `gorm:"size:20"`
	Pwd       string `gorm:"size:100"`
	CreatedAt time.Time
}

func CheckLogin

func CheckLogin(name, pwd string) SysUsers

登录验证

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)

Jump to

Keyboard shortcuts

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