diff --git a/desc/inference/inference.api b/desc/inference/inference.api index abbd56ae..cbcd0030 100644 --- a/desc/inference/inference.api +++ b/desc/inference/inference.api @@ -157,7 +157,7 @@ type ( } GetRunningInstanceReq { - Id string `json:"deployTaskId"` + Id string `form:"deployTaskId"` } GetRunningInstanceResp { List interface{} `json:"list"` diff --git a/desc/pcm.api b/desc/pcm.api index 421604fc..9f068aa7 100644 --- a/desc/pcm.api +++ b/desc/pcm.api @@ -966,8 +966,8 @@ service pcm { @handler StopAllByDeployTaskId post /inference/stopAll (StopAllByDeployTaskIdReq) returns (StopAllByDeployTaskIdResp) - @handler GetRunningInstanceByType - get /inference/getInstanceByType (GetRunningInstanceReq) returns (GetRunningInstanceResp) + @handler GetRunningInstanceById + get /inference/getRunningInstanceById (GetRunningInstanceReq) returns (GetRunningInstanceResp) @handler GetDeployTasksByType get /inference/getDeployTasksByType (GetDeployTasksByTypeReq) returns (GetDeployTasksByTypeResp) diff --git a/internal/handler/inference/getrunninginstancebytypehandler.go b/internal/handler/inference/getrunninginstancebyidhandler.go similarity index 55% rename from internal/handler/inference/getrunninginstancebytypehandler.go rename to internal/handler/inference/getrunninginstancebyidhandler.go index 628ca46a..5861991d 100644 --- a/internal/handler/inference/getrunninginstancebytypehandler.go +++ b/internal/handler/inference/getrunninginstancebyidhandler.go @@ -1,7 +1,6 @@ package inference import ( - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" "net/http" "github.com/zeromicro/go-zero/rest/httpx" @@ -10,17 +9,20 @@ import ( "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" ) -func GetRunningInstanceByTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { +func GetRunningInstanceByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetRunningInstanceReq if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) + httpx.ErrorCtx(r.Context(), w, err) return } - l := inference.NewGetRunningInstanceByTypeLogic(r.Context(), svcCtx) - resp, err := l.GetRunningInstanceByType(&req) - result.HttpResult(r, w, resp, err) - + l := inference.NewGetRunningInstanceByIdLogic(r.Context(), svcCtx) + resp, err := l.GetRunningInstanceById(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } } } diff --git a/internal/handler/routes.go b/internal/handler/routes.go index c9524f9d..0e7f6b77 100644 --- a/internal/handler/routes.go +++ b/internal/handler/routes.go @@ -1225,8 +1225,8 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { }, { Method: http.MethodGet, - Path: "/inference/getInstanceByType", - Handler: inference.GetRunningInstanceByTypeHandler(serverCtx), + Path: "/inference/getRunningInstanceById", + Handler: inference.GetRunningInstanceByIdHandler(serverCtx), }, { Method: http.MethodGet, diff --git a/internal/logic/inference/getrunninginstancebyidlogic.go b/internal/logic/inference/getrunninginstancebyidlogic.go new file mode 100644 index 00000000..ab4d75c0 --- /dev/null +++ b/internal/logic/inference/getrunninginstancebyidlogic.go @@ -0,0 +1,30 @@ +package inference + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetRunningInstanceByIdLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetRunningInstanceByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRunningInstanceByIdLogic { + return &GetRunningInstanceByIdLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetRunningInstanceByIdLogic) GetRunningInstanceById(req *types.GetRunningInstanceReq) (resp *types.GetRunningInstanceResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/internal/logic/inference/getrunninginstancebytypelogic.go b/internal/logic/inference/getrunninginstancebytypelogic.go deleted file mode 100644 index e6e15ced..00000000 --- a/internal/logic/inference/getrunninginstancebytypelogic.go +++ /dev/null @@ -1,30 +0,0 @@ -package inference - -import ( - "context" - - "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetRunningInstanceByTypeLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetRunningInstanceByTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRunningInstanceByTypeLogic { - return &GetRunningInstanceByTypeLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetRunningInstanceByTypeLogic) GetRunningInstanceByType(req *types.GetRunningInstanceReq) (resp *types.GetRunningInstanceResp, err error) { - resp = &types.GetRunningInstanceResp{} - - return -} diff --git a/internal/types/types.go b/internal/types/types.go index ca3a2125..9ba67844 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -6053,7 +6053,7 @@ type StopAllByDeployTaskIdResp struct { } type GetRunningInstanceReq struct { - Id string `json:"deployTaskId"` + Id string `form:"deployTaskId"` } type GetRunningInstanceResp struct {