model

package
v0.0.0-...-f18df89 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessKey = utils.AccessKey
View Source
var Bucket = utils.Bucket
View Source
var Db *gorm.DB
View Source
var QiniuServer = utils.QiniuServer
View Source
var SecretKey = utils.SecretKey

Functions

func CheckCategory

func CheckCategory(name string) int

func CheckLogin

func CheckLogin(username string, password string) int

func CheckUser

func CheckUser(username string) int

func CreateArt

func CreateArt(data *Article) int

func CreateCategory

func CreateCategory(data *Category) int

func CreateUser

func CreateUser(data *User) int

func DeleteArt

func DeleteArt(id int) int

func DeleteCategory

func DeleteCategory(id int) int

func DeleteUser

func DeleteUser(id int) int

func EditArt

func EditArt(id int, data *Article) int

func EditCategory

func EditCategory(id int, data *Category) int

func EditUser

func EditUser(id int, data *User) int

func InitDb

func InitDb()

func ScryptPw

func ScryptPw(password string) string

func UpLoadFile

func UpLoadFile(file multipart.File, filesize int64) (string, int)

Types

type Article

type Article struct {
	gorm.Model
	Title    string   `gorm:"type:varchar(100);not null" json:"title"`
	Category Category `gorm:"foreignkey:Cid"`
	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"`
}

func GetArt

func GetArt(pageSize int, pageNum int) ([]Article, int, int64)

func GetArtInfo

func GetArtInfo(id int) (Article, int)

func GetCateArt

func GetCateArt(id int, pageSize int, pageNum int) ([]Article, int, int64)

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 GetCategories

func GetCategories(pageSize int, pageNum int) ([]Category, int64)

type User

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(20);not null" json:"username" validate:"required,min=4,max=12"`
	Password string `gorm:"type:varchar(20);not null" json:"password" validate:"required,min=6,max=20"`
	Role     int    `gorm:"type:int;DEFAULT:2" json:"role" validate:"required,gte=2"`
}

func GetUsers

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

Jump to

Keyboard shortcuts

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