model

package
v0.0.0-...-8da5f6f Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCategory

func CheckCategory(name string) int

CheckCategory 查詢分類是否存在

func CheckLogin

func CheckLogin(username string, password string) int

CheckLogin 登入驗證

func CheckUser

func CheckUser(user string) int

CheckUser 查詢帳號是否存在

func CreateArticle

func CreateArticle(data *Article) int

CreateArticle 新增文章

func CreateCategory

func CreateCategory(data *Category) int

CreateCategory 新增分類

func CreateUser

func CreateUser(data *User) int

CreateUser 新增帳號

func DeleteArticle

func DeleteArticle(id int) int

DeleteArticle 刪除文章

func DeleteCategory

func DeleteCategory(id int) int

DeleteCategory 刪除分類

func DeleteUser

func DeleteUser(id int) int

DeleteUser 刪除帳號

func EditArticle

func EditArticle(id int, data *Article) int

EditArticle 編輯文章

func EditCategory

func EditCategory(id int, data *Category) int

EditCategory 編輯分類

func EditUser

func EditUser(id int, data *User) int

EditUser 編輯帳號

func InitDb

func InitDb()

InitDb 初始化連接 Database

func ScryptPassWord

func ScryptPassWord(password string) string

ScryptPassWord 密碼加密

Types

type Article

type Article struct {
	gorm.Model
	Category Category `gorm:"foreignkey:Cid"`
	Title    string   `gorm:"type:varchar(200); not null" json:"title"`
	Cid      uint     `gorm:"type:int; not null" json:"cid"`
	Name     string   `gorm:"type:varchar(20); not null" json:"name"`
	Desc     string   `gorm:"type:varchar(200)" json:"desc"`
	Content  string   `gorm:"type:longtext" json:"content"`
	Img      string   `gorm:"type:varchar(100)" json:"img"`
}

func GetArticleInfo

func GetArticleInfo(id int) (Article, int)

GetArticleInfo 查詢單個文章訊息

func GetArticleList

func GetArticleList(pageSize int, pageNum int) ([]Article, int, int)

GetArticleList 查詢文章列表

func GetCategoryArticle

func GetCategoryArticle(id int, pageSize int, pageNum int) ([]Article, int, int)

GetCategoryArticle 查詢分類下的所有文章

type Category

type Category struct {
	gorm.Model
	Name string `gorm:"type:varchar(20); not null" json:"name"`
}

func GetCategoryList

func GetCategoryList(pageSize int, pageNum int) ([]Category, int)

GetCategoryList 查詢分類列表

type User

type User struct {
	gorm.Model
	UserName string `gorm:"column:username; type:varchar(20); not null" json:"username" validate:"required,min=3,max=12" label:"帳號"`
	PassWord string `gorm:"column:password; type:varchar(20); not null" json:"password" validate:"required,min=6,max=20" label:"密碼"`
	Role     uint   `gorm:"column:role; type:int DEFAULT:2"  json:"role" validate:"required,gte=2" label:"權限代碼"`
}

func GetUserList

func GetUserList(pageSize int, pageNum int) ([]User, int)

GetUserList 查詢帳號列表

Jump to

Keyboard shortcuts

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