fix: 主播修改昵称审核 upsert

This commit is contained in:
wangxinyu 2024-12-11 18:22:19 +08:00
parent 523b277364
commit 83cd231f76
3 changed files with 24 additions and 4 deletions

View File

@ -1281,6 +1281,17 @@ func (m *Mongo) UpdateAccount(ctx *gin.Context, account *dbstruct.Account) error
return err
}
func (m *Mongo) UpsertAccount(ctx *gin.Context, account *dbstruct.Account) error {
col := m.getColAccount()
set := util.EntityToM(account)
set["ut"] = time.Now().Unix()
up := qmgo.M{
"$set": set,
}
_, err := col.UpsertId(ctx, util.DerefInt64(account.Mid), up)
return err
}
func (m *Mongo) UpdateAccountByMidAndStatus(ctx *gin.Context, account *dbstruct.Account, status int64) error {
col := m.getColAccount()
set := util.EntityToM(account)

View File

@ -371,9 +371,9 @@ func (s *Service) ApiUpdateAccount(ctx *gin.Context, req *accountproto.ApiUpdate
// 主播昵称需要先过审核
if oldAccount.GetRole() == consts.Streamer && oldAccount.GetName() != req.Account.GetName() {
// TODO:wxy, 测试日志
logger.Info("ApiUpdateAccount test log, NewName: %v, auditStatus: %v", opUpdateReq.GetNewName(), opUpdateReq.GetAuditStatus())
logger.Info("ApiUpdateAccount test log, NewName: %v, auditStatus: %v", oldAccount.GetNewName(), oldAccount.GetAuditStatus())
opUpdateReq.NewName = goproto.String(req.Account.GetName())
auditStatus := s.SetAuditStatusBitMap(opUpdateReq.GetAuditStatus(), consts.StreamNikeAudit, consts.StreamerNikeNameAuditing)
auditStatus := s.SetAuditStatusBitMap(oldAccount.GetAuditStatus(), consts.StreamNikeAudit, consts.StreamerNikeNameAuditing)
opUpdateReq.AuditStatus = goproto.Int64(auditStatus)
logger.Info("ApiUpdateAccount test log, NewName: %v, auditStatus: %v", opUpdateReq.GetNewName(), opUpdateReq.GetAuditStatus())
} else {
@ -384,8 +384,8 @@ func (s *Service) ApiUpdateAccount(ctx *gin.Context, req *accountproto.ApiUpdate
logger.Info("ApiUpdateAccount test log,req: %v", util.ToJson(req))
// 用户只允许修改昵称和头像
if err := _DefaultAccount.OpUpdate(ctx, opUpdateReq); err != nil {
logger.Error("OpUpdate fail, req: %v, err: %v", util.ToJson(req), err)
if err := _DefaultAccount.OpUpsert(ctx, opUpdateReq); err != nil {
logger.Error("OpUpsert fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeAccountSrvFail
return
}

View File

@ -66,6 +66,15 @@ func (p *Account) OpUpdate(ctx *gin.Context, req *accountproto.OpUpdateReq) erro
return nil
}
func (p *Account) OpUpsert(ctx *gin.Context, req *accountproto.OpUpdateReq) error {
err := p.store.UpsertAccount(ctx, req.Account)
if err != nil {
logger.Error("UpdateAccount fail, err: %v", err)
return err
}
return nil
}
func (p *Account) OpUpdateByMidAndStatus(ctx *gin.Context, req *accountproto.OpUpdateReq, status int64) error {
err := p.store.UpdateAccountByMidAndStatus(ctx, req.Account, status)
if err != nil {