user.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package models
  2. import "gorm.io/gorm"
  3. //User 用户数据映射模型
  4. type User struct {
  5. gorm.Model
  6. Password string `gorm:"password type:varchar(50) not null comment '密码'" `
  7. UserName string `gorm:"user_name"`
  8. Phone string `gorm:"phone"`
  9. Role *uint8 `gorm:"role" `
  10. Gender string `gorm:"gender type:varchar(2) comment '性别:1男 0女'"`
  11. Age string `gorm:"age type:varchar(10) comment '年龄'"`
  12. Height string `gorm:"height type:varchar(10) comment '身高:cm'"`
  13. Weight string `gorm:"weight type:varchar(10) comment '体重'"`
  14. }
  15. type UserRegister struct {
  16. Phone string `json:"phone" binding:"required"`
  17. UserName string `json:"userName" binding:"required"`
  18. Password string `json:"password" binding:"required"`
  19. Role *uint8 `json:"role" binding:"required,gte=0" `
  20. }
  21. type UserLogin struct {
  22. Phone string `json:"phone" binding:"required"`
  23. Password string `json:"password" binding:"required"`
  24. Role *uint8 `json:"role" binding:"required,gte=0"`
  25. }
  26. type ResetPassword struct {
  27. Phone string `json:"phone" binding:"required"`
  28. PhoneInit string `json:"phoneInit" binding:"required"`
  29. }
  30. type UserListParam struct {
  31. PageNum int `json:"pageNum" binding:"required,gt=0"`
  32. PageSize int `json:"pageSize" binding:"required,gt=1"`
  33. UserName string `json:"userName"`
  34. Role *uint8 `json:"role" binding:"required,gte=0"`
  35. }
  36. type ChangePassword struct {
  37. Phone string `json:"phone" binding:"required"`
  38. Password string `json:"password" binding:"required"`
  39. NewPassword string `json:"newPassword" binding:"required"`
  40. }
  41. type WriteData struct {
  42. UserName string `json:"userName" binding:"required"`
  43. Gender int64 `json:"gender"`
  44. Height int64 `json:"height"`
  45. Weight int64 `json:"weight"`
  46. Age int64 `json:"age"`
  47. Mac string `json:"mac" binding:"required"`
  48. }