From 06227bd983deea765e05d4867980fc90a81a9fb7 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Thu, 9 May 2024 18:07:05 +0800 Subject: [PATCH] by Robin at 20240509 --- app/mix/dao/mongo.go | 14 ++++++++++++- app/mix/service/apiservice.go | 8 ++++++++ app/mix/service/logic/account.go | 9 +++++++++ app/mix/service/service.go | 8 ++++++++ .../service/textaudittask_result_handler.go | 20 ++++++++++++++++++- 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 3fc578f3..01bb8f5f 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -1446,13 +1446,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 773a5f23..c9e10bca 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 c8cfb879..03ed1555 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 } } }