model

package
v0.0.0-...-296dcbf Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 13 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 QiniuServer = utils.QiniuServer
View Source
var SecretKey = utils.SecretKey

Functions

func CheckCategoryExist

func CheckCategoryExist(name string) (bool, error)

CheckCategoryExist 查询分类是否已经存在

func CheckLogin

func CheckLogin(username, password string) error

CheckLogin 登录验证

func CheckUserExist

func CheckUserExist(name string) (bool, error)

CheckUserExist 查询用户是否已经存在

func CreateArticle

func CreateArticle(a *Article) error

CreateArticle 创建文章

func CreateCategory

func CreateCategory(c *Category) error

CreateCategory 创建分类

func CreateUser

func CreateUser(u *User) error

CreateUser 添加用户

func DeleteArticle

func DeleteArticle(id int) error

DeleteArticle 删除文章

func DeleteCategory

func DeleteCategory(id int) error

DeleteCategory 删除分类

func DeleteUser

func DeleteUser(id int) error

DeleteUser 删除用户

func InitDb

func InitDb()

func UpdateArticle

func UpdateArticle(id int, a *Article) error

UpdateArticle 更新文章

func UpdateCategory

func UpdateCategory(id int, c *Category) error

UpdateCategory 更新分类

func UpdateProfile

func UpdateProfile(id int, profile *Profile) error

UpdateProfile 更改个人信息

func UpdateUser

func UpdateUser(id int, u *User) error

UpdateUser 更新用户

func UploadFile

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

Types

type Article

type Article struct {
	gorm.Model
	Title      string   `gorm:"type:varchar(100);not null" json:"title"`
	Desc       string   `gorm:"type:varchar(200)" json:"desc"`
	Content    string   `gorm:"type:longtext" json:"content"`
	Image      string   `gorm:"type:varchar(100)" json:"image"`
	CategoryID int      `gorm:"type:int;not null" json:"category_id"`
	Category   Category `gorm:"foreignKey:CategoryID"`
}

func IndexArticle

func IndexArticle(pageSize, page int, categoryID int, title string) ([]*Article, int64, error)

IndexArticle 查询文章

func ShowArticle

func ShowArticle(id int) (*Article, error)

ShowArticle 查询单个文章

type Category

type Category struct {
	ID   int    `gorm:"primary_key;auto_increment" json:"ID"`
	Name string `gorm:"type:varchar(128);unique;not null" json:"name"`
}

func IndexCategory

func IndexCategory(pageSize, page int) ([]*Category, int64, error)

IndexCategory 查询分类

func ShowCategory

func ShowCategory(id int) (*Category, error)

ShowCategory 获取单个分类信息

type Profile

type Profile struct {
	gorm.Model
	Name   string `gorm:"type:varchar(20)" json:"name"`
	Desc   string `gorm:"type:varchar(200)" json:"desc"`
	QQChat string `gorm:"type:varchar(200)" json:"qq_chat"`
	WeChat string `gorm:"type:varchar(200)" json:"wechat"`
	Weibo  string `gorm:"type:varchar(200)" json:"weibo"`
	Bili   string `gorm:"type:varchar(200)" json:"bili"`
	Email  string `gorm:"type:varchar(200)" json:"email"`
	Image  string `gorm:"type:varchar(200)" json:"image"`
	Avatar string `gorm:"type:varchar(200)" json:"avatar"`
}

Profile 用户信息

func ShowProfile

func ShowProfile(id int) (*Profile, error)

ShowProfile 获取个人信息

type User

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

func IndexUser

func IndexUser(pageSize, page int, username string) ([]*User, int64, error)

IndexUser 查询用户列表

func ShowUser

func ShowUser(id int) (*User, error)

ShowUser 查询单个用户

func (*User) BeforeSave

func (u *User) BeforeSave(tx *gorm.DB) error

Jump to

Keyboard shortcuts

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