From aa7d4f0b87895503da3bd9d823bc23ce3940383d Mon Sep 17 00:00:00 2001 From: jagger Date: Wed, 27 Mar 2024 10:57:11 +0800 Subject: [PATCH] :bug: fix bugs Signed-off-by: jagger Former-commit-id: 367ad56fcdb1a90bfd13279601a8189343dc2911 --- api/desc/core/pcm-core.api | 2 ++ api/internal/handler/routes.go | 5 ++++ .../schedule/schedulegetalgorithmshandler.go | 24 +++++++++++++++ .../logic/adapters/getadapterrelationlogic.go | 2 ++ .../schedule/schedulegetalgorithmslogic.go | 30 +++++++++++++++++++ api/internal/types/types.go | 12 ++++++++ 6 files changed, 75 insertions(+) create mode 100644 api/internal/handler/schedule/schedulegetalgorithmshandler.go create mode 100644 api/internal/logic/schedule/schedulegetalgorithmslogic.go diff --git a/api/desc/core/pcm-core.api b/api/desc/core/pcm-core.api index f36d67dd..459b153b 100644 --- a/api/desc/core/pcm-core.api +++ b/api/desc/core/pcm-core.api @@ -727,6 +727,8 @@ type ClusterRelationInfo { CLabel string `json:"cLabel,omitempty" db:"label"` COwnerId string `json:"cOwnerId,omitempty" db:"owner_id"` CAuthType string `json:"cAuthType,omitempty" db:"auth_type"` + CRegionDict string `json:"cRegionDict,omitempty" db:"-"` + CProducerDict string `json:"CProducerDict,omitempty" db:"-"` CCreateTime string `json:"cCreateTime,omitempty" db:"created_time" gorm:"autoCreateTime"` } diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index a75f4e5a..5bb2e74f 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -1109,6 +1109,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/schedule/ai/getStrategies", Handler: schedule.ScheduleGetStrategyHandler(serverCtx), }, + { + Method: http.MethodGet, + Path: "/schedule/ai/getAlgorithms", + Handler: schedule.ScheduleGetAlgorithmsHandler(serverCtx), + }, { Method: http.MethodPost, Path: "/schedule/submit", diff --git a/api/internal/handler/schedule/schedulegetalgorithmshandler.go b/api/internal/handler/schedule/schedulegetalgorithmshandler.go new file mode 100644 index 00000000..a1f28eab --- /dev/null +++ b/api/internal/handler/schedule/schedulegetalgorithmshandler.go @@ -0,0 +1,24 @@ +package schedule + +import ( + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/schedule" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" +) + +func ScheduleGetAlgorithmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AiAlgorithmsReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + + l := schedule.NewScheduleGetAlgorithmsLogic(r.Context(), svcCtx) + resp, err := l.ScheduleGetAlgorithms(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/api/internal/logic/adapters/getadapterrelationlogic.go b/api/internal/logic/adapters/getadapterrelationlogic.go index afc6952b..cb1617bc 100644 --- a/api/internal/logic/adapters/getadapterrelationlogic.go +++ b/api/internal/logic/adapters/getadapterrelationlogic.go @@ -75,6 +75,8 @@ func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterRelationQ cr.CLabel = c.Label cr.COwnerId = c.OwnerId cr.CAuthType = c.AuthType + cr.CRegionDict = c.RegionDict + cr.CProducerDict = c.ProducerDict cr.CCreateTime = c.CreateTime rlist = append(rlist, cr) } diff --git a/api/internal/logic/schedule/schedulegetalgorithmslogic.go b/api/internal/logic/schedule/schedulegetalgorithmslogic.go new file mode 100644 index 00000000..fe949b41 --- /dev/null +++ b/api/internal/logic/schedule/schedulegetalgorithmslogic.go @@ -0,0 +1,30 @@ +package schedule + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ScheduleGetAlgorithmsLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewScheduleGetAlgorithmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetAlgorithmsLogic { + return &ScheduleGetAlgorithmsLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ScheduleGetAlgorithmsLogic) ScheduleGetAlgorithms(req *types.AiAlgorithmsReq) (resp *types.AiAlgorithmsResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/api/internal/types/types.go b/api/internal/types/types.go index fa7709f8..bd450f29 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -704,6 +704,8 @@ type ClusterRelationInfo struct { CLabel string `json:"cLabel,omitempty" db:"label"` COwnerId string `json:"cOwnerId,omitempty" db:"owner_id"` CAuthType string `json:"cAuthType,omitempty" db:"auth_type"` + CRegionDict string `json:"cRegionDict,omitempty" db:"-"` + CProducerDict string `json:"CProducerDict,omitempty" db:"-"` CCreateTime string `json:"cCreateTime,omitempty" db:"created_time" gorm:"autoCreateTime"` } @@ -5205,6 +5207,16 @@ type AiStrategyResp struct { Strategies []string `json:"strategies"` } +type AiAlgorithmsReq struct { + ResourceType string `json:"resourceType"` + TaskType string `json:"taskType"` + Dataset string `json:"dataset"` +} + +type AiAlgorithmsResp struct { + Algorithms []string `json:"algorithms"` +} + type PullTaskInfoReq struct { AdapterId int64 `form:"adapterId"` }