From f94f90b0e7ce1ad3bd200f87137e59eb4dbf1eda Mon Sep 17 00:00:00 2001 From: Leufolium Date: Fri, 8 Mar 2024 12:52:10 +0800 Subject: [PATCH] by Robin at 20240308; logout --- app/mix/dao/mongo.go | 11 +++++++++++ app/mix/service/logic/token.go | 9 +++++++++ app/mix/service/utilservice.go | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 253dd659..9b006559 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -891,6 +891,17 @@ func (m *Mongo) DeleteTokenByMid(ctx *gin.Context, mid int64) error { return err } +func (m *Mongo) DeleteTokenByMids(ctx *gin.Context, mids []int64) error { + col := m.getColToken() + + err := col.Remove(ctx, qmgo.M{ + "mid": qmgo.M{ + "$in": mids, + }, + }) + return err +} + func (m *Mongo) GetTokenList(ctx *gin.Context, req *tokenproto.OpListReq) ([]*dbstruct.Token, error) { list := make([]*dbstruct.Token, 0) col := m.getColToken() diff --git a/app/mix/service/logic/token.go b/app/mix/service/logic/token.go index 7f2f7548..52deae54 100644 --- a/app/mix/service/logic/token.go +++ b/app/mix/service/logic/token.go @@ -57,6 +57,15 @@ func (p *Token) OpDeleteByMid(ctx *gin.Context, mid int64) error { return nil } +func (p *Token) OpDeleteByMids(ctx *gin.Context, mids []int64) error { + err := p.store.DeleteTokenByMids(ctx, mids) + if err != nil { + logger.Error("OpDeleteByMids fail, err: %v", err) + return err + } + return nil +} + func (p *Token) OpList(ctx *gin.Context, req *tokenproto.OpListReq) ([]*dbstruct.Token, error) { list, err := p.store.GetTokenList(ctx, req) if err != nil { diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 897df529..5cc1e04e 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -636,6 +636,12 @@ func (s *Service) utilCancelAccountByMids(ctx *gin.Context, midList []int64) err return nil } + // 执行下线操作 + if err := _DefaultToken.OpDeleteByMids(ctx, midList); err != nil { + logger.Error("_DefaultToken OpDeleteByMids fail, err: %v", err) + return err + } + // 查询相应的login和account信息 logins, err := _DefaultLogin.OpListByMids(ctx, &loginproto.OpListByMidsReq{ Mids: midList,