fetchInitialCredentialsHandler.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Code scaffolded by goctl. Safe to edit.
  2. // goctl 1.10.0
  3. package product
  4. import (
  5. "net/http"
  6. "github.com/zeromicro/go-zero/rest/httpx"
  7. "perms-system-server/internal/logic/product"
  8. "perms-system-server/internal/response"
  9. "perms-system-server/internal/svc"
  10. "perms-system-server/internal/types"
  11. )
  12. // FetchInitialCredentialsHandler 一次性领取 CreateProduct 响应中未带回的 appSecret / adminPassword。
  13. // 审计 M-4:配合 CreateProductHandler 把"敏感凭证落响应体"的老路径替换掉。
  14. func FetchInitialCredentialsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  15. return func(w http.ResponseWriter, r *http.Request) {
  16. var req types.FetchInitialCredentialsReq
  17. if err := httpx.Parse(r, &req); err != nil {
  18. httpx.ErrorCtx(r.Context(), w, response.ErrBadRequest(err.Error()))
  19. return
  20. }
  21. l := product.NewFetchInitialCredentialsLogic(r.Context(), svcCtx)
  22. resp, err := l.FetchInitialCredentials(&req)
  23. if err != nil {
  24. httpx.ErrorCtx(r.Context(), w, err)
  25. } else {
  26. httpx.OkJsonCtx(r.Context(), w, resp)
  27. }
  28. }
  29. }