diff --git a/api/internal/logic/storelink/getlinkimagelistlogic.go b/api/internal/logic/storelink/getlinkimagelistlogic.go index 4fbe66e8..ea976eb4 100644 --- a/api/internal/logic/storelink/getlinkimagelistlogic.go +++ b/api/internal/logic/storelink/getlinkimagelistlogic.go @@ -2,7 +2,7 @@ package storelink import ( "context" - + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/pkg/storeLink" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" @@ -24,7 +24,13 @@ func NewGetLinkImageListLogic(ctx context.Context, svcCtx *svc.ServiceContext) * } func (l *GetLinkImageListLogic) GetLinkImageList(req *types.GetLinkImageListReq) (resp *types.GetLinkImageListResp, err error) { - // todo: add your logic here and delete this line + var imgListResp types.GetLinkImageListResp + storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, req.PartId) + imageList, err := storelink.ILinkage.QueryImageList() + if err != nil { + return nil, err + } - return + imgListResp = imageList.(types.GetLinkImageListResp) + return &imgListResp, nil } diff --git a/api/internal/pkg/storeLink/octopus.go b/api/internal/pkg/storeLink/octopus.go new file mode 100644 index 00000000..e705f231 --- /dev/null +++ b/api/internal/pkg/storeLink/octopus.go @@ -0,0 +1,87 @@ +package storeLink + +import ( + "context" + "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/pcm-participant-octopus/octopus" +) + +type OctopusLink struct { + ctx context.Context + svcCtx *svc.ServiceContext + platform string + pageIndex int32 + pageSize int32 +} + +func NewOctopusLink(ctx context.Context, svcCtx *svc.ServiceContext, platform string) *OctopusLink { + return &OctopusLink{ctx: ctx, svcCtx: svcCtx, platform: platform, pageIndex: 1, pageSize: 100} +} + +func (o *OctopusLink) UploadImage() (interface{}, error) { + var uploadResp types.UploadLinkImageImageResp + + createReq := &octopus.CreateImageReq{ + Platform: o.platform, + CreateImage: &octopus.CreateImage{ + SourceType: 1, + }, + } + createResp, err := o.svcCtx.OctopusRpc.CreateImage(o.ctx, createReq) + if err != nil { + return nil, err + } + uploadReq := &octopus.UploadImageReq{ + ImageId: createResp.Payload.ImageId, + Params: &octopus.UploadImageParam{}, + } + octUpResp, err := o.svcCtx.OctopusRpc.UploadImage(o.ctx, uploadReq) + if err != nil { + return nil, err + } + octUpResp.String() + return uploadResp, nil +} + +func (o *OctopusLink) DeleteImage() (interface{}, error) { + //TODO implement me + panic("implement me") +} + +func (o *OctopusLink) QueryImageList() (interface{}, error) { + var imgListResp types.GetLinkImageListResp + + req := &octopus.GetUserImageListReq{ + Platform: o.platform, + PageIndex: o.pageIndex, + PageSize: o.pageSize, + } + resp, err := o.svcCtx.OctopusRpc.GetUserImageList(o.ctx, req) + if err != nil { + return nil, err + } + + imgListResp.ImageIds = append(imgListResp.ImageIds, resp.Payload.Images[0].Image.CreatedAt) + return imgListResp, nil +} + +func (o *OctopusLink) SubmitTask() (interface{}, error) { + //req := &octopus.CreateTrainJobReq{} + //TODO implement me + panic("implement me") +} + +func (o *OctopusLink) QueryTask() (interface{}, error) { + //TODO implement me + panic("implement me") +} + +func (o *OctopusLink) DeleteTask() (interface{}, error) { + //TODO implement me + panic("implement me") +} + +func (o *OctopusLink) name() { + +} diff --git a/api/internal/pkg/storeLink/storeLink.go b/api/internal/pkg/storeLink/storeLink.go new file mode 100644 index 00000000..40606dab --- /dev/null +++ b/api/internal/pkg/storeLink/storeLink.go @@ -0,0 +1,24 @@ +package storeLink + +import ( + "context" + "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" +) + +type Linkage interface { + UploadImage() (interface{}, error) + DeleteImage() (interface{}, error) + QueryImageList() (interface{}, error) + SubmitTask() (interface{}, error) + QueryTask() (interface{}, error) + DeleteTask() (interface{}, error) +} + +type StoreLink struct { + ILinkage Linkage +} + +func NewStoreLink(ctx context.Context, svcCtx *svc.ServiceContext, partId int64) *StoreLink { + linkStruct := NewOctopusLink(ctx, svcCtx, "hanwuji") + return &StoreLink{ILinkage: linkStruct} +}