Documentation
¶
Index ¶
- func AddComment(comment *Comment) int
- func AddUser(data *User) int
- func ChangePassword(id int, data *User) int
- func CreateArticle(data *Article) int
- func CreateCategory(data *Category) int
- func DeleteArticle(id int) int
- func DeleteCategory(id int) int
- func DeleteComment(id int) int
- func DeleteUser(id int) int
- func EditArticle(id int, data *Article) int
- func EditCategory(id int, data *Category) int
- func EditUser(id int, data *User) int
- func GetCommentNumber(id int) int64
- func InitDb()
- func IsArticleExist(name string) (code int)
- func IsCategoryExist(name string) (code int)
- func IsUserExist(name string) (code int)
- func PassTheComment(id int, data *Comment) int
- func RemoveTheComment(id int, data *Comment) int
- func ScryptPassword(password string) string
- func UpdateProfile(id int, data *Profile) int
- func UpdateUser(id int, username string) int
- func VerifyAdminLogin(username, password string) int
- type Article
- type Category
- type Comment
- type LogOperation
- type Profile
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VerifyAdminLogin ¶
VerifyAdminLogin 后台登录验证
Types ¶
type Article ¶
type Article struct { gorm.Model Category Category `gorm:"foreignKey:Cid"` // Cid CategoryId和分类的id对应 Title string `gorm:"type:varchar(100);not null" json:"title"` Cid int `gorm:"type:int;not null" json:"cid"` Description string `gorm:"type:varchar(200)" json:"description"` Content string `gorm:"type:longtext" json:"content"` Img string `gorm:"type:varchar(100)" json:"img"` ReadCount uint `gorm:"type:int(100)" json:"read_count"` CommentCount int `gorm:"type:int(100);not null;default:0" json:"comment_count"` }
func GetArticleList ¶
GetArticleList 查询文章列表
type Category ¶
type Comment ¶
type Comment struct { gorm.Model UserId uint `json:"user_id"` ArticleId uint `json:"article_id"` ArticleTitle string `json:"article_title"` UserName string `json:"username"` Content string `gorm:"varchar(500);not null" json:"content"` Status int `json:"status"` }
func ArticleGetCommentList ¶
ArticleGetCommentList 展示文章底下的评论
type LogOperation ¶
type LogOperation struct { gorm.Model Type uint `gorm:"type:smallint(5); not null" json:"type"` Ip string `gorm:"type:varchar(100); not null" json:"ip"` UserAgent string `gorm:"type:varchar(100); not null" json:"user_agent"` Size uint `gorm:"type:int(100); not null" json:"size"` Method string `gorm:"type:varchar(20); not null" json:"method"` Code uint `gorm:"type:int(5); not null" json:"code"` HostName string `gorm:"type:varchar(100); not null" json:"host_name"` }
LogOperation 日志字段 请求时间 CreatedAt 状态码 Code 请求IP Ip 客户端信息 UserAgent 请求大小 Size 请求方法 Method 请求路径 Type
type Profile ¶
type Profile struct { ID int `gorm:"primary_key;auto_increment" json:"id"` Name string `gorm:"type:varchar(20)" json:"name"` Description string `gorm:"type:varchar(200)" json:"description"` Github string `gorm:"type:varchar(200)" json:"github"` Email string `gorm:"type:varchar(200)" json:"email"` Img string `gorm:"type:varchar(200)" json:"img"` Avatar string `gorm:"type:varchar(200)" json:"avatar"` Bili string `gorm:"type:varchar(200)" json:"bili"` IcpRecord string `gorm:"type:varchar(200)" json:"icp_record"` }
type User ¶
type User struct { // gorm.Model 提供了以下四个字段: ID, CreatedAt, UpdatedAt, DeletedAt gorm.Model Username string `gorm:"type:varchar(20);not null" json:"username" validate:"required,min=4,max=15" label:"用户名"` Password string `gorm:"type:varchar(20);not null" json:"password" validate:"required,min=6,max=20" label:"密码"` // 0无权限,1为管理员 Role int `gorm:"type:int;default:2" json:"role" validate:"required,lte=2" label:"角色码"` }
func GetUserList ¶
GetUserList 查询用户列表
func VerifyFrontLogin ¶
VerifyFrontLogin 前台登录验证
Click to show internal directories.
Click to hide internal directories.