update_gpts_user_pwd_handler.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package User
  2. import (
  3. "net/http"
  4. jwtutils "wechat-api/internal/utils/jwt"
  5. "github.com/zeromicro/go-zero/rest/httpx"
  6. "wechat-api/internal/logic/User"
  7. "wechat-api/internal/svc"
  8. "wechat-api/internal/types"
  9. )
  10. // swagger:route post /gpts/user/password User UpdateGptsUserPwd
  11. //
  12. // Get user basic information | 获取用户基本信息
  13. //
  14. // Get user basic information | 获取用户基本信息
  15. //
  16. // Parameters:
  17. // + name: body
  18. // require: true
  19. // in: body
  20. // type: PasswordReq
  21. //
  22. // Responses:
  23. // 200: BaseDataInfo
  24. func UpdateGptsUserPwdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  25. return func(w http.ResponseWriter, r *http.Request) {
  26. var req types.PasswordReq
  27. if err := httpx.Parse(r, &req, true); err != nil {
  28. httpx.ErrorCtx(r.Context(), w, err)
  29. return
  30. }
  31. tokenStr := jwtutils.StripBearerPrefixFromToken(r.Header.Get("Authorization"))
  32. l := User.NewUpdateGptsUserPwdLogic(r.Context(), svcCtx)
  33. resp, err := l.UpdateGptsUserPwd(tokenStr, &req)
  34. if err != nil {
  35. httpx.ErrorCtx(r.Context(), w, err)
  36. } else {
  37. httpx.OkJsonCtx(r.Context(), w, resp)
  38. }
  39. }
  40. }