Merge branch 'feature-four-daiyb' into jng
This commit is contained in:
commit
1096dde762
File diff suppressed because it is too large
Load Diff
@ -206,6 +206,15 @@ func (this *GenerateJWTRequest) Validate() error {
|
||||
func (this *GenerateJWTResponse) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *UnlinkSocialNetworkRequest) Validate() error {
|
||||
if this.Platform == "" {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Platform", fmt.Errorf(`platform不能为空`))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *UnlinkSocialNetworkResponse) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *HistoryPostId) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-triple v1.0.8
|
||||
// - protoc v3.21.1
|
||||
// - protoc v6.32.0--rc2
|
||||
// source: pb/ayrshare.proto
|
||||
|
||||
package aryshare
|
||||
@ -37,6 +37,7 @@ type AyrshareClient interface {
|
||||
CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc_go.CallOption) (*CreateProfileResponse, common.ErrorWithAttachment)
|
||||
GetProfiles(ctx context.Context, in *GetProfilesRequest, opts ...grpc_go.CallOption) (*GetProfilesResponse, common.ErrorWithAttachment)
|
||||
GenerateJWT(ctx context.Context, in *GenerateJWTRequest, opts ...grpc_go.CallOption) (*GenerateJWTResponse, common.ErrorWithAttachment)
|
||||
UnlinkSocialNetwork(ctx context.Context, in *UnlinkSocialNetworkRequest, opts ...grpc_go.CallOption) (*UnlinkSocialNetworkResponse, common.ErrorWithAttachment)
|
||||
// 历史记录相关 api
|
||||
GetHistory(ctx context.Context, in *GetHistoryRequest, opts ...grpc_go.CallOption) (*GetHistoryResponse, common.ErrorWithAttachment)
|
||||
GetHistoryById(ctx context.Context, in *GetHistoryByIdRequest, opts ...grpc_go.CallOption) (*GetHistoryByIdResponse, common.ErrorWithAttachment)
|
||||
@ -71,6 +72,7 @@ type AyrshareClientImpl struct {
|
||||
CreateProfile func(ctx context.Context, in *CreateProfileRequest) (*CreateProfileResponse, error)
|
||||
GetProfiles func(ctx context.Context, in *GetProfilesRequest) (*GetProfilesResponse, error)
|
||||
GenerateJWT func(ctx context.Context, in *GenerateJWTRequest) (*GenerateJWTResponse, error)
|
||||
UnlinkSocialNetwork func(ctx context.Context, in *UnlinkSocialNetworkRequest) (*UnlinkSocialNetworkResponse, error)
|
||||
GetHistory func(ctx context.Context, in *GetHistoryRequest) (*GetHistoryResponse, error)
|
||||
GetHistoryById func(ctx context.Context, in *GetHistoryByIdRequest) (*GetHistoryByIdResponse, error)
|
||||
GetHistoryByPlatform func(ctx context.Context, in *GetHistoryByPlatformRequest) (*GetHistoryByPlatformResponse, error)
|
||||
@ -137,6 +139,12 @@ func (c *ayrshareClient) GenerateJWT(ctx context.Context, in *GenerateJWTRequest
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GenerateJWT", in, out)
|
||||
}
|
||||
|
||||
func (c *ayrshareClient) UnlinkSocialNetwork(ctx context.Context, in *UnlinkSocialNetworkRequest, opts ...grpc_go.CallOption) (*UnlinkSocialNetworkResponse, common.ErrorWithAttachment) {
|
||||
out := new(UnlinkSocialNetworkResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UnlinkSocialNetwork", in, out)
|
||||
}
|
||||
|
||||
func (c *ayrshareClient) GetHistory(ctx context.Context, in *GetHistoryRequest, opts ...grpc_go.CallOption) (*GetHistoryResponse, common.ErrorWithAttachment) {
|
||||
out := new(GetHistoryResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
@ -246,6 +254,7 @@ type AyrshareServer interface {
|
||||
CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error)
|
||||
GetProfiles(context.Context, *GetProfilesRequest) (*GetProfilesResponse, error)
|
||||
GenerateJWT(context.Context, *GenerateJWTRequest) (*GenerateJWTResponse, error)
|
||||
UnlinkSocialNetwork(context.Context, *UnlinkSocialNetworkRequest) (*UnlinkSocialNetworkResponse, error)
|
||||
// 历史记录相关 api
|
||||
GetHistory(context.Context, *GetHistoryRequest) (*GetHistoryResponse, error)
|
||||
GetHistoryById(context.Context, *GetHistoryByIdRequest) (*GetHistoryByIdResponse, error)
|
||||
@ -293,6 +302,9 @@ func (UnimplementedAyrshareServer) GetProfiles(context.Context, *GetProfilesRequ
|
||||
func (UnimplementedAyrshareServer) GenerateJWT(context.Context, *GenerateJWTRequest) (*GenerateJWTResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GenerateJWT not implemented")
|
||||
}
|
||||
func (UnimplementedAyrshareServer) UnlinkSocialNetwork(context.Context, *UnlinkSocialNetworkRequest) (*UnlinkSocialNetworkResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnlinkSocialNetwork not implemented")
|
||||
}
|
||||
func (UnimplementedAyrshareServer) GetHistory(context.Context, *GetHistoryRequest) (*GetHistoryResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetHistory not implemented")
|
||||
}
|
||||
@ -543,6 +555,35 @@ func _Ayrshare_GenerateJWT_Handler(srv interface{}, ctx context.Context, dec fun
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Ayrshare_UnlinkSocialNetwork_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UnlinkSocialNetworkRequest)
|
||||
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("UnlinkSocialNetwork", 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 _Ayrshare_GetHistory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetHistoryRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@ -1038,6 +1079,10 @@ var Ayrshare_ServiceDesc = grpc_go.ServiceDesc{
|
||||
MethodName: "GenerateJWT",
|
||||
Handler: _Ayrshare_GenerateJWT_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UnlinkSocialNetwork",
|
||||
Handler: _Ayrshare_UnlinkSocialNetwork_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetHistory",
|
||||
Handler: _Ayrshare_GetHistory_Handler,
|
||||
|
||||
14220
api/cast/cast.pb.go
14220
api/cast/cast.pb.go
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-triple v1.0.8
|
||||
// - protoc v3.21.1
|
||||
// - protoc v6.32.0--rc2
|
||||
// source: pb/fiee/cast.proto
|
||||
|
||||
package cast
|
||||
@ -54,6 +54,7 @@ type CastClient interface {
|
||||
RefreshWorkList(ctx context.Context, in *RefreshWorkListReq, opts ...grpc_go.CallOption) (*RefreshWorkListResp, common.ErrorWithAttachment)
|
||||
WorkResource(ctx context.Context, in *WorkResourceReq, opts ...grpc_go.CallOption) (*WorkResourceResp, common.ErrorWithAttachment)
|
||||
UpdateWorkResource(ctx context.Context, in *UpdateWorkResourceReq, opts ...grpc_go.CallOption) (*UpdateWorkResourceResp, common.ErrorWithAttachment)
|
||||
UpdateMediaAccStatus(ctx context.Context, in *UpdateMediaAccStatusReq, opts ...grpc_go.CallOption) (*UpdateMediaAccStatusResp, common.ErrorWithAttachment)
|
||||
OAuthAccount(ctx context.Context, in *OAuthAccountReq, opts ...grpc_go.CallOption) (*OAuthAccountResp, common.ErrorWithAttachment)
|
||||
OAuthAccountV2(ctx context.Context, in *OAuthAccountV2Req, opts ...grpc_go.CallOption) (*OAuthAccountV2Resp, common.ErrorWithAttachment)
|
||||
OAuthCodeToToken(ctx context.Context, in *OAuthCodeToTokenReq, opts ...grpc_go.CallOption) (*OAuthCodeToTokenResp, common.ErrorWithAttachment)
|
||||
@ -164,6 +165,7 @@ type CastClientImpl struct {
|
||||
RefreshWorkList func(ctx context.Context, in *RefreshWorkListReq) (*RefreshWorkListResp, error)
|
||||
WorkResource func(ctx context.Context, in *WorkResourceReq) (*WorkResourceResp, error)
|
||||
UpdateWorkResource func(ctx context.Context, in *UpdateWorkResourceReq) (*UpdateWorkResourceResp, error)
|
||||
UpdateMediaAccStatus func(ctx context.Context, in *UpdateMediaAccStatusReq) (*UpdateMediaAccStatusResp, error)
|
||||
OAuthAccount func(ctx context.Context, in *OAuthAccountReq) (*OAuthAccountResp, error)
|
||||
OAuthAccountV2 func(ctx context.Context, in *OAuthAccountV2Req) (*OAuthAccountV2Resp, error)
|
||||
OAuthCodeToToken func(ctx context.Context, in *OAuthCodeToTokenReq) (*OAuthCodeToTokenResp, error)
|
||||
@ -391,6 +393,12 @@ func (c *castClient) UpdateWorkResource(ctx context.Context, in *UpdateWorkResou
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateWorkResource", in, out)
|
||||
}
|
||||
|
||||
func (c *castClient) UpdateMediaAccStatus(ctx context.Context, in *UpdateMediaAccStatusReq, opts ...grpc_go.CallOption) (*UpdateMediaAccStatusResp, common.ErrorWithAttachment) {
|
||||
out := new(UpdateMediaAccStatusResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateMediaAccStatus", in, out)
|
||||
}
|
||||
|
||||
func (c *castClient) OAuthAccount(ctx context.Context, in *OAuthAccountReq, opts ...grpc_go.CallOption) (*OAuthAccountResp, common.ErrorWithAttachment) {
|
||||
out := new(OAuthAccountResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
@ -798,6 +806,7 @@ type CastServer interface {
|
||||
RefreshWorkList(context.Context, *RefreshWorkListReq) (*RefreshWorkListResp, error)
|
||||
WorkResource(context.Context, *WorkResourceReq) (*WorkResourceResp, error)
|
||||
UpdateWorkResource(context.Context, *UpdateWorkResourceReq) (*UpdateWorkResourceResp, error)
|
||||
UpdateMediaAccStatus(context.Context, *UpdateMediaAccStatusReq) (*UpdateMediaAccStatusResp, error)
|
||||
OAuthAccount(context.Context, *OAuthAccountReq) (*OAuthAccountResp, error)
|
||||
OAuthAccountV2(context.Context, *OAuthAccountV2Req) (*OAuthAccountV2Resp, error)
|
||||
OAuthCodeToToken(context.Context, *OAuthCodeToTokenReq) (*OAuthCodeToTokenResp, error)
|
||||
@ -959,6 +968,9 @@ func (UnimplementedCastServer) WorkResource(context.Context, *WorkResourceReq) (
|
||||
func (UnimplementedCastServer) UpdateWorkResource(context.Context, *UpdateWorkResourceReq) (*UpdateWorkResourceResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateWorkResource not implemented")
|
||||
}
|
||||
func (UnimplementedCastServer) UpdateMediaAccStatus(context.Context, *UpdateMediaAccStatusReq) (*UpdateMediaAccStatusResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateMediaAccStatus not implemented")
|
||||
}
|
||||
func (UnimplementedCastServer) OAuthAccount(context.Context, *OAuthAccountReq) (*OAuthAccountResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method OAuthAccount not implemented")
|
||||
}
|
||||
@ -1901,6 +1913,35 @@ func _Cast_UpdateWorkResource_Handler(srv interface{}, ctx context.Context, dec
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Cast_UpdateMediaAccStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateMediaAccStatusReq)
|
||||
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("UpdateMediaAccStatus", 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_OAuthAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(OAuthAccountReq)
|
||||
if err := dec(in); err != nil {
|
||||
@ -3835,6 +3876,10 @@ var Cast_ServiceDesc = grpc_go.ServiceDesc{
|
||||
MethodName: "UpdateWorkResource",
|
||||
Handler: _Cast_UpdateWorkResource_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateMediaAccStatus",
|
||||
Handler: _Cast_UpdateMediaAccStatus_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "OAuthAccount",
|
||||
Handler: _Cast_OAuthAccount_Handler,
|
||||
|
||||
@ -576,6 +576,10 @@ func AyrshareMetricsCollectorTask() {
|
||||
}
|
||||
|
||||
func RefreshArtistOrderTask() {
|
||||
now := time.Now()
|
||||
if now.Day() == 1 && now.Hour() < 1 {
|
||||
return
|
||||
}
|
||||
_, _ = service.CastProvider.Tools(context.Background(), &cast.ToolsReq{Action: "artistOrderInfo"})
|
||||
}
|
||||
|
||||
|
||||
@ -29,3 +29,7 @@ var NamePlatformIDKv = map[string]uint32{
|
||||
"DM": 4,
|
||||
"bluesky": 5,
|
||||
}
|
||||
|
||||
type UnbindAccountReq struct {
|
||||
MediaAccountUuids []string `json:"media_account_uuids"`
|
||||
}
|
||||
|
||||
@ -43,13 +43,6 @@ var PlatformPublishStatusMM = map[cast.PublishStatusENUM]string{
|
||||
cast.PublishStatusENUM_PublishMediaStatus_EXCEPTION: "异常",
|
||||
}
|
||||
|
||||
var PlatformIDMM = map[int]string{
|
||||
1: "TIKTOK",
|
||||
2: "YouTube",
|
||||
3: "Ins",
|
||||
4: "DM",
|
||||
}
|
||||
|
||||
var WorkStatusMM = map[int]string{
|
||||
1: "草稿",
|
||||
2: "审核中",
|
||||
|
||||
@ -24,6 +24,7 @@ func MediaRouter(r *gin.RouterGroup) {
|
||||
media.POST("artist-info", serviceCast.ArtistInfo)
|
||||
media.POST("sync-as-profile", serviceCast.SyncAsProfile)
|
||||
media.POST("import-media-account", serviceCast.ImportMediaAccount)
|
||||
media.POST("unbind-auth", serviceCast.UnbindAuth)
|
||||
}
|
||||
mediaNoLogin := r.Group("media")
|
||||
{
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
"fonchain-fiee/cmd/config"
|
||||
"fonchain-fiee/pkg/model/login"
|
||||
"fonchain-fiee/pkg/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -16,7 +17,7 @@ func UserAccounts(ctx *gin.Context) {
|
||||
userInfo := login.GetUserInfoFromC(ctx)
|
||||
req.ArtistUuid = fmt.Sprint(userInfo.ID)
|
||||
} else {
|
||||
req.ArtistUuid = "61"
|
||||
req.ArtistUuid = "1234"
|
||||
}
|
||||
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
|
||||
@ -992,6 +992,10 @@ func processMediaMetricsTask(ctx context.Context, task mediaMetricsTask) *cast.M
|
||||
}
|
||||
socialResp, err := service.AyrshareProvider.GetSocialAnalytics(ctx, socialReq)
|
||||
if err != nil {
|
||||
// 传送账号错误,用来判断是不是被封了
|
||||
go func(task mediaMetricsTask) {
|
||||
UpdateAccStatus(task.artistInfo.ArtistUuid, task.platformID, err.Error())
|
||||
}(task)
|
||||
// 构建失败记录
|
||||
return buildFailedMediaMetricsItem(task.artistInfo, task.dateCN, 3, "获取社交分析数据失败", task.platformID, mediaInfoResp.Info)
|
||||
}
|
||||
@ -2681,3 +2685,19 @@ func retryFailedWorkMetrics(ctx context.Context, dateCN int) {
|
||||
fmt.Printf("[%s] [INFO] 没有需要重试的作品指标\n", time.Now().Format("2006-01-02 15:04:05"))
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateAccStatus(artistUuid string, platformID uint32, resp string) {
|
||||
accResp, _err := service.CastProvider.UpdateMediaAccStatus(context.Background(), &cast.UpdateMediaAccStatusReq{
|
||||
ArtistUuid: artistUuid,
|
||||
PlatformID: platformID,
|
||||
InfoResp: resp,
|
||||
})
|
||||
if _err != nil {
|
||||
zap.L().Error("更新媒体账号状态失败", zap.Error(_err),
|
||||
zap.String("artistUuid", artistUuid), zap.Uint32("platformID", platformID), zap.Error(_err))
|
||||
return
|
||||
}
|
||||
if accResp != nil && accResp.ExceptionStatus == 2 {
|
||||
_ = UnbindAyr([]string{accResp.MediaAccUserID})
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,11 +39,25 @@ func MediaUserList(ctx *gin.Context) {
|
||||
service.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
resp, err := service.CastProvider.MediaUserList(ctx, req)
|
||||
resp, err := MediaListCombine(req)
|
||||
if err != nil {
|
||||
service.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
for _, v := range resp.Data {
|
||||
_ = SyncAsAuth(v.ArtistUuid)
|
||||
}
|
||||
}()
|
||||
service.Success(ctx, resp)
|
||||
return
|
||||
}
|
||||
|
||||
func MediaListCombine(req *cast.MediaUserListReq) (*cast.MediaUserListResp, error) {
|
||||
resp, err := service.CastProvider.MediaUserList(context.Background(), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if req.NeedStats {
|
||||
var statResp *bundle.ArtistUploadStatsResponse
|
||||
zap.L().Info("MediaUserList 1")
|
||||
@ -63,8 +77,7 @@ func MediaUserList(ctx *gin.Context) {
|
||||
})
|
||||
zap.L().Info("MediaUserList 2")
|
||||
if err != nil {
|
||||
service.Error(ctx, err)
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range resp.Data {
|
||||
for _, vv := range statResp.Items {
|
||||
@ -82,14 +95,7 @@ func MediaUserList(ctx *gin.Context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
zap.L().Info("MediaUserList 3")
|
||||
go func() {
|
||||
for _, v := range resp.Data {
|
||||
_ = SyncAsAuth(v.ArtistUuid)
|
||||
}
|
||||
}()
|
||||
service.Success(ctx, resp)
|
||||
return
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func UnbindManager(ctx *gin.Context) {
|
||||
@ -337,7 +343,6 @@ func OAuth2Callback(ctx *gin.Context) {
|
||||
ctx.Redirect(http.StatusFound, fmt.Sprintf("%s?%s", config.AppConfig.System.AuthRedirectUrl, "status=1"))
|
||||
return
|
||||
}
|
||||
// TODO 跳转到前端页面
|
||||
ctx.Redirect(http.StatusFound, fmt.Sprintf("%s?%s", config.AppConfig.System.AuthRedirectUrl, "status=0"))
|
||||
//service.Success(ctx, map[string]interface{}{
|
||||
// "req": req,
|
||||
@ -772,3 +777,51 @@ func updateMediaAccount(platformName string, platformId cast.PlatformIDENUM, sub
|
||||
//}
|
||||
return err
|
||||
}
|
||||
|
||||
func UnbindAuth(ctx *gin.Context) {
|
||||
var req modelCast.UnbindAccountReq
|
||||
var err error
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
service.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
err = UnbindAyr(req.MediaAccountUuids)
|
||||
if err != nil {
|
||||
service.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
service.Success(ctx, nil)
|
||||
return
|
||||
}
|
||||
|
||||
func UnbindAyr(MediaAccountUuids []string) error {
|
||||
for _, mediaAccountUuid := range MediaAccountUuids {
|
||||
mediaResp, err := service.CastProvider.MediaUserList(context.Background(), &cast.MediaUserListReq{
|
||||
MediaUserID: mediaAccountUuid,
|
||||
Page: 1,
|
||||
PageSize: 1,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if mediaResp == nil || len(mediaResp.Data) == 0 {
|
||||
return errors.New("未找到该账号")
|
||||
}
|
||||
asArtistResp, _err := service.CastProvider.GetArtist(context.Background(), &cast.GetArtistReq{
|
||||
ArtistUuid: fmt.Sprint(mediaResp.Data[0].ArtistUuid),
|
||||
})
|
||||
if _err != nil {
|
||||
return errors.New("未找到该艺人")
|
||||
}
|
||||
_, err = service.AyrshareProvider.UnlinkSocialNetwork(context.Background(), &aryshare.UnlinkSocialNetworkRequest{
|
||||
Platform: modelCast.PlatformNameKv[mediaResp.Data[0].PlatformID],
|
||||
ProfileKey: asArtistResp.ArtistInfo.ProfileKey,
|
||||
})
|
||||
if err != nil {
|
||||
zap.L().Error("UnlinkSocialNetwork err", zap.Error(err))
|
||||
return errors.New("解除授权失败")
|
||||
}
|
||||
_ = SyncAsAuth(mediaResp.Data[0].ArtistUuid)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -17,13 +17,19 @@ import (
|
||||
func Test(ctx *gin.Context) {
|
||||
action := ctx.PostForm("action")
|
||||
if action == "" {
|
||||
workUuid := ctx.PostForm("workUuid")
|
||||
err := CheckImage(workUuid)
|
||||
if err != nil {
|
||||
service.Error(ctx, err)
|
||||
return
|
||||
numKey := map[string]string{}
|
||||
for _, v := range numKey {
|
||||
resp, err := service.AyrshareProvider.UnlinkSocialNetwork(context.Background(), &aryshare.UnlinkSocialNetworkRequest{
|
||||
Platform: "bluesky",
|
||||
ProfileKey: v,
|
||||
})
|
||||
if err != nil {
|
||||
service.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
fmt.Println(v)
|
||||
fmt.Println(resp)
|
||||
}
|
||||
service.Success(ctx, nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -866,6 +866,7 @@ func PostAS(ctx context.Context, workUuid string) error {
|
||||
})
|
||||
zap.L().Info("UpdateWorkPlatformInfo", zap.Any("infoReq", infoReq))
|
||||
_, errS = service.CastProvider.UpdateWorkPlatformInfo(context.Background(), infoReq)
|
||||
go UpdateAccStatus(workDetail.ArtistUuid, uint32(platformID), _err.Error())
|
||||
if errS != nil {
|
||||
zap.L().Error("PostAs UpdateWorkPlatformInfo err", zap.Error(errS), zap.Any("WorkUuid", workDetail.WorkUuid))
|
||||
}
|
||||
@ -948,6 +949,9 @@ func RePublish(ctx *gin.Context) {
|
||||
service.Error(ctx, err)
|
||||
return
|
||||
}
|
||||
if req.PublishSource == cast.PublishSourceENUM_RePublishType_UNKNOW {
|
||||
req.PublishSource = cast.PublishSourceENUM_RePublishType_MANUAL
|
||||
}
|
||||
newCtx := NewCtxWithUserInfo(ctx)
|
||||
/* workInfoResp, err = service.CastProvider.WorkInfo(context.Background(), &cast.WorkInfoReq{
|
||||
WorkUuid: req.WorkUuid,
|
||||
@ -976,6 +980,39 @@ func RePublish(ctx *gin.Context) {
|
||||
service.Error(ctx, err)
|
||||
return
|
||||
}*/
|
||||
if len(req.PlatformIDs) == 0 && len(req.MediaAccountUuids) == 0 {
|
||||
service.Error(ctx, errors.New("请选择发布平台或账号"))
|
||||
return
|
||||
}
|
||||
if len(req.MediaAccountUuids) == 0 {
|
||||
if len(req.WorkUuids) != 1 {
|
||||
service.Error(ctx, errors.New("只选择平台时只能单个作品重发"))
|
||||
return
|
||||
}
|
||||
workInfo, _err := service.CastProvider.WorkInfo(context.Background(), &cast.WorkInfoReq{WorkUuid: req.WorkUuids[0]})
|
||||
if _err != nil {
|
||||
service.Error(ctx, _err)
|
||||
return
|
||||
}
|
||||
accountResp, _err := service.CastProvider.MediaAccounts(context.Background(), &cast.MediaAccountsReq{
|
||||
ArtistUuid: workInfo.ArtistUuid,
|
||||
})
|
||||
if _err != nil {
|
||||
service.Error(ctx, _err)
|
||||
return
|
||||
}
|
||||
if accountResp == nil || len(accountResp.Data) == 0 {
|
||||
service.Error(ctx, errors.New("该艺人无可用媒体账号"))
|
||||
return
|
||||
}
|
||||
for _, platformId := range req.PlatformIDs {
|
||||
for _, v := range accountResp.Data {
|
||||
if v.PlatformID == uint32(platformId) {
|
||||
req.MediaAccountUuids = append(req.MediaAccountUuids, v.MediaAccountUuid)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resp, err = service.CastProvider.RePublish(newCtx, req)
|
||||
if err != nil {
|
||||
service.Error(ctx, err)
|
||||
@ -1497,6 +1534,7 @@ func ImportWorkBatch(ctx *gin.Context) {
|
||||
temp.ArtistName = subInfoResp.Name
|
||||
temp.ArtistPhone = subInfoResp.TelNum
|
||||
temp.ArtistPhoneAreaCode = subInfoResp.TelAreaCode
|
||||
temp.ArtistSubNum = subInfoResp.SubNum
|
||||
}
|
||||
if len(row) > 7 {
|
||||
temp.Title = utils.CleanString(row[7])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user