From 6e3d0267be01fdd162ada0f242613b889e535912 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Fri, 27 Sep 2024 15:08:48 +0800 Subject: [PATCH] by Robin at 20240927 --- app/mix/service/utilservice.go | 35 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 45f3237d..afb58243 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -594,31 +594,38 @@ func (s *Service) utilCancelAccountByMids(ctx *gin.Context, midList []int64) err for _, account := range accounts { phoneHash := strings.ToLower(util.DerefString(account.PhoneHash)) - err = _DefaultAccount.OpUpdate(ctx, &accountproto.OpUpdateReq{ + updateReq := &accountproto.OpUpdateReq{ Account: &dbstruct.Account{ Mid: account.Mid, - Name: goproto.String(cfg.Name), PhoneHash: goproto.String(phoneHash), MobilePhone: goproto.String(cfg.MobilePhone), - Avatar: &dbstruct.MediaComponent{ - ImageIds: &imageIds, - }, - Status: goproto.Int64(consts.AccountStatus_Cancelled), + Status: goproto.Int64(consts.AccountStatus_Cancelled), }, - }) + } + // 非主播才修改名字和头像 + if account.GetRole() != consts.Streamer { + updateReq.Account.Name = goproto.String(cfg.Name) + updateReq.Account.Avatar = &dbstruct.MediaComponent{ + ImageIds: &imageIds, + } + } + err = _DefaultAccount.OpUpdate(ctx, updateReq) if qmgo.IsDup(err) { - err = _DefaultAccount.OpUpdate(ctx, &accountproto.OpUpdateReq{ + updateReq := &accountproto.OpUpdateReq{ Account: &dbstruct.Account{ Mid: account.Mid, - Name: goproto.String(cfg.Name), PhoneHash: goproto.String(phoneHash + qmgo.NewObjectID().Hex()), MobilePhone: goproto.String(cfg.MobilePhone), - Avatar: &dbstruct.MediaComponent{ - ImageIds: &imageIds, - }, - Status: goproto.Int64(consts.AccountStatus_Cancelled), + Status: goproto.Int64(consts.AccountStatus_Cancelled), }, - }) + } + if account.GetRole() != consts.Streamer { + updateReq.Account.Name = goproto.String(cfg.Name) + updateReq.Account.Avatar = &dbstruct.MediaComponent{ + ImageIds: &imageIds, + } + } + err = _DefaultAccount.OpUpdate(ctx, updateReq) } if err != nil { logger.Error("_DefaultAccount OpUpdate fail, err: %v", err)