model

package
v0.0.0-...-4434514 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCate

func CheckCate(username string) (code int)

CheckCate 查询分类是否存在

func CheckUser

func CheckUser(username string) (code int)

CheckUser 查询用户是否存在

func CreateCate

func CreateCate(data *Category) int

CreateCate 新增分类

func CreateUser

func CreateUser(data *User) int

CreateUser 新增用户

func DeleteCate

func DeleteCate(id int) int

DeleteCate 删除分类

func DeleteUser

func DeleteUser(id int) int

DeleteUser 删除用户

func EditCate

func EditCate(id int, data *Category) int

EditCate 编辑分类信息

func EditUser

func EditUser(id int, data User) int

EditUser 编辑用户

func InitDb

func InitDb()

func ScryptPw

func ScryptPw(password string) string

ScryptPw 生成密码

Types

type Article

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

type Category

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

func GetCate

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

GetCate 查询分类列表

type User

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(20);not null" json:"username"`
	Password string `gorm:"type:varchar(100);not null" json:"password"`
	Role     int    `gorm:"type:int" json:"role"`
}

func GetUsers

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

GetUsers 查询用户列表

func (*User) BeforeCreate

func (u *User) BeforeCreate(_ *gorm.DB) (err error)

BeforeCreate 密码加密&权限控制

func (*User) BeforeUpdate

func (u *User) BeforeUpdate(_ *gorm.DB) (err error)

Jump to

Keyboard shortcuts

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