user.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. Info map[string]interface{} `json:"info"`
  25. }
  26. func (up *UserPayload) FromUser(user *model.User) *UserPayload {
  27. up.Name = user.Username
  28. up.IsAdmin = user.IsAdmin
  29. up.Status = int(user.Status)
  30. up.Info = map[string]interface{}{}
  31. return up
  32. }
  33. /*
  34. class HttpType {
  35. static const kAuthReqTypeAccount = "account";
  36. static const kAuthReqTypeMobile = "mobile";
  37. static const kAuthReqTypeSMSCode = "sms_code";
  38. static const kAuthReqTypeEmailCode = "email_code";
  39. static const kAuthReqTypeTfaCode = "tfa_code";
  40. static const kAuthResTypeToken = "access_token";
  41. static const kAuthResTypeEmailCheck = "email_check";
  42. static const kAuthResTypeTfaCheck = "tfa_check";
  43. }
  44. */
  45. type LoginRes struct {
  46. Type string `json:"type"`
  47. AccessToken string `json:"access_token"`
  48. User UserPayload `json:"user"`
  49. Secret string `json:"secret,omitempty"`
  50. TfaType string `json:"tfa_type,omitempty"`
  51. }