detailHandler.go 835 B

123456789101112131415161718192021222324252627282930313233
  1. package user
  2. import (
  3. "github.com/zeromicro/go-zero/rest/httpx"
  4. "microGame/app/usercenter/cmd/api/internal/logic/user"
  5. "microGame/app/usercenter/cmd/api/internal/svc"
  6. "microGame/app/usercenter/cmd/api/internal/types"
  7. "microGame/pkg/ctxdata"
  8. "microGame/pkg/result"
  9. "net/http"
  10. )
  11. // DetailHandler get user info
  12. func DetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13. return func(w http.ResponseWriter, r *http.Request) {
  14. var req types.UserInfoReq
  15. if err := httpx.Parse(r, &req); err != nil {
  16. httpx.ErrorCtx(r.Context(), w, err)
  17. return
  18. }
  19. ctx := ctxdata.AddJwtToCtx(r)
  20. l := user.NewDetailLogic(ctx, svcCtx)
  21. resp, err := l.Detail(&req)
  22. //if err != nil {
  23. // httpx.ErrorCtx(r.Context(), w, err)
  24. //} else {
  25. // httpx.OkJsonCtx(r.Context(), w, resp)
  26. //}
  27. result.HttpResult(r, w, resp, err)
  28. }
  29. }