Merge branch 'feature-multicast-daiyb' into dev

This commit is contained in:
戴育兵 2025-06-20 16:42:04 +08:00
commit c34cc285bb
6 changed files with 787 additions and 539 deletions

File diff suppressed because it is too large Load Diff

View File

@ -729,6 +729,110 @@ var _ interface {
ErrorName() string ErrorName() string
} = UnbindManagerReqValidationError{} } = UnbindManagerReqValidationError{}
// Validate checks the field values on UnbindManagerResp 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 *UnbindManagerResp) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on UnbindManagerResp 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
// UnbindManagerRespMultiError, or nil if none found.
func (m *UnbindManagerResp) ValidateAll() error {
return m.validate(true)
}
func (m *UnbindManagerResp) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for OldBindArtistUuid
if len(errors) > 0 {
return UnbindManagerRespMultiError(errors)
}
return nil
}
// UnbindManagerRespMultiError is an error wrapping multiple validation errors
// returned by UnbindManagerResp.ValidateAll() if the designated constraints
// aren't met.
type UnbindManagerRespMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m UnbindManagerRespMultiError) 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 UnbindManagerRespMultiError) AllErrors() []error { return m }
// UnbindManagerRespValidationError is the validation error returned by
// UnbindManagerResp.Validate if the designated constraints aren't met.
type UnbindManagerRespValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e UnbindManagerRespValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e UnbindManagerRespValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e UnbindManagerRespValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e UnbindManagerRespValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e UnbindManagerRespValidationError) ErrorName() string {
return "UnbindManagerRespValidationError"
}
// Error satisfies the builtin error interface
func (e UnbindManagerRespValidationError) 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 %sUnbindManagerResp.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = UnbindManagerRespValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = UnbindManagerRespValidationError{}
// Validate checks the field values on BindManagerReq with the rules defined in // Validate checks the field values on BindManagerReq 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.
@ -3038,6 +3142,8 @@ func (m *RePublishResp) validate(all bool) error {
// no validation rules for ArtistUuid // no validation rules for ArtistUuid
// no validation rules for WorkCategory
if len(errors) > 0 { if len(errors) > 0 {
return RePublishRespMultiError(errors) return RePublishRespMultiError(errors)
} }
@ -3576,6 +3682,8 @@ func (m *WorkListResp_Info) validate(all bool) error {
// no validation rules for StatusUpdateTime // no validation rules for StatusUpdateTime
// no validation rules for ApprovalID
if len(errors) > 0 { if len(errors) > 0 {
return WorkListResp_InfoMultiError(errors) return WorkListResp_InfoMultiError(errors)
} }

View File

@ -31,7 +31,7 @@ const _ = grpc_go.SupportPackageIsVersion7
type CastClient interface { type CastClient interface {
MediaUserList(ctx context.Context, in *MediaUserListReq, opts ...grpc_go.CallOption) (*MediaUserListResp, common.ErrorWithAttachment) MediaUserList(ctx context.Context, in *MediaUserListReq, opts ...grpc_go.CallOption) (*MediaUserListResp, common.ErrorWithAttachment)
UpdateMediaAccount(ctx context.Context, in *UpdateMediaAccountReq, opts ...grpc_go.CallOption) (*UpdateMediaAccountResp, common.ErrorWithAttachment) UpdateMediaAccount(ctx context.Context, in *UpdateMediaAccountReq, opts ...grpc_go.CallOption) (*UpdateMediaAccountResp, common.ErrorWithAttachment)
UnbindManager(ctx context.Context, in *UnbindManagerReq, opts ...grpc_go.CallOption) (*emptypb.Empty, common.ErrorWithAttachment) UnbindManager(ctx context.Context, in *UnbindManagerReq, opts ...grpc_go.CallOption) (*UnbindManagerResp, common.ErrorWithAttachment)
BindManager(ctx context.Context, in *BindManagerReq, opts ...grpc_go.CallOption) (*emptypb.Empty, common.ErrorWithAttachment) BindManager(ctx context.Context, in *BindManagerReq, opts ...grpc_go.CallOption) (*emptypb.Empty, common.ErrorWithAttachment)
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)
@ -52,7 +52,7 @@ type castClient struct {
type CastClientImpl struct { type CastClientImpl struct {
MediaUserList func(ctx context.Context, in *MediaUserListReq) (*MediaUserListResp, error) MediaUserList func(ctx context.Context, in *MediaUserListReq) (*MediaUserListResp, error)
UpdateMediaAccount func(ctx context.Context, in *UpdateMediaAccountReq) (*UpdateMediaAccountResp, error) UpdateMediaAccount func(ctx context.Context, in *UpdateMediaAccountReq) (*UpdateMediaAccountResp, error)
UnbindManager func(ctx context.Context, in *UnbindManagerReq) (*emptypb.Empty, error) UnbindManager func(ctx context.Context, in *UnbindManagerReq) (*UnbindManagerResp, error)
BindManager func(ctx context.Context, in *BindManagerReq) (*emptypb.Empty, error) BindManager func(ctx context.Context, in *BindManagerReq) (*emptypb.Empty, error)
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)
@ -90,8 +90,8 @@ func (c *castClient) UpdateMediaAccount(ctx context.Context, in *UpdateMediaAcco
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateMediaAccount", in, out) return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateMediaAccount", in, out)
} }
func (c *castClient) UnbindManager(ctx context.Context, in *UnbindManagerReq, opts ...grpc_go.CallOption) (*emptypb.Empty, common.ErrorWithAttachment) { func (c *castClient) UnbindManager(ctx context.Context, in *UnbindManagerReq, opts ...grpc_go.CallOption) (*UnbindManagerResp, common.ErrorWithAttachment) {
out := new(emptypb.Empty) out := new(UnbindManagerResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string) interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UnbindManager", in, out) return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UnbindManager", in, out)
} }
@ -168,7 +168,7 @@ func (c *castClient) OAuthYoutubeToken(ctx context.Context, in *OAuthYoutubeToke
type CastServer interface { type CastServer interface {
MediaUserList(context.Context, *MediaUserListReq) (*MediaUserListResp, error) MediaUserList(context.Context, *MediaUserListReq) (*MediaUserListResp, error)
UpdateMediaAccount(context.Context, *UpdateMediaAccountReq) (*UpdateMediaAccountResp, error) UpdateMediaAccount(context.Context, *UpdateMediaAccountReq) (*UpdateMediaAccountResp, error)
UnbindManager(context.Context, *UnbindManagerReq) (*emptypb.Empty, error) UnbindManager(context.Context, *UnbindManagerReq) (*UnbindManagerResp, error)
BindManager(context.Context, *BindManagerReq) (*emptypb.Empty, error) BindManager(context.Context, *BindManagerReq) (*emptypb.Empty, error)
UpdateWorkImage(context.Context, *UpdateWorkImageReq) (*UpdateWorkImageResp, error) UpdateWorkImage(context.Context, *UpdateWorkImageReq) (*UpdateWorkImageResp, error)
UpdateWorkVideo(context.Context, *UpdateWorkVideoReq) (*UpdateWorkVideoResp, error) UpdateWorkVideo(context.Context, *UpdateWorkVideoReq) (*UpdateWorkVideoResp, error)
@ -194,7 +194,7 @@ func (UnimplementedCastServer) MediaUserList(context.Context, *MediaUserListReq)
func (UnimplementedCastServer) UpdateMediaAccount(context.Context, *UpdateMediaAccountReq) (*UpdateMediaAccountResp, error) { func (UnimplementedCastServer) UpdateMediaAccount(context.Context, *UpdateMediaAccountReq) (*UpdateMediaAccountResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateMediaAccount not implemented") return nil, status.Errorf(codes.Unimplemented, "method UpdateMediaAccount not implemented")
} }
func (UnimplementedCastServer) UnbindManager(context.Context, *UnbindManagerReq) (*emptypb.Empty, error) { func (UnimplementedCastServer) UnbindManager(context.Context, *UnbindManagerReq) (*UnbindManagerResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method UnbindManager not implemented") return nil, status.Errorf(codes.Unimplemented, "method UnbindManager not implemented")
} }
func (UnimplementedCastServer) BindManager(context.Context, *BindManagerReq) (*emptypb.Empty, error) { func (UnimplementedCastServer) BindManager(context.Context, *BindManagerReq) (*emptypb.Empty, error) {

View File

@ -6,15 +6,21 @@ import (
"fmt" "fmt"
"fonchain-fiee/cmd/config" "fonchain-fiee/cmd/config"
"fonchain-fiee/pkg/e" "fonchain-fiee/pkg/e"
"fonchain-fiee/pkg/utils"
modelCast "fonchain-fiee/pkg/model/cast" modelCast "fonchain-fiee/pkg/model/cast"
"fonchain-fiee/pkg/utils"
) )
type CastService struct { type CastService struct {
} }
func (c *CastService) ApprovalDetail(approvalIds []int) (data map[int]int, err error) { func (c *CastService) ApprovalDetail(approvalIds []int) (data map[int]int, err error) {
idsBytes, _ := json.Marshal(approvalIds) type ApprovalDetailRequest struct {
ID []int `json:"ID"`
}
req := ApprovalDetailRequest{
ID: approvalIds,
}
idsBytes, _ := json.Marshal(req)
var respBody string var respBody string
url := fmt.Sprintf(config.AppConfig.System.ErpHost + "/approval/list/ex") url := fmt.Sprintf(config.AppConfig.System.ErpHost + "/approval/list/ex")
respBody, err = utils.Post(url, string(idsBytes)) respBody, err = utils.Post(url, string(idsBytes))

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"errors" "errors"
"fonchain-fiee/api/accountFiee" "fonchain-fiee/api/accountFiee"
"fonchain-fiee/api/bundle"
"fonchain-fiee/api/cast" "fonchain-fiee/api/cast"
"fonchain-fiee/cmd/config" "fonchain-fiee/cmd/config"
"fonchain-fiee/pkg/e" "fonchain-fiee/pkg/e"
@ -34,6 +35,7 @@ func MediaUserList(ctx *gin.Context) {
func UnbindManager(ctx *gin.Context) { func UnbindManager(ctx *gin.Context) {
var req *cast.UnbindManagerReq var req *cast.UnbindManagerReq
var resp *cast.UnbindManagerResp
var err error var err error
if err = ctx.ShouldBind(&req); err != nil { if err = ctx.ShouldBind(&req); err != nil {
service.Error(ctx, err) service.Error(ctx, err)
@ -43,11 +45,23 @@ func UnbindManager(ctx *gin.Context) {
service.Error(ctx, err) service.Error(ctx, err)
return return
} }
_, err = service.CastProvider.UnbindManager(ctx, req) resp, err = service.CastProvider.UnbindManager(ctx, req)
if err != nil { if err != nil {
service.Error(ctx, err) service.Error(ctx, err)
return return
} }
if resp.OldBindArtistUuid != "" {
userID, _ := strconv.ParseInt(resp.OldBindArtistUuid, 10, 64)
_, err = service.BundleProvider.AddBundleBalance(context.Background(), &bundle.AddBundleBalanceReq{
UserId: int32(userID),
AccountConsumptionNumber: -1,
})
if err != nil {
service.Error(ctx, err)
//FIXME 进行回滚
return
}
}
service.Success(ctx, nil) service.Success(ctx, nil)
return return
} }
@ -113,6 +127,18 @@ func UpdateMediaAccount(ctx *gin.Context) {
service.Error(ctx, err) service.Error(ctx, err)
return return
} }
if req.MediaAccountUuid == "" {
userID, _ := strconv.ParseInt(req.ArtistUuid, 10, 64)
_, err = service.BundleProvider.AddBundleBalance(context.Background(), &bundle.AddBundleBalanceReq{
UserId: int32(userID),
AccountConsumptionNumber: 1,
})
if err != nil {
service.Error(ctx, err)
//FIXME 进行回滚
return
}
}
service.Success(ctx, resp) service.Success(ctx, resp)
return return
} }

View File

@ -131,6 +131,38 @@ func WorkList(ctx *gin.Context) {
service.Error(ctx, err) service.Error(ctx, err)
return return
} }
var castS = new(CastService)
if len(resp.Data) > 0 {
var approvalIDs []int
var data map[int]int
var workUuidApprovalIDMap = make(map[int]string)
for _, v := range resp.Data {
if v.WorkStatus == 2 && v.ApprovalID != "" {
approvalID, _ := strconv.ParseUint(v.ApprovalID, 10, 64)
approvalIDs = append(approvalIDs, int(approvalID))
workUuidApprovalIDMap[int(approvalID)] = v.WorkUuid
}
}
if len(approvalIDs) > 0 {
data, err = castS.ApprovalDetail(approvalIDs)
if len(data) > 0 {
for approvalId, approvalStatus := range data {
var workAction cast.WorkActionENUM
if approvalStatus == 2 {
workAction = cast.WorkActionENUM_APPROVAL_PASS
} else {
workAction = cast.WorkActionENUM_APPROVAL_REJECT
}
_, _ = service.CastProvider.UpdateStatus(context.Background(), &cast.UpdateStatusReq{
WorkAction: workAction,
WorkUuid: workUuidApprovalIDMap[approvalId],
ApprovalID: fmt.Sprint(approvalId),
})
}
}
}
}
service.Success(ctx, resp) service.Success(ctx, resp)
return return
} }
@ -186,10 +218,16 @@ func RePublish(ctx *gin.Context) {
return return
} }
artistID, _ := strconv.ParseUint(resp.ArtistUuid, 10, 64) artistID, _ := strconv.ParseUint(resp.ArtistUuid, 10, 64)
_, err = service.BundleProvider.AddBundleBalance(context.Background(), &bundle.AddBundleBalanceReq{ balanceReq := &bundle.AddBundleBalanceReq{
UserId: int32(artistID), UserId: int32(artistID),
AccountConsumptionNumber: -1, }
}) if resp.WorkCategory == 1 {
balanceReq.ImageConsumptionNumber = 1
}
if resp.WorkCategory == 2 {
balanceReq.VideoConsumptionNumber = 1
}
_, err = service.BundleProvider.AddBundleBalance(context.Background(), balanceReq)
if err != nil { if err != nil {
service.Error(ctx, err) service.Error(ctx, err)
//FIXME 进行回滚 //FIXME 进行回滚