topfans/backend/services/taskService/client/gallery_rpc_client.go
2026-06-15 16:28:35 +08:00

41 lines
1.3 KiB
Go

package client
import (
"context"
"fmt"
"github.com/topfans/backend/pkg/logger"
pbGallery "github.com/topfans/backend/pkg/proto/gallery"
"go.uber.org/zap"
"google.golang.org/grpc/codes"
)
type GalleryServiceClient interface {
RemoveExhibitionByAsset(ctx context.Context, assetID int64) error
}
type galleryServiceClient struct {
client pbGallery.GalleryService
}
func NewGalleryServiceClient(client pbGallery.GalleryService) GalleryServiceClient {
return &galleryServiceClient{client: client}
}
func (c *galleryServiceClient) RemoveExhibitionByAsset(ctx context.Context, assetID int64) error {
logger.Logger.Debug("Calling GalleryService.RemoveExhibitionByAsset",
zap.Int64("asset_id", assetID))
resp, err := c.client.RemoveExhibitionByAsset(ctx, &pbGallery.RemoveExhibitionByAssetRequest{
AssetId: assetID,
})
if err != nil {
logger.Logger.Error("GalleryService.RemoveExhibitionByAsset failed", zap.Error(err))
return err
}
if resp.Base.Code != uint32(codes.OK) {
logger.Logger.Warn("RemoveExhibitionByAsset non-zero code", zap.Int32("code", int32(resp.Base.Code)), zap.String("message", resp.Base.Message))
return fmt.Errorf("RemoveExhibitionByAsset failed with code: %d, message: %s", resp.Base.Code, resp.Base.Message)
}
return nil
}