Documentation
¶
Index ¶
- Variables
- func CheckCategoryExist(name string) (bool, error)
- func CheckLogin(username, password string) error
- func CheckUserExist(name string) (bool, error)
- func CreateArticle(a *Article) error
- func CreateCategory(c *Category) error
- func CreateUser(u *User) error
- func DeleteArticle(id int) error
- func DeleteCategory(id int) error
- func DeleteUser(id int) error
- func InitDb()
- func UpdateArticle(id int, a *Article) error
- func UpdateCategory(id int, c *Category) error
- func UpdateProfile(id int, profile *Profile) error
- func UpdateUser(id int, u *User) error
- func UploadFile(file multipart.File, fileSize int64) (string, error)
- type Article
- type Category
- type Profile
- type User
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 ¶
CheckCategoryExist 查询分类是否已经存在
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 ¶
IndexArticle 查询文章
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 ¶
IndexCategory 查询分类
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 用户信息
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:"角色码"`
}
Click to show internal directories.
Click to hide internal directories.