Documentation ¶
Index ¶
- Constants
- Variables
- func CheckCategoryExist(name string) (int, int)
- func CheckLogin(username, password string) int
- func CheckUserExist(name string) (int, int)
- func CreateAtr(data *Article) int
- func CreateCategory(data *Category) int
- func CreateUser(data *User) int
- func DeleteArt(id int) int
- func DeleteCategory(id int) int
- func DeleteUser(id int) int
- func EditArt(id int, data *Article) int
- func EditCategory(id int, data *Category) int
- func EditUser(id int, data *User) int
- func InitDb()
- func ScrypPwd(password string) string
- func UploadFile(file multipart.File, fileSize int64) (string, int)
- type Article
- type Category
- type User
Constants ¶
View Source
const PwdKeyLen = 10
密码加密
Variables ¶
View Source
var AccessKey = utils.AccessKey
View Source
var Bucket = utils.Bucket
View Source
var ImgUrl = utils.QiniuServer
View Source
var SecretKey = utils.SecreKey
Functions ¶
func EditCategory ¶
编辑分类信息, 昵称,非修改密码 结构体更新只会更新非0值,所以要用map更新
Types ¶
type Article ¶
type Article struct { Category Category `gorm:"foreignKey:ID;references: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 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=16"` Nick string `gorm:"type:varchar(20);not null" json:"nick"` Role int `gorm:"type: int;DEFAULT:2" json:"role" validate:"required,lte=2"` // 1 管理员 2 阅读者 }
Click to show internal directories.
Click to hide internal directories.