Skip to content

Commit

Permalink
fix: add repo actions in service
Browse files Browse the repository at this point in the history
  • Loading branch information
macgeargear committed Jun 25, 2024
1 parent 7e476c8 commit f26799e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/object/object.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/isd-sgcu/rpkm67-store/config"
"github.com/isd-sgcu/rpkm67-store/constant"
"github.com/isd-sgcu/rpkm67-store/internal/client/store"
"github.com/isd-sgcu/rpkm67-store/internal/model"
"github.com/minio/minio-go/v7"
"go.uber.org/zap"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -66,6 +67,15 @@ func (s *serviceImpl) Upload(_ context.Context, req *proto.UploadObjectRequest)
Key: uploadOutput.Key,
}

err = s.repo.Upload(&model.Object{
ImageUrl: objectResp.Url,
ObjectKey: objectResp.Key,
})
if err != nil {
s.log.Named("Upload").Error("Upload: ", zap.Error(err))
return nil, status.Error(codes.Internal, constant.InternalServerErrorMessage)
}

return &proto.UploadObjectResponse{
Object: objectResp,
}, nil
Expand All @@ -91,6 +101,11 @@ func (s *serviceImpl) DeleteByKey(_ context.Context, req *proto.DeleteByKeyObjec
}, status.Error(codes.Internal, constant.InternalServerErrorMessage)
}

err = s.repo.DeleteByKey(req.Key)
if err != nil {
s.log.Named("DeleteByKey").Error("DeleteByKey: ", zap.Error(err))
}

return &proto.DeleteByKeyObjectResponse{
Success: true,
}, nil
Expand Down

0 comments on commit f26799e

Please sign in to comment.