From b2b29d74667b1f35d5cf4f0b3bf5f335f3966ae7 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Sat, 2 Mar 2024 08:29:20 +0800 Subject: [PATCH 1/4] by Robin at 20240302 --- app/mix/service/xxljob_tasks.go | 2 +- library/dingtalk/client.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/mix/service/xxljob_tasks.go b/app/mix/service/xxljob_tasks.go index acc173cc..94427118 100644 --- a/app/mix/service/xxljob_tasks.go +++ b/app/mix/service/xxljob_tasks.go @@ -290,7 +290,7 @@ func (s *CronService) SendContactCustomerServicesOfLastMinute(ctx context.Contex return err.Error() } - err = dingtalk.SendMsgToAll(msg) + err = dingtalk.SendMsg(msg) if err != nil { return err.Error() } diff --git a/library/dingtalk/client.go b/library/dingtalk/client.go index de1bf304..a98fa1d6 100644 --- a/library/dingtalk/client.go +++ b/library/dingtalk/client.go @@ -18,6 +18,16 @@ func NewDingTalkCilent(cfg *configcenter.DingTalkRobotConfig) *dingtalk.Client { return client } +func SendMsg(message string) error { + msg := dingtalk.NewTextMessage().SetContent(message) + _, _, err := defaultDingTalkClient.Send(msg) + if err != nil { + logger.Error("SendMsgToAll fail, err: %v", err) + return err + } + return nil +} + func SendMsgToAll(message string) error { msg := dingtalk.NewTextMessage().SetContent(message).SetAt(nil, true) _, _, err := defaultDingTalkClient.Send(msg) -- 2.41.0 From 5fab9ff0fd1eb741a17629919b813074238e7889 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Mon, 4 Mar 2024 19:21:30 +0800 Subject: [PATCH 2/4] By Robin at 20240304; cancel account function at mongo part --- api/errcode/errcode.go | 6 +- api/proto/account/proto/account_api.go | 13 ++++ app/mix/controller/account_api.go | 12 ++++ app/mix/controller/init.go | 1 + app/mix/dao/mongo.go | 51 +++++++++++++++ app/mix/service/apiservice.go | 65 +++++++++++++++++++ app/mix/service/logic/accountrelation.go | 33 ++++++++++ .../service/logic/contact_customer_service.go | 9 +++ .../logic/contact_customer_service_session.go | 9 +++ app/mix/service/utilservice.go | 23 +++++++ 10 files changed, 220 insertions(+), 2 deletions(-) diff --git a/api/errcode/errcode.go b/api/errcode/errcode.go index 9bf99398..ad62026f 100644 --- a/api/errcode/errcode.go +++ b/api/errcode/errcode.go @@ -40,6 +40,7 @@ var ErrCodeMsgMap = map[ErrCode]string{ ErrCodeAccountNotExist: "账户信息不存在", ErrCodeAccountInviterNotExist: "邀请人不存在", ErrCodeAccountInviterIsNotAStreamer: "邀请人非主播", + ErrCodeNonUserAccountCancellation: "非普通用户注销需联系客服手工操作", ErrCodeVasSrvFail: "增值服务错误", ErrCodeVasProductNotExist: "商品不存在", @@ -204,8 +205,9 @@ const ( ErrCodeAccountSrvOk ErrCode = ErrCodeOk ErrCodeAccountSrvFail ErrCode = -6001 //账户服务错误 ErrCodeAccountNotExist ErrCode = -6002 //账户信息不存在 - ErrCodeAccountInviterNotExist ErrCode = -6003 //邀请人不存在, - ErrCodeAccountInviterIsNotAStreamer ErrCode = -6004 //邀请人非主播, + ErrCodeAccountInviterNotExist ErrCode = -6003 //邀请人不存在 + ErrCodeAccountInviterIsNotAStreamer ErrCode = -6004 //邀请人非主播 + ErrCodeNonUserAccountCancellation ErrCode = -6005 //非普通用户注销 // Vas: 7xxx ErrCodeVasSrvOk ErrCode = ErrCodeOk diff --git a/api/proto/account/proto/account_api.go b/api/proto/account/proto/account_api.go index 2f1fcdaf..7834cf00 100644 --- a/api/proto/account/proto/account_api.go +++ b/api/proto/account/proto/account_api.go @@ -207,3 +207,16 @@ type ApiUpdateByIdsResp struct { base.BaseResponse Data *ApiUpdateByIdsData `json:"data"` } + +// api 注销 +type ApiCancelReq struct { + base.BaseRequest +} + +type ApiCancelData struct { +} + +type ApiCancelResp struct { + base.BaseResponse + Data *ApiCancelData `json:"data"` +} diff --git a/app/mix/controller/account_api.go b/app/mix/controller/account_api.go index 0f7854d5..f3b4d04b 100644 --- a/app/mix/controller/account_api.go +++ b/app/mix/controller/account_api.go @@ -24,6 +24,18 @@ func ApiUpdateAccount(ctx *gin.Context) { ReplyOk(ctx, nil) } +func ApiCancelAccount(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*accountproto.ApiCancelReq) + ec := service.DefaultService.ApiCancelAccount(ctx, req) + if ec != errcode.ErrCodeAccountSrvOk { + logger.Error("ApiCancelAccount fail, req: %v, ec: %v", util.ToJson(req), ec) + ReplyErrCodeMsg(ctx, ec) + return + } + + ReplyOk(ctx, nil) +} + func ApiGetAccountListByMid(ctx *gin.Context) { req := ctx.MustGet("client_req").(*accountproto.ApiListByMidReq) diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index d6633c5d..ab07ffce 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -74,6 +74,7 @@ func Init(r *gin.Engine) { // 账号,用户端支持改、查自己、查别人、经验增长,不支持增删 apiAccountGroup := r.Group("/api/account", PrepareToC()) apiAccountGroup.POST("update", middleware.JSONParamValidator(accountproto.ApiUpdateReq{}), middleware.JwtAuthenticator(), middleware.RequestDecryptor(), ApiUpdateAccount) + apiAccountGroup.POST("cancel", middleware.JSONParamValidator(accountproto.ApiCancelReq{}), middleware.JwtAuthenticator(), ApiCancelAccount) apiAccountGroup.POST("list_by_mid", middleware.JSONParamValidator(accountproto.ApiListByMidReq{}), middleware.JwtAuthenticator(), ApiGetAccountListByMid) //apiAccountGroup.POST("list_by_user_id", middleware.JSONParamValidator(accountproto.ApiListByUserIdReq{}), middleware.JwtAuthenticator(), ApiGetAccountListByUserId) apiAccountGroup.POST("list_others_by_mid", middleware.JSONParamValidator(accountproto.ApiListOthersByMidReq{}), middleware.JwtAuthenticator(), ApiGetAccountListForOthersByMid) diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 7ff1516f..8a3ae916 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -1566,6 +1566,31 @@ func (m *Mongo) DeleteAccountRelationByIds(ctx *gin.Context, ids []int64) error return err } +func (m *Mongo) GetAccountRelationByMid(ctx *gin.Context, mid int64) ([]*dbstruct.AccountRelation, error) { + col := m.getColAccountRelation() + + list := make([]*dbstruct.AccountRelation, 0) + + query := qmgo.M{ + "$and": []qmgo.M{ + { + "sub_mid": mid, + }, + { + "obj_mid": mid, + }, + }, + "del_flag": 0, + } + + err := col.Find(ctx, query).All(&list) + if err == qmgo.ErrNoSuchDocuments { + err = nil + return list, err + } + return list, err +} + func (m *Mongo) GetAccountRelationListBySubMidAndPredicate(ctx *gin.Context, req *accountrelationproto.OpListBySubMidAndPredicateReq) ([]*dbstruct.AccountRelation, error) { list := make([]*dbstruct.AccountRelation, 0) col := m.getColAccountRelation() @@ -2425,6 +2450,20 @@ func (m *Mongo) DeleteContactCustomerService(ctx *gin.Context, id int64) error { return err } +func (m *Mongo) DeleteContactCustomerServiceBySessionId(ctx *gin.Context, sessionId int64) error { + col := m.getColContactCustomerService() + update := qmgo.M{ + "$set": qmgo.M{ + "del_flag": 1, + }, + } + filter := qmgo.M{ + "session_id": sessionId, + } + _, err := col.UpdateAll(ctx, filter, update) + return err +} + func (m *Mongo) GetContactCustomerServiceList(ctx *gin.Context, req *contact_customer_service_proto.OpListReq) ([]*dbstruct.ContactCustomerService, error) { list := make([]*dbstruct.ContactCustomerService, 0) col := m.getColContactCustomerService() @@ -3126,6 +3165,18 @@ func (m *Mongo) UpdateContactCustomerServiceSession(ctx *gin.Context, contact_cu return err } +func (m *Mongo) DeleteContactCustomerServiceSession(ctx *gin.Context, id int64) error { + col := m.getColContactCustomerServiceSession() + + update := qmgo.M{ + "$set": qmgo.M{ + "del_flag": 1, + }, + } + err := col.UpdateId(ctx, id, update) + return err +} + func (m *Mongo) GetContactCustomerServiceSessionListByMid(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListByMidReq) (*dbstruct.ContactCustomerServiceSession, error) { session := &dbstruct.ContactCustomerServiceSession{} col := m.getColContactCustomerServiceSession() diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index cfafedb5..e0e49c93 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -363,6 +363,71 @@ func (s *Service) ApiUpdateAccount(ctx *gin.Context, req *accountproto.ApiUpdate return } +func (s *Service) ApiCancelAccount(ctx *gin.Context, req *accountproto.ApiCancelReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeAccountSrvOk + + // 查询账户信息 + account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{ + Mid: goproto.Int64(req.Mid), + }) + if err != nil { + logger.Error("OpListByMid fail, err: %v", err) + ec = errcode.ErrCodeAccountSrvFail + return + } + if account == nil { + logger.Error("No account entity was found!") + ec = errcode.ErrCodeAccountNotExist + return + } + + if util.DerefInt64(account.Role) != consts.User { + logger.Error("Cancellation of non-user account requires manual operation") + ec = errcode.ErrCodeNonUserAccountCancellation + return + } + + // 删除账号 + err = _DefaultAccount.OpDelete(ctx, util.DerefInt64(account.Mid)) + if err != nil { + logger.Error("OpDelete fail, err: %v", err) + ec = errcode.ErrCodeAccountSrvFail + return + } + logger.Info("account deletion finished...") + + // 删除主播认证审批 + err = _DefaultStreamerAuthApproval.OpDelete(ctx, &streamerauthapprovalproto.ApiDeleteReq{ + Mid: goproto.Int64(req.Mid), + }) + if err != qmgo.ErrNoSuchDocuments && err != nil { + logger.Error("_DefaultStreamerAuthApproval OpDelete fail, req: %v, err: %v", req, err) + ec = errcode.ErrCodeStreamerAuthApprovalSrvFail + return + } + logger.Info("streamer_auth_approval deletion finished...") + + // 删除用户关系 + err = _DefaultAccountRelation.OpDeleteByMid(ctx, req.Mid) + if err != qmgo.ErrNoSuchDocuments && err != nil { + logger.Error("_DefaultAccountRelation OpDeleteByMid fail, req: %v, err: %v", req, err) + ec = errcode.ErrCodeAccountRelationSrvFail + return + } + logger.Info("account_relation deletion finished...") + + // 删除联系客服 + err = s.utilDeleteContactCustomerServiceByMid(ctx, req.Mid) + if err != qmgo.ErrNoSuchDocuments && err != nil { + logger.Error("utilDeleteContactCustomerServiceByMid fail, req: %v, err: %v", req, err) + ec = errcode.ErrCodeAccountRelationSrvFail + return + } + logger.Info("contact_customer_service deletion finished...") + + return +} + func (s *Service) ApiGetAccountListByMid(ctx *gin.Context, req *accountproto.ApiListByMidReq) (vo *accountproto.ApiListVO, ec errcode.ErrCode) { ec = errcode.ErrCodeAccountSrvOk diff --git a/app/mix/service/logic/accountrelation.go b/app/mix/service/logic/accountrelation.go index f4db4911..820a13d2 100644 --- a/app/mix/service/logic/accountrelation.go +++ b/app/mix/service/logic/accountrelation.go @@ -91,6 +91,39 @@ func (p *AccountRelation) OpDelete(ctx *gin.Context, req *accountrelationproto.O return nil } +func (p *AccountRelation) OpDeleteByMid(ctx *gin.Context, mid int64) error { + //1.查出原有用户关系 + list, err := p.store.GetAccountRelationByMid(ctx, mid) + if len(list) == 0 { + logger.Error("GetAccountRelationByMid fail, err: %v", qmgo.ErrNoSuchDocuments) + return qmgo.ErrNoSuchDocuments + } + if err != nil { + logger.Error("GetAccountRelationByMid fail, err: %v", err) + return err + } + + //2.用户关系标志删除后转存到历史表,并取出ids + ids := make([]int64, len(list)) + for i, accountrelation := range list { + accountrelation.DelFlag = goproto.Int64(consts.Deleted) + ids[i] = util.DerefInt64(accountrelation.Id) + } + err = p.store.CreateAccountRelationHis(ctx, list) + if err != nil { + logger.Error("CreateAccountRelationHis fail, err: %v", err) + return err + } + + //3.真删除原有用户关系 + err = p.store.DeleteAccountRelationByIds(ctx, ids) + if err != nil { + logger.Error("DeleteAccountRelationByIds fail, err: %v", err) + return err + } + return nil +} + func (p *AccountRelation) OpListBySentence(ctx *gin.Context, req *accountrelationproto.OpListBySentenceReq) (*dbstruct.AccountRelation, error) { accountrelation, err := p.store.GetAccountRelationBySentence(ctx, req) if err != nil { diff --git a/app/mix/service/logic/contact_customer_service.go b/app/mix/service/logic/contact_customer_service.go index 05552362..a171061f 100644 --- a/app/mix/service/logic/contact_customer_service.go +++ b/app/mix/service/logic/contact_customer_service.go @@ -63,6 +63,15 @@ func (p *ContactCustomerService) OpDelete(ctx *gin.Context, id int64) error { return nil } +func (p *ContactCustomerService) OpDeleteBySessionId(ctx *gin.Context, sessionId int64) error { + err := p.store.DeleteContactCustomerServiceBySessionId(ctx, sessionId) + if err != nil { + logger.Error("DeleteContactCustomerServiceBySessionId fail, err: %v", err) + return err + } + return nil +} + func (p *ContactCustomerService) OpList(ctx *gin.Context, req *contact_customer_serviceproto.OpListReq) ([]*dbstruct.ContactCustomerService, error) { list, err := p.store.GetContactCustomerServiceList(ctx, req) if err != nil { diff --git a/app/mix/service/logic/contact_customer_service_session.go b/app/mix/service/logic/contact_customer_service_session.go index 0a47a52f..e152a235 100644 --- a/app/mix/service/logic/contact_customer_service_session.go +++ b/app/mix/service/logic/contact_customer_service_session.go @@ -53,6 +53,15 @@ func (p *ContactCustomerServiceSession) OpUpdate(ctx *gin.Context, req *contact_ return nil } +func (p *ContactCustomerServiceSession) OpDelete(ctx *gin.Context, id int64) error { + err := p.store.DeleteContactCustomerServiceSession(ctx, id) + if err != nil { + logger.Error("DeleteContactCustomerServiceSession fail, err: %v", err) + return err + } + return nil +} + func (p *ContactCustomerServiceSession) OpListByMid(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListByMidReq) (*dbstruct.ContactCustomerServiceSession, error) { session, err := p.store.GetContactCustomerServiceSessionListByMid(ctx, req) if err != nil { diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 08bb0755..0089ac76 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -626,3 +626,26 @@ func (s *Service) utilStringifyContactCustomerServices(ctx *gin.Context, contact msg = msgBuilder.String() return } + +func (s *Service) utilDeleteContactCustomerServiceByMid(ctx *gin.Context, mid int64) (err error) { + session, err := _DefaultContactCustomerServiceSession.OpListByMid(ctx, &contact_customer_service_sessionproto.OpListByMidReq{ + Mid: goproto.Int64(mid), + }) + if err != nil { + logger.Error("_DefaultContactCustomerServiceSession OpListByMid fail, err: %v", err) + return + } + if session != nil { + // 删除联系客服对话 + if err = _DefaultContactCustomerServiceSession.OpDelete(ctx, util.DerefInt64(session.Id)); err != nil { + logger.Error("_DefaultContactCustomerServiceSession OpDelete fail, err: %v", err) + return + } + // 删除联系客服 + if err = _DefaultContactCustomerService.OpDeleteBySessionId(ctx, util.DerefInt64(session.Id)); err != nil { + logger.Error("_DefaultContactCustomerService OpDeleteBySessionId fail, err: %v", err) + return + } + } + return +} -- 2.41.0 From e95ca7f4f109331c242c504b61d34b73aaa7af55 Mon Sep 17 00:00:00 2001 From: chenhao Date: Tue, 5 Mar 2024 13:21:22 +0800 Subject: [PATCH 3/4] revert 5fab9ff0fd1eb741a17629919b813074238e7889 revert By Robin at 20240304; cancel account function at mongo part --- api/errcode/errcode.go | 6 +- api/proto/account/proto/account_api.go | 13 ---- app/mix/controller/account_api.go | 12 ---- app/mix/controller/init.go | 1 - app/mix/dao/mongo.go | 51 --------------- app/mix/service/apiservice.go | 65 ------------------- app/mix/service/logic/accountrelation.go | 33 ---------- .../service/logic/contact_customer_service.go | 9 --- .../logic/contact_customer_service_session.go | 9 --- app/mix/service/utilservice.go | 23 ------- 10 files changed, 2 insertions(+), 220 deletions(-) diff --git a/api/errcode/errcode.go b/api/errcode/errcode.go index ad62026f..9bf99398 100644 --- a/api/errcode/errcode.go +++ b/api/errcode/errcode.go @@ -40,7 +40,6 @@ var ErrCodeMsgMap = map[ErrCode]string{ ErrCodeAccountNotExist: "账户信息不存在", ErrCodeAccountInviterNotExist: "邀请人不存在", ErrCodeAccountInviterIsNotAStreamer: "邀请人非主播", - ErrCodeNonUserAccountCancellation: "非普通用户注销需联系客服手工操作", ErrCodeVasSrvFail: "增值服务错误", ErrCodeVasProductNotExist: "商品不存在", @@ -205,9 +204,8 @@ const ( ErrCodeAccountSrvOk ErrCode = ErrCodeOk ErrCodeAccountSrvFail ErrCode = -6001 //账户服务错误 ErrCodeAccountNotExist ErrCode = -6002 //账户信息不存在 - ErrCodeAccountInviterNotExist ErrCode = -6003 //邀请人不存在 - ErrCodeAccountInviterIsNotAStreamer ErrCode = -6004 //邀请人非主播 - ErrCodeNonUserAccountCancellation ErrCode = -6005 //非普通用户注销 + ErrCodeAccountInviterNotExist ErrCode = -6003 //邀请人不存在, + ErrCodeAccountInviterIsNotAStreamer ErrCode = -6004 //邀请人非主播, // Vas: 7xxx ErrCodeVasSrvOk ErrCode = ErrCodeOk diff --git a/api/proto/account/proto/account_api.go b/api/proto/account/proto/account_api.go index 7834cf00..2f1fcdaf 100644 --- a/api/proto/account/proto/account_api.go +++ b/api/proto/account/proto/account_api.go @@ -207,16 +207,3 @@ type ApiUpdateByIdsResp struct { base.BaseResponse Data *ApiUpdateByIdsData `json:"data"` } - -// api 注销 -type ApiCancelReq struct { - base.BaseRequest -} - -type ApiCancelData struct { -} - -type ApiCancelResp struct { - base.BaseResponse - Data *ApiCancelData `json:"data"` -} diff --git a/app/mix/controller/account_api.go b/app/mix/controller/account_api.go index f3b4d04b..0f7854d5 100644 --- a/app/mix/controller/account_api.go +++ b/app/mix/controller/account_api.go @@ -24,18 +24,6 @@ func ApiUpdateAccount(ctx *gin.Context) { ReplyOk(ctx, nil) } -func ApiCancelAccount(ctx *gin.Context) { - req := ctx.MustGet("client_req").(*accountproto.ApiCancelReq) - ec := service.DefaultService.ApiCancelAccount(ctx, req) - if ec != errcode.ErrCodeAccountSrvOk { - logger.Error("ApiCancelAccount fail, req: %v, ec: %v", util.ToJson(req), ec) - ReplyErrCodeMsg(ctx, ec) - return - } - - ReplyOk(ctx, nil) -} - func ApiGetAccountListByMid(ctx *gin.Context) { req := ctx.MustGet("client_req").(*accountproto.ApiListByMidReq) diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index ab07ffce..d6633c5d 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -74,7 +74,6 @@ func Init(r *gin.Engine) { // 账号,用户端支持改、查自己、查别人、经验增长,不支持增删 apiAccountGroup := r.Group("/api/account", PrepareToC()) apiAccountGroup.POST("update", middleware.JSONParamValidator(accountproto.ApiUpdateReq{}), middleware.JwtAuthenticator(), middleware.RequestDecryptor(), ApiUpdateAccount) - apiAccountGroup.POST("cancel", middleware.JSONParamValidator(accountproto.ApiCancelReq{}), middleware.JwtAuthenticator(), ApiCancelAccount) apiAccountGroup.POST("list_by_mid", middleware.JSONParamValidator(accountproto.ApiListByMidReq{}), middleware.JwtAuthenticator(), ApiGetAccountListByMid) //apiAccountGroup.POST("list_by_user_id", middleware.JSONParamValidator(accountproto.ApiListByUserIdReq{}), middleware.JwtAuthenticator(), ApiGetAccountListByUserId) apiAccountGroup.POST("list_others_by_mid", middleware.JSONParamValidator(accountproto.ApiListOthersByMidReq{}), middleware.JwtAuthenticator(), ApiGetAccountListForOthersByMid) diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 8a3ae916..7ff1516f 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -1566,31 +1566,6 @@ func (m *Mongo) DeleteAccountRelationByIds(ctx *gin.Context, ids []int64) error return err } -func (m *Mongo) GetAccountRelationByMid(ctx *gin.Context, mid int64) ([]*dbstruct.AccountRelation, error) { - col := m.getColAccountRelation() - - list := make([]*dbstruct.AccountRelation, 0) - - query := qmgo.M{ - "$and": []qmgo.M{ - { - "sub_mid": mid, - }, - { - "obj_mid": mid, - }, - }, - "del_flag": 0, - } - - err := col.Find(ctx, query).All(&list) - if err == qmgo.ErrNoSuchDocuments { - err = nil - return list, err - } - return list, err -} - func (m *Mongo) GetAccountRelationListBySubMidAndPredicate(ctx *gin.Context, req *accountrelationproto.OpListBySubMidAndPredicateReq) ([]*dbstruct.AccountRelation, error) { list := make([]*dbstruct.AccountRelation, 0) col := m.getColAccountRelation() @@ -2450,20 +2425,6 @@ func (m *Mongo) DeleteContactCustomerService(ctx *gin.Context, id int64) error { return err } -func (m *Mongo) DeleteContactCustomerServiceBySessionId(ctx *gin.Context, sessionId int64) error { - col := m.getColContactCustomerService() - update := qmgo.M{ - "$set": qmgo.M{ - "del_flag": 1, - }, - } - filter := qmgo.M{ - "session_id": sessionId, - } - _, err := col.UpdateAll(ctx, filter, update) - return err -} - func (m *Mongo) GetContactCustomerServiceList(ctx *gin.Context, req *contact_customer_service_proto.OpListReq) ([]*dbstruct.ContactCustomerService, error) { list := make([]*dbstruct.ContactCustomerService, 0) col := m.getColContactCustomerService() @@ -3165,18 +3126,6 @@ func (m *Mongo) UpdateContactCustomerServiceSession(ctx *gin.Context, contact_cu return err } -func (m *Mongo) DeleteContactCustomerServiceSession(ctx *gin.Context, id int64) error { - col := m.getColContactCustomerServiceSession() - - update := qmgo.M{ - "$set": qmgo.M{ - "del_flag": 1, - }, - } - err := col.UpdateId(ctx, id, update) - return err -} - func (m *Mongo) GetContactCustomerServiceSessionListByMid(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListByMidReq) (*dbstruct.ContactCustomerServiceSession, error) { session := &dbstruct.ContactCustomerServiceSession{} col := m.getColContactCustomerServiceSession() diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index e0e49c93..cfafedb5 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -363,71 +363,6 @@ func (s *Service) ApiUpdateAccount(ctx *gin.Context, req *accountproto.ApiUpdate return } -func (s *Service) ApiCancelAccount(ctx *gin.Context, req *accountproto.ApiCancelReq) (ec errcode.ErrCode) { - ec = errcode.ErrCodeAccountSrvOk - - // 查询账户信息 - account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{ - Mid: goproto.Int64(req.Mid), - }) - if err != nil { - logger.Error("OpListByMid fail, err: %v", err) - ec = errcode.ErrCodeAccountSrvFail - return - } - if account == nil { - logger.Error("No account entity was found!") - ec = errcode.ErrCodeAccountNotExist - return - } - - if util.DerefInt64(account.Role) != consts.User { - logger.Error("Cancellation of non-user account requires manual operation") - ec = errcode.ErrCodeNonUserAccountCancellation - return - } - - // 删除账号 - err = _DefaultAccount.OpDelete(ctx, util.DerefInt64(account.Mid)) - if err != nil { - logger.Error("OpDelete fail, err: %v", err) - ec = errcode.ErrCodeAccountSrvFail - return - } - logger.Info("account deletion finished...") - - // 删除主播认证审批 - err = _DefaultStreamerAuthApproval.OpDelete(ctx, &streamerauthapprovalproto.ApiDeleteReq{ - Mid: goproto.Int64(req.Mid), - }) - if err != qmgo.ErrNoSuchDocuments && err != nil { - logger.Error("_DefaultStreamerAuthApproval OpDelete fail, req: %v, err: %v", req, err) - ec = errcode.ErrCodeStreamerAuthApprovalSrvFail - return - } - logger.Info("streamer_auth_approval deletion finished...") - - // 删除用户关系 - err = _DefaultAccountRelation.OpDeleteByMid(ctx, req.Mid) - if err != qmgo.ErrNoSuchDocuments && err != nil { - logger.Error("_DefaultAccountRelation OpDeleteByMid fail, req: %v, err: %v", req, err) - ec = errcode.ErrCodeAccountRelationSrvFail - return - } - logger.Info("account_relation deletion finished...") - - // 删除联系客服 - err = s.utilDeleteContactCustomerServiceByMid(ctx, req.Mid) - if err != qmgo.ErrNoSuchDocuments && err != nil { - logger.Error("utilDeleteContactCustomerServiceByMid fail, req: %v, err: %v", req, err) - ec = errcode.ErrCodeAccountRelationSrvFail - return - } - logger.Info("contact_customer_service deletion finished...") - - return -} - func (s *Service) ApiGetAccountListByMid(ctx *gin.Context, req *accountproto.ApiListByMidReq) (vo *accountproto.ApiListVO, ec errcode.ErrCode) { ec = errcode.ErrCodeAccountSrvOk diff --git a/app/mix/service/logic/accountrelation.go b/app/mix/service/logic/accountrelation.go index 820a13d2..f4db4911 100644 --- a/app/mix/service/logic/accountrelation.go +++ b/app/mix/service/logic/accountrelation.go @@ -91,39 +91,6 @@ func (p *AccountRelation) OpDelete(ctx *gin.Context, req *accountrelationproto.O return nil } -func (p *AccountRelation) OpDeleteByMid(ctx *gin.Context, mid int64) error { - //1.查出原有用户关系 - list, err := p.store.GetAccountRelationByMid(ctx, mid) - if len(list) == 0 { - logger.Error("GetAccountRelationByMid fail, err: %v", qmgo.ErrNoSuchDocuments) - return qmgo.ErrNoSuchDocuments - } - if err != nil { - logger.Error("GetAccountRelationByMid fail, err: %v", err) - return err - } - - //2.用户关系标志删除后转存到历史表,并取出ids - ids := make([]int64, len(list)) - for i, accountrelation := range list { - accountrelation.DelFlag = goproto.Int64(consts.Deleted) - ids[i] = util.DerefInt64(accountrelation.Id) - } - err = p.store.CreateAccountRelationHis(ctx, list) - if err != nil { - logger.Error("CreateAccountRelationHis fail, err: %v", err) - return err - } - - //3.真删除原有用户关系 - err = p.store.DeleteAccountRelationByIds(ctx, ids) - if err != nil { - logger.Error("DeleteAccountRelationByIds fail, err: %v", err) - return err - } - return nil -} - func (p *AccountRelation) OpListBySentence(ctx *gin.Context, req *accountrelationproto.OpListBySentenceReq) (*dbstruct.AccountRelation, error) { accountrelation, err := p.store.GetAccountRelationBySentence(ctx, req) if err != nil { diff --git a/app/mix/service/logic/contact_customer_service.go b/app/mix/service/logic/contact_customer_service.go index a171061f..05552362 100644 --- a/app/mix/service/logic/contact_customer_service.go +++ b/app/mix/service/logic/contact_customer_service.go @@ -63,15 +63,6 @@ func (p *ContactCustomerService) OpDelete(ctx *gin.Context, id int64) error { return nil } -func (p *ContactCustomerService) OpDeleteBySessionId(ctx *gin.Context, sessionId int64) error { - err := p.store.DeleteContactCustomerServiceBySessionId(ctx, sessionId) - if err != nil { - logger.Error("DeleteContactCustomerServiceBySessionId fail, err: %v", err) - return err - } - return nil -} - func (p *ContactCustomerService) OpList(ctx *gin.Context, req *contact_customer_serviceproto.OpListReq) ([]*dbstruct.ContactCustomerService, error) { list, err := p.store.GetContactCustomerServiceList(ctx, req) if err != nil { diff --git a/app/mix/service/logic/contact_customer_service_session.go b/app/mix/service/logic/contact_customer_service_session.go index e152a235..0a47a52f 100644 --- a/app/mix/service/logic/contact_customer_service_session.go +++ b/app/mix/service/logic/contact_customer_service_session.go @@ -53,15 +53,6 @@ func (p *ContactCustomerServiceSession) OpUpdate(ctx *gin.Context, req *contact_ return nil } -func (p *ContactCustomerServiceSession) OpDelete(ctx *gin.Context, id int64) error { - err := p.store.DeleteContactCustomerServiceSession(ctx, id) - if err != nil { - logger.Error("DeleteContactCustomerServiceSession fail, err: %v", err) - return err - } - return nil -} - func (p *ContactCustomerServiceSession) OpListByMid(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListByMidReq) (*dbstruct.ContactCustomerServiceSession, error) { session, err := p.store.GetContactCustomerServiceSessionListByMid(ctx, req) if err != nil { diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 0089ac76..08bb0755 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -626,26 +626,3 @@ func (s *Service) utilStringifyContactCustomerServices(ctx *gin.Context, contact msg = msgBuilder.String() return } - -func (s *Service) utilDeleteContactCustomerServiceByMid(ctx *gin.Context, mid int64) (err error) { - session, err := _DefaultContactCustomerServiceSession.OpListByMid(ctx, &contact_customer_service_sessionproto.OpListByMidReq{ - Mid: goproto.Int64(mid), - }) - if err != nil { - logger.Error("_DefaultContactCustomerServiceSession OpListByMid fail, err: %v", err) - return - } - if session != nil { - // 删除联系客服对话 - if err = _DefaultContactCustomerServiceSession.OpDelete(ctx, util.DerefInt64(session.Id)); err != nil { - logger.Error("_DefaultContactCustomerServiceSession OpDelete fail, err: %v", err) - return - } - // 删除联系客服 - if err = _DefaultContactCustomerService.OpDeleteBySessionId(ctx, util.DerefInt64(session.Id)); err != nil { - logger.Error("_DefaultContactCustomerService OpDeleteBySessionId fail, err: %v", err) - return - } - } - return -} -- 2.41.0 From e5bc859d98882e002380cfa0d4b43bdc3e39559c Mon Sep 17 00:00:00 2001 From: Leufolium Date: Wed, 6 Mar 2024 20:07:34 +0800 Subject: [PATCH 4/4] by Robin at 20240306; mix test sql conn info --- etc/mix/mix-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/mix/mix-test.yaml b/etc/mix/mix-test.yaml index 5efaa1bb..cd30bb7f 100644 --- a/etc/mix/mix-test.yaml +++ b/etc/mix/mix-test.yaml @@ -22,7 +22,7 @@ mix_mongo: mix_mysql: uri: "127.0.0.1:3306" username: "root" - password: "Xbz@114514" + password: "Wishpal@2023" timeout: 3 read_timeout_s: 5 write_timeout_s: 3 -- 2.41.0