绑定
This commit is contained in:
parent
b51d4d39ca
commit
7588bf4b28
1116
api/cast/cast.pb.go
1116
api/cast/cast.pb.go
File diff suppressed because it is too large
Load Diff
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -218,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 进行回滚
|
||||||
|
Loading…
Reference in New Issue
Block a user