Merge branch 'feat-cjy-data' into dev

# Conflicts:
#	api/cast/cast.pb.go
This commit is contained in:
cjy 2025-12-18 10:42:03 +08:00
commit 766f1eddd1
4 changed files with 7189 additions and 3697 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2017,6 +2017,243 @@ var _ interface {
ErrorName() string ErrorName() string
} = MediaInfoRespValidationError{} } = MediaInfoRespValidationError{}
// Validate checks the field values on MediaInfoByPlatformReq with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *MediaInfoByPlatformReq) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on MediaInfoByPlatformReq with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// MediaInfoByPlatformReqMultiError, or nil if none found.
func (m *MediaInfoByPlatformReq) ValidateAll() error {
return m.validate(true)
}
func (m *MediaInfoByPlatformReq) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for ArtistUuid
// no validation rules for PlatformID
if len(errors) > 0 {
return MediaInfoByPlatformReqMultiError(errors)
}
return nil
}
// MediaInfoByPlatformReqMultiError is an error wrapping multiple validation
// errors returned by MediaInfoByPlatformReq.ValidateAll() if the designated
// constraints aren't met.
type MediaInfoByPlatformReqMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m MediaInfoByPlatformReqMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m MediaInfoByPlatformReqMultiError) AllErrors() []error { return m }
// MediaInfoByPlatformReqValidationError is the validation error returned by
// MediaInfoByPlatformReq.Validate if the designated constraints aren't met.
type MediaInfoByPlatformReqValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e MediaInfoByPlatformReqValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e MediaInfoByPlatformReqValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e MediaInfoByPlatformReqValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e MediaInfoByPlatformReqValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e MediaInfoByPlatformReqValidationError) ErrorName() string {
return "MediaInfoByPlatformReqValidationError"
}
// Error satisfies the builtin error interface
func (e MediaInfoByPlatformReqValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sMediaInfoByPlatformReq.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = MediaInfoByPlatformReqValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = MediaInfoByPlatformReqValidationError{}
// Validate checks the field values on MediaInfoByPlatformResp with the rules
// defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *MediaInfoByPlatformResp) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on MediaInfoByPlatformResp with the
// rules defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// MediaInfoByPlatformRespMultiError, or nil if none found.
func (m *MediaInfoByPlatformResp) ValidateAll() error {
return m.validate(true)
}
func (m *MediaInfoByPlatformResp) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
if all {
switch v := interface{}(m.GetInfo()).(type) {
case interface{ ValidateAll() error }:
if err := v.ValidateAll(); err != nil {
errors = append(errors, MediaInfoByPlatformRespValidationError{
field: "Info",
reason: "embedded message failed validation",
cause: err,
})
}
case interface{ Validate() error }:
if err := v.Validate(); err != nil {
errors = append(errors, MediaInfoByPlatformRespValidationError{
field: "Info",
reason: "embedded message failed validation",
cause: err,
})
}
}
} else if v, ok := interface{}(m.GetInfo()).(interface{ Validate() error }); ok {
if err := v.Validate(); err != nil {
return MediaInfoByPlatformRespValidationError{
field: "Info",
reason: "embedded message failed validation",
cause: err,
}
}
}
if len(errors) > 0 {
return MediaInfoByPlatformRespMultiError(errors)
}
return nil
}
// MediaInfoByPlatformRespMultiError is an error wrapping multiple validation
// errors returned by MediaInfoByPlatformResp.ValidateAll() if the designated
// constraints aren't met.
type MediaInfoByPlatformRespMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m MediaInfoByPlatformRespMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m MediaInfoByPlatformRespMultiError) AllErrors() []error { return m }
// MediaInfoByPlatformRespValidationError is the validation error returned by
// MediaInfoByPlatformResp.Validate if the designated constraints aren't met.
type MediaInfoByPlatformRespValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e MediaInfoByPlatformRespValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e MediaInfoByPlatformRespValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e MediaInfoByPlatformRespValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e MediaInfoByPlatformRespValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e MediaInfoByPlatformRespValidationError) ErrorName() string {
return "MediaInfoByPlatformRespValidationError"
}
// Error satisfies the builtin error interface
func (e MediaInfoByPlatformRespValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sMediaInfoByPlatformResp.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = MediaInfoByPlatformRespValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = MediaInfoByPlatformRespValidationError{}
// Validate checks the field values on WorkListReq with the rules defined in // Validate checks the field values on WorkListReq with the rules defined in
// the proto definition for this message. If any rules are violated, the first // the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations. // error encountered is returned, or nil if there are no violations.

View File

@ -36,6 +36,7 @@ type CastClient interface {
UpdateWorkImage(ctx context.Context, in *UpdateWorkImageReq, opts ...grpc_go.CallOption) (*UpdateWorkImageResp, common.ErrorWithAttachment) UpdateWorkImage(ctx context.Context, in *UpdateWorkImageReq, opts ...grpc_go.CallOption) (*UpdateWorkImageResp, common.ErrorWithAttachment)
UpdateWorkVideo(ctx context.Context, in *UpdateWorkVideoReq, opts ...grpc_go.CallOption) (*UpdateWorkVideoResp, common.ErrorWithAttachment) UpdateWorkVideo(ctx context.Context, in *UpdateWorkVideoReq, opts ...grpc_go.CallOption) (*UpdateWorkVideoResp, common.ErrorWithAttachment)
MediaInfo(ctx context.Context, in *MediaInfoReq, opts ...grpc_go.CallOption) (*MediaInfoResp, common.ErrorWithAttachment) MediaInfo(ctx context.Context, in *MediaInfoReq, opts ...grpc_go.CallOption) (*MediaInfoResp, common.ErrorWithAttachment)
MediaInfoByPlatform(ctx context.Context, in *MediaInfoByPlatformReq, opts ...grpc_go.CallOption) (*MediaInfoByPlatformResp, common.ErrorWithAttachment)
WorkList(ctx context.Context, in *WorkListReq, opts ...grpc_go.CallOption) (*WorkListResp, common.ErrorWithAttachment) WorkList(ctx context.Context, in *WorkListReq, opts ...grpc_go.CallOption) (*WorkListResp, common.ErrorWithAttachment)
WorkDetail(ctx context.Context, in *WorkDetailReq, opts ...grpc_go.CallOption) (*WorkDetailResp, common.ErrorWithAttachment) WorkDetail(ctx context.Context, in *WorkDetailReq, opts ...grpc_go.CallOption) (*WorkDetailResp, common.ErrorWithAttachment)
UpdateStatus(ctx context.Context, in *UpdateStatusReq, opts ...grpc_go.CallOption) (*emptypb.Empty, common.ErrorWithAttachment) UpdateStatus(ctx context.Context, in *UpdateStatusReq, opts ...grpc_go.CallOption) (*emptypb.Empty, common.ErrorWithAttachment)
@ -114,6 +115,7 @@ type CastClientImpl struct {
UpdateWorkImage func(ctx context.Context, in *UpdateWorkImageReq) (*UpdateWorkImageResp, error) UpdateWorkImage func(ctx context.Context, in *UpdateWorkImageReq) (*UpdateWorkImageResp, error)
UpdateWorkVideo func(ctx context.Context, in *UpdateWorkVideoReq) (*UpdateWorkVideoResp, error) UpdateWorkVideo func(ctx context.Context, in *UpdateWorkVideoReq) (*UpdateWorkVideoResp, error)
MediaInfo func(ctx context.Context, in *MediaInfoReq) (*MediaInfoResp, error) MediaInfo func(ctx context.Context, in *MediaInfoReq) (*MediaInfoResp, error)
MediaInfoByPlatform func(ctx context.Context, in *MediaInfoByPlatformReq) (*MediaInfoByPlatformResp, error)
WorkList func(ctx context.Context, in *WorkListReq) (*WorkListResp, error) WorkList func(ctx context.Context, in *WorkListReq) (*WorkListResp, error)
WorkDetail func(ctx context.Context, in *WorkDetailReq) (*WorkDetailResp, error) WorkDetail func(ctx context.Context, in *WorkDetailReq) (*WorkDetailResp, error)
UpdateStatus func(ctx context.Context, in *UpdateStatusReq) (*emptypb.Empty, error) UpdateStatus func(ctx context.Context, in *UpdateStatusReq) (*emptypb.Empty, error)
@ -224,6 +226,12 @@ func (c *castClient) MediaInfo(ctx context.Context, in *MediaInfoReq, opts ...gr
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/MediaInfo", in, out) return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/MediaInfo", in, out)
} }
func (c *castClient) MediaInfoByPlatform(ctx context.Context, in *MediaInfoByPlatformReq, opts ...grpc_go.CallOption) (*MediaInfoByPlatformResp, common.ErrorWithAttachment) {
out := new(MediaInfoByPlatformResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/MediaInfoByPlatform", in, out)
}
func (c *castClient) WorkList(ctx context.Context, in *WorkListReq, opts ...grpc_go.CallOption) (*WorkListResp, common.ErrorWithAttachment) { func (c *castClient) WorkList(ctx context.Context, in *WorkListReq, opts ...grpc_go.CallOption) (*WorkListResp, common.ErrorWithAttachment) {
out := new(WorkListResp) out := new(WorkListResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string) interfaceKey := ctx.Value(constant.InterfaceKey).(string)
@ -559,6 +567,7 @@ type CastServer interface {
UpdateWorkImage(context.Context, *UpdateWorkImageReq) (*UpdateWorkImageResp, error) UpdateWorkImage(context.Context, *UpdateWorkImageReq) (*UpdateWorkImageResp, error)
UpdateWorkVideo(context.Context, *UpdateWorkVideoReq) (*UpdateWorkVideoResp, error) UpdateWorkVideo(context.Context, *UpdateWorkVideoReq) (*UpdateWorkVideoResp, error)
MediaInfo(context.Context, *MediaInfoReq) (*MediaInfoResp, error) MediaInfo(context.Context, *MediaInfoReq) (*MediaInfoResp, error)
MediaInfoByPlatform(context.Context, *MediaInfoByPlatformReq) (*MediaInfoByPlatformResp, error)
WorkList(context.Context, *WorkListReq) (*WorkListResp, error) WorkList(context.Context, *WorkListReq) (*WorkListResp, error)
WorkDetail(context.Context, *WorkDetailReq) (*WorkDetailResp, error) WorkDetail(context.Context, *WorkDetailReq) (*WorkDetailResp, error)
UpdateStatus(context.Context, *UpdateStatusReq) (*emptypb.Empty, error) UpdateStatus(context.Context, *UpdateStatusReq) (*emptypb.Empty, error)
@ -652,6 +661,9 @@ func (UnimplementedCastServer) UpdateWorkVideo(context.Context, *UpdateWorkVideo
func (UnimplementedCastServer) MediaInfo(context.Context, *MediaInfoReq) (*MediaInfoResp, error) { func (UnimplementedCastServer) MediaInfo(context.Context, *MediaInfoReq) (*MediaInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method MediaInfo not implemented") return nil, status.Errorf(codes.Unimplemented, "method MediaInfo not implemented")
} }
func (UnimplementedCastServer) MediaInfoByPlatform(context.Context, *MediaInfoByPlatformReq) (*MediaInfoByPlatformResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method MediaInfoByPlatform not implemented")
}
func (UnimplementedCastServer) WorkList(context.Context, *WorkListReq) (*WorkListResp, error) { func (UnimplementedCastServer) WorkList(context.Context, *WorkListReq) (*WorkListResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method WorkList not implemented") return nil, status.Errorf(codes.Unimplemented, "method WorkList not implemented")
} }
@ -1045,6 +1057,35 @@ func _Cast_MediaInfo_Handler(srv interface{}, ctx context.Context, dec func(inte
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Cast_MediaInfoByPlatform_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(MediaInfoByPlatformReq)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(dubbo3.Dubbo3GrpcService)
args := []interface{}{}
args = append(args, in)
md, _ := metadata.FromIncomingContext(ctx)
invAttachment := make(map[string]interface{}, len(md))
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("MediaInfoByPlatform", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
info := &grpc_go.UnaryServerInfo{
Server: srv,
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
return interceptor(ctx, in, info, handler)
}
func _Cast_WorkList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { func _Cast_WorkList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(WorkListReq) in := new(WorkListReq)
if err := dec(in); err != nil { if err := dec(in); err != nil {
@ -2646,6 +2687,10 @@ var Cast_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "MediaInfo", MethodName: "MediaInfo",
Handler: _Cast_MediaInfo_Handler, Handler: _Cast_MediaInfo_Handler,
}, },
{
MethodName: "MediaInfoByPlatform",
Handler: _Cast_MediaInfoByPlatform_Handler,
},
{ {
MethodName: "WorkList", MethodName: "WorkList",
Handler: _Cast_WorkList_Handler, Handler: _Cast_WorkList_Handler,

View File

@ -789,13 +789,17 @@ func collectMediaMetricsForAyrshare(ctx context.Context, dateCN int) ([]*cast.Me
} }
fmt.Printf("[%s] [INFO] 账号指标采集完成,共采集 %d 条\n", time.Now().Format("2006-01-02 15:04:05"), len(metricsList)) fmt.Printf("[%s] [INFO] 账号指标采集完成,共采集 %d 条\n", time.Now().Format("2006-01-02 15:04:05"), len(metricsList))
fmt.Println("--------------------------------")
fmt.Println("账号的指标数据")
fmt.Println("metricsList", metricsList) fmt.Println("metricsList", metricsList)
fmt.Println("--------------------------------")
return metricsList, nil return metricsList, nil
} }
// parseSocialAnalyticsToMediaMetricsForAyrshare 解析社交分析数据并转换为媒体指标 // parseSocialAnalyticsToMediaMetricsForAyrshare 解析社交分析数据并转换为媒体指标
func parseSocialAnalyticsToMediaMetricsForAyrshare(socialResp *aryshare.GetSocialAnalyticsResponse, artistInfo *cast.ArtistAyrShareInfo, dateCN int) []*cast.MediaMetricsDailyItem { func parseSocialAnalyticsToMediaMetricsForAyrshare(socialResp *aryshare.GetSocialAnalyticsResponse, artistInfo *cast.ArtistAyrShareInfo, dateCN int) []*cast.MediaMetricsDailyItem {
items := make([]*cast.MediaMetricsDailyItem, 0) items := make([]*cast.MediaMetricsDailyItem, 0)
ctx := context.Background()
// 解析 Instagram 数据 // 解析 Instagram 数据
if socialResp.Instagram != "" { if socialResp.Instagram != "" {
@ -808,6 +812,24 @@ func parseSocialAnalyticsToMediaMetricsForAyrshare(socialResp *aryshare.GetSocia
item := parsePlatformDataForAyrshare(socialResp.Instagram, "instagram", artistInfo, dateCN) item := parsePlatformDataForAyrshare(socialResp.Instagram, "instagram", artistInfo, dateCN)
if item != nil { if item != nil {
// 获取 Instagram 平台的用户信息
mediaInfoReq := &cast.MediaInfoByPlatformReq{
ArtistUuid: artistInfo.ArtistUuid,
PlatformID: cast.PlatformIDENUM_INS, // Instagram 平台 ID 为 3
}
mediaInfoResp, err := service.CastProvider.MediaInfoByPlatform(ctx, mediaInfoReq)
if err != nil {
zap.L().Warn("获取Instagram媒体账号信息失败", zap.Error(err), zap.String("artistUuid", artistInfo.ArtistUuid))
fmt.Printf("[%s] [WARN] 获取Instagram媒体账号信息失败artistUuid: %s, 错误: %v\n", time.Now().Format("2006-01-02 15:04:05"), artistInfo.ArtistUuid, err)
} else if mediaInfoResp != nil && mediaInfoResp.Info != nil {
// 填充媒体账号信息
item.MediaName = mediaInfoResp.Info.PlatformUserName
item.ArtistName = mediaInfoResp.Info.ArtistName
item.ArtistPhone = mediaInfoResp.Info.ArtistPhone
item.MediaAccUserID = mediaInfoResp.Info.MediaAccountUuid
fmt.Printf("[%s] [INFO] 成功获取Instagram账号信息账号名: %s\n", time.Now().Format("2006-01-02 15:04:05"), item.MediaName)
}
items = append(items, item) items = append(items, item)
fmt.Printf("[%s] [INFO] 解析 Instagram 账号指标成功,艺人: %s\n", time.Now().Format("2006-01-02 15:04:05"), artistInfo.ArtistUuid) fmt.Printf("[%s] [INFO] 解析 Instagram 账号指标成功,艺人: %s\n", time.Now().Format("2006-01-02 15:04:05"), artistInfo.ArtistUuid)
} }
@ -824,6 +846,24 @@ func parseSocialAnalyticsToMediaMetricsForAyrshare(socialResp *aryshare.GetSocia
item := parsePlatformDataForAyrshare(socialResp.Tiktok, "tiktok", artistInfo, dateCN) item := parsePlatformDataForAyrshare(socialResp.Tiktok, "tiktok", artistInfo, dateCN)
if item != nil { if item != nil {
// 获取 TikTok 平台的用户信息
mediaInfoReq := &cast.MediaInfoByPlatformReq{
ArtistUuid: artistInfo.ArtistUuid,
PlatformID: cast.PlatformIDENUM_TIKTOK, // TikTok 平台 ID 为 1
}
mediaInfoResp, err := service.CastProvider.MediaInfoByPlatform(ctx, mediaInfoReq)
if err != nil {
zap.L().Warn("获取TikTok媒体账号信息失败", zap.Error(err), zap.String("artistUuid", artistInfo.ArtistUuid))
fmt.Printf("[%s] [WARN] 获取TikTok媒体账号信息失败artistUuid: %s, 错误: %v\n", time.Now().Format("2006-01-02 15:04:05"), artistInfo.ArtistUuid, err)
} else if mediaInfoResp != nil && mediaInfoResp.Info != nil {
// 填充媒体账号信息
item.MediaName = mediaInfoResp.Info.PlatformUserName
item.ArtistName = mediaInfoResp.Info.ArtistName
item.ArtistPhone = mediaInfoResp.Info.ArtistPhone
item.MediaAccUserID = mediaInfoResp.Info.MediaAccountUuid
fmt.Printf("[%s] [INFO] 成功获取TikTok账号信息账号名: %s\n", time.Now().Format("2006-01-02 15:04:05"), item.MediaName)
}
items = append(items, item) items = append(items, item)
fmt.Printf("[%s] [INFO] 解析 TikTok 账号指标成功,艺人: %s\n", time.Now().Format("2006-01-02 15:04:05"), artistInfo.ArtistUuid) fmt.Printf("[%s] [INFO] 解析 TikTok 账号指标成功,艺人: %s\n", time.Now().Format("2006-01-02 15:04:05"), artistInfo.ArtistUuid)
} }