login_by_sms_handler.go 901 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package auth
  2. import (
  3. "net/http"
  4. "github.com/zeromicro/go-zero/rest/httpx"
  5. "wechat-api/internal/logic/auth"
  6. "wechat-api/internal/svc"
  7. "wechat-api/internal/types"
  8. )
  9. // swagger:route post /user/login_by_sms auth LoginBySms
  10. //
  11. // Log in by SMS | 短信登录
  12. //
  13. // Log in by SMS | 短信登录
  14. //
  15. // Parameters:
  16. // + name: body
  17. // require: true
  18. // in: body
  19. // type: LoginBySmsReq
  20. //
  21. // Responses:
  22. // 200: LoginResp
  23. func LoginBySmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  24. return func(w http.ResponseWriter, r *http.Request) {
  25. var req types.LoginBySmsReq
  26. if err := httpx.Parse(r, &req, true); err != nil {
  27. httpx.ErrorCtx(r.Context(), w, err)
  28. return
  29. }
  30. l := auth.NewLoginBySmsLogic(r.Context(), svcCtx, w)
  31. resp, err := l.LoginBySms(&req)
  32. if err != nil {
  33. httpx.ErrorCtx(r.Context(), w, err)
  34. } else {
  35. httpx.OkJsonCtx(r.Context(), w, resp)
  36. }
  37. }
  38. }