model

package
v0.0.0-...-17949e6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AccessKey = utils.AccessKey
	SecretKey = utils.SecretKey
	Bucket    = utils.Bucket
	ImgUrl    = utils.Qiniuserver
)
View Source
var Db *gorm.DB

Functions

func AddArtDao

func AddArtDao(data *Article) int

新增分类

func AddCategoryDao

func AddCategoryDao(data *Category) int

新增分类

func AddUserDao

func AddUserDao(data *User) int

新增用户

func CheckCategory

func CheckCategory(name string) (code int)

查询分类是否存在

func CheckLogin

func CheckLogin(username, password string) int

登录验证

func CheckUser

func CheckUser(username string) (code int)

查询用户是否存在

func DeleteArtDao

func DeleteArtDao(id int) int

删除文章

func DeleteCategoryDao

func DeleteCategoryDao(id int) int

删除用户

func DeleteUserDao

func DeleteUserDao(id int) int

删除用户

func EditArtDao

func EditArtDao(id int, a *Article) int

编辑文章

func EditCategoryDao

func EditCategoryDao(id int, c *Category) int

编辑分类

func EditUserDao

func EditUserDao(id int, u *User) int

编辑用户

func InitDB

func InitDB()

InitDB 初始化数据库

func ScryptPwd

func ScryptPwd(password string) string

密码加密

func UploadFile

func UploadFile(file multipart.File, fileSize int64) (string, int)

Types

type Article

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

Article Article

func GetArtDao

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

查询文章列表

func GetArtInfoDao

func GetArtInfoDao(id int) (Article, int)

查询单个文章

func GetCateArtDao

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

查询分类下的所有文章

type Category

type Category struct {
	ID   uint   `gorm:"primary_key; auto_increment" json:"id"`
	Name string `gorm:"type: varchar(20); not null " json:"name"`
}

Category Category

func GetCategoryDao

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

查询分类列表

type User

type User struct {
	gorm.Model
	Username string `gorm:"type: varchar(20); not null " json:"username" validate:"required,min=6,max=12" label:"用户名"`
	Password string `gorm:"type: varchar(20); not null " json:"password" validate:"required,min=6,max=20" label:"密码"`
	Role     int    `gorm:"type: int; DEFAULT:2" json:"role" validate:"required,gte=1" label:"权限"`
}

User 用户

func GetUsersDao

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

查询用户列表

Jump to

Keyboard shortcuts

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