auth_login.api 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import "../base.api"
  2. type (
  3. // The log in information | 登陆返回的数据信息
  4. LoginInfo {
  5. // User's UUID | 用户的UUID
  6. UserId string `json:"userId"`
  7. // Token for authorization | 验证身份的token
  8. Token string `json:"token"`
  9. // Expire timestamp | 过期时间戳
  10. Expire uint64 `json:"expire"`
  11. }
  12. // The permission code for front end permission control | 权限码: 用于前端权限控制
  13. PermCodeResp {
  14. BaseDataInfo
  15. // Permission code data | 权限码数据
  16. Data []string `json:"data"`
  17. }
  18. // Login request | 登录参数
  19. LoginReq {
  20. // User Name | 用户名
  21. Username string `json:"username" validate:"required,alphanum,max=20"`
  22. // Password | 密码
  23. Password string `json:"password" validate:"required,max=30,min=6"`
  24. // Captcha ID which store in redis | 验证码编号, 存在redis中
  25. CaptchaId string `json:"captchaId" validate:"required,len=20"`
  26. // The Captcha which users input | 用户输入的验证码
  27. Captcha string `json:"captcha" validate:"required,len=5"`
  28. }
  29. // Log in by email request | 邮箱登录参数
  30. LoginByEmailReq {
  31. // The user's email address | 用户的邮箱
  32. Email string `json:"email" validate:"required,email,max=100"`
  33. // The Captcha which users input | 用户输入的验证码
  34. Captcha string `json:"captcha,optional" validate:"omitempty,len=5"`
  35. }
  36. // Log in by SMS request | 短信登录参数
  37. LoginBySmsReq {
  38. // The user's mobile phone number | 用户的手机号码
  39. PhoneNumber string `json:"phoneNumber" validate:"required,numeric,max=20"`
  40. // The Captcha which users input | 用户输入的验证码
  41. Captcha string `json:"captcha,optional" validate:"omitempty,len=5"`
  42. }
  43. // The log in response data | 登录返回数据
  44. LoginResp {
  45. BaseDataInfo
  46. // The log in information | 登陆返回的数据信息
  47. Data LoginInfo `json:"data"`
  48. }
  49. )
  50. @server(
  51. group: auth
  52. )
  53. service Wechat {
  54. // Log in | 登录
  55. @handler login
  56. post /user/login (LoginReq) returns (LoginResp)
  57. // Log in by email | 邮箱登录
  58. @handler loginByEmail
  59. post /user/login_by_email (LoginByEmailReq) returns (LoginResp)
  60. // Log in by SMS | 短信登录
  61. @handler loginBySms
  62. post /user/login_by_sms (LoginBySmsReq) returns (LoginResp)
  63. }