فهرست منبع

Merge remote-tracking branch 'origin/feature/v1.2.6' into dev/v1.2.6_dx

# Conflicts:
#	api/messagecenter/internal/handler/routes.go
#	api/messagecenter/internal/types/types.go
#	api/messagecenter/messagecenter.api
#	entity/util.go
#	go.mod
#	go.sum
#	rpc/messagecenter/internal/server/messagecenterserver.go
#	rpc/messagecenter/messagecenter.proto
#	rpc/messagecenter/messagecenter/messagecenter.go
#	rpc/messagecenter/messagecenter/messagecenter.pb.go
#	rpc/messagecenter/messagecenter/messagecenter_grpc.pb.go
#	service/message_mail_box.go
duxin 2 سال پیش
والد
کامیت
08554890ba
52فایلهای تغییر یافته به همراه4722 افزوده شده و 1257 حذف شده
  1. 1 1
      Makefile
  2. 2 2
      README.md
  3. 0 10
      api/messagecenter/etc/messagecenter-api.yaml
  4. 28 0
      api/messagecenter/internal/handler/chatgroupaddhandler.go
  5. 28 0
      api/messagecenter/internal/handler/chatgroupjoinhandler.go
  6. 28 0
      api/messagecenter/internal/handler/chatgrouplisthandler.go
  7. 28 0
      api/messagecenter/internal/handler/chatgrouppersonhandler.go
  8. 28 0
      api/messagecenter/internal/handler/groupnameupdatehandler.go
  9. 28 0
      api/messagecenter/internal/handler/groupnoticeaddhandler.go
  10. 28 0
      api/messagecenter/internal/handler/groupnoticegethandler.go
  11. 28 0
      api/messagecenter/internal/handler/groupnoticeupdatehandler.go
  12. 31 6
      api/messagecenter/internal/handler/routes.go
  13. 47 0
      api/messagecenter/internal/logic/chatgroupaddlogic.go
  14. 30 0
      api/messagecenter/internal/logic/chatgroupjoinlogic.go
  15. 30 0
      api/messagecenter/internal/logic/chatgrouplistlogic.go
  16. 30 0
      api/messagecenter/internal/logic/chatgrouppersonlogic.go
  17. 30 0
      api/messagecenter/internal/logic/groupnameupdatelogic.go
  18. 30 0
      api/messagecenter/internal/logic/groupnoticeaddlogic.go
  19. 30 0
      api/messagecenter/internal/logic/groupnoticegetlogic.go
  20. 30 0
      api/messagecenter/internal/logic/groupnoticeupdatelogic.go
  21. 41 23
      api/messagecenter/internal/types/types.go
  22. 53 32
      api/messagecenter/messagecenter.api
  23. 24 14
      entity/db.go
  24. 30 69
      entity/util.go
  25. 6 6
      go.mod
  26. 624 15
      go.sum
  27. 21 1
      rpc/messagecenter/etc/db.yaml
  28. 0 7
      rpc/messagecenter/etc/messagecenter.yaml
  29. 49 23
      rpc/messagecenter/init/init.go
  30. 2 1
      rpc/messagecenter/internal/config/config.go
  31. 37 0
      rpc/messagecenter/internal/logic/chatgroupaddlogic.go
  32. 34 0
      rpc/messagecenter/internal/logic/chatgroupjoinlogic.go
  33. 49 0
      rpc/messagecenter/internal/logic/chatgrouplistlogic.go
  34. 56 0
      rpc/messagecenter/internal/logic/chatgrouppersonlogic.go
  35. 31 0
      rpc/messagecenter/internal/logic/entpersonslistlogic.go
  36. 34 0
      rpc/messagecenter/internal/logic/groupnameupdatelogic.go
  37. 34 0
      rpc/messagecenter/internal/logic/groupnoticeaddlogic.go
  38. 42 0
      rpc/messagecenter/internal/logic/groupnoticegetlogic.go
  39. 34 0
      rpc/messagecenter/internal/logic/groupnoticeupdatelogic.go
  40. 54 18
      rpc/messagecenter/internal/server/messagecenterserver.go
  41. 23 0
      rpc/messagecenter/logs/access.log
  42. 2 0
      rpc/messagecenter/logs/error.log
  43. 167 81
      rpc/messagecenter/messagecenter.proto
  44. 73 22
      rpc/messagecenter/messagecenter/messagecenter.go
  45. 1647 499
      rpc/messagecenter/messagecenter/messagecenter.pb.go
  46. 280 52
      rpc/messagecenter/messagecenter/messagecenter_grpc.pb.go
  47. 225 0
      service/chat_group.go
  48. 285 0
      service/chat_group_test.go
  49. 59 0
      service/ent_address_book.go
  50. 34 0
      service/ent_address_book_test.go
  51. 144 372
      service/message_mail_box.go
  52. 13 3
      service/message_mail_box_test.go

+ 1 - 1
Makefile

@@ -2,7 +2,7 @@ SHELL=cmd
 .PHONY: all
 all:  fmt tidy lint
 genRpc:
-	cd rpc/messagecenter && goctl rpc protoc messageCenter.proto --go_out=./ --go-grpc_out=./ --zrpc_out=.
+	cd rpc/messagecenter && goctl rpc protoc messagecenter.proto --go_out=./ --go-grpc_out=./ --zrpc_out=.
 	@echo "===========> genRpc finish"
 
 genApi:

+ 2 - 2
README.md

@@ -5,9 +5,9 @@
 `go mod tidy`
 ### 生成代码命令
 - api 生成代码
-`goctl api go -api messageCenter.api -dir .`
+`goctl api go -api messagecenter.api -dir .`
 - rpc 生成代码
