user.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package api
  2. import "Gwen/model"
  3. /*
  4. pub enum UserStatus {
  5. Disabled = 0,
  6. Normal = 1,
  7. Unverified = -1,
  8. }
  9. */
  10. /*
  11. UserPayload
  12. String name = ”;
  13. String email = ”;
  14. String note = ”;
  15. UserStatus status;
  16. bool isAdmin = false;
  17. */
  18. type UserPayload struct {
  19. Name string `json:"name"`
  20. Email string `json:"email"`
  21. Note string `json:"note"`
  22. IsAdmin *bool `json:"is_admin"`
  23. Status int `json:"status"`
  24. }
  25. func (up *UserPayload) FromUser(user *model.User) *UserPayload {
  26. up.Name = user.Username
  27. up.IsAdmin = user.IsAdmin
  28. up.Status = int(user.Status)
  29. return up
  30. }
  31. /*
  32. class HttpType {
  33. static const kAuthReqTypeAccount = "account";
  34. static const kAuthReqTypeMobile = "mobile";
  35. static const kAuthReqTypeSMSCode = "sms_code";
  36. static const kAuthReqTypeEmailCode = "email_code";
  37. static const kAuthReqTypeTfaCode = "tfa_code";
  38. static const kAuthResTypeToken = "access_token";
  39. static const kAuthResTypeEmailCheck = "email_check";
  40. static const kAuthResTypeTfaCheck = "tfa_check";
  41. }
  42. */
  43. type LoginRes struct {
  44. Type string `json:"type"`
  45. AccessToken string `json:"access_token"`
  46. User UserPayload `json:"user"`
  47. Secret string `json:"secret"`
  48. TfaType string `json:"tfa_type"`
  49. }