diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 9798064f..20c5f84c 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -1448,13 +1448,25 @@ func (m *Mongo) CreateAccountHis(ctx *gin.Context, accounts []*dbstruct.Account) return err } -// account相关 +// streamer_acct相关 func (m *Mongo) CreateStreamerAcct(ctx *gin.Context, accounts []*dbstruct.StreamerAcct) error { col := m.getColStreamerAcct() _, err := col.InsertMany(ctx, accounts) return err } +func (m *Mongo) UpdateStreamerAcctName(ctx *gin.Context, id int64, name string) error { + col := m.getColStreamerAcct() + up := qmgo.M{ + "$set": qmgo.M{ + "ut": time.Now().Unix(), + "name": name, + }, + } + err := col.UpdateId(ctx, id, up) + return err +} + // vericode相关 func (m *Mongo) CreateVeriCode(ctx *gin.Context, vericode *dbstruct.VeriCode) error { col := m.getColVeriCode() diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index f1db8ce6..c61dde98 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -364,6 +364,14 @@ func (s *Service) ApiUpdateAccount(ctx *gin.Context, req *accountproto.ApiUpdate return } + if oldAccount.GetRole() == consts.Streamer { + if err := _DefaultAccount.OpUpdateStreamerAcctName(ctx, util.DerefInt64(req.Account.Mid), util.DerefString(req.Account.Name)); err != nil { + logger.Error("OpUpdateStreamerAcctName fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeAccountSrvFail + return + } + } + // 审核任务加入队列 imageaudit.AddTasks(imageaudittasks) textaudit.AddTasks(textaudittasks) diff --git a/app/mix/service/logic/account.go b/app/mix/service/logic/account.go index 3694893a..0919c9d1 100644 --- a/app/mix/service/logic/account.go +++ b/app/mix/service/logic/account.go @@ -292,3 +292,12 @@ func (p *Account) OpCreateStreamerAcct(ctx *gin.Context, accounts []*dbstruct.St } return nil } + +func (p *Account) OpUpdateStreamerAcctName(ctx *gin.Context, mid int64, name string) error { + err := p.store.UpdateStreamerAcctName(ctx, mid, name) + if err != nil { + logger.Error("UpdateAccount fail, err: %v", err) + return err + } + return nil +} diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 09cd56f5..e1770787 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -810,6 +810,14 @@ func (s *Service) OpUpdateAccount(ctx *gin.Context, req *accountproto.OpUpdateRe return } + if oldAccount.GetRole() == consts.Streamer { + if err := _DefaultAccount.OpUpdateStreamerAcctName(ctx, util.DerefInt64(req.Account.Mid), util.DerefString(req.Account.Name)); err != nil { + logger.Error("OpUpdateStreamerAcctName fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeAccountSrvFail + return + } + } + // 审核任务加入队列 textaudit.AddTasks(textaudittasks) return diff --git a/app/mix/service/textaudittask_result_handler.go b/app/mix/service/textaudittask_result_handler.go index e248d569..fbc2db38 100644 --- a/app/mix/service/textaudittask_result_handler.go +++ b/app/mix/service/textaudittask_result_handler.go @@ -72,12 +72,30 @@ func (handler *TextAuditTaskResultHandler) generateAccountNameUpdateFunc() { } else { name = task.OldText } - return _DefaultAccount.OpUpdate(ctx, &accountproto.OpUpdateReq{ + + err := _DefaultAccount.OpUpdate(ctx, &accountproto.OpUpdateReq{ Account: &dbstruct.Account{ Mid: mid, Name: name, }, }) + + if err != nil { + return err + } + + acct, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{ + Mid: mid, + }) + if err != nil { + return err + } + + if acct.GetRole() == consts.Streamer { + return _DefaultAccount.OpUpdateStreamerAcctName(ctx, util.DerefInt64(mid), util.DerefString(name)) + } + + return nil } } }