diff --git a/api/proto/contact_customer_service_session/proto/contact_customer_service_session_op.go b/api/proto/contact_customer_service_session/proto/contact_customer_service_session_op.go index c04a55bb..8105949e 100644 --- a/api/proto/contact_customer_service_session/proto/contact_customer_service_session_op.go +++ b/api/proto/contact_customer_service_session/proto/contact_customer_service_session_op.go @@ -34,7 +34,7 @@ type OpUpdateResp struct { Data *OpUpdateData `json:"data"` } -// op 列表 +// op 列表-mid单查 type OpListByMidReq struct { base.BaseRequest Mid *int64 `json:"mid"` @@ -49,6 +49,21 @@ type OpListByMidResp struct { Data *OpListByMidData `json:"data"` } +// op 列表-session_id单查 +type OpListBySessionIdReq struct { + base.BaseRequest + SessionId *int64 `json:"session_id"` +} + +type OpListBySessionIdData struct { + Session *dbstruct.ContactCustomerServiceSession `json:"session"` +} + +type OpListBySessionIdResp struct { + base.BaseResponse + Data *OpListBySessionIdData `json:"data"` +} + // op 列出所有对话 type OpListReq struct { base.BaseRequest diff --git a/api/proto/contact_customer_service_session/proto/not_null_def_op.go b/api/proto/contact_customer_service_session/proto/not_null_def_op.go index b7a47650..71018ea8 100644 --- a/api/proto/contact_customer_service_session/proto/not_null_def_op.go +++ b/api/proto/contact_customer_service_session/proto/not_null_def_op.go @@ -20,3 +20,10 @@ func (p *OpListByMidReq) ProvideNotNullValue() (params []*validator.JsonParam) { params = append(params, validator.NewInt64PtrParam("mid should not be null", p.Mid)) return params } + +// op 列表-session_id单查 +func (p *OpListBySessionIdReq) ProvideNotNullValue() (params []*validator.JsonParam) { + params = make([]*validator.JsonParam, 0) + params = append(params, validator.NewInt64PtrParam("session_id should not be null", p.SessionId)) + return params +} diff --git a/app/mix/controller/contact_customer_service_session_op.go b/app/mix/controller/contact_customer_service_session_op.go index 3dbde2cc..925c1873 100644 --- a/app/mix/controller/contact_customer_service_session_op.go +++ b/app/mix/controller/contact_customer_service_session_op.go @@ -41,6 +41,21 @@ func OpGetContactCustomerServiceSessionListByMid(ctx *gin.Context) { ReplyOk(ctx, data) } +func OpGetContactCustomerServiceSessionListBySessionId(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*contact_customer_service_sessionproto.OpListBySessionIdReq) + session, ec := service.DefaultService.OpGetContactCustomerServiceSessionListBySessionId(ctx, req) + if ec != errcode.ErrCodeContactCustomerServiceSessionSrvOk { + logger.Error("OpGetContactCustomerServiceSessionListBySessionId fail, req: %v, ec: %v", util.ToJson(req), ec) + ReplyErrCodeMsg(ctx, ec) + return + } + + data := &contact_customer_service_sessionproto.OpListBySessionIdData{ + Session: session, + } + ReplyOk(ctx, data) +} + func OpGetContactCustomerServiceSessionList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*contact_customer_service_sessionproto.OpListReq) list, ec := service.DefaultService.OpGetContactCustomerServiceSessionList(ctx, req) diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 4d61054a..e0102dcc 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -2552,6 +2552,21 @@ func (m *Mongo) GetContactCustomerServiceSessionListByMid(ctx *gin.Context, req return session, err } +func (m *Mongo) GetContactCustomerServiceSessionListBySessionId(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListBySessionIdReq) (*dbstruct.ContactCustomerServiceSession, error) { + session := &dbstruct.ContactCustomerServiceSession{} + col := m.getColContactCustomerServiceSession() + query := qmgo.M{ + "session_id": util.DerefInt64(req.SessionId), + "del_flag": 0, + } + err := col.Find(ctx, query).One(&session) + if err == qmgo.ErrNoSuchDocuments { + err = nil + return nil, err + } + return session, err +} + func (m *Mongo) GetContactCustomerServiceSessionList(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListReq) ([]*dbstruct.ContactCustomerServiceSession, error) { list := make([]*dbstruct.ContactCustomerServiceSession, 0) col := m.getColContactCustomerServiceSession() diff --git a/app/mix/service/logic/contact_customer_service_session.go b/app/mix/service/logic/contact_customer_service_session.go index 2827bc73..40116a78 100644 --- a/app/mix/service/logic/contact_customer_service_session.go +++ b/app/mix/service/logic/contact_customer_service_session.go @@ -62,6 +62,15 @@ func (p *ContactCustomerServiceSession) OpListByMid(ctx *gin.Context, req *conta return session, nil } +func (p *ContactCustomerServiceSession) OpListBySessionId(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListBySessionIdReq) (*dbstruct.ContactCustomerServiceSession, error) { + session, err := p.store.GetContactCustomerServiceSessionListBySessionId(ctx, req) + if err != nil { + logger.Error("GetContactCustomerServiceSessionList fail, err: %v", err) + return nil, err + } + return session, nil +} + func (p *ContactCustomerServiceSession) OpList(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListReq) ([]*dbstruct.ContactCustomerServiceSession, error) { list, err := p.store.GetContactCustomerServiceSessionList(ctx, req) if err != nil { diff --git a/app/mix/service/opservice_business_validation.go b/app/mix/service/opservice_business_validation.go index c0d8cd2a..a19d14ab 100644 --- a/app/mix/service/opservice_business_validation.go +++ b/app/mix/service/opservice_business_validation.go @@ -1056,6 +1056,23 @@ func (s *Service) OpGetContactCustomerServiceSessionListByMidBusinessValidate(ct return } +func (s *Service) OpGetContactCustomerServiceSessionListBySessionIdBusinessValidate(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListBySessionIdReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk + + // 1.业务校验 + result := businessvalidator.NewAuthBusinessValidator(ctx, req). + QueryAccount(_DefaultAccount.OpListByMid). + EnsureAccountExist(). + EnsureIsOpRole(). + Validate(). + Collect() + if ec = result[0].(errcode.ErrCode); ec != errcode.ErrCodeOk { + logger.Error("OpGetContactCustomerServiceSessionListBySessionId business validation failed") + return + } + return +} + func (s *Service) OpGetContactCustomerServiceSessionListBusinessValidate(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 70ca64e8..38fdb9ff 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -2455,6 +2455,23 @@ func (s *Service) OpGetContactCustomerServiceSessionListByMid(ctx *gin.Context, return } +func (s *Service) OpGetContactCustomerServiceSessionListBySessionId(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListBySessionIdReq) (session *dbstruct.ContactCustomerServiceSession, ec errcode.ErrCode) { + + ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk + + if ec = s.OpGetContactCustomerServiceSessionListBySessionIdBusinessValidate(ctx, req); ec != errcode.ErrCodeContactCustomerServiceSessionSrvOk { + return + } + + session, err := _DefaultContactCustomerServiceSession.OpListBySessionId(ctx, req) + if err != nil { + logger.Error("OpListBySessionId fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeContactCustomerServiceSessionSrvFail + return + } + return +} + func (s *Service) OpGetContactCustomerServiceSessionList(ctx *gin.Context, req *contact_customer_service_sessionproto.OpListReq) (list []*dbstruct.ContactCustomerServiceSession, ec errcode.ErrCode) { ec = errcode.ErrCodeContactCustomerServiceSessionSrvOk