Documentation
¶
Index ¶
- Variables
- func Md5Pwd(password string) string
- func ScryptPwd(password string) string
- func UserAdd(useradd *UserAddModel) int
- func UserChangePassword(id int, data *UserPasswordModel) (int, string)
- func UserDel(id int) int
- func UserUpdate(id int, data *UserUpdateModel) int
- type Article
- type Category
- type Comment
- type HTTPError
- type Praise
- type Profile
- type User
- type UserAddModel
- type UserLoginModel
- type UserPasswordModel
- type UserQueryModel
- type UserUpdateModel
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *gorm.DB
Functions ¶
func UserChangePassword ¶
func UserChangePassword(id int, data *UserPasswordModel) (int, string)
UserChangePassword 修改用户密码
Types ¶
type Article ¶
type Article struct { ArticleId uint `json:"article_id" gorm:"primaryKey;autoIncrement"` Title string `json:"title" gorm:"type:VARCHAR(200);comment:'标题'" binding:"required" label:"标题" example:"go语言"` Content string `` /* 228-byte string literal not displayed */ Status int `json:"status" gorm:"type:TINYINT UNSIGNED;default:1;comment:'状态'" binding:"required" label:"状态" example:"1"` PraiseCount int `json:"praise_count" gorm:"default:0;comment:'点赞数'" binding:"required" label:"点赞数" example:"10"` CommentCount int `json:"comment_count" gorm:"default:0;comment:'评论数'" binding:"required" label:"评论数" example:"10"` CreatedAt time.Time `json:"created_at" gorm:"comment:'创建时间'"` UpdatedAt time.Time `json:"updated_at" gorm:"comment:'更新时间'"` DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index;comment:'删除时间'"` CategoryId uint `json:"category_id" gorm:"comment:'文章分类ID'"` UserId uint `json:"user_id" gorm:"comment:'用户ID'"` }
Article 文章
type Category ¶
type Category struct { CategoryId uint `json:"category_id" gorm:"primaryKey;autoIncrement"` Name string `json:"name" gorm:"type:VARCHAR(20);comment:'分类名称'" binding:"required" label:"分类名称" example:"go"` UserId uint `json:"user_id" gorm:"comment:'用户ID'"` }
Category 文章分类表
type Comment ¶
type Comment struct { CommentId uint `json:"comment_id" gorm:"primaryKey;autoIncrement"` Content string `json:"content" gorm:"type:TEXT;comment:'评论内容'" binding:"required" label:"评论内容" example:"观点阐述到位"` CreatedAt time.Time `json:"created_at" gorm:"comment:'创建时间'"` ArticleId uint `json:"article_id" gorm:"comment:'文章ID'"` UserId uint `json:"user_id" gorm:"comment:'用户ID'"` }
Comment 评论
type Praise ¶
type Praise struct { ArticleId uint `json:"article_id" gorm:"primaryKey;comment:'文章ID'"` UserId uint `json:"user_id" gorm:"primaryKey;comment:'用户ID'"` CreatedAt time.Time `json:"created_at" gorm:"comment:'创建时间'"` }
Praise 点赞
type Profile ¶
type Profile struct { gorm.Model Name string `json:"name" gorm:"varchar(20);comment:'昵称'"` Desc string `json:"desc" gorm:"varchar(200);comment:'简介'"` Qqchat string `json:"qq_chat" gorm:"varchar(100);comment:'QQ号'"` Wechat string `json:"wechat" gorm:"varchar(100);comment:'微信号'"` Email string `json:"email" gorm:"varchar(200);comment:'邮箱'"` Img string `json:"img" gorm:"varchar(200);comment:'图片地址'"` Avatar string `json:"avatar" gorm:"varchar(200);comment:'头像'"` IcpRecord string `json:"icp_record" gorm:"varchar(200)"` }
type User ¶
type User struct { UserId uint `json:"user_id" gorm:"primaryKey;autoIncrement"` Username string `` /* 135-byte string literal not displayed */ Password string `` /* 129-byte string literal not displayed */ Role uint8 `json:"role" gorm:"type:TINYINT UNSIGNED;not null;default:1;comment:'角色'" binding:"required" label:"角色" example:"3"` CreatedAt time.Time `json:"created_at" gorm:"comment:'创建时间'"` UpdatedAt time.Time `json:"updated_at" gorm:"comment:'更新时间'"` DeletedAt sql.NullTime `json:"deleted_at" gorm:"index;comment:'删除时间'"` }
User 用户
type UserAddModel ¶
type UserAddModel struct { Username string `` /* 135-byte string literal not displayed */ Password string `` /* 129-byte string literal not displayed */ Role uint8 `json:"role" gorm:"type:TINYINT UNSIGNED;not null;default:1;comment:'角色'" binding:"required" label:"角色" example:"3"` }
func (*UserAddModel) CheckUser ¶
func (u *UserAddModel) CheckUser(username string) int
CheckUser 验证用户是否存在
type UserLoginModel ¶
type UserPasswordModel ¶
type UserPasswordModel struct {
Password string `json:"password" binding:"required,min=6,max=18" label:"密码" example:"123456"`
}
type UserQueryModel ¶
type UserUpdateModel ¶
type UserUpdateModel struct { Username string `json:"username" binding:"required,min=4,max=50" label:"用户名" example:"test"` Role uint8 `json:"role" binding:"required" label:"角色" example:"3"` }
func (*UserUpdateModel) CheckUpUser ¶
func (u *UserUpdateModel) CheckUpUser(id int, username string) int
CheckUpUser 更新用户时调用此方法验证用户是否存在
Click to show internal directories.
Click to hide internal directories.