-`goctl rpc proto -src messageCenter.proto -dir .
+`goctl rpc proto -src messagecenter.proto -dir .
 `
 goctl 1.1.6 
 

+ 0 - 10
api/messagecenter/etc/messagecenter-api.yaml

@@ -12,16 +12,6 @@ Gateway:
   ServerCode: messagecenter
   Etcd:
     - 127.0.0.1:2379
-IsShunt: true
-ZhiCiUrl:
-  Pc: zcpc
-  App: zcapp
-  Wx: zcapp
-MessageUrl:
-  Pc: messagepc
-  App: messageapp
-  Wx: zcapp
-ShuntProbability: 70
 
 
 

+ 28 - 0
api/messagecenter/internal/handler/chatgroupaddhandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/logic"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func chatGroupAddHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ChatGroupAddReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewChatGroupAddLogic(r.Context(), svcCtx)
+		resp, err := l.ChatGroupAdd(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
api/messagecenter/internal/handler/chatgroupjoinhandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/logic"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func chatGroupJoinHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ChatGroupJoinReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewChatGroupJoinLogic(r.Context(), svcCtx)
+		resp, err := l.ChatGroupJoin(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
api/messagecenter/internal/handler/chatgrouplisthandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/logic"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func chatGroupListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ChatGroupListReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewChatGroupListLogic(r.Context(), svcCtx)
+		resp, err := l.ChatGroupList(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
api/messagecenter/internal/handler/chatgrouppersonhandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/logic"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func chatGroupPersonHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ChatGroupPersonReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewChatGroupPersonLogic(r.Context(), svcCtx)
+		resp, err := l.ChatGroupPerson(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
api/messagecenter/internal/handler/groupnameupdatehandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/logic"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func groupNameUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.GroupNameUpdateReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewGroupNameUpdateLogic(r.Context(), svcCtx)
+		resp, err := l.GroupNameUpdate(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
api/messagecenter/internal/handler/groupnoticeaddhandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/logic"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func groupNoticeAddHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.GroupNoticeAddReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewGroupNoticeAddLogic(r.Context(), svcCtx)
+		resp, err := l.GroupNoticeAdd(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
api/messagecenter/internal/handler/groupnoticegethandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/logic"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func groupNoticeGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ChatGroupPersonReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewGroupNoticeGetLogic(r.Context(), svcCtx)
+		resp, err := l.GroupNoticeGet(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 28 - 0
api/messagecenter/internal/handler/groupnoticeupdatehandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/logic"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func groupNoticeUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.GroupNameUpdateReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewGroupNoticeUpdateLogic(r.Context(), svcCtx)
+		resp, err := l.GroupNoticeUpdate(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 31 - 6
api/messagecenter/internal/handler/routes.go

@@ -54,18 +54,43 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/message/withdrawMessage",
-				Handler: withdrawMessageHandler(serverCtx),
+				Path:    "/message/chatGroupList",
+				Handler: chatGroupListHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/message/appraiseMessage",
-				Handler: AppraiseMessageHandler(serverCtx),
+				Path:    "/message/chatGroupAdd",
+				Handler: chatGroupAddHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/message/conversationList",
-				Handler: ConversationListHandler(serverCtx),
+				Path:    "/message/chatGroupPerson",
+				Handler: chatGroupPersonHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/message/chatGroupJoin",
+				Handler: chatGroupJoinHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/message/groupNameUpdate",
+				Handler: groupNameUpdateHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/message/groupNoticeAdd",
+				Handler: groupNoticeAddHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/message/groupNoticeUpdate",
+				Handler: groupNoticeUpdateHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/message/groupNoticeGet",
+				Handler: groupNoticeGetHandler(serverCtx),
 			},
 		},
 	)

+ 47 - 0
api/messagecenter/internal/logic/chatgroupaddlogic.go

@@ -0,0 +1,47 @@
+package logic
+
+import (
+	quitl "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ChatGroupAddLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewChatGroupAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatGroupAddLogic {
+	return &ChatGroupAddLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ChatGroupAddLogic) ChatGroupAdd(req *types.ChatGroupAddReq) (resp *types.CommonRes, err error) {
+	// todo: add your logic here and delete this line
+	userIdArr := []int64{}
+	for _, v := range req.UserIdArr {
+		userIdArr = append(userIdArr, quitl.Int64All(encrypt.SE.Decode4Hex(v)))
+	}
+	result, err := l.svcCtx.Message.ChatGroupAdd(l.ctx, &messagecenter.ChatGroupAddReq{
+		PositionId: req.PositionId,
+		EntId:      req.EntId,
+		UserIdArr:  userIdArr,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonRes{
+		Error_msg:  result.ErrorMsg,
+		Error_code: int(result.ErrorCode),
+	}, nil
+}

+ 30 - 0
api/messagecenter/internal/logic/chatgroupjoinlogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ChatGroupJoinLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewChatGroupJoinLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatGroupJoinLogic {
+	return &ChatGroupJoinLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ChatGroupJoinLogic) ChatGroupJoin(req *types.ChatGroupJoinReq) (resp *types.CommonRes, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 30 - 0
api/messagecenter/internal/logic/chatgrouplistlogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ChatGroupListLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewChatGroupListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatGroupListLogic {
+	return &ChatGroupListLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ChatGroupListLogic) ChatGroupList(req *types.ChatGroupListReq) (resp *types.CommonRes, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 30 - 0
api/messagecenter/internal/logic/chatgrouppersonlogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ChatGroupPersonLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewChatGroupPersonLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatGroupPersonLogic {
+	return &ChatGroupPersonLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ChatGroupPersonLogic) ChatGroupPerson(req *types.ChatGroupPersonReq) (resp *types.CommonRes, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 30 - 0
api/messagecenter/internal/logic/groupnameupdatelogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GroupNameUpdateLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGroupNameUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupNameUpdateLogic {
+	return &GroupNameUpdateLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *GroupNameUpdateLogic) GroupNameUpdate(req *types.GroupNameUpdateReq) (resp *types.CommonRes, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 30 - 0
api/messagecenter/internal/logic/groupnoticeaddlogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GroupNoticeAddLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGroupNoticeAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupNoticeAddLogic {
+	return &GroupNoticeAddLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *GroupNoticeAddLogic) GroupNoticeAdd(req *types.GroupNoticeAddReq) (resp *types.CommonRes, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 30 - 0
api/messagecenter/internal/logic/groupnoticegetlogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GroupNoticeGetLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGroupNoticeGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupNoticeGetLogic {
+	return &GroupNoticeGetLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *GroupNoticeGetLogic) GroupNoticeGet(req *types.ChatGroupPersonReq) (resp *types.CommonRes, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 30 - 0
api/messagecenter/internal/logic/groupnoticeupdatelogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GroupNoticeUpdateLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGroupNoticeUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupNoticeUpdateLogic {
+	return &GroupNoticeUpdateLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *GroupNoticeUpdateLogic) GroupNoticeUpdate(req *types.GroupNameUpdateReq) (resp *types.CommonRes, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 41 - 23
api/messagecenter/internal/types/types.go

@@ -14,17 +14,12 @@ type CountResp struct {
 }
 
 type UserReq struct {
-	Phone        string `json:"phone,optional"`
-	UserType     int64  `json:"userType"`
-	StartTime    string `json:"startTime,optional"`
-	EndTime      string `json:"endTime,optional"`
-	NewUserId    int64  `header:"newUserId"`
-	EntId        int64  `header:"entId,optional"`
-	EntUserId    int64  `header:"entUserId,optional"`
-	Page         int64  `json:"page,optional"`
-	Size         int64  `json:"size,optional"`
-	IsArtificial int64  `json:"isArtificial,optional"`
-	FiltrationId string `json:"filtrationId,optional"`
+	Phone     string `json:"phone,optional"`
+	UserType  int64  `json:"userType"`
+	StartTime string `json:"startTime,optional"`
+	EndTime   string `json:"endTime,optional"`
+	NewUserId int64  `header:"newUserId"`
+	EntUserId int64  `header:"entUserId,optional"`
 }
 
 type MessageEntity struct {
@@ -88,18 +83,41 @@ type ReadStateReq struct {
 	NewUserId int64  `header:"newUserId"`
 }
 
-type ReadWithdrawReq struct {
-	MessageId string `json:"messageId"`
-	Appid     string `header:"appid"`
-	NewUserId int64  `header:"newUserId,optional"`
-	EntUserId int64  `header:"entUserId,optional"`
-	UserType  int64  `json:"userType"`
+type ChatGroupListReq struct {
+	EntId      int64  `header:"entId,optional"`
+	UserName   string `json:"userName"`
+	GroupName  string `json:"groupName"`
+	PositionId string `header:"positionId,optional"`
 }
 
-type AppraiseMessageReq struct {
-	EntId     int64  `header:"entId,optional"`
-	AppId     string `header:"appId"`
-	NewUserId int64  `header:"newUserId"`
-	MessageId string `json:"messageId"`
-	Appraise  int64  `json:"appraise,options=-1|1"`
+type ChatGroupAddReq struct {
+	EntId      int64    `header:"entId,optional"`
+	PositionId int64    `header:"positionId,optional"`
+	UserIdArr  []string `json:"userIdArr"`
+}
+
+type ChatGroupPersonReq struct {
+	ChatGroupId string `json:"chatGroupId"`
+	EntId       int64  `header:"entId,optional"`
+}
+
+type ChatGroupJoinReq struct {
+	ChatGroupId string `json:"chatGroupId"`
+	PositionId  string `json:"positionId"`
+}
+
+type GroupNameUpdateReq struct {
+	ChatGroupId string `json:"chatGroupId"`
+	PositionId  string `header:"positionId,optional"`
+	GroupName   string `json:"groupName"`
+}
+
+type GroupNoticeAddReq struct {
+	ChatGroupId string `json:"chatGroupId"`
+	Content     string `json:"content"`
+}
+
+type GroupNoticeUpdateReq struct {
+	Content       string `json:"content"`
+	GroupNoticeId string `json:"groupNoticeId"`
 }

+ 53 - 32
api/messagecenter/messagecenter.api

@@ -1,3 +1,4 @@
+syntax = "v1"
 type CountReq {
 	UserType  int64 `json:"userType"`
 	NewUserId int64 `header:"newUserId,optional"`
@@ -10,17 +11,12 @@ type CountResp {
 }
 
 type UserReq {
-	Phone        string `json:"phone,optional"`
-	UserType     int64  `json:"userType"`
-	StartTime    string `json:"startTime,optional"`
-	EndTime      string `json:"endTime,optional"`
-	NewUserId    int64  `header:"newUserId"`
-	EntId        int64  `header:"entId,optional"`
-	EntUserId    int64  `header:"entUserId,optional"`
-	Page         int64  `json:"page,optional"`
-	Size         int64  `json:"size,optional"`
-	IsArtificial int64  `json:"isArtificial,optional"`
-	FiltrationId string `json:"filtrationId,optional"`
+	Phone     string `json:"phone,optional"`
+	UserType  int64  `json:"userType"`
+	StartTime string `json:"startTime,optional"`
+	EndTime   string `json:"endTime,optional"`
+	NewUserId int64  `header:"newUserId"`
+	EntUserId int64  `header:"entUserId,optional"`
 }
 type MessageEntity {
 	OwnType   int64  `json:"ownType"`
@@ -77,23 +73,38 @@ type ReadStateReq {
 	EntUserId int64  `header:"entUserId,optional"`
 	NewUserId int64  `header:"newUserId"`
 }
-
-type ReadWithdrawReq {
-	MessageId string `json:"messageId"`
-	Appid     string `header:"appid"`
-	NewUserId int64  `header:"newUserId,optional"`
-	EntUserId int64  `header:"entUserId,optional"`
-	UserType  int64  `json:"userType"`
+type ChatGroupListReq {
+	EntId      int64  `header:"entId,optional"`
+	UserName   string `json:"userName"`
+	GroupName  string `json:"groupName"`
+	PositionId string `header:"positionId,optional"`
 }
-
-type AppraiseMessageReq {
-	EntId     int64  `header:"entId,optional"`
-	AppId     string `header:"appId"`
-	NewUserId int64  `header:"newUserId"`
-	MessageId string `json:"messageId"`
-	Appraise  int64  `json:"appraise,options=-1|1"`
+type ChatGroupAddReq {
+	EntId      int64    `header:"entId,optional"`
+	PositionId int64    `header:"positionId,optional"`
+	UserIdArr  []string `json:"userIdArr"`
+}
+type ChatGroupPersonReq {
+	ChatGroupId string `json:"chatGroupId"`
+	EntId       int64  `header:"entId,optional"`
+}
+type ChatGroupJoinReq {
+	ChatGroupId string `json:"chatGroupId"`
+	PositionId  string `json:"positionId"`
+}
+type GroupNameUpdateReq {
+	ChatGroupId string `json:"chatGroupId"`
+	PositionId  string `header:"positionId,optional"`
+	GroupName   string `json:"groupName"`
+}
+type GroupNoticeAddReq {
+	ChatGroupId string `json:"chatGroupId"`
+	Content     string `json:"content"`
+}
+type GroupNoticeUpdateReq {
+	Content       string `json:"content"`
+	GroupNoticeId string `json:"groupNoticeId"`
 }
-
 service messagecenter-api {
 	@handler messageCount
 	post /message/messageCount (CountReq) returns (CommonRes);
@@ -111,10 +122,20 @@ service messagecenter-api {
 	post /message/obtainShunt (ShuntReq) returns (CommonRes);
 	@handler updateReadById
 	post /message/updateReadById (ReadStateReq) returns (CommonRes);
-	@handler withdrawMessage //撤回消息
-	post /message/withdrawMessage (ReadWithdrawReq) returns (CommonRes);
-	@handler AppraiseMessage // 消息评价
-	post /message/appraiseMessage (AppraiseMessageReq) returns (CommonRes);
-	@handler ConversationList // 会话列表
-	post /message/conversationList (UserReq) returns (CommonRes);
+	@handler chatGroupList
+	post /message/chatGroupList (ChatGroupListReq) returns (CommonRes);
+	@handler chatGroupAdd
+	post /message/chatGroupAdd (ChatGroupAddReq) returns (CommonRes);
+	@handler chatGroupPerson
+	post /message/chatGroupPerson (ChatGroupPersonReq) returns (CommonRes);
+	@handler chatGroupJoin
+	post /message/chatGroupJoin (ChatGroupJoinReq) returns (CommonRes);
+	@handler groupNameUpdate
+	post /message/groupNameUpdate (GroupNameUpdateReq) returns (CommonRes);
+	@handler groupNoticeAdd
+	post /message/groupNoticeAdd (GroupNoticeAddReq) returns (CommonRes);
+	@handler groupNoticeUpdate
+	post /message/groupNoticeUpdate (GroupNoticeUpdateReq) returns (CommonRes);
+	@handler groupNoticeGet
+	post /message/groupNoticeGet (ChatGroupPersonReq) returns (CommonRes);
 }

+ 24 - 14
entity/db.go

@@ -1,23 +1,33 @@
 package entity
 
-import (
-	"app.yhyue.com/moapp/jybase/mysql"
-)
+type RedisStuct struct {
+	Addr []string `json:"addr"`
+}
+type Mysql struct {
+	Main        *MysqlStruct `json:"main,omitempty"`
+	BaseService *MysqlStruct `json:"baseService,omitempty"`
+}
+type Mongo struct {
+	Main *MongoStruct `json:"main,optional"`
+}
+type MongoStruct struct {
+	Address        string `json:"address"`
+	Size           int    `json:"size"`
+	DbName         string `json:"dbName"`
+	UserName       string `json:"userName,optional"`
+	Password       string `json:"password,optional"`
+	Collection     string `json:"collection,optional"`
+	CollectionBack string `json:"collectionBack,optional"`
+	MaxOpenConns   int    `json:"maxOpenConns,optional"`
+	MaxIdleConns   int    `json:"maxIdleConns,optional"`
+}
 
-type MysqlMainStruct struct {
+//mysql
+type MysqlStruct struct {
 	DbName       string `json:"dbName"`
 	Address      string `json:"address"`
 	UserName     string `json:"userName"`
-	PassWord     string `json:"passWord"`
+	Password     string `json:"passWord"`
 	MaxOpenConns int    `json:"maxOpenConns"`
 	MaxIdleConns int    `json:"maxIdleConns"`
 }
-
-var (
-	Mysql        *mysql.Mysql
-	SurvivalTime int
-)
-
-type RedisStuct struct {
-	Addr []string `json:"addr"`
-}

+ 30 - 69
entity/util.go

@@ -5,19 +5,24 @@ import (
 	"app.yhyue.com/moapp/jybase/redis"
 	"encoding/json"
 	"fmt"
-	"reflect"
-	"sort"
+	"strings"
 )
 
 const (
-	Date_Full_Layout          = "2006-01-02 15:04:05"
-	SOCIALIZE_CHAT_SESSION    = "socialize_chat_session"
-	SOCIALIZE_MESSAGE         = "socialize_message"
-	SOCIALIZE_MESSAGE_MAILBOX = "socialize_message_mailbox"
-	SOCIALIZE_TENANT_ROBOT    = "socialize_tenant_robot"
-	BASE_USER                 = "base_user"
-	SOCIALIZE_APPRAISE        = "socialize_message_appraise"
-	User_message_list         = "user_message_list"
+	Date_Full_Layout = "2006-01-02 15:04:05"
+	//baseMysql
+	SOCIALIZE_CHAT_SESSION      = "socialize_chat_session"
+	SOCIALIZE_MESSAGE           = "socialize_message"
+	SOCIALIZE_MESSAGE_MAILBOX   = "socialize_message_mailbox"
+	SOCIALIZE_TENANT_ROBOT      = "socialize_tenant_robot"
+	BASE_USER                   = "base_user"
+	SOCIALIZE_CHAT_GROUP        = "socialize_chat_group"
+	SOCIALIZE_CHAT_GROUP_NOTICE = "socialize_chat_group_notice"
+	SOCIALIZE_CHAT_GROUP_PERSON = "socialize_chat_group_person"
+	//mainMysql
+	ENTNICHE_USER = "entniche_user"
+	//mongo
+	ENTNICHE_DELETE = "entniche_delete"
 )
 const (
 	SUCCESS_CODE = int64(0)
@@ -32,7 +37,7 @@ func SafeConvert2String(obj interface{}) string {
 	return ""
 }
 
-// in数据处理
+//in数据处理
 func Inhandle(data *[]map[string]interface{}) (messId string) {
 	if len(*data) == 0 {
 		messId = "''"
@@ -74,64 +79,20 @@ func SetData(userType int64, userId int64, data map[string]interface{}, survival
 	redis.Put(redisModule, todayKey(userType, userId), data, survivalTime)
 }
 
-// 排序 排序键必须为数字类型
-type SortBy struct {
-	Data    []map[string]interface{}
-	Sortkey string
-}
-
-func (a SortBy) Len() int { return len(a.Data) }
-
-func (a SortBy) Swap(i, j int) {
-	a.Data[i], a.Data[j] = a.Data[j], a.Data[i]
-}
-
-func (a SortBy) Less(i, j int) bool {
-	//return Float64(a.Data[i][a.Sortkey]) < Float64(a.Data[j][a.Sortkey])
-	m := a.Data[i][a.Sortkey]
-	n := a.Data[j][a.Sortkey]
-	w := reflect.ValueOf(m)
-	v := reflect.ValueOf(n)
-	switch v.Kind() {
-	case reflect.String:
-		return w.String() < v.String()
-	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
-		return w.Int() < v.Int()
-	case reflect.Float64, reflect.Float32:
-		return w.Float() < v.Float()
-	default:
-		return fmt.Sprintf("%v", w) < fmt.Sprintf("%v", v)
+func IntJoin(elems []int64, sep string) string {
+	switch len(elems) {
+	case 0:
+		return ""
+	case 1:
+		return quitl.InterfaceToStr(elems[0])
 	}
-}
-
-// 根据指定字符排序
-//
-//	m := []map[string]int{
-//	   {"k": 2},
-//	   {"k": 1},
-//	   {"k": 3},
-//	}
-//
-// customer.SortData(&m, "k", true)
-// ture  倒序3, 2, 1
-// fmt.Println(m)
-func SortData(data interface{}, sortkey string, reverse bool) {
-	//func SortData(data interface{}, sortkey string, reverse bool) {
-	var db []map[string]interface{}
-	err := quitl.Bind(data, &db)
-	if err != nil {
-		fmt.Println(err)
-		return
-	}
-	stb := SortBy{db, sortkey}
-	if !reverse {
-		sort.Sort(stb)
-	} else {
-		sort.Sort(sort.Reverse(stb))
-	}
-	err = quitl.Bind(stb.Data, data)
-	if err != nil {
-		fmt.Println(err)
+	var b strings.Builder
+	b.Grow(len(elems))
+	for k, s := range elems {
+		if k > 0 {
+			b.WriteString(sep)
+		}
+		b.WriteString(quitl.InterfaceToStr(s))
 	}
-
+	return b.String()
 }

+ 6 - 6
go.mod

@@ -3,11 +3,11 @@ module bp.jydev.jianyu360.cn/SocialPlatform/messageCenter
 go 1.16
 
 require (
-	app.yhyue.com/moapp/jybase v0.0.0-20220722023023-2a57d1ee061f
+	app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a
+	app.yhyue.com/moapp/jypkg v0.0.0-20230407092858-0d6d33fa63d6
 	bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4
-	github.com/go-sql-driver/mysql v1.6.0
-	github.com/microcosm-cc/bluemonday v1.0.23
-	github.com/zeromicro/go-zero v1.3.5
-	google.golang.org/grpc v1.47.0
-	google.golang.org/protobuf v1.28.0
+	github.com/go-sql-driver/mysql v1.7.0
+	github.com/zeromicro/go-zero v1.4.4
+	google.golang.org/grpc v1.53.0
+	google.golang.org/protobuf v1.28.1
 )

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 624 - 15
go.sum


+ 21 - 1
rpc/messagecenter/etc/db.yaml

@@ -1,3 +1,23 @@
 redis:
     addr:
-        - other=127.0.0.1:6379
+        - msgCount=127.0.0.1:6379
+mysql:
+    main:
+        dbName: jianyu
+        address: 192.168.3.149:3306
+        userName: root
+        passWord: Topnet123
+        maxOpenConns: 5
+        maxIdleConns: 5
+    baseService:
+        dbName: base_service
+        address: 192.168.3.217:4000
+        userName: root
+        passWord: =PDT49#80Z!RVv52_z
+        maxOpenConns: 5
+        maxIdleConns: 5
+mongo:
+    main:
+        dbName: qfw
+        size: 5
+        address: 192.168.3.206:27080

+ 0 - 7
rpc/messagecenter/etc/messagecenter.yaml

@@ -6,13 +6,6 @@ Etcd:
   - 127.0.0.1:2379
   Key: messagecenter.rpc
 WebRpcPort: 8016
-MysqlMain:
-  dbName: base_service
-  address: 192.168.3.217:4000
-  userName: root
-  passWord: =PDT49#80Z!RVv52_z
-  maxOpenConns: 5
-  maxIdleConns: 5
 TestConf:
   Etcd:
     Hosts:

+ 49 - 23
rpc/messagecenter/init/init.go

@@ -1,6 +1,7 @@
 package init
 
 import (
+	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
 	"app.yhyue.com/moapp/jybase/redis"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/entity"
@@ -13,6 +14,12 @@ import (
 	"strings"
 )
 
+var (
+	MainMysql    *mysql.Mysql
+	BaseMysql    *mysql.Mysql
+	SurvivalTime int
+	Mgo          mongodb.MongodbSim
+)
 var configF = flag.String("ff", "etc/messagecenter.yaml", "the config file")
 var C config.Config
 
@@ -24,28 +31,6 @@ var DB config.Db
 
 func init() {
 	conf.MustLoad(*configF, &C)
-	//初始化mysql
-	mm := C.MysqlMain
-	if mm.Address != "" {
-		log.Println("--初始化 mysql--")
-		entity.Mysql = &mysql.Mysql{
-			Address:      mm.Address,
-			UserName:     mm.UserName,
-			PassWord:     mm.PassWord,
-			DBName:       mm.DbName,
-			MaxOpenConns: mm.MaxOpenConns,
-			MaxIdleConns: mm.MaxIdleConns,
-		}
-		entity.Mysql.Init()
-
-	}
-	//初始化数据库配置
-	conf.MustLoad(*dbFile, &DB)
-	rm := DB.Redis
-	if len(rm.Addr) > 0 {
-		logx.Info("--初始化 redis--")
-		redis.InitRedisBySize(strings.Join(rm.Addr, ","), 100, 30, 300)
-	}
 	//初始化日志信息
 	conf.MustLoad(*logFile, &logc)
 	if len(logc.Level) > 0 {
@@ -59,5 +44,46 @@ func init() {
 			logx.Info(v, "--日志记录")
 		}
 	}
-	entity.SurvivalTime = C.SurvivalTime
+	conf.MustLoad(*dbFile, &DB)
+	//初始化mysql
+	if DB.Mysql.Main.Address != "" {
+		log.Println("--初始化 mysql--")
+		MainMysql = &mysql.Mysql{
+			Address:      DB.Mysql.Main.Address,
+			UserName:     DB.Mysql.Main.UserName,
+			PassWord:     DB.Mysql.Main.Password,
+			DBName:       DB.Mysql.Main.DbName,
+			MaxOpenConns: DB.Mysql.Main.MaxOpenConns,
+			MaxIdleConns: DB.Mysql.Main.MaxIdleConns,
+		}
+		MainMysql.Init()
+	}
+	if DB.Mysql.BaseService.Address != "" {
+		log.Println("--初始化 mysql--")
+		BaseMysql = &mysql.Mysql{
+			Address:      DB.Mysql.BaseService.Address,
+			UserName:     DB.Mysql.BaseService.UserName,
+			PassWord:     DB.Mysql.BaseService.Password,
+			DBName:       DB.Mysql.BaseService.DbName,
+			MaxOpenConns: DB.Mysql.BaseService.MaxOpenConns,
+			MaxIdleConns: DB.Mysql.BaseService.MaxIdleConns,
+		}
+		BaseMysql.Init()
+	}
+	//初始化数据库配置
+	rm := DB.Redis
+	if len(rm.Addr) > 0 {
+		logx.Info("--初始化 redis--")
+		redis.InitRedisBySize(strings.Join(rm.Addr, ","), 100, 30, 300)
+	}
+	if DB.Mongo.Main.Address != "" {
+		logx.Info("--初始化 mongodb--")
+		Mgo = mongodb.MongodbSim{
+			MongodbAddr: DB.Mongo.Main.Address,
+			Size:        DB.Mongo.Main.Size,
+			DbName:      DB.Mongo.Main.DbName,
+		}
+		Mgo.InitPool()
+	}
+	SurvivalTime = C.SurvivalTime
 }

+ 2 - 1
rpc/messagecenter/internal/config/config.go

@@ -8,11 +8,12 @@ import (
 type Config struct {
 	zrpc.RpcServerConf
 	WebRpcPort   int64
-	MysqlMain    entity.MysqlMainStruct
 	TestConf     zrpc.RpcClientConf
 	SurvivalTime int
 }
 
 type Db struct {
+	Mysql entity.Mysql      `json:"mysql"`
 	Redis entity.RedisStuct `json:"redis"`
+	Mongo entity.Mongo      `json:"mongo"`
 }

+ 37 - 0
rpc/messagecenter/internal/logic/chatgroupaddlogic.go

@@ -0,0 +1,37 @@
+package logic
+
+import (
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/service"
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ChatGroupAddLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewChatGroupAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatGroupAddLogic {
+	return &ChatGroupAddLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+var ChatGroup service.ChatGroupService
+
+// 群组新增
+func (l *ChatGroupAddLogic) ChatGroupAdd(in *messagecenter.ChatGroupAddReq) (*messagecenter.CommonReq, error) {
+	// todo: add your logic here and delete this line
+	status := ChatGroup.ChatGroupAdd(in.EntId, in.PositionId, in.UserIdArr, in.AppId)
+	return &messagecenter.CommonReq{
+		ErrorCode: 0,
+		Status:    status,
+	}, nil
+}

+ 34 - 0
rpc/messagecenter/internal/logic/chatgroupjoinlogic.go

@@ -0,0 +1,34 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ChatGroupJoinLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewChatGroupJoinLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatGroupJoinLogic {
+	return &ChatGroupJoinLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 加入群组
+func (l *ChatGroupJoinLogic) ChatGroupJoin(in *messagecenter.ChatGroupJoinReq) (*messagecenter.CommonReq, error) {
+	// todo: add your logic here and delete this line
+	status := ChatGroup.ChatGroupJoin(in.ChatGroupId, in.PositionId, in.UserIdArr, in.AppId)
+	return &messagecenter.CommonReq{
+		ErrorCode: 0,
+		Status:    status,
+	}, nil
+}

+ 49 - 0
rpc/messagecenter/internal/logic/chatgrouplistlogic.go

@@ -0,0 +1,49 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ChatGroupListLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewChatGroupListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatGroupListLogic {
+	return &ChatGroupListLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 群组列表查询
+func (l *ChatGroupListLogic) ChatGroupList(in *messagecenter.ChatGroupListReq) (*messagecenter.ChatGroupListResp, error) {
+	// todo: add your logic here and delete this line
+	data := ChatGroup.ChatGroupList(in.EntId, in.PositionId, in.UserName, in.GroupName, in.AppId)
+	chatGroupList := []*messagecenter.ChatGroupList{}
+	if len(data) > 0 {
+		for _, v := range data {
+			chatGroupId := encrypt.SE.Encode2Hex(common.InterfaceToStr(v["chatGroupId"]))
+			chatGroup := messagecenter.ChatGroupList{
+				GroupName:   common.ObjToString(v["name"]),
+				PersonCount: common.Int64All(v["count"]),
+				ChatGroupId: chatGroupId,
+			}
+			chatGroupList = append(chatGroupList, &chatGroup)
+		}
+
+	}
+	return &messagecenter.ChatGroupListResp{
+		ErrorCode: 0,
+		Data:      chatGroupList,
+	}, nil
+}

+ 56 - 0
rpc/messagecenter/internal/logic/chatgrouppersonlogic.go

@@ -0,0 +1,56 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ChatGroupPersonLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewChatGroupPersonLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChatGroupPersonLogic {
+	return &ChatGroupPersonLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 群组成员查询
+func (l *ChatGroupPersonLogic) ChatGroupPerson(in *messagecenter.ChatGroupPersonReq) (*messagecenter.ChatGroupPersonResp, error) {
+	// todo: add your logic here and delete this line
+	data := ChatGroup.ChatGroupPerson(in.ChatGroupId, in.EntId, in.AppId)
+	chatGroupList := map[string]*messagecenter.ChatGroupPersonList{}
+	if len(data) > 0 {
+		for k, v := range data {
+			personList := []*messagecenter.ChatGroupPerson{}
+			for _, m := range v {
+				positionId := encrypt.SE.Encode2Hex(common.InterfaceToStr(m["position_id"]))
+				person := messagecenter.ChatGroupPerson{
+					PersonName: common.ObjToString(m["name"]),
+					IsSystem:   common.Int64All(m["isgroup_admin"]) > 0,
+					PositionId: positionId,
+				}
+				personList = append(personList, &person)
+			}
+			ChatList := messagecenter.ChatGroupPersonList{
+				Data: personList,
+			}
+			chatGroupList[k] = &ChatList
+		}
+
+	}
+	return &messagecenter.ChatGroupPersonResp{
+		ErrorCode: 0,
+		Data:      chatGroupList,
+	}, nil
+}

+ 31 - 0
rpc/messagecenter/internal/logic/entpersonslistlogic.go

@@ -0,0 +1,31 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type EntPersonsListLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewEntPersonsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EntPersonsListLogic {
+	return &EntPersonsListLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 通讯录 -企业人员列表
+func (l *EntPersonsListLogic) EntPersonsList(in *messagecenter.EntPersonsListReq) (*messagecenter.EntPersonListResp, error) {
+	// todo: add your logic here and delete this line
+	ChatGroup.EntPersonsList(in)
+	return &messagecenter.EntPersonListResp{}, nil
+}

+ 34 - 0
rpc/messagecenter/internal/logic/groupnameupdatelogic.go

@@ -0,0 +1,34 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GroupNameUpdateLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGroupNameUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupNameUpdateLogic {
+	return &GroupNameUpdateLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 群组名称修改
+func (l *GroupNameUpdateLogic) GroupNameUpdate(in *messagecenter.GroupNameUpdateReq) (*messagecenter.CommonReq, error) {
+	// todo: add your logic here and delete this line
+	status := ChatGroup.GroupNameUpdate(in.ChatGroupId, in.GroupName, in.AppId)
+	return &messagecenter.CommonReq{
+		ErrorCode: 0,
+		Status:    status,
+	}, nil
+}

+ 34 - 0
rpc/messagecenter/internal/logic/groupnoticeaddlogic.go

@@ -0,0 +1,34 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GroupNoticeAddLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGroupNoticeAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupNoticeAddLogic {
+	return &GroupNoticeAddLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 群任务新增
+func (l *GroupNoticeAddLogic) GroupNoticeAdd(in *messagecenter.GroupNoticeAddReq) (*messagecenter.CommonReq, error) {
+	// todo: add your logic here and delete this line
+	status := ChatGroup.GroupNoticeAdd(in.ChatGroupId, in.Content, in.AppId)
+	return &messagecenter.CommonReq{
+		ErrorCode: 0,
+		Status:    status,
+	}, nil
+}

+ 42 - 0
rpc/messagecenter/internal/logic/groupnoticegetlogic.go

@@ -0,0 +1,42 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GroupNoticeGetLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGroupNoticeGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupNoticeGetLogic {
+	return &GroupNoticeGetLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 群任务详情
+func (l *GroupNoticeGetLogic) GroupNoticeGet(in *messagecenter.ChatGroupPersonReq) (*messagecenter.GroupNoticeGetResp, error) {
+	// todo: add your logic here and delete this line
+	data := ChatGroup.GroupNoticeGet(in.ChatGroupId, in.AppId)
+	groupNotice := messagecenter.GroupNotice{}
+	if data != nil {
+		groupNoticeId := encrypt.SE.Encode2Hex(common.InterfaceToStr(data["id"]))
+		groupNotice.GroupNoticeId = groupNoticeId
+		groupNotice.Content = common.ObjToString(data["content"])
+	}
+	return &messagecenter.GroupNoticeGetResp{
+		ErrorCode: 0,
+		Data:      &groupNotice,
+	}, nil
+}

+ 34 - 0
rpc/messagecenter/internal/logic/groupnoticeupdatelogic.go

@@ -0,0 +1,34 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GroupNoticeUpdateLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGroupNoticeUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupNoticeUpdateLogic {
+	return &GroupNoticeUpdateLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 群任务编辑
+func (l *GroupNoticeUpdateLogic) GroupNoticeUpdate(in *messagecenter.GroupNoticeUpdateReq) (*messagecenter.CommonReq, error) {
+	// todo: add your logic here and delete this line
+	status := ChatGroup.GroupNoticeUpdate(in.GroupNoticeId, in.Content, in.AppId)
+	return &messagecenter.CommonReq{
+		ErrorCode: 0,
+		Status:    status,
+	}, nil
+}

+ 54 - 18
rpc/messagecenter/internal/server/messagecenterserver.go

@@ -22,37 +22,37 @@ func NewMessageCenterServer(svcCtx *svc.ServiceContext) *MessageCenterServer {
 	}
 }
 
-// 查询数量
+//  查询数量
 func (s *MessageCenterServer) Count(ctx context.Context, in *messagecenter.CountReq) (*messagecenter.CountResp, error) {
 	l := logic.NewCountLogic(ctx, s.svcCtx)
 	return l.Count(in)
 }
 
-// 用户列表查询
+//  用户列表查询
 func (s *MessageCenterServer) UserList(ctx context.Context, in *messagecenter.UserReq) (*messagecenter.UserResp, error) {
 	l := logic.NewUserListLogic(ctx, s.svcCtx)
 	return l.UserList(in)
 }
 
-// 聊天内容查询
+//  聊天内容查询
 func (s *MessageCenterServer) FindMessage(ctx context.Context, in *messagecenter.MessageReq) (*messagecenter.MessageResp, error) {
 	l := logic.NewFindMessageLogic(ctx, s.svcCtx)
 	return l.FindMessage(in)
 }
 
-// 聊天保存
+//  聊天保存
 func (s *MessageCenterServer) SaveMessage(ctx context.Context, in *messagecenter.MessageEntity) (*messagecenter.SaveMessageResp, error) {
 	l := logic.NewSaveMessageLogic(ctx, s.svcCtx)
 	return l.SaveMessage(in)
 }
 
-// 会话创建
+//  会话创建
 func (s *MessageCenterServer) CreateChatSession(ctx context.Context, in *messagecenter.ChatSessionReq) (*messagecenter.ChatSessionResp, error) {
 	l := logic.NewCreateChatSessionLogic(ctx, s.svcCtx)
 	return l.CreateChatSession(in)
 }
 
-// 会话关闭
+//  会话关闭
 func (s *MessageCenterServer) CloseChatSession(ctx context.Context, in *messagecenter.CloseSessionReq) (*messagecenter.ChatSessionResp, error) {
 	l := logic.NewCloseChatSessionLogic(ctx, s.svcCtx)
 	return l.CloseChatSession(in)
@@ -70,20 +70,56 @@ func (s *MessageCenterServer) UpdateReadById(ctx context.Context, in *messagecen
 	return l.UpdateReadById(in)
 }
 
-// 用户撤回消息
-func (s *MessageCenterServer) WithdrawMessage(ctx context.Context, in *messagecenter.ReadWithdrawReq) (*messagecenter.CurrencyResp, error) {
-	l := logic.NewWithdrawMessageLogic(ctx, s.svcCtx)
-	return l.WithdrawMessage(in)
+// 群组列表查询
+func (s *MessageCenterServer) ChatGroupList(ctx context.Context, in *messagecenter.ChatGroupListReq) (*messagecenter.ChatGroupListResp, error) {
+	l := logic.NewChatGroupListLogic(ctx, s.svcCtx)
+	return l.ChatGroupList(in)
 }
 
-// 用户评价回复
-func (s *MessageCenterServer) AppraiseMessage(ctx context.Context, in *messagecenter.AppraiseReq) (*messagecenter.CurrencyResp, error) {
-	l := logic.NewAppraiseMessageLogic(ctx, s.svcCtx)
-	return l.AppraiseMessage(in)
+// 群组新增
+func (s *MessageCenterServer) ChatGroupAdd(ctx context.Context, in *messagecenter.ChatGroupAddReq) (*messagecenter.CommonReq, error) {
+	l := logic.NewChatGroupAddLogic(ctx, s.svcCtx)
+	return l.ChatGroupAdd(in)
 }
 
-// 客服列表查询
-func (s *MessageCenterServer) ConversationList(ctx context.Context, in *messagecenter.ConversationReq) (*messagecenter.UserResp, error) {
-	l := logic.NewConversationListLogic(ctx, s.svcCtx)
-	return l.ConversationList(in)
+// 群组成员查询
+func (s *MessageCenterServer) ChatGroupPerson(ctx context.Context, in *messagecenter.ChatGroupPersonReq) (*messagecenter.ChatGroupPersonResp, error) {
+	l := logic.NewChatGroupPersonLogic(ctx, s.svcCtx)
+	return l.ChatGroupPerson(in)
+}
+
+// 加入群组
+func (s *MessageCenterServer) ChatGroupJoin(ctx context.Context, in *messagecenter.ChatGroupJoinReq) (*messagecenter.CommonReq, error) {
+	l := logic.NewChatGroupJoinLogic(ctx, s.svcCtx)
+	return l.ChatGroupJoin(in)
+}
+
+// 群组名称修改
+func (s *MessageCenterServer) GroupNameUpdate(ctx context.Context, in *messagecenter.GroupNameUpdateReq) (*messagecenter.CommonReq, error) {
+	l := logic.NewGroupNameUpdateLogic(ctx, s.svcCtx)
+	return l.GroupNameUpdate(in)
+}
+
+// 群任务新增
+func (s *MessageCenterServer) GroupNoticeAdd(ctx context.Context, in *messagecenter.GroupNoticeAddReq) (*messagecenter.CommonReq, error) {
+	l := logic.NewGroupNoticeAddLogic(ctx, s.svcCtx)
+	return l.GroupNoticeAdd(in)
+}
+
+// 群任务编辑
+func (s *MessageCenterServer) GroupNoticeUpdate(ctx context.Context, in *messagecenter.GroupNoticeUpdateReq) (*messagecenter.CommonReq, error) {
+	l := logic.NewGroupNoticeUpdateLogic(ctx, s.svcCtx)
+	return l.GroupNoticeUpdate(in)
+}
+
+// 群任务详情
+func (s *MessageCenterServer) GroupNoticeGet(ctx context.Context, in *messagecenter.ChatGroupPersonReq) (*messagecenter.GroupNoticeGetResp, error) {
+	l := logic.NewGroupNoticeGetLogic(ctx, s.svcCtx)
+	return l.GroupNoticeGet(in)
+}
+
+// 通讯录 -企业人员列表
+func (s *MessageCenterServer) EntPersonsList(ctx context.Context, in *messagecenter.EntPersonsListReq) (*messagecenter.EntPersonListResp, error) {
+	l := logic.NewEntPersonsListLogic(ctx, s.svcCtx)
+	return l.EntPersonsList(in)
 }

+ 23 - 0
rpc/messagecenter/logs/access.log

@@ -123,3 +123,26 @@
 {"@timestamp":"2022-08-08T19:51:37.034+08:00","caller":"init/init.go:51","content":"info--日志记录","level":"info"}
 {"@timestamp":"2022-08-08T19:54:16.937+08:00","caller":"init/init.go:51","content":"info--日志记录","level":"info"}
 {"@timestamp":"2022-08-08T19:57:26.494+08:00","caller":"serverinterceptors/statinterceptor.go:76","content":"127.0.0.1:52746 - /messagecenter.messageCenter/UserList - {\"newUserId\":4318,\"userType\":1,\"entUserId\":4318}","duration":"134.7ms","level":"info","span":"0f2ec03ba33bd44b","trace":"135c80d20d5e202b9c65a31f651e324c"}
+{"@timestamp":"2023-04-19T10:29:06.346+08:00","caller":"init/init.go:44","content":"info--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T10:31:21.202+08:00","caller":"init/init.go:44","content":"info--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T10:31:21.202+08:00","caller":"init/init.go:44","content":"error--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T10:33:13.477+08:00","caller":"init/init.go:44","content":"info--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T10:33:13.477+08:00","caller":"init/init.go:44","content":"error--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T10:36:23.443+08:00","caller":"init/init.go:44","content":"info--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T10:36:23.443+08:00","caller":"init/init.go:44","content":"error--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T11:23:33.099+08:00","caller":"init/init.go:44","content":"info--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T11:23:33.099+08:00","caller":"init/init.go:44","content":"error--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T11:23:33.176+08:00","caller":"init/init.go:76","content":"--初始化 redis--","level":"info"}
+{"@timestamp":"2023-04-19T11:23:33.176+08:00","caller":"init/init.go:80","content":"--初始化 mongodb--","level":"info"}
+{"@timestamp":"2023-04-19T11:23:59.357+08:00","caller":"init/init.go:44","content":"info--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T11:23:59.357+08:00","caller":"init/init.go:44","content":"error--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T11:23:59.488+08:00","caller":"init/init.go:76","content":"--初始化 redis--","level":"info"}
+{"@timestamp":"2023-04-19T11:23:59.488+08:00","caller":"init/init.go:80","content":"--初始化 mongodb--","level":"info"}
+{"@timestamp":"2023-04-19T13:24:04.640+08:00","caller":"init/init.go:44","content":"info--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T13:24:04.640+08:00","caller":"init/init.go:44","content":"error--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T13:24:05.348+08:00","caller":"init/init.go:76","content":"--初始化 redis--","level":"info"}
+{"@timestamp":"2023-04-19T13:24:05.348+08:00","caller":"init/init.go:80","content":"--初始化 mongodb--","level":"info"}
+{"@timestamp":"2023-04-19T13:24:25.952+08:00","caller":"init/init.go:44","content":"info--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T13:24:25.952+08:00","caller":"init/init.go:44","content":"error--日志记录","level":"info"}
+{"@timestamp":"2023-04-19T13:24:42.678+08:00","caller":"init/init.go:76","content":"--初始化 redis--","level":"info"}
+{"@timestamp":"2023-04-19T13:24:42.678+08:00","caller":"init/init.go:80","content":"--初始化 mongodb--","level":"info"}

+ 2 - 0
rpc/messagecenter/logs/error.log

@@ -40,3 +40,5 @@
 {"@timestamp":"2022-08-08T19:54:52.975+08:00","caller":"discov/publisher.go:144","content":"etcdserver: requested lease not found","level":"error"}
 {"@timestamp":"2022-08-08T19:55:28.597+08:00","caller":"discov/publisher.go:144","content":"etcdserver: requested lease not found","level":"error"}
 {"@timestamp":"2022-08-08T19:56:49.962+08:00","caller":"discov/publisher.go:144","content":"etcdserver: requested lease not found","level":"error"}
+{"@timestamp":"2023-04-19T11:23:38.197+08:00","caller":"zrpc/server.go:91","content":"context deadline exceeded","level":"error"}
+{"@timestamp":"2023-04-19T11:24:04.510+08:00","caller":"zrpc/server.go:91","content":"context deadline exceeded","level":"error"}

+ 167 - 81
rpc/messagecenter/messagecenter.proto

@@ -1,16 +1,16 @@
 syntax = "proto3";
 
 package messagecenter;
-option go_package="./messagecenter";
+option go_package = "./messagecenter";
 
 message CountReq {
-  int64     userType=2;      //用户类型:2用户1客服
+  int64     userType = 2;      //用户类型:2用户1客服
   int64     newUserId = 1;      // 用户id
   int64     entUserId = 3;      // 客服id
 }
 message CountResp {
   int64 count = 1;
-  MessageEntity lastMessage= 4;
+  MessageEntity lastMessage = 4;
   int64 error_code = 2; //响应代码
   string error_msg = 3; //响应消息
 }
@@ -19,54 +19,47 @@ message UserReq {
   string    startTime = 2;
   string    endTime = 3;
   int64     newUserId = 4;  //用户标识
-  int64     userType=5;  //用户类型:2用户1客服
+  int64     userType = 5;  //用户类型:2用户1客服
   int64     entUserId = 6;  //企业标识
-  int64     page = 7;  //页
-  int64     size =8; //数
-  int64     isArtificial =9; //是否人工介入 1:人工介入 2:非让人工介入
-  string    filtrationId = 10; //客服列表过滤会话中派对中用户
-  int64  entId = 11;
 }
 message UserResp {
-   repeated UserEntity data=1;
-   int64 error_code = 2; //响应代码
-   string error_msg = 3; //响应消息
-  int64 count = 4; //响应代码
+  repeated UserEntity data = 1;
+  int64 error_code = 2; //响应代码
+  string error_msg = 3; //响应消息
 }
 message UserEntity {
   string userId = 1;
-  string name= 2;
+  string name = 2;
   string title = 3;
-  int64 type= 4;
+  int64 type = 4;
   string link = 5;
-  string content= 6;
+  string content = 6;
   int64 userType = 7;
-  int64 create_time= 8;
-  int64 number= 9;
-  string headimg=11;
-  bool isOnline=12;
+  int64 create_time = 8;
+  int64 number = 9;
+  string headimg = 11;
 }
 message MessageReq {
   int64         msgType = 1;     // 消息类型 ;1:站内信消息 2:点对点消息 3:群消息 4:机器人消息 5:客服消息
-  int64         userType=6;      //用户类型:2用户1客服
+  int64         userType = 6;      //用户类型:2用户1客服
   int64         LastId = 2;
   int64         pageSize = 3;
   int64         sendId = 4;
   int64         newUserId = 5;
-  int64         entUserId=7;
-  int64         entId=8;
-  int64         customerEntId=9;
-  string        sort=10;
+  int64         entUserId = 7;
+  int64         entId = 8;
+  int64         customerEntId = 9;
+  string        sort = 10;
 }
 message MessageResp {
   int64         count = 1;
-  repeated      MessageEntity data= 2;
+  repeated      MessageEntity data = 2;
   int64         error_code = 4; //响应代码
   string        error_msg = 3; //响应消息
 }
 message SaveMessageResp {
   int64         count = 1;
-  MessageEntity data= 2;
+  MessageEntity data = 2;
   int64         error_code = 4; //响应代码
   string        error_msg = 3; //响应消息
 }
@@ -77,99 +70,192 @@ message MessageEntity {
   int64         type = 4;
   string        link = 5;
   int64         create_time = 6;
-  string        appid=7;
-  int64         itemType=8;
-  int64         sendId=9;
-  int64         entUserId=10;
-  int64         newUserId=16;
-  int64         own_type =11;//拥有者类型;1:用户 2:会话
-  int64         fool=12;
-  string        robotName=13;
-  string        robotImg=14;
-  string        setName=15;
-  int64         receiveId=17;
-  string        ownImg=18;
-  string        messageId=19;
-  int64         appraise=20;
+  string        appid = 7;
+  int64         itemType = 8;
+  int64         sendId = 9;
+  int64         entUserId = 10;
+  int64         newUserId = 16;
+  int64         own_type = 11;//拥有者类型;1:用户 2:会话
+  int64         fool = 12;
+  string        robotName = 13;
+  string        robotImg = 14;
+  string        setName = 15;
+  int64         receiveId = 17;
+  string        ownImg = 18;
+  string        messageId = 19;
 }
 
 message ChatSessionReq {
   int64         entId = 1;
-  int64         customerServiceId= 2;
+  int64         customerServiceId = 2;
   int64         userId = 3;
   string        appId = 4;
-  string        customerserviceName=5;
+  string        customerserviceName = 5;
 }
 message CloseSessionReq {
   int64         sessionId = 1;
 }
 message ChatSessionResp {
-   int64 error_code = 2; //响应代码
-   string error_msg = 1; //响应消息
-   string  sessionId=3;
+  int64 error_code = 2; //响应代码
+  string error_msg = 1; //响应消息
+  string  sessionId = 3;
 }
 message SaveAutoReplyReq {
   int64         entId = 1;
-  int64         entUserId= 2;
+  int64         entUserId = 2;
   int64         userId = 3;
   int64         userType = 4;
   string        content = 5;
   string        appId = 6;
-  string        nowFormat=7;
+  string        nowFormat = 7;
 }
 message ReadStateReq {
   int64         messageId = 1;
-  int64         entUserId=2;
-  int64         newUserId=3;
-}
-
-message ReadWithdrawReq {
-  string        messageId = 1;
   int64         entUserId = 2;
-  string        appid=3;
-  int64         newUserId = 4;
-  int64         userType=6;      //用户类型:2用户1客服
-}
-
-message AppraiseReq {
-  string        appid=1;
-  string        messageId = 2;
   int64         newUserId = 3;
-  int64         appraise = 4;
 }
 
 message CurrencyResp {
-   int64 error_code = 2; //响应代码
-   string error_msg = 1; //响应消息
+  int64 error_code = 2; //响应代码
+  string error_msg = 1; //响应消息
 }
-
-message ConversationReq {
-  int64     newUserId = 4;  //用户标识
-  int64     userType=5;  //用户类型:2用户1客服
-  int64     entUserId = 6;  //企业标识
-  string    filtrationId = 10; //客服列表过滤会话中派对中用户
+message ChatGroupListReq{
+  int64 entId = 1;
+  string userName = 2;
+  string groupName = 3;
+  int64 positionId = 4;
+  string appId = 5;
+}
+message ChatGroupListResp {
+  repeated      ChatGroupList data = 1;
+  int64         error_code = 2; //响应代码
+  string        error_msg = 3; //响应消息
+}
+message ChatGroupList {
+  string  groupName = 1;
+  int64   personCount = 2;
+  string  chatGroupId = 3;
+  string  appId = 4;
+}
+message ChatGroupAddReq {
+  int64  entId = 1;
+  int64   positionId = 2;
+  repeated int64 userIdArr = 3;
+  string  appId = 4;
+}
+message CommonReq {
+  bool          status = 1;
+  int64         error_code = 2; //响应代码
+  string        error_msg = 3; //响应消息
 }
+message ChatGroupPersonReq{
+  int64 chatGroupId = 1;
+  int64 ent_id = 2;
+  string  appId = 3;
+}
+message ChatGroupPersonResp{
+  map<string, ChatGroupPersonList> data = 1;//地区
+  int64         error_code = 2; //响应代码
+  string        error_msg = 3; //响应消息
+}
+message ChatGroupPersonList{
+  repeated      ChatGroupPerson data = 1;
+}
+message ChatGroupPerson{
+  string   personName = 1;
+  bool     isSystem = 2;
+  string   appId = 3;
+  string   positionId = 4;
+}
+message ChatGroupJoinReq{
+  int64 chatGroupId = 1;
+  int64 positionId = 2;
+  repeated int64 userIdArr = 3;
+  string  appId = 4;
+}
+message GroupNameUpdateReq{
+  int64  chatGroupId = 1;
+  int64  positionId = 2;
+  string groupName = 3;
+  string  appId = 4;
+}
+message GroupNoticeAddReq{
+  int64 chatGroupId = 1;
+  string content = 2;
+  string  appId = 3;
+}
+message GroupNoticeUpdateReq{
+  int64 groupNoticeId = 1;
+  string content = 2;
+  string appId = 3;
+}
+message GroupNoticeGetResp{
+  GroupNotice        data = 1;
+  int64         error_code = 2; //响应代码
+  string        error_msg = 3; //响应消息
+}
+message  GroupNotice{
+  string content = 1;
+  string  groupNoticeId = 2;
+}
+//企业人员列表、拉人进群列表
+message EntPersonsListReq{
+  string name =1;
+  int64 entId = 2;
+  int64 GroupId = 3;
+}
+message PersonInfo{
+  int64 id = 1;
+  string personName = 2;
+  string phone = 3;
+  string email = 4;
+  int64 positionId = 5;
+}
+message departmentsInfo{
+  int64 id = 1;
+  string departmentName = 2;
+  repeated PersonInfo persons = 3;//部门下的人
+}
+message EntPersonListResp{
+  int64         error_code = 1; //响应代码
+  string        error_msg = 2; //响应消息
+  repeated departmentsInfo data = 3; //返回数据
+  string entName = 4;
+}
+
 service messageCenter {
   // 查询数量
-  rpc Count(CountReq) returns (CountResp);
+  rpc Count(CountReq) returns(CountResp);
   // 用户列表查询
   rpc UserList(UserReq) returns(UserResp);
   // 聊天内容查询
   rpc FindMessage(MessageReq) returns(MessageResp);
-   // 聊天保存
+  // 聊天保存
   rpc SaveMessage(MessageEntity) returns(SaveMessageResp);
   // 会话创建
   rpc CreateChatSession(ChatSessionReq) returns(ChatSessionResp);
   // 会话关闭
   rpc CloseChatSession(CloseSessionReq) returns(ChatSessionResp);
-   //创建会话并且保存信息
+  //创建会话并且保存信息
   rpc SaveAutoReplyMsg(SaveAutoReplyReq)returns(MessageResp);
-   //根据消息修改已读状态
+  //根据消息修改已读状态
   rpc UpdateReadById(ReadStateReq)returns(CurrencyResp);
-  //用户撤回消息
-  rpc WithdrawMessage(ReadWithdrawReq)returns(CurrencyResp);
-  // 用户评价回复
-  rpc AppraiseMessage(AppraiseReq) returns(CurrencyResp);
-  // 客服列表查询
-  rpc ConversationList(ConversationReq) returns(UserResp);
+  //群组列表查询
+  rpc ChatGroupList(ChatGroupListReq)returns(ChatGroupListResp);
+  //群组新增
+  rpc ChatGroupAdd(ChatGroupAddReq)returns(CommonReq);
+  //群组成员查询
+  rpc ChatGroupPerson(ChatGroupPersonReq)returns(ChatGroupPersonResp);
+  //加入群组
+  rpc ChatGroupJoin(ChatGroupJoinReq)returns(CommonReq);
+  //群组名称修改
+  rpc GroupNameUpdate(GroupNameUpdateReq)returns(CommonReq);
+  //群任务新增
+  rpc GroupNoticeAdd(GroupNoticeAddReq)returns(CommonReq);
+  //群任务编辑
+  rpc GroupNoticeUpdate(GroupNoticeUpdateReq)returns(CommonReq);
+  //群任务详情
+  rpc GroupNoticeGet(ChatGroupPersonReq)returns(GroupNoticeGetResp);
+  //通讯录 -企业人员列表
+  rpc EntPersonsList(EntPersonsListReq) returns(EntPersonListResp);
 }

+ 73 - 22
rpc/messagecenter/messagecenter/messagecenter.go

@@ -1,4 +1,5 @@
-// Code generated by goctl. DO NOT EDIT!
+
+// Code generated by goctl. DO NOT EDIT.
 // Source: messagecenter.proto
 
 package messagecenter
@@ -12,28 +13,41 @@ import (
 
 type (
 	MessageCenter interface {
-		//  查询数量
+		// 查询数量
 		Count(ctx context.Context, in *CountReq, opts ...grpc.CallOption) (*CountResp, error)
-		//  用户列表查询
+		// 用户列表查询
 		UserList(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserResp, error)
-		//  聊天内容查询
+		// 聊天内容查询
 		FindMessage(ctx context.Context, in *MessageReq, opts ...grpc.CallOption) (*MessageResp, error)
-		//  聊天保存
+		// 聊天保存
 		SaveMessage(ctx context.Context, in *MessageEntity, opts ...grpc.CallOption) (*SaveMessageResp, error)
-		//  会话创建
+		// 会话创建
 		CreateChatSession(ctx context.Context, in *ChatSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error)
-		//  会话关闭
+		// 会话关闭
 		CloseChatSession(ctx context.Context, in *CloseSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error)
 		// 创建会话并且保存信息
 		SaveAutoReplyMsg(ctx context.Context, in *SaveAutoReplyReq, opts ...grpc.CallOption) (*MessageResp, error)
 		// 根据消息修改已读状态
 		UpdateReadById(ctx context.Context, in *ReadStateReq, opts ...grpc.CallOption) (*CurrencyResp, error)
-		// 用户撤回消息
-		WithdrawMessage(ctx context.Context, in *ReadWithdrawReq, opts ...grpc.CallOption) (*CurrencyResp, error)
-		//  用户评价回复
-		AppraiseMessage(ctx context.Context, in *AppraiseReq, opts ...grpc.CallOption) (*CurrencyResp, error)
-		//  客服列表查询
-		ConversationList(ctx context.Context, in *ConversationReq, opts ...grpc.CallOption) (*UserResp, error)
+		// 群组列表查询
+		ChatGroupList(ctx context.Context, in *ChatGroupListReq, opts ...grpc.CallOption) (*ChatGroupListResp, error)
+		// 群组新增
+		ChatGroupAdd(ctx context.Context, in *ChatGroupAddReq, opts ...grpc.CallOption) (*CommonReq, error)
+		// 群组成员查询
+		ChatGroupPerson(ctx context.Context, in *ChatGroupPersonReq, opts ...grpc.CallOption) (*ChatGroupPersonResp, error)
+		// 加入群组
+		ChatGroupJoin(ctx context.Context, in *ChatGroupJoinReq, opts ...grpc.CallOption) (*CommonReq, error)
+		// 群组名称修改
+		GroupNameUpdate(ctx context.Context, in *GroupNameUpdateReq, opts ...grpc.CallOption) (*CommonReq, error)
+		// 群任务新增
+		GroupNoticeAdd(ctx context.Context, in *GroupNoticeAddReq, opts ...grpc.CallOption) (*CommonReq, error)
+		// 群任务编辑
+		GroupNoticeUpdate(ctx context.Context, in *GroupNoticeUpdateReq, opts ...grpc.CallOption) (*CommonReq, error)
+		// 群任务详情
+		GroupNoticeGet(ctx context.Context, in *ChatGroupPersonReq, opts ...grpc.CallOption) (*GroupNoticeGetResp, error)
+		// 通讯录 -企业人员列表
+		EntPersonsList(ctx context.Context, in *EntPersonsListReq, opts ...grpc.CallOption) (*EntPersonListResp, error)
+
 	}
 
 	defaultMessageCenter struct {
@@ -95,20 +109,57 @@ func (m *defaultMessageCenter) UpdateReadById(ctx context.Context, in *ReadState
 	return client.UpdateReadById(ctx, in, opts...)
 }
 
-// 用户撤回消息
-func (m *defaultMessageCenter) WithdrawMessage(ctx context.Context, in *ReadWithdrawReq, opts ...grpc.CallOption) (*CurrencyResp, error) {
+// 群组列表查询
+func (m *defaultMessageCenter) ChatGroupList(ctx context.Context, in *ChatGroupListReq, opts ...grpc.CallOption) (*ChatGroupListResp, error) {
+	client := NewMessageCenterClient(m.cli.Conn())
+	return client.ChatGroupList(ctx, in, opts...)
+}
+
+// 群组新增
+func (m *defaultMessageCenter) ChatGroupAdd(ctx context.Context, in *ChatGroupAddReq, opts ...grpc.CallOption) (*CommonReq, error) {
+	client := NewMessageCenterClient(m.cli.Conn())
+	return client.ChatGroupAdd(ctx, in, opts...)
+}
+
+// 群组成员查询
+func (m *defaultMessageCenter) ChatGroupPerson(ctx context.Context, in *ChatGroupPersonReq, opts ...grpc.CallOption) (*ChatGroupPersonResp, error) {
+	client := NewMessageCenterClient(m.cli.Conn())
+	return client.ChatGroupPerson(ctx, in, opts...)
+}
+
+// 加入群组
+func (m *defaultMessageCenter) ChatGroupJoin(ctx context.Context, in *ChatGroupJoinReq, opts ...grpc.CallOption) (*CommonReq, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
-	return client.WithdrawMessage(ctx, in, opts...)
+	return client.ChatGroupJoin(ctx, in, opts...)
 }
 
-// 用户评价回复
-func (m *defaultMessageCenter) AppraiseMessage(ctx context.Context, in *AppraiseReq, opts ...grpc.CallOption) (*CurrencyResp, error) {
+// 群组名称修改
+func (m *defaultMessageCenter) GroupNameUpdate(ctx context.Context, in *GroupNameUpdateReq, opts ...grpc.CallOption) (*CommonReq, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
-	return client.AppraiseMessage(ctx, in, opts...)
+	return client.GroupNameUpdate(ctx, in, opts...)
 }
 
-// 客服列表查询
-func (m *defaultMessageCenter) ConversationList(ctx context.Context, in *ConversationReq, opts ...grpc.CallOption) (*UserResp, error) {
+// 群任务新增
+func (m *defaultMessageCenter) GroupNoticeAdd(ctx context.Context, in *GroupNoticeAddReq, opts ...grpc.CallOption) (*CommonReq, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
-	return client.ConversationList(ctx, in, opts...)
+	return client.GroupNoticeAdd(ctx, in, opts...)
 }
+
+// 群任务编辑
+func (m *defaultMessageCenter) GroupNoticeUpdate(ctx context.Context, in *GroupNoticeUpdateReq, opts ...grpc.CallOption) (*CommonReq, error) {
+	client := NewMessageCenterClient(m.cli.Conn())
+	return client.GroupNoticeUpdate(ctx, in, opts...)
+}
+
+// 群任务详情
+func (m *defaultMessageCenter) GroupNoticeGet(ctx context.Context, in *ChatGroupPersonReq, opts ...grpc.CallOption) (*GroupNoticeGetResp, error) {
+	client := NewMessageCenterClient(m.cli.Conn())
+	return client.GroupNoticeGet(ctx, in, opts...)
+}
+
+// 通讯录 -企业人员列表
+func (m *defaultMessageCenter) EntPersonsList(ctx context.Context, in *EntPersonsListReq, opts ...grpc.CallOption) (*EntPersonListResp, error) {
+	client := NewMessageCenterClient(m.cli.Conn())
+	return client.EntPersonsList(ctx, in, opts...)
+}
+

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1647 - 499
rpc/messagecenter/messagecenter/messagecenter.pb.go


+ 280 - 52
rpc/messagecenter/messagecenter/messagecenter_grpc.pb.go

@@ -34,16 +34,28 @@ type MessageCenterClient interface {
 	CreateChatSession(ctx context.Context, in *ChatSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error)
 	// 会话关闭
 	CloseChatSession(ctx context.Context, in *CloseSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error)
-	// 创建会话并且保存信息
+	//创建会话并且保存信息
 	SaveAutoReplyMsg(ctx context.Context, in *SaveAutoReplyReq, opts ...grpc.CallOption) (*MessageResp, error)
-	// 根据消息修改已读状态
+	//根据消息修改已读状态
 	UpdateReadById(ctx context.Context, in *ReadStateReq, opts ...grpc.CallOption) (*CurrencyResp, error)
-	// 用户撤回消息
-	WithdrawMessage(ctx context.Context, in *ReadWithdrawReq, opts ...grpc.CallOption) (*CurrencyResp, error)
-	// 用户评价回复
-	AppraiseMessage(ctx context.Context, in *AppraiseReq, opts ...grpc.CallOption) (*CurrencyResp, error)
-	// 客服列表查询
-	ConversationList(ctx context.Context, in *ConversationReq, opts ...grpc.CallOption) (*UserResp, error)
+	//群组列表查询
+	ChatGroupList(ctx context.Context, in *ChatGroupListReq, opts ...grpc.CallOption) (*ChatGroupListResp, error)
+	//群组新增
+	ChatGroupAdd(ctx context.Context, in *ChatGroupAddReq, opts ...grpc.CallOption) (*CommonReq, error)
+	//群组成员查询
+	ChatGroupPerson(ctx context.Context, in *ChatGroupPersonReq, opts ...grpc.CallOption) (*ChatGroupPersonResp, error)
+	//加入群组
+	ChatGroupJoin(ctx context.Context, in *ChatGroupJoinReq, opts ...grpc.CallOption) (*CommonReq, error)
+	//群组名称修改
+	GroupNameUpdate(ctx context.Context, in *GroupNameUpdateReq, opts ...grpc.CallOption) (*CommonReq, error)
+	//群任务新增
+	GroupNoticeAdd(ctx context.Context, in *GroupNoticeAddReq, opts ...grpc.CallOption) (*CommonReq, error)
+	//群任务编辑
+	GroupNoticeUpdate(ctx context.Context, in *GroupNoticeUpdateReq, opts ...grpc.CallOption) (*CommonReq, error)
+	//群任务详情
+	GroupNoticeGet(ctx context.Context, in *ChatGroupPersonReq, opts ...grpc.CallOption) (*GroupNoticeGetResp, error)
+	//通讯录 -企业人员列表
+	EntPersonsList(ctx context.Context, in *EntPersonsListReq, opts ...grpc.CallOption) (*EntPersonListResp, error)
 }
 
 type messageCenterClient struct {
@@ -126,27 +138,81 @@ func (c *messageCenterClient) UpdateReadById(ctx context.Context, in *ReadStateR
 	return out, nil
 }
 
-func (c *messageCenterClient) WithdrawMessage(ctx context.Context, in *ReadWithdrawReq, opts ...grpc.CallOption) (*CurrencyResp, error) {
-	out := new(CurrencyResp)
-	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/WithdrawMessage", in, out, opts...)
+func (c *messageCenterClient) ChatGroupList(ctx context.Context, in *ChatGroupListReq, opts ...grpc.CallOption) (*ChatGroupListResp, error) {
+	out := new(ChatGroupListResp)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/ChatGroupList", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
 	return out, nil
 }
 
-func (c *messageCenterClient) AppraiseMessage(ctx context.Context, in *AppraiseReq, opts ...grpc.CallOption) (*CurrencyResp, error) {
-	out := new(CurrencyResp)
-	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/AppraiseMessage", in, out, opts...)
+func (c *messageCenterClient) ChatGroupAdd(ctx context.Context, in *ChatGroupAddReq, opts ...grpc.CallOption) (*CommonReq, error) {
+	out := new(CommonReq)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/ChatGroupAdd", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
 	return out, nil
 }
 
-func (c *messageCenterClient) ConversationList(ctx context.Context, in *ConversationReq, opts ...grpc.CallOption) (*UserResp, error) {
-	out := new(UserResp)
-	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/ConversationList", in, out, opts...)
+func (c *messageCenterClient) ChatGroupPerson(ctx context.Context, in *ChatGroupPersonReq, opts ...grpc.CallOption) (*ChatGroupPersonResp, error) {
+	out := new(ChatGroupPersonResp)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/ChatGroupPerson", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *messageCenterClient) ChatGroupJoin(ctx context.Context, in *ChatGroupJoinReq, opts ...grpc.CallOption) (*CommonReq, error) {
+	out := new(CommonReq)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/ChatGroupJoin", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *messageCenterClient) GroupNameUpdate(ctx context.Context, in *GroupNameUpdateReq, opts ...grpc.CallOption) (*CommonReq, error) {
+	out := new(CommonReq)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/GroupNameUpdate", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *messageCenterClient) GroupNoticeAdd(ctx context.Context, in *GroupNoticeAddReq, opts ...grpc.CallOption) (*CommonReq, error) {
+	out := new(CommonReq)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/GroupNoticeAdd", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *messageCenterClient) GroupNoticeUpdate(ctx context.Context, in *GroupNoticeUpdateReq, opts ...grpc.CallOption) (*CommonReq, error) {
+	out := new(CommonReq)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/GroupNoticeUpdate", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *messageCenterClient) GroupNoticeGet(ctx context.Context, in *ChatGroupPersonReq, opts ...grpc.CallOption) (*GroupNoticeGetResp, error) {
+	out := new(GroupNoticeGetResp)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/GroupNoticeGet", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *messageCenterClient) EntPersonsList(ctx context.Context, in *EntPersonsListReq, opts ...grpc.CallOption) (*EntPersonListResp, error) {
+	out := new(EntPersonListResp)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/EntPersonsList", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -169,16 +235,28 @@ type MessageCenterServer interface {
 	CreateChatSession(context.Context, *ChatSessionReq) (*ChatSessionResp, error)
 	// 会话关闭
 	CloseChatSession(context.Context, *CloseSessionReq) (*ChatSessionResp, error)
-	// 创建会话并且保存信息
+	//创建会话并且保存信息
 	SaveAutoReplyMsg(context.Context, *SaveAutoReplyReq) (*MessageResp, error)
-	// 根据消息修改已读状态
+	//根据消息修改已读状态
 	UpdateReadById(context.Context, *ReadStateReq) (*CurrencyResp, error)
-	// 用户撤回消息
-	WithdrawMessage(context.Context, *ReadWithdrawReq) (*CurrencyResp, error)
-	// 用户评价回复
-	AppraiseMessage(context.Context, *AppraiseReq) (*CurrencyResp, error)
-	// 客服列表查询
-	ConversationList(context.Context, *ConversationReq) (*UserResp, error)
+	//群组列表查询
+	ChatGroupList(context.Context, *ChatGroupListReq) (*ChatGroupListResp, error)
+	//群组新增
+	ChatGroupAdd(context.Context, *ChatGroupAddReq) (*CommonReq, error)
+	//群组成员查询
+	ChatGroupPerson(context.Context, *ChatGroupPersonReq) (*ChatGroupPersonResp, error)
+	//加入群组
+	ChatGroupJoin(context.Context, *ChatGroupJoinReq) (*CommonReq, error)
+	//群组名称修改
+	GroupNameUpdate(context.Context, *GroupNameUpdateReq) (*CommonReq, error)
+	//群任务新增
+	GroupNoticeAdd(context.Context, *GroupNoticeAddReq) (*CommonReq, error)
+	//群任务编辑
+	GroupNoticeUpdate(context.Context, *GroupNoticeUpdateReq) (*CommonReq, error)
+	//群任务详情
+	GroupNoticeGet(context.Context, *ChatGroupPersonReq) (*GroupNoticeGetResp, error)
+	//通讯录 -企业人员列表
+	EntPersonsList(context.Context, *EntPersonsListReq) (*EntPersonListResp, error)
 	mustEmbedUnimplementedMessageCenterServer()
 }
 
@@ -210,14 +288,32 @@ func (UnimplementedMessageCenterServer) SaveAutoReplyMsg(context.Context, *SaveA
 func (UnimplementedMessageCenterServer) UpdateReadById(context.Context, *ReadStateReq) (*CurrencyResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method UpdateReadById not implemented")
 }
-func (UnimplementedMessageCenterServer) WithdrawMessage(context.Context, *ReadWithdrawReq) (*CurrencyResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method WithdrawMessage not implemented")
+func (UnimplementedMessageCenterServer) ChatGroupList(context.Context, *ChatGroupListReq) (*ChatGroupListResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ChatGroupList not implemented")
+}
+func (UnimplementedMessageCenterServer) ChatGroupAdd(context.Context, *ChatGroupAddReq) (*CommonReq, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ChatGroupAdd not implemented")
+}
+func (UnimplementedMessageCenterServer) ChatGroupPerson(context.Context, *ChatGroupPersonReq) (*ChatGroupPersonResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ChatGroupPerson not implemented")
+}
+func (UnimplementedMessageCenterServer) ChatGroupJoin(context.Context, *ChatGroupJoinReq) (*CommonReq, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ChatGroupJoin not implemented")
+}
+func (UnimplementedMessageCenterServer) GroupNameUpdate(context.Context, *GroupNameUpdateReq) (*CommonReq, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GroupNameUpdate not implemented")
 }
-func (UnimplementedMessageCenterServer) AppraiseMessage(context.Context, *AppraiseReq) (*CurrencyResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method AppraiseMessage not implemented")
+func (UnimplementedMessageCenterServer) GroupNoticeAdd(context.Context, *GroupNoticeAddReq) (*CommonReq, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GroupNoticeAdd not implemented")
 }
-func (UnimplementedMessageCenterServer) ConversationList(context.Context, *ConversationReq) (*UserResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method ConversationList not implemented")
+func (UnimplementedMessageCenterServer) GroupNoticeUpdate(context.Context, *GroupNoticeUpdateReq) (*CommonReq, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GroupNoticeUpdate not implemented")
+}
+func (UnimplementedMessageCenterServer) GroupNoticeGet(context.Context, *ChatGroupPersonReq) (*GroupNoticeGetResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GroupNoticeGet not implemented")
+}
+func (UnimplementedMessageCenterServer) EntPersonsList(context.Context, *EntPersonsListReq) (*EntPersonListResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method EntPersonsList not implemented")
 }
 func (UnimplementedMessageCenterServer) mustEmbedUnimplementedMessageCenterServer() {}
 
@@ -376,56 +472,164 @@ func _MessageCenter_UpdateReadById_Handler(srv interface{}, ctx context.Context,
 	return interceptor(ctx, in, info, handler)
 }
 
-func _MessageCenter_WithdrawMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(ReadWithdrawReq)
+func _MessageCenter_ChatGroupList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ChatGroupListReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).ChatGroupList(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/ChatGroupList",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).ChatGroupList(ctx, req.(*ChatGroupListReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _MessageCenter_ChatGroupAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ChatGroupAddReq)
 	if err := dec(in); err != nil {
 		return nil, err
 	}
 	if interceptor == nil {
-		return srv.(MessageCenterServer).WithdrawMessage(ctx, in)
+		return srv.(MessageCenterServer).ChatGroupAdd(ctx, in)
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: "/messagecenter.messageCenter/WithdrawMessage",
+		FullMethod: "/messagecenter.messageCenter/ChatGroupAdd",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(MessageCenterServer).WithdrawMessage(ctx, req.(*ReadWithdrawReq))
+		return srv.(MessageCenterServer).ChatGroupAdd(ctx, req.(*ChatGroupAddReq))
 	}
 	return interceptor(ctx, in, info, handler)
 }
 
-func _MessageCenter_AppraiseMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(AppraiseReq)
+func _MessageCenter_ChatGroupPerson_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ChatGroupPersonReq)
 	if err := dec(in); err != nil {
 		return nil, err
 	}
 	if interceptor == nil {
-		return srv.(MessageCenterServer).AppraiseMessage(ctx, in)
+		return srv.(MessageCenterServer).ChatGroupPerson(ctx, in)
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: "/messagecenter.messageCenter/AppraiseMessage",
+		FullMethod: "/messagecenter.messageCenter/ChatGroupPerson",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(MessageCenterServer).AppraiseMessage(ctx, req.(*AppraiseReq))
+		return srv.(MessageCenterServer).ChatGroupPerson(ctx, req.(*ChatGroupPersonReq))
 	}
 	return interceptor(ctx, in, info, handler)
 }
 
-func _MessageCenter_ConversationList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(ConversationReq)
+func _MessageCenter_ChatGroupJoin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ChatGroupJoinReq)
 	if err := dec(in); err != nil {
 		return nil, err
 	}
 	if interceptor == nil {
-		return srv.(MessageCenterServer).ConversationList(ctx, in)
+		return srv.(MessageCenterServer).ChatGroupJoin(ctx, in)
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: "/messagecenter.messageCenter/ConversationList",
+		FullMethod: "/messagecenter.messageCenter/ChatGroupJoin",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(MessageCenterServer).ConversationList(ctx, req.(*ConversationReq))
+		return srv.(MessageCenterServer).ChatGroupJoin(ctx, req.(*ChatGroupJoinReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _MessageCenter_GroupNameUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(GroupNameUpdateReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).GroupNameUpdate(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/GroupNameUpdate",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).GroupNameUpdate(ctx, req.(*GroupNameUpdateReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _MessageCenter_GroupNoticeAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(GroupNoticeAddReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).GroupNoticeAdd(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/GroupNoticeAdd",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).GroupNoticeAdd(ctx, req.(*GroupNoticeAddReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _MessageCenter_GroupNoticeUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(GroupNoticeUpdateReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).GroupNoticeUpdate(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/GroupNoticeUpdate",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).GroupNoticeUpdate(ctx, req.(*GroupNoticeUpdateReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _MessageCenter_GroupNoticeGet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ChatGroupPersonReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).GroupNoticeGet(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/GroupNoticeGet",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).GroupNoticeGet(ctx, req.(*ChatGroupPersonReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _MessageCenter_EntPersonsList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(EntPersonsListReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).EntPersonsList(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/EntPersonsList",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).EntPersonsList(ctx, req.(*EntPersonsListReq))
 	}
 	return interceptor(ctx, in, info, handler)
 }
@@ -470,16 +674,40 @@ var MessageCenter_ServiceDesc = grpc.ServiceDesc{
 			Handler:    _MessageCenter_UpdateReadById_Handler,
 		},
 		{
-			MethodName: "WithdrawMessage",
-			Handler:    _MessageCenter_WithdrawMessage_Handler,
+			MethodName: "ChatGroupList",
+			Handler:    _MessageCenter_ChatGroupList_Handler,
+		},
+		{
+			MethodName: "ChatGroupAdd",
+			Handler:    _MessageCenter_ChatGroupAdd_Handler,
+		},
+		{
+			MethodName: "ChatGroupPerson",
+			Handler:    _MessageCenter_ChatGroupPerson_Handler,
+		},
+		{
+			MethodName: "ChatGroupJoin",
+			Handler:    _MessageCenter_ChatGroupJoin_Handler,
+		},
+		{
+			MethodName: "GroupNameUpdate",
+			Handler:    _MessageCenter_GroupNameUpdate_Handler,
+		},
+		{
+			MethodName: "GroupNoticeAdd",
+			Handler:    _MessageCenter_GroupNoticeAdd_Handler,
+		},
+		{
+			MethodName: "GroupNoticeUpdate",
+			Handler:    _MessageCenter_GroupNoticeUpdate_Handler,
 		},
 		{
-			MethodName: "AppraiseMessage",
-			Handler:    _MessageCenter_AppraiseMessage_Handler,
+			MethodName: "GroupNoticeGet",
+			Handler:    _MessageCenter_GroupNoticeGet_Handler,
 		},
 		{
-			MethodName: "ConversationList",
-			Handler:    _MessageCenter_ConversationList_Handler,
+			MethodName: "EntPersonsList",
+			Handler:    _MessageCenter_EntPersonsList_Handler,
 		},
 	},
 	Streams:  []grpc.StreamDesc{},

+ 225 - 0
service/chat_group.go

@@ -0,0 +1,225 @@
+package service
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jypkg/ent/chain-zhang/pinyin"
+	util "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/entity"
+	IC "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/init"
+	"database/sql"
+	"fmt"
+	"time"
+)
+
+type ChatGroupService struct{}
+
+//群组列表查询
+func (b ChatGroupService) ChatGroupList(entId, positionId int64, userName, groupName string, appid string) []map[string]interface{} {
+	userNameStr := ""
+	groupNameStr := ""
+	if userName != "" {
+		positionIdArr := NameToPositionIdp("%"+userName+"%", entId)
+		userNameStr = " and find_in_set(f.position_id,'" + positionIdArr + "')"
+	}
+	if groupName != "" {
+		groupNameStr = " and b.name like '%" + groupName + "%'"
+	}
+	data := IC.BaseMysql.SelectBySql(fmt.Sprintf("SELECT e.chat_group_id as chatGroupId,b.name,(select count(id) from  socialize_chat_group_person c where c.chat_group_id=b.id  and c.status=1) as  count   FROM  "+
+		"socialize_chat_group_person e "+
+		"INNER JOIN socialize_chat_group_person f ON e.position_id = %d  %s  AND e.chat_group_id = f.chat_group_id  and e.status=1  "+
+		"INNER JOIN  socialize_chat_group b on  e.chat_group_id=b.id %s "+
+		"GROUP BY  e.chat_group_id order by b.create_time desc", positionId, userNameStr, groupNameStr))
+	return *data
+}
+
+//群组新增
+func (b ChatGroupService) ChatGroupAdd(entId, positionId int64, userIdArr []int64, appid string) bool {
+	nowStr := time.Now().Local().Format(util.Date_Full_Layout)
+	insertMap := map[string]interface{}{
+		"name":        "无主题群聊",
+		"appid":       appid,
+		"create_time": nowStr,
+		"isdismiss":   0,
+	}
+	fool := IC.BaseMysql.ExecTx("群组人员保存", func(tx *sql.Tx) bool {
+		ok1 := IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_CHAT_GROUP, insertMap)
+		personKey := []string{"appid", "chat_group_id", "position_id", "join_time", "invite_id", "isgroup_admin", "iscommon_admin", "status"}
+		pushInsert := []interface{}{}
+		for _, v := range userIdArr {
+			pushInsert = append(pushInsert, appid, ok1, v, nowStr, positionId, 0, 0, 1)
+		}
+		pushInsert = append(pushInsert, appid, ok1, positionId, nowStr, positionId, 1, 0, 1)
+		_, ok2 := IC.BaseMysql.InsertIgnoreBatchByTx(tx, util.SOCIALIZE_CHAT_GROUP_PERSON, personKey, pushInsert)
+		return ok1 > 0 && ok2 > 0
+	})
+	return fool
+}
+
+//群组成员查询
+func (b ChatGroupService) ChatGroupPerson(chatGroupId int64, entId int64, appid string) map[string][]map[string]interface{} {
+	//先查询企业下的人
+	personMap, _ := EntPerson(entId, false)
+	//用户下员工查询
+	personData := map[string][]map[string]interface{}{}
+	personList := IC.BaseMysql.SelectBySql("select DISTINCT  a.position_id,a.isgroup_admin,a.iscommon_admin,d.contact as phone   from socialize_chat_group_person  a left JOIN   base_position b on  a.position_id=b.id left join  base_account c  on  c.id=b.account_id  LEFT JOIN base_person d on  c.person_id=d.id where  a.chat_group_id=? and a.status=1 ", chatGroupId)
+	if personList != nil && len(*personList) > 0 {
+		for k, v := range *personList {
+			name := personMap[common.InterfaceToStr(v["phone"])]
+			if name != "" {
+				str, _ := pinyin.New(name).Mode(pinyin.InitialsInCapitals).Convert()
+				zimu := str[0:1]
+				(*personList)[k]["name"] = name
+				personData[zimu] = append(personData[zimu], (*personList)[k])
+			}
+		}
+	}
+	return personData
+}
+
+//加入群组
+func (b ChatGroupService) ChatGroupJoin(chatGroupId, positionId int64, userIdArr []int64, appid string) bool {
+	nowStr := time.Now().Local().Format(util.Date_Full_Layout)
+	if len(userIdArr) == 0 {
+		return false
+	}
+	personStr := util.IntJoin(userIdArr, ",")
+	countData := IC.BaseMysql.SelectBySql(fmt.Sprintf("select count(1) as count from  %s where  chat_group_id=? and  find_in_set(position_id,?)", util.SOCIALIZE_CHAT_GROUP_PERSON), chatGroupId, personStr)
+	if countData == nil || len(*countData) == 0 {
+		return false
+	}
+	if common.Int64All((*countData)[0]["count"]) > 0 {
+		return false
+	}
+	fool := IC.BaseMysql.ExecTx("聊天信息保存", func(tx *sql.Tx) bool {
+		personKey := []string{"appid", "chat_group_id", "position_id", "join_time", "invite_id", "isgroup_admin", "iscommon_admin", "status"}
+		pushInsert := []interface{}{}
+		for _, v := range userIdArr {
+			pushInsert = append(pushInsert, appid, chatGroupId, v, nowStr, positionId, 1, 0, 1)
+		}
+		_, ok1 := IC.BaseMysql.InsertIgnoreBatchByTx(tx, util.SOCIALIZE_CHAT_GROUP_PERSON, personKey, pushInsert)
+		if ok1 == 0 {
+			return false
+		}
+		//30条历史记录添加
+		messageList := IC.BaseMysql.SelectBySqlByTx(tx,
+			fmt.Sprintf("SELECT  messag_id,  MAX( appid ) AS appid,MAX( type ) AS type,MAX( send_user_id ) AS send_user_id,MAX( send_user_type ) AS send_user_type,MAX( read_time ) AS read_time,MAX( create_time ) AS create_time,MAX( chat_group_id ) AS chat_group_id  "+
+				"FROM  %s   WHERE   chat_group_id = ?  and  type in (3,6)   AND iswithdraw = 0     GROUP BY  messag_id", util.SOCIALIZE_MESSAGE_MAILBOX), chatGroupId)
+		if len(*messageList) > 0 && messageList != nil {
+			messageKey := []string{
+				"appid", "messag_id", "type", "send_user_id", "send_user_type", "receive_user_id", "receive_user_type", "iswithdraw", "own_type", "own_id", "read_time", "create_time", "isread", "chat_group_id"}
+			messageInsert := []interface{}{}
+			for _, userValue := range userIdArr {
+				for _, v := range *messageList {
+					messageInsert = append(messageInsert,
+						v["appid"],
+						v["messag_id"],
+						v["type"],
+						v["send_user_id"],
+						v["send_user_type"],
+						userValue,
+						1,
+						0,
+						1,
+						userValue,
+						v["read_time"],
+						v["create_time"],
+						1,
+						v["chat_group_id"],
+					)
+				}
+			}
+			_, ok2 := IC.BaseMysql.InsertIgnoreBatchByTx(tx, util.SOCIALIZE_MESSAGE_MAILBOX, messageKey, messageInsert)
+			if ok2 == 0 {
+				return false
+			}
+			return ok1 > 0 && ok2 > 0
+		}
+		return true
+	})
+	return fool
+}
+
+//群组名称修改
+func (b ChatGroupService) GroupNameUpdate(chatGroupId int64, groupName, appid string) bool {
+	IC.BaseMysql.Update(util.SOCIALIZE_CHAT_GROUP, map[string]interface{}{
+		"id":    chatGroupId,
+		"appid": appid,
+	}, map[string]interface{}{
+		"name": groupName,
+	})
+	return true
+}
+
+//群任务编辑
+func (b ChatGroupService) GroupNoticeUpdate(groupNoticeId int64, content, appid string) bool {
+	return IC.BaseMysql.Update(util.SOCIALIZE_CHAT_GROUP_NOTICE, map[string]interface{}{
+		"appid": appid,
+		"id":    groupNoticeId,
+	}, map[string]interface{}{
+		"content": content,
+	})
+}
+
+//群任务新增
+func (b ChatGroupService) GroupNoticeAdd(chatGroupId int64, content, appid string) bool {
+	nowStr := time.Now().Local().Format(util.Date_Full_Layout)
+	id := IC.BaseMysql.Insert(util.SOCIALIZE_CHAT_GROUP_NOTICE, map[string]interface{}{
+		"appid":         appid,
+		"chat_group_id": chatGroupId,
+		"create_time":   nowStr,
+		"content":       content,
+	})
+	if id > 0 {
+		return true
+	}
+	return false
+}
+
+//群任务详情
+func (b ChatGroupService) GroupNoticeGet(chatGroupId int64, appid string) map[string]interface{} {
+	data := IC.BaseMysql.FindOne(util.SOCIALIZE_CHAT_GROUP_NOTICE, map[string]interface{}{
+		"chat_group_id": chatGroupId,
+		"appid":         appid,
+	}, "", "create_time")
+	return *data
+}
+
+//企业用户查询
+func EntPerson(entId int64, isAll bool) (map[string]string, map[string]string) {
+	phoneData := map[string]string{}
+	nameData := map[string]string{}
+	//在职人员查询
+	personList := IC.MainMysql.Find(util.ENTNICHE_USER, map[string]interface{}{
+		"ent_Id": entId,
+	}, "phone,name", "", -1, -1)
+	if personList != nil && len(*personList) > 0 {
+		for _, v := range *personList {
+			phoneData[common.InterfaceToStr(v["phone"])] = common.InterfaceToStr(v["name"])
+			nameData[common.InterfaceToStr(v["name"])] = common.InterfaceToStr(v["phone"])
+		}
+	}
+	//离职人员查看
+	if isAll {
+		departData, _ := IC.Mgo.Find(util.ENTNICHE_DELETE, map[string]interface{}{
+			"bablename": "entniche_user",
+			"ent_id":    entId,
+		}, "", `{"name":1,"phone":1}`, true, -1, -1)
+		if departData != nil && len(*departData) > 0 {
+			for _, v := range *departData {
+				phoneData[common.InterfaceToStr(v["phone"])] = common.InterfaceToStr(v["name"])
+				nameData[common.InterfaceToStr(v["name"])] = common.InterfaceToStr(v["phone"])
+			}
+		}
+	}
+	return phoneData, nameData
+}
+func NameToPositionIdp(userName string, entId int64) string {
+	personList := IC.MainMysql.SelectBySql(fmt.Sprintf(" select GROUP_CONCAT(phone) as phone from %s where ent_id=%d and name like '%s'  ", util.ENTNICHE_USER, entId, userName))
+	if len(*personList) > 0 {
+		phoneStr := (*personList)[0]["phone"]
+		positionArr := IC.BaseMysql.SelectBySql(fmt.Sprintf("select  GROUP_CONCAT(b.id) as positionIdArr from  %s a INNER JOIN  base_position b  on  b.type=1 and    find_in_set(a.phone,'%s') and  b.ent_id=%d  and  a.id=b.user_id ", util.BASE_USER, phoneStr, entId))
+		if len(*positionArr) > 0 {
+			return common.ObjToString((*positionArr)[0]["positionIdArr"])
+		}
+	}
+	return ""
+}

+ 285 - 0
service/chat_group_test.go

@@ -0,0 +1,285 @@
+package service
+
+import (
+	"reflect"
+	"testing"
+)
+
+func TestChatGroupService_ChatGroupAdd(t *testing.T) {
+	type args struct {
+		entId      int64
+		positionId int64
+		userIdArr  []int64
+		appid      string
+	}
+	tests := []struct {
+		name string
+		args args
+		want bool
+	}{
+		// TODO: Add test cases.
+		{
+			name: "群组新增",
+			args: args{
+				entId:      15755,
+				positionId: 1204781623,
+				userIdArr:  []int64{1204841316},
+				appid:      "10000",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			b := ChatGroupService{}
+			if got := b.ChatGroupAdd(tt.args.entId, tt.args.positionId, tt.args.userIdArr, tt.args.appid); got != tt.want {
+				t.Errorf("ChatGroupAdd() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestChatGroupService_ChatGroupJoin(t *testing.T) {
+	type args struct {
+		chatGroupId int64
+		positionId  int64
+		userIdArr   []int64
+		appid       string
+	}
+	tests := []struct {
+		name string
+		args args
+		want bool
+	}{
+		// TODO: Add test cases.
+		{
+			name: "拉人进群",
+			args: args{
+				chatGroupId: 3,
+				positionId:  1204781623,
+				userIdArr:   []int64{1204841317},
+				appid:       "10000",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			b := ChatGroupService{}
+			if got := b.ChatGroupJoin(tt.args.chatGroupId, tt.args.positionId, tt.args.userIdArr, tt.args.appid); got != tt.want {
+				t.Errorf("ChatGroupJoin() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestChatGroupService_ChatGroupList(t *testing.T) {
+	type args struct {
+		entId      int64
+		positionId int64
+		userName   string
+		groupName  string
+		appid      string
+	}
+	tests := []struct {
+		name string
+		args args
+		want []map[string]interface{}
+	}{
+		// TODO: Add test cases.
+		{name: "我的群聊列表默认",
+			args: args{
+				entId:      15755,
+				positionId: 1204781623,
+				userName:   "张",
+				groupName:  "",
+				appid:      "10000",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			b := ChatGroupService{}
+			if got := b.ChatGroupList(tt.args.entId, tt.args.positionId, tt.args.userName, tt.args.groupName, tt.args.appid); !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("ChatGroupList() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestChatGroupService_ChatGroupPerson(t *testing.T) {
+	type args struct {
+		ChatGroupId int64
+		entId       int64
+		appid       string
+	}
+	tests := []struct {
+		name string
+		args args
+		want map[string][]map[string]interface{}
+	}{
+		// TODO: Add test cases.
+		{
+			name: "群成员",
+			args: args{
+				ChatGroupId: 3,
+				entId:       15755,
+				appid:       "10000",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			b := ChatGroupService{}
+			if got := b.ChatGroupPerson(tt.args.ChatGroupId, tt.args.entId, tt.args.appid); !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("ChatGroupPerson() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestChatGroupService_GroupNameUpdate(t *testing.T) {
+	type args struct {
+		chatGroupId int64
+		groupName   string
+		appid       string
+	}
+	tests := []struct {
+		name string
+		args args
+		want bool
+	}{
+		// TODO: Add test cases.
+		{
+			name: "表名修改",
+			args: args{
+				chatGroupId: 3,
+				groupName:   "策士",
+				appid:       "10000",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			b := ChatGroupService{}
+			if got := b.GroupNameUpdate(tt.args.chatGroupId, tt.args.groupName, tt.args.appid); got != tt.want {
+				t.Errorf("GroupNameUpdate() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestChatGroupService_GroupNoticeAdd(t *testing.T) {
+	type args struct {
+		chatGroupId int64
+		content     string
+		appid       string
+	}
+	tests := []struct {
+		name string
+		args args
+		want bool
+	}{
+		// TODO: Add test cases.
+		{
+			name: "公告新增",
+			args: args{
+				chatGroupId: 3,
+				content:     "一起来玩啊",
+				appid:       "10000",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			b := ChatGroupService{}
+			if got := b.GroupNoticeAdd(tt.args.chatGroupId, tt.args.content, tt.args.appid); got != tt.want {
+				t.Errorf("GroupNoticeAdd() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestChatGroupService_GroupNoticeGet(t *testing.T) {
+	type args struct {
+		chatGroupId int64
+		appid       string
+	}
+	tests := []struct {
+		name string
+		args args
+		want map[string]interface{}
+	}{
+		// TODO: Add test cases.
+		{
+			name: "公告获取",
+			args: args{
+				chatGroupId: 3,
+				appid:       "10000",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			b := ChatGroupService{}
+			if got := b.GroupNoticeGet(tt.args.chatGroupId, tt.args.appid); !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("GroupNoticeGet() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestChatGroupService_GroupNoticeUpdate(t *testing.T) {
+	type args struct {
+		groupNoticeId int64
+		content       string
+		appid         string
+	}
+	tests := []struct {
+		name string
+		args args
+		want bool
+	}{
+		// TODO: Add test cases.
+		{
+			name: "公告修改",
+			args: args{
+				groupNoticeId: 1,
+				content:       "一起来吗qqqqq",
+				appid:         "10000",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			b := ChatGroupService{}
+			if got := b.GroupNoticeUpdate(tt.args.groupNoticeId, tt.args.content, tt.args.appid); got != tt.want {
+				t.Errorf("GroupNoticeUpdate() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestEntPerson(t *testing.T) {
+	type args struct {
+		entId int64
+		isAll bool
+	}
+	tests := []struct {
+		name  string
+		args  args
+		want  map[string]string
+		want1 map[string]string
+	}{
+		// TODO: Add test cases.
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			got, got1 := EntPerson(tt.args.entId, tt.args.isAll)
+			if !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("EntPerson() got = %v, want %v", got, tt.want)
+			}
+			if !reflect.DeepEqual(got1, tt.want1) {
+				t.Errorf("EntPerson() got1 = %v, want %v", got1, tt.want1)
+			}
+		})
+	}
+}

+ 59 - 0
service/ent_address_book.go

@@ -0,0 +1,59 @@
+package service
+
+import (
+	"app.yhyue.com/moapp/jybase/go-xweb/log"
+	IC "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/init"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+)
+
+func (b ChatGroupService) EntPersonsList(param *messagecenter.EntPersonsListReq) {
+	var sql string
+	if param.Name != "" {
+		sql = "SELECT a.id,a.pid,a.name,c.id as user_id,c.name as user_name,c.phone as user_phone,c.power as user_power,e.name as role from entniche_department a " +
+			"INNER JOIN entniche_department_user b on (a.ent_id=? and a.id=b.dept_id) " +
+			"INNER JOIN entniche_user c on (b.user_id=c.id and c.name like '%" + param.Name + "%') " +
+			"LEFT JOIN entniche_user_role d on (c.id=d.user_id) " +
+			"LEFT JOIN entniche_role e on (d.role_id=e.id) " +
+			"order by a.id,convert(c.name using gbk) COLLATE gbk_chinese_ci asc"
+	} else {
+		sql = `SELECT a.id,a.pid,a.name,c.id as user_id,c.name as user_name,c.phone as user_phone,c.power as user_power,e.name as role from entniche_department a 
+			INNER JOIN entniche_department_user b on (a.ent_id=? and a.id=b.dept_id) 
+			INNER JOIN entniche_user c on (b.user_id=c.id) 
+			LEFT JOIN entniche_user_role d on (c.id=d.user_id) 
+			LEFT JOIN entniche_role e on (d.role_id=e.id) 
+			order by a.id,convert(c.name using gbk) COLLATE gbk_chinese_ci asc`
+	}
+	data := IC.MainMysql.SelectBySql(sql, param.EntId)
+	if data != nil && len(*data) > 0 {
+		for _, v := range *data {
+			log.Println(v)
+			//id := cm.IntAll(v["id"])
+
+			/*user := map[string]interface{}{
+				"user_id":  cm.IntAll(v["user_id"]),
+				"power":    user_power,
+				"username": cm.ObjToString(v["user_name"]),
+				"phone":    cm.ObjToString(v["user_phone"]),
+				"role":     cm.ObjToString(v["role"]),
+			}
+			//log.Println("权限:", user_power)
+
+			list = append(list, map[string]interface{}{
+				"id":    id,
+				"pid":   cm.IntAll(v["pid"]),
+				"name":  cm.ObjToString(v["name"]),
+				"users": []map[string]interface{}{user},
+			})*/
+		}
+	}
+
+	//log.Println(checkedArr)
+	/*this.ServeJson(Result{Data: M{
+		"entname":     this.GetSession("entName"),
+		"checked":     checked,
+		"quota":       VarEntInfo.GetById(entId).Quota,
+		"mystaff":     Mysql.Count(Entniche_user, map[string]interface{}{"ent_id": entId}),
+		"list":        list,
+		"checkedList": checkedArr,
+	}})*/
+}

+ 34 - 0
service/ent_address_book_test.go

@@ -0,0 +1,34 @@
+package service
+
+import (
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+	"testing"
+)
+
+func TestChatGroupService_EntPersonsList(t *testing.T) {
+	type args struct {
+		param *messagecenter.EntPersonsListReq
+	}
+	tests := []struct {
+		name string
+		args args
+	}{
+		// TODO: Add test cases.
+		{
+			name: "企业列表",
+			args: args{
+				&messagecenter.EntPersonsListReq{
+					EntId:   14929,
+					Name:    "",
+					GroupId: 0,
+				},
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			b := ChatGroupService{}
+			b.EntPersonsList(tt.args.param)
+		})
+	}
+}

+ 144 - 372
service/message_mail_box.go

@@ -2,22 +2,19 @@ package service
 
 import (
 	quitl "app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/encrypt"
 	util "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/entity"
+	IC "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/init"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
 	"database/sql"
 	"fmt"
 	"log"
-	"strings"
-	"sync"
 	"time"
 )
 
 type MessaggeService struct{}
 
-// 未读消息查询
+//未读消息查询
 func (b MessaggeService) Count(newUserId, userType, entUserId int64, isClean bool) (count int, last map[string]interface{}, err error) {
-	log.Printf("用户id:%d,userType:%d,entUserId:%d,isClean:%v", newUserId, userType, entUserId, isClean)
 	v := make([]interface{}, 0)
 	sqlStr := ""
 	if userType == 1 {
@@ -32,8 +29,7 @@ func (b MessaggeService) Count(newUserId, userType, entUserId int64, isClean boo
 		sqlStr = fmt.Sprintf("select  count(b.id) from   %s a  "+
 			"LEFT  JOIN  %s  b ON a.id=b.own_id "+
 			"where  b.type=5 "+
-			"AND   a.customer_service_id=%d  "+
-			"AND b.iswithdraw = 0  "+
+			"AND   a.customer_service_id=%d   "+
 			"AND  b.isread=0  "+
 			"AND own_type = 1 "+
 			"order by create_time", util.SOCIALIZE_CHAT_SESSION, util.SOCIALIZE_MESSAGE_MAILBOX, entUserId)
@@ -47,55 +43,51 @@ func (b MessaggeService) Count(newUserId, userType, entUserId int64, isClean boo
 		}
 		sqlStr = fmt.Sprintf("select  count(b.id) from    %s  b "+
 			"where   b.send_user_id != %d    "+
-			"AND   b.own_id=%d "+
-			"AND b.iswithdraw = 0  "+
+			"AND   b.own_id=%d  "+
 			"AND  b.isread=0 "+
 			"AND own_type = 2 "+
 			"order by create_time", util.SOCIALIZE_MESSAGE_MAILBOX, newUserId, newUserId)
 
 	}
 	log.Println(sqlStr, v)
-	rs := util.Mysql.CountBySql(sqlStr, v...)
+	rs := IC.BaseMysql.CountBySql(sqlStr, v...)
 	log.Println(rs)
 	count = int(rs)
 	//最后一条信息查询
 	sqlStr = fmt.Sprintf("SELECT  c.* FROM %s  b   "+
 		"LEFT join %s c on  b.messag_id=c.id "+
 		"WHERE  b.send_user_id != %d   "+
-		"AND b.own_id = %d "+
-		"AND b.iswithdraw = 0  "+
+		"AND b.own_id = %d  "+
 		"AND   b.isread=0  "+
 		"AND own_type = 2  "+
 		"ORDER BY  create_time DESC   "+
 		"LIMIT 0,1", util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE,
 		newUserId, newUserId)
-	lastData := util.Mysql.SelectBySql(sqlStr)
+	lastData := IC.BaseMysql.SelectBySql(sqlStr)
 	if len(*lastData) > 0 {
 		last = (*lastData)[0]
 		if userType == 1 {
-			util.SetData(userType, entUserId, map[string]interface{}{"data": last, "count": count}, util.SurvivalTime)
+			util.SetData(userType, entUserId, map[string]interface{}{"data": last, "count": count}, IC.SurvivalTime)
 		} else {
-			util.SetData(userType, newUserId, map[string]interface{}{"data": last, "count": count}, util.SurvivalTime)
+			util.SetData(userType, newUserId, map[string]interface{}{"data": last, "count": count}, IC.SurvivalTime)
 		}
 	} else {
 		if userType == 1 {
-			util.SetData(userType, entUserId, map[string]interface{}{"data": map[string]interface{}{}, "count": count}, util.SurvivalTime)
+			util.SetData(userType, entUserId, map[string]interface{}{"data": map[string]interface{}{}, "count": count}, IC.SurvivalTime)
 		} else {
-			util.SetData(userType, newUserId, map[string]interface{}{"data": map[string]interface{}{}, "count": count}, util.SurvivalTime)
+			util.SetData(userType, newUserId, map[string]interface{}{"data": map[string]interface{}{}, "count": count}, IC.SurvivalTime)
 		}
 	}
 	return
 }
 
-// 用户列表查询
-func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string]interface{}, count int64, err error) {
+//用户列表查询
+func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string]interface{}, err error) {
 	sqlStr := ""
-	tm := time.Now()
 	if in.UserType == 2 {
 		//用户最后一次信息查询
 		userSql := fmt.Sprintf("SELECT  MAX( c.id )   as messageId  FROM  socialize_message_mailbox c "+
-			"WHERE  c.own_id = %d  "+
-			"AND c.iswithdraw = 0  "+
+			"WHERE  c.own_id = %d   "+
 			"AND c.type = 2   "+
 			"AND c.own_type = 2 "+
 			"GROUP BY  (  CASE  WHEN c.send_user_id > c.receive_user_id "+
@@ -103,29 +95,28 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 			"WHEN c.send_user_id < c.receive_user_id "+
 			"THEN  CONCAT( c.receive_user_id, c.send_user_id )  END  ) ", in.NewUserId,
 		)
-		data = util.Mysql.SelectBySql(userSql)
+		data = IC.BaseMysql.SelectBySql(userSql)
 		userMessageId := util.Inhandle(data)
 		//客服最后一次信息查询
 		customerSql := fmt.Sprintf("SELECT   MAX( c.id )   as messageId  FROM   %s c "+
 			"LEFT JOIN %s d ON  IF   ( c.send_user_type = 1, d.id = c.send_user_id, d.id = c.receive_user_id ) "+
 			"WHERE   c.own_id = %d  "+
-			"AND c.iswithdraw = 0 "+
 			"AND ( c.type = 4 OR c.type = 5  or c.type=6 or  c.type=7 ) "+
 			"AND c.own_type = 2 "+
 			"AND   d.user_id=c.own_id "+
 			"GROUP BY   d.ent_id  ", util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION, in.NewUserId)
-		data = util.Mysql.SelectBySql(customerSql)
+		data = IC.BaseMysql.SelectBySql(customerSql)
 		customerMessageId := util.Inhandle(data)
 		//用户的列表
 		sqlStr = fmt.Sprintf("SELECT "+
-			"(  CASE        WHEN SUBSTR( b.nickname, 1, 3 ) = 'JY_' THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) )     WHEN b.nickname = '' or b.nickname is null THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) ELSE b.nickname    END    )"+
+			"(  CASE        WHEN SUBSTR( b.nickname, 1, 3 ) = 'JY_' THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) )     WHEN b.nickname = '' THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) ELSE b.nickname    END    )"+
 			"AS name, b.id, e.title, b.headimg, e.type, e.link, e.content, 2 AS userType, a.create_time, a.type AS itemType, "+
 			"( SELECT  count( h.id )  FROM  %s h  "+
 			"WHERE  h.type = 2  "+
 			"AND h.own_id = %d  "+
 			"AND h.own_type = 2  "+
 			"AND   h.send_user_id=b.id   "+
-			"AND h.isread = 0 AND h.iswithdraw = 0  ) AS number  FROM  %s a "+
+			"AND h.isread = 0  ) AS number  FROM  %s a "+
 			"LEFT JOIN  %s b ON  b.id = a.receive_user_id or  b.id = a.send_user_id  "+
 			"LEFT JOIN  %s e ON e.id = a.messag_id  "+
 			"WHERE a.id IN ( %s )  AND b.id != %d "+
@@ -154,168 +145,75 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 			util.SOCIALIZE_TENANT_ROBOT,
 			customerMessageId)
 	} else {
-		idSql := fmt.Sprintf(" (a.customer_service_id = %d OR a.customer_service_id = 0) ", in.EntUserId)
-		if in.IsArtificial == 1 {
-			idSql = fmt.Sprintf(" a.customer_service_id = %d ", in.EntUserId)
-		} else if in.IsArtificial == 2 {
-			idSql = " a.customer_service_id = 0 "
+		phoneSql := ""
+		if in.Phone != "" {
+			phoneSql = "AND  b.phone like '%" + in.Phone + "%'"
 		}
+		startTimeSql := ""
 		if in.StartTime != "" {
-			idSql += " AND  DATE_FORMAT(a.update_time,'%Y-%m-%d') >= '" + in.StartTime + "' "
+			startTimeSql = "AND  DATE_FORMAT(c.create_time,'%Y-%m-%d') >= '" + in.StartTime + "' "
 		}
+		endTimeSql := ""
 		if in.EndTime != "" {
-			idSql += "AND DATE_FORMAT(a.update_time,'%Y-%m-%d') <= '" + in.EndTime + "' "
-		}
-		if in.Phone != "" {
-			idSql += " AND  b.phone like '%" + in.Phone + "%'"
-		}
-		if in.FiltrationId != "" {
-			var ids []string
-			for _, v := range strings.Split(in.FiltrationId, ",") {
-				ids = append(ids, encrypt.SE.Decode4Hex(v))
-			}
-			idSql += fmt.Sprintf(" AND  b.id not in (%s)", strings.Join(ids, ","))
-		}
-		if in.Page <= 0 {
-			in.Page = 1
+			endTimeSql = "AND DATE_FORMAT(c.create_time,'%Y-%m-%d') <= '" + in.EndTime + "' "
+		}
+		//先获取每个用户最后聊天记录
+		userSql := fmt.Sprintf("SELECT   MAX( c.id ) as messageId   FROM  %s c   "+
+			"LEFT JOIN %s d ON   c.own_type=1 AND  c.own_id=d.id   "+
+			"WHERE   c.own_type = 1    "+
+			"AND d.customer_service_id = %d   "+
+			"AND ( c.type = 4 OR c.type = 5 or  c.type=6 or  c.type=7 )   "+
+			"AND d.customer_service_id !=0   %s %s  "+
+			"GROUP BY   (   CASE  WHEN  c.send_user_type =2 THEN  CONCAT( c.send_user_id )   WHEN c.send_user_type =1 THEN  CONCAT( c.receive_user_id )  END  ) ",
+			util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION,
+			in.EntUserId, startTimeSql, endTimeSql)
+		data = IC.BaseMysql.SelectBySql(userSql)
+		if data != nil {
+			customerMessageId := util.Inhandle(data)
+			//客服的用户列表
+			sqlStr = fmt.Sprintf("SELECT  "+
+				"(  CASE        WHEN SUBSTR( b.nickname, 1, 3 ) = 'JY_' THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) )     WHEN b.nickname = '' THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) ELSE b.nickname    END    )"+
+				" AS name,  b.id,  e.title,  b.headimg,  e.type,  e.link,  e.content,  a.create_time,  "+
+				"(  SELECT   count( h.id )   FROM   %s h   "+
+				"LEFT JOIN %s i ON h.own_type = 1 AND h.own_id = i.id     "+
+				"WHERE  h.own_type = 1  "+
+				"AND i.ent_id=f.ent_id "+
+				"AND  i.user_id=f.user_id    "+
+				"AND h.isread = 0    "+
+				"AND  i.customer_service_id= %d ) AS number "+
+				"FROM  %s a  "+
+				"LEFT JOIN %s b ON if (a.send_user_type=1 ,a.receive_user_id,a.send_user_id)=b.id  "+
+				"LEFT JOIN %s e ON e.id = a.messag_id  "+
+				"LEFT JOIN %s f ON a.own_type=1 AND  a.own_id=f.id   "+
+				"WHERE  a.id IN  ( %s) %s ORDER BY  a.create_time DESC",
+				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION,
+				in.EntUserId, util.SOCIALIZE_MESSAGE_MAILBOX, util.BASE_USER, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION, customerMessageId, phoneSql)
 		}
-		if in.Size <= 0 || in.Size > 100 {
-			in.Size = 50
-		}
-		sqlStr = fmt.Sprintf(`SELECT(
-			 CASE
-            	WHEN SUBSTR( b.nickname, 1, 3 ) = 'JY_' THEN
-            	CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) 
-            	WHEN b.nickname = '' 
-            	OR b.nickname IS NULL THEN
-            	CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) ELSE b.nickname 
-            	END 
-            ) AS name,
-			b.id,
-			e.title,
-			b.headimg,
-			e.type,
-			e.link,
-			e.content,
-			a.update_time as create_time,
-			(
-			SELECT
-				count( h.id ) 
-			FROM
-				 %s h
-				LEFT JOIN  %s i ON h.own_id = i.id 
-			WHERE
-				h.own_type = 1 
-				AND i.ent_id = a.ent_id 
-				AND i.user_id = a.user_id 
-				AND h.isread = 0 
-				AND h.iswithdraw = 0 
-				AND i.customer_service_id = %d 
-			) AS number 
-		FROM
-			%s a
-			INNER JOIN %s b ON  a.ent_id = %d and %s 
-			AND a.user_id = b.id
-			LEFT JOIN  %s e ON e.id = a.message_id 
-	ORDER BY
-	a.update_time DESC`, util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION, in.EntUserId, util.User_message_list, util.BASE_USER, in.EntId, idSql, util.SOCIALIZE_MESSAGE)
 	}
-	dataSize := []map[string]interface{}{}
 	if sqlStr != "" {
-		log.Println("查询列表sql:", sqlStr)
-		data = util.Mysql.SelectBySql(sqlStr)
-		if data != nil && len(*data) > 0 {
-			count = quitl.Int64All(len(*data))
-			log.Println("查询列表耗时2:", time.Since(tm), count)
-			if in.UserType != 2 {
-				if in.Page*in.Size >= count {
-					dataSize = (*data)[(in.Page-1)*in.Size:]
-				} else {
-					dataSize = (*data)[(in.Page-1)*in.Size : in.Page*in.Size]
-				}
-				return &dataSize, count, err
-			}
-		}
+		log.Println(sqlStr)
+		data = IC.BaseMysql.SelectBySql(sqlStr)
 	}
 	return
 }
 
-// 客服会话列表
-func (b MessaggeService) ConversationList(in *messagecenter.ConversationReq) (data *[]map[string]interface{}, count int64, err error) {
-	sqlStr := ""
-	tm := time.Now()
-	if in.UserType == 1 && in.FiltrationId != "" {
-		var ids []string
-		for _, v := range strings.Split(in.FiltrationId, ",") {
-			ids = append(ids, encrypt.SE.Decode4Hex(v))
-		}
-
-		idSql := fmt.Sprintf("a.customer_service_id = %d AND  b.id  in (%s) ", in.EntUserId, strings.Join(ids, ","))
-		sqlStr = fmt.Sprintf(`SELECT(
-			CASE
-            	WHEN SUBSTR( b.nickname, 1, 3 ) = 'JY_' THEN
-            	CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) 
-            	WHEN b.nickname = '' 
-            	OR b.nickname IS NULL THEN
-            	CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) ELSE b.nickname 
-            	END 
-            ) AS name,
-			b.id,
-			e.title,
-			b.headimg,
-			e.type,
-			e.link,
-			e.content,
-			a.update_time as create_time,
-			(
-			SELECT
-				count( h.id ) 
-			FROM
-				 %s h
-				LEFT JOIN  %s i ON h.own_id = i.id 
-			WHERE
-				h.own_type = 1 
-				AND i.ent_id = a.ent_id 
-				AND i.user_id = a.user_id 
-				AND h.isread = 0 
-				AND h.iswithdraw = 0 
-				AND i.customer_service_id = %d 
-			) AS number 
-		FROM
-			%s a
-			INNER JOIN %s b ON  %s 
-			AND a.user_id = b.id
-			LEFT JOIN  %s e ON e.id = a.message_id`,
-			util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION, in.EntUserId, util.User_message_list, util.BASE_USER, idSql, util.SOCIALIZE_MESSAGE)
-	}
-
-	if sqlStr != "" {
-		log.Println("查询列表sql:", sqlStr)
-		data = util.Mysql.SelectBySql(sqlStr)
-		log.Println("查询耗时2:", time.Since(tm), count)
-	}
-	return
-}
-
-// 消息保存
+//消息保存
 func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool, errorMsg string, content string, messageId, nowInt int64) {
 	//先插入信息表
 	//判断会话标识是否属于本人
-	var customer_service_id, userid, entid, message_id int64
 	nowForm := time.Now().Local()
-	create_time := nowForm.Format(util.Date_Full_Layout)
 	if in.ItemType != 2 {
 		userId := int64(0)
 		sessionId := int64(0)
 		switch in.ItemType {
-		case 4, 5, 8:
+		case 4, 5:
 			if in.OwnType == 1 {
 				sessionId = in.ReceiveId
 				userId = in.NewUserId
 			} else {
 				sessionId = in.SendId
 				userId = in.ReceiveId
-				if in.ItemType == 4 || in.ItemType == 8 {
+				if in.ItemType == 4 {
 					userId = in.NewUserId
 				}
 			}
@@ -334,7 +232,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 			break
 		}
 		//查找会话信息
-		chatJson := util.Mysql.FindOne(util.SOCIALIZE_CHAT_SESSION, map[string]interface{}{"id": sessionId}, "user_id,ent_id,customer_service_id", "")
+		chatJson := IC.BaseMysql.FindOne(util.SOCIALIZE_CHAT_SESSION, map[string]interface{}{"id": sessionId}, "user_id", "")
 		if chatJson == nil {
 			return false, "会话标识不存在", "", 0, nowForm.Unix()
 		} else {
@@ -342,12 +240,10 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 				return false, "会话标识不属于此用户", "", 0, nowForm.Unix()
 			}
 		}
-		customer_service_id = quitl.Int64All((*chatJson)["customer_service_id"])
-		entid = quitl.Int64All((*chatJson)["ent_id"])
-		userid = userId
 	}
-	fool = util.Mysql.ExecTx("聊天信息保存", func(tx *sql.Tx) bool {
+	fool = IC.BaseMysql.ExecTx("聊天信息保存", func(tx *sql.Tx) bool {
 		//先插入信息表
+		create_time := nowForm.Format(util.Date_Full_Layout)
 		userType := int64(1)
 		userId := int64(0)
 		message := map[string]interface{}{
@@ -366,9 +262,9 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 			"create_time": create_time,
 			"content":     in.Content,
 		}
-		ok := util.Mysql.InsertByTx(tx, util.SOCIALIZE_MESSAGE, message)
+		ok := IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_MESSAGE, message)
 		receiveOk := int64(0)
-		messageId, message_id = ok, ok
+		messageId = ok
 		data["id"] = ok
 		//在插入邮箱表socialize_message_mailbox
 		messageMailBox := map[string]interface{}{
@@ -420,10 +316,10 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 				messageMailBox["send_user_id"] = in.NewUserId
 				messageMailBox["receive_user_id"] = in.ReceiveId
 			}
-			receiveOk = util.Mysql.InsertByTx(tx, util.SOCIALIZE_MESSAGE_MAILBOX, messageMailBox)
+			receiveOk = IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_MESSAGE_MAILBOX, messageMailBox)
 			return ok > 1 && receiveOk > 1
 		}
-		if in.ItemType == 4 || in.ItemType == 8 || in.ItemType == 5 {
+		if in.ItemType == 4 || in.ItemType == 5 {
 			//客服或者机器人聊天
 			if in.OwnType == 1 {
 				// (用户发送)客服接受
@@ -444,7 +340,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 				messageMailBox["send_user_id"] = in.SendId
 				messageMailBox["receive_user_id"] = in.ReceiveId
 				userId = in.ReceiveId
-				if in.ItemType == 4 || in.ItemType == 8 {
+				if in.ItemType == 4 {
 					messageMailBox["receive_user_id"] = in.NewUserId
 					userId = in.NewUserId
 					messageMailBox["own_id"] = in.NewUserId
@@ -464,7 +360,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 			userType = 2
 			userId = in.ReceiveId
 		}
-		receiveOk = util.Mysql.InsertByTx(tx, util.SOCIALIZE_MESSAGE_MAILBOX, messageMailBox)
+		receiveOk = IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_MESSAGE_MAILBOX, messageMailBox)
 		messageMailBox = map[string]interface{}{
 			"appid":         in.Appid,
 			"messag_id":     ok,
@@ -476,7 +372,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 			"receive_isdel": 0,
 			"iswithdraw":    0,
 		}
-		if in.ItemType == 4 || in.ItemType == 8 || in.ItemType == 5 {
+		if in.ItemType == 4 || in.ItemType == 5 {
 			//客服或者机器人聊天
 			if in.OwnType == 1 {
 				//用户发送(用户接受)
@@ -495,7 +391,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 				messageMailBox["own_id"] = in.SendId
 				messageMailBox["send_user_id"] = in.SendId
 				messageMailBox["receive_user_id"] = in.ReceiveId
-				if in.ItemType == 4 || in.ItemType == 8 {
+				if in.ItemType == 4 {
 					messageMailBox["receive_user_id"] = in.NewUserId
 				}
 			}
@@ -507,58 +403,21 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 			messageMailBox["send_user_id"] = in.NewUserId
 			messageMailBox["receive_user_id"] = in.ReceiveId
 		}
-		receiveOk = util.Mysql.InsertByTx(tx, util.SOCIALIZE_MESSAGE_MAILBOX, messageMailBox)
+		receiveOk = IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_MESSAGE_MAILBOX, messageMailBox)
 		if ok > 1 && receiveOk > 1 {
 			pc_a, err := util.GetData(userType, userId)
 			count := 1
 			if err == nil && pc_a != nil {
 				count += pc_a.Count
 			}
-			util.SetData(userType, userId, map[string]interface{}{"data": data, "count": count}, util.SurvivalTime)
+			util.SetData(userType, userId, map[string]interface{}{"data": data, "count": count}, IC.SurvivalTime)
 		}
 		return ok > 1 && receiveOk > 1
 	})
-	if fool && in.ItemType != 2 && in.ItemType != 3 {
-		go UserSynchronousList(customer_service_id, userid, entid, message_id, create_time)
-	}
 	return fool, "", in.Content, messageId, nowForm.Unix()
 }
 
-var rwLock = new(sync.RWMutex)
-
-// 客服 用户聊天消息列表同步
-func UserSynchronousList(customerServiceId, userId, entId, messageId int64, createTime string) {
-	log.Printf("同步最后消息参数customerServiceId:%d,userId:%d,entId%d,messageId:%d", customerServiceId, userId, entId, messageId)
-	rwLock.Lock()
-	defer rwLock.Unlock()
-	if util.Mysql.Count(util.User_message_list, map[string]interface{}{"user_id": userId, "ent_id": entId}) > 0 {
-		upData := map[string]interface{}{
-			"message_id":  messageId,
-			"update_time": createTime,
-		}
-		//判断是否机器人聊天
-		if customerServiceId > 0 && util.Mysql.Count(util.User_message_list, map[string]interface{}{"user_id": userId, "ent_id": entId, "customer_service_id": 0}) > 0 {
-			//将机器人列表更新成用户
-			upData["customer_service_id"] = customerServiceId
-			//转人工 机器人聊天类型修改
-			upData["type"] = 1
-		}
-		//已于人工客服联系过 只同步最后消息
-		util.Mysql.Update(util.User_message_list, map[string]interface{}{"user_id": userId, "ent_id": entId}, upData)
-		return
-	}
-	//不存在消息列表 创建
-	util.Mysql.Insert(util.User_message_list, map[string]interface{}{
-		"ent_id":              entId,
-		"user_id":             userId,
-		"message_id":          messageId,
-		"update_time":         createTime,
-		"customer_service_id": customerServiceId,
-		"type":                quitl.If(customerServiceId == 0, 0, 1),
-	})
-}
-
-// 历史信息查询
+//历史信息查询
 func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string]interface{} {
 	sqlStr := ""
 	lastStr := ""
@@ -576,10 +435,10 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 			"LEFT JOIN %s b on  a.messag_id=b.id  "+
 			"LEFT  JOIN  %s c on  c.id=a.send_user_id   "+
 			"LEFT JOIN  %s d on  d.id=a.receive_user_id  "+
-			"where  a.own_id=  %d and a.iswithdraw = 0"+
+			"where  a.own_id=  %d "+
 			"AND ((a.send_user_id=   %d AND   a.receive_user_id=   %d) or (a.send_user_id=  %d AND  a.receive_user_id=  %d)) "+
 			"AND  a.type=2  %s "+
-			"ORDER BY a.create_time desc,a.id   asc "+
+			"ORDER BY a.create_time desc ,a.id   asc "+
 			"limit 0 ,  %d ",
 			util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.BASE_USER, util.BASE_USER,
 			in.NewUserId, in.NewUserId, in.SendId, in.SendId, in.NewUserId, lastStr, in.PageSize)
@@ -591,39 +450,38 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 				"FROM   %s a   "+
 				"LEFT JOIN %s b ON a.messag_id = b.id   "+
 				"LEFT JOIN %s c ON   a.own_type = 1  AND  a.own_id=c.id    "+
-				"WHERE   a.own_type = 1 and a.iswithdraw = 0  "+
-				"AND (a.type = 5 or a.type=4 or a.type=6 or  a.type=7 or a.type=8 )   "+
+				"WHERE   a.own_type = 1   "+
+				"AND (a.type = 5 or a.type=4 or  a.type=6 or  a.type=7)   "+
 				"AND c.ent_id =   %d "+
 				"AND c.user_id =   %d  %s "+
-				"ORDER BY a.create_time desc ,a.id asc "+
+				"ORDER BY a.create_time desc ,a.id   asc "+
 				"limit 0 ,  %d ",
 				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION,
 				in.EntId, in.SendId, lastStr, in.PageSize)
 		} else {
 			//用户聊天记录查看
-			sqlStr = fmt.Sprintf("SELECT a.messag_id as messageId,e.appraise as appraise, b.*,   IF ( a.own_id = a.send_user_id, 1, 2 ) AS fool ,   a.send_user_type,   a.type as  itemType,   d.nickname as  robotName,   d.headimage as  robotImg,   c.customer_service_name as  setName   "+
+			sqlStr = fmt.Sprintf("SELECT a.messag_id as messageId,  b.*,   IF   ( a.own_id = a.send_user_id, 1, 2 ) AS fool ,   a.send_user_type,   a.type as  itemType,   d.nickname as  robotName,   d.headimage as  robotImg,   c.customer_service_name as  setName   "+
 				"FROM   %s a   "+
 				"LEFT JOIN %s b ON a.messag_id = b.id   "+
 				"LEFT JOIN %s c ON   IF   ( a.send_user_type = 1, a.send_user_id, a.receive_user_id ) = c.id AND  c.ent_id = %d AND c.user_id = %d "+
 				"LEFT JOIN  %s d on  c.ent_id=d.ent_id    "+
-				"LEFT JOIN %s e on  e.messag_id=b.id "+
-				"WHERE   a.own_type = 2  and a.iswithdraw = 0  "+
+				"WHERE   a.own_type = 2    "+
 				"AND a.own_id =  %d "+
 				"AND  c.ent_id = %d "+
 				"AND c.user_id =  %d "+
-				"AND ( a.type = 4 OR a.type = 5 or a.type=6 or  a.type=7 or  a.type=8)  %s "+
-				"ORDER BY a.create_time  desc,a.id   asc "+
+				"AND ( a.type = 4 OR a.type = 5 or a.type=6 or  a.type=7)  %s "+
+				"ORDER BY a.create_time desc ,a.id   asc "+
 				"limit 0 ,   %d ",
-				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION, in.SendId, in.NewUserId, util.SOCIALIZE_TENANT_ROBOT, util.SOCIALIZE_APPRAISE,
+				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION, in.SendId, in.NewUserId, util.SOCIALIZE_TENANT_ROBOT,
 				in.NewUserId, in.SendId, in.NewUserId, lastStr, in.PageSize)
 		}
 		break
 	}
 	log.Println(sqlStr)
-	data := util.Mysql.SelectBySql(sqlStr)
+	data := IC.BaseMysql.SelectBySql(sqlStr)
 	//自己头像处理
 	if in.UserType == 2 {
-		userData := util.Mysql.FindOne(util.BASE_USER, map[string]interface{}{"id": in.NewUserId}, "headimg", "")
+		userData := IC.BaseMysql.FindOne(util.BASE_USER, map[string]interface{}{"id": in.NewUserId}, "headimg", "")
 		if userData != nil {
 			for key := range *data {
 				(*data)[key]["ownImg"] = (*userData)["headimg"]
@@ -633,8 +491,8 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 	}
 	go func() {
 		updateMap := map[string]interface{}{}
-		if len(*data) > 0 && data != nil {
-			//if true {
+		//if len(*data) > 0 && data != nil {
+		if true {
 			//未读信息修改
 			switch in.MsgType {
 			case 2: //点对点聊天
@@ -644,25 +502,25 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 					"type":     2,
 					"isread":   0,
 				}
-				util.Mysql.Update(util.SOCIALIZE_MESSAGE_MAILBOX, updateMap, map[string]interface{}{"isread": 1, "read_time": time.Now().Local().Format(util.Date_Full_Layout)})
+				IC.BaseMysql.Update(util.SOCIALIZE_MESSAGE_MAILBOX, updateMap, map[string]interface{}{"isread": 1, "read_time": time.Now().Local().Format(util.Date_Full_Layout)})
 				break
 			case 4, 5:
 				sqlStr := ""
 				if in.UserType == 1 {
 					sqlStr = fmt.Sprintf("UPDATE %s a  SET a.isread = 1,    a.read_time = now( )  "+
-						"WHERE    a.own_type = 1 and a.iswithdraw = 0 "+
+						"WHERE    a.own_type = 1  "+
 						"AND a.type IN ( 4,5,6,7)  "+
 						"AND a.isread = 0    "+
 						"AND a.own_id IN ( SELECT b.id FROM %s b WHERE   b.customer_service_id=%d AND    b.user_id=%d  )",
 						util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION, in.EntUserId, in.SendId)
 				} else {
 					sqlStr = fmt.Sprintf("UPDATE %s a  SET a.isread = 1,    a.read_time = now( )  "+
-						"WHERE    a.own_type = 2 and a.iswithdraw = 0 "+
+						"WHERE    a.own_type = 2  "+
 						"AND a.type IN ( 4,5,6,7 )  "+
 						"AND a.isread = 0    "+
 						"AND a.own_id =%d ", util.SOCIALIZE_MESSAGE_MAILBOX, in.NewUserId)
 				}
-				util.Mysql.UpdateOrDeleteBySql(sqlStr)
+				IC.BaseMysql.UpdateOrDeleteBySql(sqlStr)
 				break
 			}
 			//redis缓存处理
@@ -672,22 +530,22 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 	return data
 }
 
-// 创建会话
+//创建会话
 func (b MessaggeService) CreateChatSession(in *messagecenter.ChatSessionReq) (fool bool, sessionId int64) {
-	fool = util.Mysql.ExecTx("会话新建", func(tx *sql.Tx) bool {
+	fool = IC.BaseMysql.ExecTx("会话新建", func(tx *sql.Tx) bool {
 		customerserviceName := in.CustomerserviceName
 		if in.CustomerServiceId != 0 {
 			sqlStr := fmt.Sprintf("select  customer_service_name from  %s "+
 				"where  ent_id= %d "+
 				"AND customer_service_id= %d ",
 				util.SOCIALIZE_CHAT_SESSION, in.EntId, in.CustomerServiceId)
-			customerList := util.Mysql.SelectBySql(sqlStr)
+			customerList := IC.BaseMysql.SelectBySql(sqlStr)
 			if len(*customerList) > 0 {
 				customerserviceName = quitl.InterfaceToStr((*customerList)[0]["customer_service_name"])
 			}
 		}
 		//查询企业是否存在
-		count := util.Mysql.Count(util.SOCIALIZE_TENANT_ROBOT, map[string]interface{}{
+		count := IC.BaseMysql.Count(util.SOCIALIZE_TENANT_ROBOT, map[string]interface{}{
 			"ent_id": in.EntId,
 		})
 		if count < 1 {
@@ -702,173 +560,87 @@ func (b MessaggeService) CreateChatSession(in *messagecenter.ChatSessionReq) (fo
 			"user_id":               in.UserId,
 			"customer_service_name": customerserviceName,
 		}
-		sessionId = util.Mysql.InsertByTx(tx, util.SOCIALIZE_CHAT_SESSION, chatMession)
+		sessionId = IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_CHAT_SESSION, chatMession)
 		return sessionId > 0
 	})
 	return
 }
 
-// 结束会话
+//结束会话
 func (b MessaggeService) CloseChatSession(in *messagecenter.CloseSessionReq) bool {
-	fool := util.Mysql.ExecTx("关闭会话", func(tx *sql.Tx) bool {
+	fool := IC.BaseMysql.ExecTx("关闭会话", func(tx *sql.Tx) bool {
 		updateMap := map[string]interface{}{
 			"id": in.SessionId,
 		}
-		fool := util.Mysql.Update(util.SOCIALIZE_CHAT_SESSION, updateMap, map[string]interface{}{"start_time": time.Now().Local().Format(util.Date_Full_Layout)})
+		fool := IC.BaseMysql.Update(util.SOCIALIZE_CHAT_SESSION, updateMap, map[string]interface{}{"start_time": time.Now().Local().Format(util.Date_Full_Layout)})
 		return fool
 	})
 	return fool
 }
 
-// 创建会话并保存信息
+//创建会话并保存信息
 func (b *MessaggeService) SaveAutoReplyMsg(userType, entId, entUserId, userId int64, content, appId, nowFormat string) (bool, int64) {
-	var customer_service_id, userid, entid, message_id int64
 	messageId := int64(0)
-	ok1 := util.Mysql.ExecTx("保存自动回复消息", func(tx *sql.Tx) bool {
+	return IC.BaseMysql.ExecTx("保存自动回复消息", func(tx *sql.Tx) bool {
 		entUserName := ""
 		if entUserId > 0 {
-			list := util.Mysql.SelectBySql(`select ? from socialize_tenant_seat where appid=? AND ent_id=? AND customer_service_id=?`, util.SOCIALIZE_CHAT_SESSION, appId, entId, entUserId)
+			list := IC.BaseMysql.SelectBySql(`select ? from socialize_tenant_seat where appid=? AND ent_id=? AND customer_service_id=?`, util.SOCIALIZE_CHAT_SESSION, appId, entId, entUserId)
 			if list != nil && len(*list) > 0 {
 				entUserName, _ = (*list)[0]["customer_service_name"].(string)
 			}
 		}
-		messageId = util.Mysql.InsertBySqlByTx(tx, `insert into socialize_message (appid,content,item,type,create_time,create_person) values (?,?,?,?,?,?)`, appId, content, 8, 1, nowFormat, "admin")
-		sessionId := util.Mysql.InsertBySqlByTx(tx, `insert into socialize_chat_session (appid,type,ent_id,customer_service_id,customer_service_name,user_id,start_time,end_time) values (?,?,?,?,?,?,?,?)`, appId, 1, entId, entUserId, entUserName, userId, nowFormat, nowFormat)
+		messageId = IC.BaseMysql.InsertBySqlByTx(tx, `insert into socialize_message (appid,content,item,type,create_time,create_person) values (?,?,?,?,?,?)`, appId, content, 8, 1, nowFormat, "admin")
+		sessionId := IC.BaseMysql.InsertBySqlByTx(tx, `insert into socialize_chat_session (appid,type,ent_id,customer_service_id,customer_service_name,user_id,start_time,end_time) values (?,?,?,?,?,?,?,?)`, appId, 1, entId, entUserId, entUserName, userId, nowFormat, nowFormat)
 		ok := false
 		if userType == 0 {
-			ok1 := util.Mysql.InsertBySqlByTx(tx, `insert into socialize_message_mailbox (appid,messag_id,type,send_user_id,send_user_type,receive_user_id,receive_user_type,own_id,own_type,create_time,isread,read_time) values (?,?,?,?,?,?,?,?,?,?,?,?)`, appId, messageId, 7, sessionId, 1, userId, 2, sessionId, 1, nowFormat, 1, nowFormat) > 0
-			ok2 := util.Mysql.InsertBySqlByTx(tx, `insert into socialize_message_mailbox (appid,messag_id,type,send_user_id,send_user_type,receive_user_id,receive_user_type,own_id,own_type,create_time) values (?,?,?,?,?,?,?,?,?,?)`, appId, messageId, 7, sessionId, 1, userId, 2, userId, 2, nowFormat) > 0
+			ok1 := IC.BaseMysql.InsertBySqlByTx(tx, `insert into socialize_message_mailbox (appid,messag_id,type,send_user_id,send_user_type,receive_user_id,receive_user_type,own_id,own_type,create_time,isread,read_time) values (?,?,?,?,?,?,?,?,?,?,?,?)`, appId, messageId, 7, sessionId, 1, userId, 2, sessionId, 1, nowFormat, 1, nowFormat) > 0
+			ok2 := IC.BaseMysql.InsertBySqlByTx(tx, `insert into socialize_message_mailbox (appid,messag_id,type,send_user_id,send_user_type,receive_user_id,receive_user_type,own_id,own_type,create_time) values (?,?,?,?,?,?,?,?,?,?)`, appId, messageId, 7, sessionId, 1, userId, 2, userId, 2, nowFormat) > 0
 			ok = ok1 && ok2
 		} else if userType == 1 {
-			ok = util.Mysql.InsertBySqlByTx(tx, `insert into socialize_message_mailbox (appid,messag_id,type,send_user_id,send_user_type,receive_user_id,receive_user_type,own_id,own_type,create_time,isread,read_time) values (?,?,?,?,?,?,?,?,?,?,?,?)`, appId, messageId, 7, sessionId, 1, userId, 2, sessionId, 1, nowFormat, 1, nowFormat) > 0
+			ok = IC.BaseMysql.InsertBySqlByTx(tx, `insert into socialize_message_mailbox (appid,messag_id,type,send_user_id,send_user_type,receive_user_id,receive_user_type,own_id,own_type,create_time,isread,read_time) values (?,?,?,?,?,?,?,?,?,?,?,?)`, appId, messageId, 7, sessionId, 1, userId, 2, sessionId, 1, nowFormat, 1, nowFormat) > 0
 		} else if userType == 2 {
-			ok = util.Mysql.InsertBySqlByTx(tx, `insert into socialize_message_mailbox (appid,messag_id,type,send_user_id,send_user_type,receive_user_id,receive_user_type,own_id,own_type,create_time) values (?,?,?,?,?,?,?,?,?,?)`, appId, messageId, 7, sessionId, 1, userId, 2, userId, 2, nowFormat) > 0
+			ok = IC.BaseMysql.InsertBySqlByTx(tx, `insert into socialize_message_mailbox (appid,messag_id,type,send_user_id,send_user_type,receive_user_id,receive_user_type,own_id,own_type,create_time) values (?,?,?,?,?,?,?,?,?,?)`, appId, messageId, 7, sessionId, 1, userId, 2, userId, 2, nowFormat) > 0
 		}
-		message_id = messageId
 		return messageId > 0 && sessionId > 0 && ok
-	})
-	if ok1 {
-		customer_service_id = entUserId
-		userid = userId
-		entid = entId
-		go UserSynchronousList(customer_service_id, userid, entid, message_id, nowFormat)
-	}
-	return ok1, messageId
+	}), messageId
 }
 
-// 修改未读状态
+//修改未读状态
 func (b MessaggeService) UpdateReadById(in *messagecenter.ReadStateReq) bool {
-	updateMap := map[string]interface{}{
-		"messag_id": in.MessageId,
-		"isread":    0,
-	}
-	if util.Mysql.Count(util.SOCIALIZE_MESSAGE_MAILBOX, updateMap) > 0 {
-		fool := util.Mysql.ExecTx("已读状态修改", func(tx *sql.Tx) bool {
-
-			fool := util.Mysql.Update(util.SOCIALIZE_MESSAGE_MAILBOX, updateMap, map[string]interface{}{"read_time": time.Now().Local().Format(util.Date_Full_Layout), "isread": 1})
-			if fool {
-				//查询此条信息拥有者
-				data := util.Mysql.FindOne(util.SOCIALIZE_MESSAGE_MAILBOX, updateMap, "receive_user_type", "")
-				if data != nil {
-					userType := int64(1)
-					userId := int64(0)
-					if (*data)["receive_user_type"] == 2 {
-						userType = 2
-						userId = in.EntUserId
-					} else {
-						userType = 1
-						userId = in.NewUserId
-					}
-					pc_a, err := util.GetData(userType, userId)
-					if fool {
-						if err == nil && pc_a != nil {
-							if pc_a.Count >= 1 {
-								//id一致
-								if in.MessageId == pc_a.Data["id"] {
-									util.SetData(userType, userId, map[string]interface{}{"data": map[string]interface{}{}, "count": pc_a.Count - 1}, util.SurvivalTime)
-								} else {
-									util.SetData(userType, userId, map[string]interface{}{"data": data, "count": pc_a.Count - 1}, util.SurvivalTime)
-								}
-							}
+	fool := IC.BaseMysql.ExecTx("已读状态修改", func(tx *sql.Tx) bool {
+		updateMap := map[string]interface{}{
+			"messag_id": in.MessageId,
+			"isread":    0,
+		}
+		fool := IC.BaseMysql.Update(util.SOCIALIZE_MESSAGE_MAILBOX, updateMap, map[string]interface{}{"read_time": time.Now().Local().Format(util.Date_Full_Layout), "isread": 1})
+		if fool {
+			//查询此条信息拥有者
+			data := IC.BaseMysql.FindOne(util.SOCIALIZE_MESSAGE_MAILBOX, updateMap, "receive_user_type", "")
+			if data != nil {
+				userType := int64(1)
+				userId := int64(0)
+				if (*data)["receive_user_type"] == 2 {
+					userType = 2
+					userId = in.EntUserId
+				} else {
+					userType = 1
+					userId = in.NewUserId
+				}
+				pc_a, err := util.GetData(userType, userId)
+				if fool {
+					if err == nil && pc_a != nil {
+						//id一致
+						if in.MessageId == pc_a.Data["id"] {
+							util.SetData(userType, userId, map[string]interface{}{"data": map[string]interface{}{}, "count": pc_a.Count - 1}, IC.SurvivalTime)
+						} else {
+							util.SetData(userType, userId, map[string]interface{}{"data": data, "count": pc_a.Count - 1}, IC.SurvivalTime)
 						}
 					}
-
 				}
-			}
-			return fool
-		})
-		return fool
-	}
-	return true
-}
 
-// WithdrawMessage 撤回消息
-func (b MessaggeService) WithdrawMessage(in *messagecenter.ReadWithdrawReq) bool {
-	messageId := encrypt.SE.Decode4Hex(in.MessageId)
-	newUserId, entUserId := NewEndId(quitl.Int64All(messageId), in.UserType)
-	msg := util.Mysql.FindOne(util.SOCIALIZE_MESSAGE, map[string]interface{}{"id": messageId}, "create_time", "")
-	if msg == nil || len(*msg) <= 0 {
-		log.Println("查询消息id失败")
-		return false
-	}
-	createTime, _ := time.Parse(util.Date_Full_Layout, quitl.InterfaceToStr((*msg)["create_time"]))
-	if createTime.Unix()+60*2 < time.Now().Unix() {
-		log.Println("消息已超过2分钟,撤回失败")
-		return false
-	}
-	nowForm := time.Now().Local()
-	m := util.Mysql.Update(util.SOCIALIZE_MESSAGE_MAILBOX,
-		map[string]interface{}{"messag_id": messageId}, map[string]interface{}{"iswithdraw": 1, "withdraw_time": nowForm.Format(util.Date_Full_Layout)})
-	if m {
-		//消息撤回 更新对方私信
-		in.UserType = quitl.Int64All(quitl.If(in.UserType == 1, 2, 1))
-		b.Count(newUserId, in.UserType, entUserId, true)
-	}
-	return m
-}
-
-// AppraiseMessage 消息评价
-func (b MessaggeService) AppraiseMessage(in *messagecenter.AppraiseReq) error {
-	messageId := encrypt.SE.Decode4Hex(in.MessageId)
-	//查询此条消息是否是当前用户的
-	if util.Mysql.Count(util.SOCIALIZE_MESSAGE_MAILBOX, map[string]interface{}{
-		"messag_id":         messageId,
-		"receive_user_id":   in.NewUserId,
-		"receive_user_type": 2,
-		"type":              8,
-	}) == 0 {
-		return fmt.Errorf("未查询到信息")
-	}
-	if util.Mysql.Count(util.SOCIALIZE_APPRAISE, map[string]interface{}{
-		"appid":     in.Appid,
-		"messag_id": messageId,
-	}) > 0 {
-		return fmt.Errorf("请勿重复评价")
-	}
-	//插入评价
-	if util.Mysql.Insert(util.SOCIALIZE_APPRAISE, map[string]interface{}{
-		"appid":       in.Appid,
-		"messag_id":   messageId,
-		"create_time": time.Now().Local().Format(util.Date_Full_Layout),
-		"appraise":    in.Appraise,
-	}) > 0 {
-		return nil
-	}
-	return fmt.Errorf("评价消息异常")
-}
-
-// NewEndId 消息撤回 获取对方userid
-func NewEndId(messageId, iType int64) (newUserId, entUserId int64) {
-	data := util.Mysql.FindOne(util.SOCIALIZE_MESSAGE_MAILBOX, map[string]interface{}{"messag_id": messageId, "own_type": iType}, "", "")
-	if data != nil && len(*data) > 0 {
-		if iType == 1 { //客服撤回消息 获取客服id与用户id
-			entUserId = quitl.Int64All((*data)["send_user_id"])
-			newUserId = quitl.Int64All((*data)["receive_user_id"])
-		} else {
-			//用户撤回消息 获取客服id与用户id
-			newUserId = quitl.Int64All((*data)["send_user_id"])
-			entUserId = quitl.Int64All((*data)["receive_user_id"])
+			}
 		}
-	}
-	return
+		return fool
+	})
+	return fool
 }

+ 13 - 3
service/message_mail_box_test.go

@@ -3,8 +3,9 @@ package service
 import (
 	"app.yhyue.com/moapp/jybase/mysql"
 	"app.yhyue.com/moapp/jybase/redis"
-	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/entity"
+	IC "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/init"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+	_ "github.com/go-sql-driver/mysql"
 	"log"
 	"reflect"
 	"strings"
@@ -12,7 +13,7 @@ import (
 )
 
 func initMysql() {
-	entity.Mysql = &mysql.Mysql{
+	IC.BaseMysql = &mysql.Mysql{
 		Address:      "192.168.3.217:4000",
 		UserName:     "root",
 		PassWord:     "=PDT49#80Z!RVv52_z",
@@ -20,7 +21,16 @@ func initMysql() {
 		MaxOpenConns: 5,
 		MaxIdleConns: 5,
 	}
-	entity.Mysql.Init()
+	IC.BaseMysql.Init()
+	IC.MainMysql = &mysql.Mysql{
+		Address:      "192.168.3.149:3306",
+		UserName:     "root",
+		PassWord:     "Topnet123",
+		DBName:       "jianyu",
+		MaxOpenConns: 5,
+		MaxIdleConns: 5,
+	}
+	IC.MainMysql.Init()
 	redis.InitRedisBySize(strings.Join([]string{"other=127.0.0.1:6379"}, ","), 100, 30, 300)
 }
 func init() {

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است