mainconflict #192

Merged
chenhao merged 9 commits from mainconflict into main 2024-03-19 00:02:18 +08:00
10 changed files with 2 additions and 220 deletions
Showing only changes of commit e95ca7f4f1 - Show all commits

View File

@ -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

View File

@ -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"`
}

View File

@ -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)

View File

@ -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)

View File

@ -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()

View File

@ -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

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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
}