diff --git a/api/internal/handler/monitoring/schedulesituationhandler.go b/api/internal/handler/monitoring/schedulesituationhandler.go index 720c1944..4677a111 100644 --- a/api/internal/handler/monitoring/schedulesituationhandler.go +++ b/api/internal/handler/monitoring/schedulesituationhandler.go @@ -1,9 +1,9 @@ package monitoring import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" "net/http" - "github.com/zeromicro/go-zero/rest/httpx" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/monitoring" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" ) @@ -12,10 +12,6 @@ func ScheduleSituationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { l := monitoring.NewScheduleSituationLogic(r.Context(), svcCtx) resp, err := l.ScheduleSituation() - if err != nil { - httpx.ErrorCtx(r.Context(), w, err) - } else { - httpx.OkJsonCtx(r.Context(), w, resp) - } + result.HttpResult(r, w, resp, err) } } diff --git a/api/internal/logic/monitoring/schedulesituationlogic.go b/api/internal/logic/monitoring/schedulesituationlogic.go index 5d7ef556..3dc1b64a 100644 --- a/api/internal/logic/monitoring/schedulesituationlogic.go +++ b/api/internal/logic/monitoring/schedulesituationlogic.go @@ -24,7 +24,6 @@ func NewScheduleSituationLogic(ctx context.Context, svcCtx *svc.ServiceContext) } func (l *ScheduleSituationLogic) ScheduleSituation() (resp *types.ScheduleSituationResp, err error) { - // todo: add your logic here and delete this line resp = &types.ScheduleSituationResp{} // node region tx := l.svcCtx.DbEngin.Raw("SELECT c.id, c.name, tdi.id AS category, count(DISTINCT ta.id)+count(DISTINCT tc.id)+COUNT(DISTINCT th.id)+COUNT(tv.id) as value FROM t_cluster c LEFT JOIN t_dict_item tdi ON c.region_dict = tdi.id left JOIN task_ai ta ON ta.cluster_id = c.id left JOIN task_cloud tc ON tc.cluster_id = c.id left JOIN task_hpc th ON th.cluster_id = c.id left JOIN task_vm tv ON tv.cluster_id = c.id WHERE tc.deleted_at IS NULL GROUP BY c.id").Scan(&resp.Nodes)