topfans/backend/services/taskService/client/gallery_rpc_client.go
zerosaturation c5bf9df955 feat: 经济系统重构 - 任务服务与画廊服务解耦
- galleryService 独立启动,配置 task-service-url
- 新增 taskService 到 galleryService 的 RPC 调用
- 更新 proto 文件并重新生成代码
- 新增展览唯一约束迁移脚本
- 修复多个 service 的配置和依赖关系

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 23:12:02 +08:00

40 lines
1.4 KiB
Go

package client
import (
"context"
"fmt"
"github.com/topfans/backend/pkg/logger"
pbCommon "github.com/topfans/backend/pkg/proto/common"
pbGallery "github.com/topfans/backend/pkg/proto/gallery"
"go.uber.org/zap"
)
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 != pbCommon.StatusCode_STATUS_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
}