diff --git a/adaptor/PCM-CORE/api/desc/pcm.api b/adaptor/PCM-CORE/api/desc/pcm.api index 6dc1a14a..3d81dc34 100644 --- a/adaptor/PCM-CORE/api/desc/pcm.api +++ b/adaptor/PCM-CORE/api/desc/pcm.api @@ -192,4 +192,7 @@ service pcm { @handler imageListHandler get /image/list () returns (imageListResp) + + @handler checkHandler + get /image/check (checkReq) returns (checkResp) } \ No newline at end of file diff --git a/adaptor/PCM-CORE/api/desc/storage/pcm-storage.api b/adaptor/PCM-CORE/api/desc/storage/pcm-storage.api index 87117496..96ecd53d 100644 --- a/adaptor/PCM-CORE/api/desc/storage/pcm-storage.api +++ b/adaptor/PCM-CORE/api/desc/storage/pcm-storage.api @@ -118,4 +118,13 @@ type ( name string `json:"name"` tags []string `json:"tags" copier:"tags"` } -) \ No newline at end of file +) + +type ( + checkReq { + fileMd5 string `json:"fileMd5"` + } + checkResp { + exist bool `json:"exist"` + } +) diff --git a/adaptor/PCM-CORE/api/internal/handler/image/checkhandler.go b/adaptor/PCM-CORE/api/internal/handler/image/checkhandler.go new file mode 100644 index 00000000..663475f2 --- /dev/null +++ b/adaptor/PCM-CORE/api/internal/handler/image/checkhandler.go @@ -0,0 +1,28 @@ +package image + +import ( + "net/http" + + "PCM/adaptor/PCM-CORE/api/internal/logic/image" + "PCM/adaptor/PCM-CORE/api/internal/svc" + "PCM/adaptor/PCM-CORE/api/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func CheckHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CheckReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := image.NewCheckLogic(r.Context(), svcCtx) + resp, err := l.Check(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/adaptor/PCM-CORE/api/internal/handler/routes.go b/adaptor/PCM-CORE/api/internal/handler/routes.go index 7acf9dc8..48c5e148 100644 --- a/adaptor/PCM-CORE/api/internal/handler/routes.go +++ b/adaptor/PCM-CORE/api/internal/handler/routes.go @@ -286,8 +286,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/image/list", Handler: image.ImageListHandler(serverCtx), }, + { + Method: http.MethodGet, + Path: "/image/check", + Handler: image.CheckHandler(serverCtx), + }, }, - rest.WithMaxBytes(624288000), rest.WithPrefix("/pcm/v1"), ) } diff --git a/adaptor/PCM-CORE/api/internal/logic/image/checklogic.go b/adaptor/PCM-CORE/api/internal/logic/image/checklogic.go new file mode 100644 index 00000000..51783b07 --- /dev/null +++ b/adaptor/PCM-CORE/api/internal/logic/image/checklogic.go @@ -0,0 +1,31 @@ +package image + +import ( + "context" + "path" + + "PCM/adaptor/PCM-CORE/api/internal/svc" + "PCM/adaptor/PCM-CORE/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CheckLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckLogic { + return &CheckLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CheckLogic) Check(req *types.CheckReq) (resp *types.CheckResp, err error) { + // todo: add your logic here and delete this line + path.Join() + return +} diff --git a/adaptor/PCM-CORE/api/internal/types/types.go b/adaptor/PCM-CORE/api/internal/types/types.go index 50522c5d..07c2ad12 100644 --- a/adaptor/PCM-CORE/api/internal/types/types.go +++ b/adaptor/PCM-CORE/api/internal/types/types.go @@ -1902,3 +1902,11 @@ type ImageTagsResp struct { Name string `json:"name"` Tags []string `json:"tags" copier:"tags"` } + +type CheckReq struct { + FileMd5 string `json:"fileMd5"` +} + +type CheckResp struct { + Exist bool `json:"exist"` +}