diff --git a/api/internal/handler/apps/appdetailhandler.go b/api/internal/handler/apps/appdetailhandler.go index 27268583..b3af8b57 100644 --- a/api/internal/handler/apps/appdetailhandler.go +++ b/api/internal/handler/apps/appdetailhandler.go @@ -5,7 +5,7 @@ import ( "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/apps" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" - "gitlink.org.cn/jcce-pcm/utils/result" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result" "net/http" ) diff --git a/api/internal/handler/apps/applisthandler.go b/api/internal/handler/apps/applisthandler.go index 3e42b3c0..5f3fa15e 100644 --- a/api/internal/handler/apps/applisthandler.go +++ b/api/internal/handler/apps/applisthandler.go @@ -5,7 +5,7 @@ import ( "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/apps" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" - "gitlink.org.cn/jcce-pcm/utils/result" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result" "net/http" ) diff --git a/api/internal/logic/apps/appdetaillogic.go b/api/internal/logic/apps/appdetaillogic.go index 55d074c6..6b913585 100644 --- a/api/internal/logic/apps/appdetaillogic.go +++ b/api/internal/logic/apps/appdetaillogic.go @@ -2,7 +2,6 @@ package apps import ( "context" - "fmt" "gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes/kubernetes" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" @@ -25,15 +24,16 @@ func NewAppDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AppDeta } } -func (l *AppDetailLogic) AppDetail(req *types.AppDetailReq) (resp *types.AppDetailResp, err error) { - // todo: add your logic here and delete this line - fmt.Println(req.Name) +func (l *AppDetailLogic) AppDetail(req *types.AppDetailReq) (resp *kubernetes.AppDetailResp, err error) { //调用p端接口 appDetail, err := l.svcCtx.K8sRpc[1727670068428410880].GetAppDetail(context.Background(), &kubernetes.AppDetailReq{ Namespace: req.NsID, Name: req.Name, }) - fmt.Println("应用详情:", appDetail) - - return + if err != nil { + appDetail.Code = "500" + appDetail.Msg = err.Error() + } + appDetail.Code = "200" + return appDetail, err } diff --git a/deploy/goctl/1.5.3/api/handler.tpl b/deploy/goctl/1.5.3/api/handler.tpl index 341afb33..d15f5c9f 100644 --- a/deploy/goctl/1.5.3/api/handler.tpl +++ b/deploy/goctl/1.5.3/api/handler.tpl @@ -2,7 +2,7 @@ package {{.PkgName}} import ( "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/jcce-pcm/utils/result" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result" "net/http" {{.ImportPackages}} ) diff --git a/pkg/repository/result/httpResult.go b/pkg/repository/result/httpResult.go index 2ba709d2..19a8c0f7 100644 --- a/pkg/repository/result/httpResult.go +++ b/pkg/repository/result/httpResult.go @@ -47,6 +47,10 @@ func HttpResult(r *http.Request, w http.ResponseWriter, resp interface{}, err er body.Data = resp httpx.OkJson(w, body) return + } else if body.Msg == "success" { + body.Code = 200 + body.TraceID = traceIDFromContext(r.Context()) + httpx.OkJson(w, body) } else { body.TraceID = traceIDFromContext(r.Context()) httpx.OkJson(w, body)