diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index 15b3ed4e..d420ca8d 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -472,6 +472,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/storelink/getImageList", Handler: storelink.GetLinkImageListHandler(serverCtx), }, + { + Method: http.MethodDelete, + Path: "/storelink/deleteImageList", + Handler: storelink.DeleteLinkImageHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/storelink/submitLinkTask", + Handler: storelink.SubmitLinkTaskHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/storelink/getLinkTask", + Handler: storelink.GetLinkTaskHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/storelink/deleteLinkTask", + Handler: storelink.DeleteLinkTaskHandler(serverCtx), + }, }, rest.WithPrefix("/pcm/v1"), ) diff --git a/api/internal/handler/storelink/deletelinkimagehandler.go b/api/internal/handler/storelink/deletelinkimagehandler.go new file mode 100644 index 00000000..d1af2ee3 --- /dev/null +++ b/api/internal/handler/storelink/deletelinkimagehandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/storelink" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" +) + +func DeleteLinkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteLinkImageReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewDeleteLinkImageLogic(r.Context(), svcCtx) + resp, err := l.DeleteLinkImage(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/storelink/deletelinktaskhandler.go b/api/internal/handler/storelink/deletelinktaskhandler.go new file mode 100644 index 00000000..63d5371a --- /dev/null +++ b/api/internal/handler/storelink/deletelinktaskhandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/storelink" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" +) + +func DeleteLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteLinkTaskReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewDeleteLinkTaskLogic(r.Context(), svcCtx) + resp, err := l.DeleteLinkTask(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/storelink/getlinktaskhandler.go b/api/internal/handler/storelink/getlinktaskhandler.go new file mode 100644 index 00000000..e5a8b1dc --- /dev/null +++ b/api/internal/handler/storelink/getlinktaskhandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/storelink" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" +) + +func GetLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetLinkTaskReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewGetLinkTaskLogic(r.Context(), svcCtx) + resp, err := l.GetLinkTask(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/handler/storelink/submitlinktaskhandler.go b/api/internal/handler/storelink/submitlinktaskhandler.go new file mode 100644 index 00000000..aa89c29d --- /dev/null +++ b/api/internal/handler/storelink/submitlinktaskhandler.go @@ -0,0 +1,28 @@ +package storelink + +import ( + "net/http" + + "github.com/zeromicro/go-zero/rest/httpx" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/storelink" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" +) + +func SubmitLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.SubmitLinkTaskReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := storelink.NewSubmitLinkTaskLogic(r.Context(), svcCtx) + resp, err := l.SubmitLinkTask(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/api/internal/logic/storelink/deletelinkimagelogic.go b/api/internal/logic/storelink/deletelinkimagelogic.go new file mode 100644 index 00000000..0d5480d0 --- /dev/null +++ b/api/internal/logic/storelink/deletelinkimagelogic.go @@ -0,0 +1,30 @@ +package storelink + +import ( + "context" + + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteLinkImageLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteLinkImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLinkImageLogic { + return &DeleteLinkImageLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteLinkImageLogic) DeleteLinkImage(req *types.DeleteLinkImageReq) (resp *types.DeleteLinkImageResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/api/internal/logic/storelink/deletelinktasklogic.go b/api/internal/logic/storelink/deletelinktasklogic.go new file mode 100644 index 00000000..70a8c9c1 --- /dev/null +++ b/api/internal/logic/storelink/deletelinktasklogic.go @@ -0,0 +1,30 @@ +package storelink + +import ( + "context" + + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteLinkTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLinkTaskLogic { + return &DeleteLinkTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteLinkTaskLogic) DeleteLinkTask(req *types.DeleteLinkTaskReq) (resp *types.DeleteLinkTaskResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/api/internal/logic/storelink/getlinktasklogic.go b/api/internal/logic/storelink/getlinktasklogic.go new file mode 100644 index 00000000..fff03e92 --- /dev/null +++ b/api/internal/logic/storelink/getlinktasklogic.go @@ -0,0 +1,30 @@ +package storelink + +import ( + "context" + + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetLinkTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLinkTaskLogic { + return &GetLinkTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetLinkTaskLogic) GetLinkTask(req *types.GetLinkTaskReq) (resp *types.GetLinkTaskResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/api/internal/logic/storelink/submitlinktasklogic.go b/api/internal/logic/storelink/submitlinktasklogic.go new file mode 100644 index 00000000..f5cffa88 --- /dev/null +++ b/api/internal/logic/storelink/submitlinktasklogic.go @@ -0,0 +1,30 @@ +package storelink + +import ( + "context" + + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type SubmitLinkTaskLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewSubmitLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SubmitLinkTaskLogic { + return &SubmitLinkTaskLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *SubmitLinkTaskLogic) SubmitLinkTask(req *types.SubmitLinkTaskReq) (resp *types.SubmitLinkTaskResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/api/internal/pkg/scheduler/scheduler.go b/api/internal/pkg/scheduler/scheduler.go index 754603ed..c677ea4e 100644 --- a/api/internal/pkg/scheduler/scheduler.go +++ b/api/internal/pkg/scheduler/scheduler.go @@ -106,6 +106,7 @@ func (s *scheduler) SaveToDb() error { } tx := s.dbEngin.Create(structForDb) if tx.Error != nil { + // todo 保存失败数据 logx.Error(tx.Error) return tx.Error } diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 17214f21..605d446b 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -2721,9 +2721,20 @@ type Cloud struct { } type UploadLinkImageReq struct { + PartId int64 `json:"partId"` + FilePath string `json:"filePath"` } -type UploadLinkImageImageResp struct { +type UploadLinkImageResp struct { + Success bool `json:"success"` + Image ImageSl `json:"image"` + ErrorMsg string `json:"errorMsg"` +} + +type ImageSl struct { + ImageId string `json:"imageId"` + ImageName string `json:"imageName"` + ImageStatus string `json:"imageStatus"` } type GetLinkImageListReq struct { @@ -2731,5 +2742,66 @@ type GetLinkImageListReq struct { } type GetLinkImageListResp struct { - ImageIds []int64 `json:"imageIds"` + Success bool `json:"success"` + Images []ImageSl `json:"images"` + ErrorMsg string `json:"errorMsg"` +} + +type DeleteLinkImageReq struct { + PartId int64 `json:"partId"` + ImageId string `json:"imageId"` +} + +type DeleteLinkImageResp struct { + Success bool `json:"success"` + Image ImageSl `json:"image"` + ErrorMsg string `json:"errorMsg"` +} + +type SubmitLinkTaskReq struct { + PartId int64 `json:"partId"` + ImageId string `json:"imageId"` + Cmd string `json:"cmd"` + Envs []EnvSl `json:"envs"` +} + +type EnvSl struct { + Key string `json:"key"` + Val string `json:"value"` +} + +type SubmitLinkTaskResp struct { + Success bool `json:"success"` + TaskId string `json:"taskId"` + ErrorMsg string `json:"errorMsg"` +} + +type GetLinkTaskReq struct { + PartId int64 `json:"partId"` + TaskId string `json:"taskId"` +} + +type GetLinkTaskResp struct { + Success bool `json:"success"` + Task TaskSl `json:"task"` + ErrorMsg string `json:"errorMsg"` +} + +type DeleteLinkTaskReq struct { + PartId int64 `json:"partId"` + TaskId string `json:"taskId"` +} + +type DeleteLinkTaskResp struct { + Success bool `json:"success"` + TaskId string `json:"taskId"` + ErrorMsg string `json:"errorMsg"` +} + +type TaskSl struct { + TaskId string `json:"taskId"` + TaskName string `json:"taskName"` + TaskStatus string `json:"taskStatus"` + StartedAt int64 `json:"startedAt"` + CompletedAt int64 `json:"completedAt"` }