Эх сурвалжийг харах

Merge branch 'feature/v1.2.6' into dev/v1.2.6_rjj

renjiaojiao 2 жил өмнө
parent
commit
ef1789c255

+ 28 - 0
api/messagecenter/internal/handler/oneuserpositionhandler.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 oneUserPositionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.OneUserPositionReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewOneUserPositionLogic(r.Context(), svcCtx)
+		resp, err := l.OneUserPosition(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 5 - 0
api/messagecenter/internal/handler/routes.go

@@ -67,6 +67,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/message/conversationList",
 				Handler: ConversationListHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/message/oneUserPosition",
+				Handler: oneUserPositionHandler(serverCtx),
+			},
 		},
 	)
 }

+ 11 - 3
api/messagecenter/internal/logic/messageaddlogic.go

@@ -11,6 +11,7 @@ import (
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
 	"github.com/microcosm-cc/bluemonday"
 
+	"github.com/gogf/gf/v2/util/gconv"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -40,7 +41,14 @@ func init() {
 }
 
 func (l *MessageAddLogic) MessageAdd(req *types.MessageEntity) (*types.CommonRes, error) {
-
+	receiverIds := []int64{}
+	for _, v := range req.ReceiverIds {
+		receiverIds = append(receiverIds, gconv.Int64(encrypt.SE.Decode4Hex(v)))
+	}
+	groupIds := []int64{}
+	for _, v := range req.GroupIds {
+		groupIds = append(groupIds, gconv.Int64(encrypt.SE.Decode4Hex(v)))
+	}
 	resp, err := l.svcCtx.Message.SaveMessage(l.ctx, &messagecenter.MessageEntity{
 		OwnType:     req.OwnType,
 		Title:       req.Title,
@@ -54,8 +62,8 @@ func (l *MessageAddLogic) MessageAdd(req *types.MessageEntity) (*types.CommonRes
 		ReceiveId:   quitl.Int64All(encrypt.SE.Decode4Hex(req.ReceiveId)),
 		NewUserId:   req.NewUserId,
 		EntUserId:   req.EntUserId,
-		ReceiverIds: req.ReceiverIds,
-		GroupIds:    req.GroupIds,
+		ReceiverIds: receiverIds,
+		GroupIds:    groupIds,
 	})
 	if err != nil {
 		return nil, err

+ 44 - 0
api/messagecenter/internal/logic/oneuserpositionlogic.go

@@ -0,0 +1,44 @@
+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 OneUserPositionLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewOneUserPositionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OneUserPositionLogic {
+	return &OneUserPositionLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *OneUserPositionLogic) OneUserPosition(req *types.OneUserPositionReq) (resp *types.CommonRes, err error) {
+	oneUserPositionReq := &messagecenter.OneUserPositionReq{
+		EntId:      req.EntId,
+		PositionId: quitl.Int64All(encrypt.SE.Decode4Hex(req.PositionId)),
+		Appid:      req.Appid,
+	}
+	oneResp, err := l.svcCtx.Message.OneUserPosition(l.ctx, oneUserPositionReq)
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonRes{
+		Error_msg:  oneResp.ErrorMsg,
+		Error_code: int(oneResp.ErrorCode),
+		Data:       oneResp.Position,
+	}, nil
+}

+ 20 - 14
api/messagecenter/internal/types/types.go

@@ -31,20 +31,20 @@ type UserReq struct {
 }
 
 type MessageEntity struct {
-	OwnType     int64   `json:"ownType"`
-	Title       string  `json:"title"`
-	Content     string  `json:"content"`
-	Item        int64   `json:"item"`
-	Type        int64   `json:"type"`
-	Link        string  `json:"link"`
-	Appid       string  `header:"appId"`
-	ItemType    int64   `json:"itemType"`
-	SendId      string  `json:"sendId,optional"`
-	EntUserId   int64   `header:"entUserId,optional"`
-	NewUserId   int64   `header:"newUserId"`
-	ReceiveId   string  `json:"receiveId,optional"`
-	ReceiverIds []int64 `json:"receiverIds,optional"` //个人[可多个]
-	GroupIds    []int64 `json:"groupIds,optional"`    //群聊[可多个]
+	OwnType     int64    `json:"ownType"`
+	Title       string   `json:"title"`
+	Content     string   `json:"content"`
+	Item        int64    `json:"item"`
+	Type        int64    `json:"type"`
+	Link        string   `json:"link"`
+	Appid       string   `header:"appId"`
+	ItemType    int64    `json:"itemType"`
+	SendId      string   `json:"sendId,optional"`
+	EntUserId   int64    `header:"entUserId,optional"`
+	NewUserId   int64    `header:"newUserId"`
+	ReceiveId   string   `json:"receiveId,optional"`
+	ReceiverIds []string `json:"receiverIds,optional"` //个人[可多个]
+	GroupIds    []string `json:"groupIds,optional"`    //群聊[可多个]
 }
 
 type MessageReq struct {
@@ -113,3 +113,9 @@ type AppraiseMessageReq struct {
 	MessageId string `json:"messageId"`
 	Appraise  int64  `json:"appraise,options=-1|1"`
 }
+
+type OneUserPositionReq struct {
+	PositionId string `json:"positionId"`
+	EntId      int64  `header:"entId,optional"`
+	Appid      string `header:"appId"`
+}

+ 22 - 14
api/messagecenter/messagecenter.api

@@ -27,20 +27,20 @@ type UserReq {
 	NameSearch   string `json:"nameSearch,optional"`
 }
 type MessageEntity {
-	OwnType     int64   `json:"ownType"`
-	Title       string  `json:"title"`
-	Content     string  `json:"content"`
-	Item        int64   `json:"item"`
-	Type        int64   `json:"type"`
-	Link        string  `json:"link"`
-	Appid       string  `header:"appId"`
-	ItemType    int64   `json:"itemType"`
-	SendId      string  `json:"sendId,optional"`
-	EntUserId   int64   `header:"entUserId,optional"`
-	NewUserId   int64   `header:"newUserId"`
-	ReceiveId   string  `json:"receiveId,optional"`
-	ReceiverIds []int64 `json:"receiverIds,optional"` //个人[可多个]
-	GroupIds    []int64 `json:"groupIds,optional"`    //群聊[可多个]
+	OwnType     int64    `json:"ownType"`
+	Title       string   `json:"title"`
+	Content     string   `json:"content"`
+	Item        int64    `json:"item"`
+	Type        int64    `json:"type"`
+	Link        string   `json:"link"`
+	Appid       string   `header:"appId"`
+	ItemType    int64    `json:"itemType"`
+	SendId      string   `json:"sendId,optional"`
+	EntUserId   int64    `header:"entUserId,optional"`
+	NewUserId   int64    `header:"newUserId"`
+	ReceiveId   string   `json:"receiveId,optional"`
+	ReceiverIds []string `json:"receiverIds,optional"` //个人[可多个]
+	GroupIds    []string `json:"groupIds,optional"`    //群聊[可多个]
 }
 type MessageReq {
 	MsgType     int64  `json:"msgType"`
@@ -104,6 +104,12 @@ type AppraiseMessageReq {
 	Appraise  int64  `json:"appraise,options=-1|1"`
 }
 
+type OneUserPositionReq {
+	PositionId string `json:"positionId"`
+	EntId      int64  `header:"entId,optional"`
+	Appid      string `header:"appId"`
+}
+
 service messagecenter-api {
 	@handler messageCount
 	post /message/messageCount (CountReq) returns (CommonRes);
@@ -127,4 +133,6 @@ service messagecenter-api {
 	post /message/appraiseMessage (AppraiseMessageReq) returns (CommonRes);
 	@handler ConversationList // 会话列表
 	post /message/conversationList (UserReq) returns (CommonRes);
+	@handler oneUserPosition // 1v1会话职位
+	post /message/oneUserPosition (OneUserPositionReq) returns (CommonRes);
 }

+ 60 - 0
rpc/messagecenter/internal/logic/oneuserpositionlogic.go

@@ -0,0 +1,60 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	util "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/entity"
+	IC "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/init"
+	"context"
+	"fmt"
+	"log"
+
+	"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 OneUserPositionLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewOneUserPositionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OneUserPositionLogic {
+	return &OneUserPositionLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 1v1会话职位
+func (l *OneUserPositionLogic) OneUserPosition(in *messagecenter.OneUserPositionReq) (*messagecenter.OneUserPositionResp, error) {
+	// 1v1聊条职位
+	log.Println("1v1会话职位", in.EntId, in.PositionId)
+	ids := IC.BaseMysql.SelectBySql(fmt.Sprintf("select b.id,b.user_id,a.phone  from  %s a INNER JOIN  base_position b  on  b.type=1  and  b.ent_id=%d and b.id=%d and  a.id=b.user_id ", util.BASE_USER, in.EntId, in.PositionId))
+	if ids == nil || len(*ids) != 1 {
+		return &messagecenter.OneUserPositionResp{}, nil
+	}
+	var phone, positionName string
+	for _, v := range *ids {
+		phone = common.InterfaceToStr(v["phone"])
+	}
+	idName := IC.MainMysql.SelectBySql(fmt.Sprintf(`SELECT a.id,c.name,d.role_id,a.phone,e.name as roleName  FROM entniche_user a
+    				INNER JOIN entniche_department_user b on a.id = b.user_id
+					INNER JOIN entniche_department c on c.id = b.dept_id
+    				INNER JOIN entniche_user_role d on a.ent_id=%d and a.phone = %s and a.id = d.user_id
+					INNER JOIN entniche_role e on e.id = d.role_id
+					`, in.EntId, phone))
+	if idName == nil || len(*idName) != 1 {
+		return &messagecenter.OneUserPositionResp{}, nil
+	}
+	userPosition := (*idName)[0]
+	switch common.IntAll(userPosition["role_id"]) {
+	case 2:
+		positionName = fmt.Sprintf("%s%s", common.InterfaceToStr(userPosition["name"]), common.InterfaceToStr(userPosition["roleName"]))
+	case 1:
+		positionName = "管理员"
+	}
+	return &messagecenter.OneUserPositionResp{Position: positionName}, nil
+}

+ 10 - 2
rpc/messagecenter/internal/logic/savemessagelogic.go

@@ -1,13 +1,14 @@
 package logic
 
 import (
+	"context"
+
 	quitl "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
 	util "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/entity"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/service"
-	"context"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -30,7 +31,14 @@ func NewSaveMessageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveM
 func (l *SaveMessageLogic) SaveMessage(in *messagecenter.MessageEntity) (*messagecenter.SaveMessageResp, error) {
 	// todo: add your logic here and delete this line
 	m := service.MessaggeService{}
-	fool, error_message, content, messageId, nowTime := m.SaveMessage(in)
+	fool, error_message, content, messageId, nowTime := func() (fool bool, errorMsg string, content string, messageId, nowInt int64) {
+		if in.ItemType != 7 {
+			return m.SaveMessage(in)
+		} else {
+			return m.Chat(in)
+		}
+	}()
+
 	error_code := util.SUCCESS_CODE
 	if fool {
 		error_code = util.SUCCESS_CODE

+ 15 - 9
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)
@@ -76,20 +76,26 @@ func (s *MessageCenterServer) WithdrawMessage(ctx context.Context, in *messagece
 	return l.WithdrawMessage(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) ConversationList(ctx context.Context, in *messagecenter.ConversationReq) (*messagecenter.UserResp, error) {
 	l := logic.NewConversationListLogic(ctx, s.svcCtx)
 	return l.ConversationList(in)
 }
 
-//  群聊
+// 群聊
 func (s *MessageCenterServer) GroupChat(ctx context.Context, in *messagecenter.MessageSaveReq) (*messagecenter.CommonReq, error) {
 	l := logic.NewGroupChatLogic(ctx, s.svcCtx)
 	return l.GroupChat(in)
 }
+
+// 1v1会话职位
+func (s *MessageCenterServer) OneUserPosition(ctx context.Context, in *messagecenter.OneUserPositionReq) (*messagecenter.OneUserPositionResp, error) {
+	l := logic.NewOneUserPositionLogic(ctx, s.svcCtx)
+	return l.OneUserPosition(in)
+}

+ 14 - 0
rpc/messagecenter/messagecenter.proto

@@ -181,6 +181,18 @@ message CommonReq {
   string        error_msg = 3; //响应消息
 }
 
+//聊天保存
+message OneUserPositionReq {
+  int64 positionId =1;
+  int64 entId =2;
+  string        appid = 3;
+}
+message OneUserPositionResp {
+  int64         error_code = 1; //响应代码
+  string        error_msg = 2; //响应消息
+  string       position =3;
+}
+
 service messageCenter {
   // 查询数量
   rpc Count(CountReq) returns(CountResp);
@@ -206,4 +218,6 @@ service messageCenter {
   rpc ConversationList(ConversationReq) returns(UserResp);
   // 群聊
   rpc GroupChat(MessageSaveReq)returns(CommonReq);
+  // 1v1会话职位
+  rpc OneUserPosition(OneUserPositionReq)returns(OneUserPositionResp);
 }

+ 17 - 9
rpc/messagecenter/messagecenter/messagecenter.go

@@ -36,6 +36,8 @@ type (
 		ConversationList(ctx context.Context, in *ConversationReq, opts ...grpc.CallOption) (*UserResp, error)
 		//  群聊
 		GroupChat(ctx context.Context, in *MessageSaveReq, opts ...grpc.CallOption) (*CommonReq, error)
+		//  1v1会话职位
+		OneUserPosition(ctx context.Context, in *OneUserPositionReq, opts ...grpc.CallOption) (*OneUserPositionResp, error)
 	}
 
 	defaultMessageCenter struct {
@@ -49,37 +51,37 @@ func NewMessageCenter(cli zrpc.Client) MessageCenter {
 	}
 }
 
-//  查询数量
+// 查询数量
 func (m *defaultMessageCenter) Count(ctx context.Context, in *CountReq, opts ...grpc.CallOption) (*CountResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.Count(ctx, in, opts...)
 }
 
-//  用户列表查询
+// 用户列表查询
 func (m *defaultMessageCenter) UserList(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.UserList(ctx, in, opts...)
 }
 
-//  聊天内容查询
+// 聊天内容查询
 func (m *defaultMessageCenter) FindMessage(ctx context.Context, in *MessageReq, opts ...grpc.CallOption) (*MessageResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.FindMessage(ctx, in, opts...)
 }
 
-//  聊天保存
+// 聊天保存
 func (m *defaultMessageCenter) SaveMessage(ctx context.Context, in *MessageEntity, opts ...grpc.CallOption) (*SaveMessageResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.SaveMessage(ctx, in, opts...)
 }
 
-//  会话创建
+// 会话创建
 func (m *defaultMessageCenter) CreateChatSession(ctx context.Context, in *ChatSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.CreateChatSession(ctx, in, opts...)
 }
 
-//  会话关闭
+// 会话关闭
 func (m *defaultMessageCenter) CloseChatSession(ctx context.Context, in *CloseSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.CloseChatSession(ctx, in, opts...)
@@ -103,20 +105,26 @@ func (m *defaultMessageCenter) WithdrawMessage(ctx context.Context, in *ReadWith
 	return client.WithdrawMessage(ctx, in, opts...)
 }
 
-//  用户评价回复
+// 用户评价回复
 func (m *defaultMessageCenter) AppraiseMessage(ctx context.Context, in *AppraiseReq, opts ...grpc.CallOption) (*CurrencyResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.AppraiseMessage(ctx, in, opts...)
 }
 
-//  客服列表查询
+// 客服列表查询
 func (m *defaultMessageCenter) ConversationList(ctx context.Context, in *ConversationReq, opts ...grpc.CallOption) (*UserResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.ConversationList(ctx, in, opts...)
 }
 
-//  群聊
+// 群聊
 func (m *defaultMessageCenter) GroupChat(ctx context.Context, in *MessageSaveReq, opts ...grpc.CallOption) (*CommonReq, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.GroupChat(ctx, in, opts...)
 }
+
+// 1v1会话职位
+func (m *defaultMessageCenter) OneUserPosition(ctx context.Context, in *OneUserPositionReq, opts ...grpc.CallOption) (*OneUserPositionResp, error) {
+	client := NewMessageCenterClient(m.cli.Conn())
+	return client.OneUserPosition(ctx, in, opts...)
+}

+ 270 - 97
rpc/messagecenter/messagecenter/messagecenter.pb.go

@@ -1,6 +1,6 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.28.0
+// 	protoc-gen-go v1.28.1
 // 	protoc        v3.19.4
 // source: messagecenter.proto
 
@@ -1650,7 +1650,7 @@ func (x *ConversationReq) GetFiltrationId() string {
 	return ""
 }
 
-//聊天保存
+// 聊天保存
 type MessageSaveReq struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -1833,6 +1833,133 @@ func (x *CommonReq) GetErrorMsg() string {
 	return ""
 }
 
+// 聊天保存
+type OneUserPositionReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	PositionId int64  `protobuf:"varint,1,opt,name=positionId,proto3" json:"positionId,omitempty"`
+	EntId      int64  `protobuf:"varint,2,opt,name=entId,proto3" json:"entId,omitempty"`
+	Appid      string `protobuf:"bytes,3,opt,name=appid,proto3" json:"appid,omitempty"`
+}
+
+func (x *OneUserPositionReq) Reset() {
+	*x = OneUserPositionReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_messagecenter_proto_msgTypes[20]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *OneUserPositionReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*OneUserPositionReq) ProtoMessage() {}
+
+func (x *OneUserPositionReq) ProtoReflect() protoreflect.Message {
+	mi := &file_messagecenter_proto_msgTypes[20]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use OneUserPositionReq.ProtoReflect.Descriptor instead.
+func (*OneUserPositionReq) Descriptor() ([]byte, []int) {
+	return file_messagecenter_proto_rawDescGZIP(), []int{20}
+}
+
+func (x *OneUserPositionReq) GetPositionId() int64 {
+	if x != nil {
+		return x.PositionId
+	}
+	return 0
+}
+
+func (x *OneUserPositionReq) GetEntId() int64 {
+	if x != nil {
+		return x.EntId
+	}
+	return 0
+}
+
+func (x *OneUserPositionReq) GetAppid() string {
+	if x != nil {
+		return x.Appid
+	}
+	return ""
+}
+
+type OneUserPositionResp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ErrorCode int64  `protobuf:"varint,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"` //响应代码
+	ErrorMsg  string `protobuf:"bytes,2,opt,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"`     //响应消息
+	Position  string `protobuf:"bytes,3,opt,name=position,proto3" json:"position,omitempty"`
+}
+
+func (x *OneUserPositionResp) Reset() {
+	*x = OneUserPositionResp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_messagecenter_proto_msgTypes[21]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *OneUserPositionResp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*OneUserPositionResp) ProtoMessage() {}
+
+func (x *OneUserPositionResp) ProtoReflect() protoreflect.Message {
+	mi := &file_messagecenter_proto_msgTypes[21]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use OneUserPositionResp.ProtoReflect.Descriptor instead.
+func (*OneUserPositionResp) Descriptor() ([]byte, []int) {
+	return file_messagecenter_proto_rawDescGZIP(), []int{21}
+}
+
+func (x *OneUserPositionResp) GetErrorCode() int64 {
+	if x != nil {
+		return x.ErrorCode
+	}
+	return 0
+}
+
+func (x *OneUserPositionResp) GetErrorMsg() string {
+	if x != nil {
+		return x.ErrorMsg
+	}
+	return ""
+}
+
+func (x *OneUserPositionResp) GetPosition() string {
+	if x != nil {
+		return x.Position
+	}
+	return ""
+}
+
 var File_messagecenter_proto protoreflect.FileDescriptor
 
 var file_messagecenter_proto_rawDesc = []byte{
@@ -2087,66 +2214,84 @@ var file_messagecenter_proto_rawDesc = []byte{
 	0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x72,
 	0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72,
 	0x5f, 0x6d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f,
-	0x72, 0x4d, 0x73, 0x67, 0x32, 0x8f, 0x07, 0x0a, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
-	0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12,
-	0x17, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e,
-	0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61,
-	0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65,
-	0x73, 0x70, 0x12, 0x3b, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x16,
-	0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x55,
-	0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
-	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12,
-	0x44, 0x0a, 0x0b, 0x46, 0x69, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x19,
-	0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d,
-	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x6d, 0x65, 0x73, 0x73,
-	0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
-	0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4b, 0x0a, 0x0b, 0x53, 0x61, 0x76, 0x65, 0x4d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x12, 0x1c, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65,
-	0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x74, 0x69,
-	0x74, 0x79, 0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74,
-	0x65, 0x72, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65,
-	0x73, 0x70, 0x12, 0x52, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x74,
-	0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
-	0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73,
-	0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
-	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69,
-	0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x52, 0x0a, 0x10, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x43,
-	0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x6d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65,
-	0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x53,
-	0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4f, 0x0a, 0x10, 0x53, 0x61,
-	0x76, 0x65, 0x41, 0x75, 0x74, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x4d, 0x73, 0x67, 0x12, 0x1f,
-	0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x53,
-	0x61, 0x76, 0x65, 0x41, 0x75, 0x74, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x1a,
-	0x1a, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e,
-	0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4a, 0x0a, 0x0e, 0x55,
-	0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x42, 0x79, 0x49, 0x64, 0x12, 0x1b, 0x2e,
-	0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x65,
-	0x61, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65,
-	0x6e, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4e, 0x0a, 0x0f, 0x57, 0x69, 0x74, 0x68, 0x64,
-	0x72, 0x61, 0x77, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x2e, 0x6d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x57,
-	0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65,
-	0x6e, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4a, 0x0a, 0x0f, 0x41, 0x70, 0x70, 0x72, 0x61,
-	0x69, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x2e, 0x6d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x72, 0x61,
-	0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
-	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x52,
-	0x65, 0x73, 0x70, 0x12, 0x4b, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74,
-	0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1e, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
-	0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61,
-	0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
+	0x72, 0x4d, 0x73, 0x67, 0x22, 0x60, 0x0a, 0x12, 0x4f, 0x6e, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50,
+	0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x6f,
+	0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a,
+	0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e,
+	0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x49, 0x64,
+	0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x22, 0x6d, 0x0a, 0x13, 0x4f, 0x6e, 0x65, 0x55, 0x73, 0x65,
+	0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a,
+	0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
+	0x03, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09,
+	0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73,
+	0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73,
+	0x69, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xe9, 0x07, 0x0a, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
+	0x65, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74,
+	0x12, 0x17, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72,
+	0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x6d, 0x65, 0x73, 0x73,
+	0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52,
+	0x65, 0x73, 0x70, 0x12, 0x3b, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12,
+	0x16, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e,
+	0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
 	0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70,
-	0x12, 0x44, 0x0a, 0x09, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x74, 0x12, 0x1d, 0x2e,
-	0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d, 0x65,
-	0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x6d,
-	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6d,
-	0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x2f, 0x6d, 0x65, 0x73, 0x73,
-	0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
-	0x33,
+	0x12, 0x44, 0x0a, 0x0b, 0x46, 0x69, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12,
+	0x19, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e,
+	0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x6d, 0x65, 0x73,
+	0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61,
+	0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4b, 0x0a, 0x0b, 0x53, 0x61, 0x76, 0x65, 0x4d, 0x65,
+	0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1c, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63,
+	0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x74,
+	0x69, 0x74, 0x79, 0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e,
+	0x74, 0x65, 0x72, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52,
+	0x65, 0x73, 0x70, 0x12, 0x52, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61,
+	0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61,
+	0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73,
+	0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
+	0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73,
+	0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x52, 0x0a, 0x10, 0x43, 0x6c, 0x6f, 0x73, 0x65,
+	0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x6d, 0x65,
+	0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x6f, 0x73,
+	0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x65,
+	0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x68, 0x61, 0x74,
+	0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4f, 0x0a, 0x10, 0x53,
+	0x61, 0x76, 0x65, 0x41, 0x75, 0x74, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x4d, 0x73, 0x67, 0x12,
+	0x1f, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e,
+	0x53, 0x61, 0x76, 0x65, 0x41, 0x75, 0x74, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x52, 0x65, 0x71,
+	0x1a, 0x1a, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72,
+	0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4a, 0x0a, 0x0e,
+	0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x42, 0x79, 0x49, 0x64, 0x12, 0x1b,
+	0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x52,
+	0x65, 0x61, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x65,
+	0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x75, 0x72, 0x72,
+	0x65, 0x6e, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4e, 0x0a, 0x0f, 0x57, 0x69, 0x74, 0x68,
+	0x64, 0x72, 0x61, 0x77, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x2e, 0x6d, 0x65,
+	0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x61, 0x64,
+	0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x65,
+	0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x75, 0x72, 0x72,
+	0x65, 0x6e, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4a, 0x0a, 0x0f, 0x41, 0x70, 0x70, 0x72,
+	0x61, 0x69, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x2e, 0x6d, 0x65,
+	0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x72,
+	0x61, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
+	0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79,
+	0x52, 0x65, 0x73, 0x70, 0x12, 0x4b, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61,
+	0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1e, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61,
+	0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73,
+	0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61,
+	0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73,
+	0x70, 0x12, 0x44, 0x0a, 0x09, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x74, 0x12, 0x1d,
+	0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d,
+	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e,
+	0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f,
+	0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x58, 0x0a, 0x0f, 0x4f, 0x6e, 0x65, 0x55, 0x73,
+	0x65, 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x2e, 0x6d, 0x65, 0x73,
+	0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4f, 0x6e, 0x65, 0x55, 0x73,
+	0x65, 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x22, 0x2e,
+	0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4f, 0x6e,
+	0x65, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73,
+	0x70, 0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65,
+	0x6e, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -2161,28 +2306,30 @@ func file_messagecenter_proto_rawDescGZIP() []byte {
 	return file_messagecenter_proto_rawDescData
 }
 
-var file_messagecenter_proto_msgTypes = make([]protoimpl.MessageInfo, 20)
+var file_messagecenter_proto_msgTypes = make([]protoimpl.MessageInfo, 22)
 var file_messagecenter_proto_goTypes = []interface{}{
-	(*CountReq)(nil),         // 0: messagecenter.CountReq
-	(*CountResp)(nil),        // 1: messagecenter.CountResp
-	(*UserReq)(nil),          // 2: messagecenter.UserReq
-	(*UserResp)(nil),         // 3: messagecenter.UserResp
-	(*UserEntity)(nil),       // 4: messagecenter.UserEntity
-	(*MessageReq)(nil),       // 5: messagecenter.MessageReq
-	(*MessageResp)(nil),      // 6: messagecenter.MessageResp
-	(*SaveMessageResp)(nil),  // 7: messagecenter.SaveMessageResp
-	(*MessageEntity)(nil),    // 8: messagecenter.MessageEntity
-	(*ChatSessionReq)(nil),   // 9: messagecenter.ChatSessionReq
-	(*CloseSessionReq)(nil),  // 10: messagecenter.CloseSessionReq
-	(*ChatSessionResp)(nil),  // 11: messagecenter.ChatSessionResp
-	(*SaveAutoReplyReq)(nil), // 12: messagecenter.SaveAutoReplyReq
-	(*ReadStateReq)(nil),     // 13: messagecenter.ReadStateReq
-	(*ReadWithdrawReq)(nil),  // 14: messagecenter.ReadWithdrawReq
-	(*AppraiseReq)(nil),      // 15: messagecenter.AppraiseReq
-	(*CurrencyResp)(nil),     // 16: messagecenter.CurrencyResp
-	(*ConversationReq)(nil),  // 17: messagecenter.ConversationReq
-	(*MessageSaveReq)(nil),   // 18: messagecenter.MessageSaveReq
-	(*CommonReq)(nil),        // 19: messagecenter.CommonReq
+	(*CountReq)(nil),            // 0: messagecenter.CountReq
+	(*CountResp)(nil),           // 1: messagecenter.CountResp
+	(*UserReq)(nil),             // 2: messagecenter.UserReq
+	(*UserResp)(nil),            // 3: messagecenter.UserResp
+	(*UserEntity)(nil),          // 4: messagecenter.UserEntity
+	(*MessageReq)(nil),          // 5: messagecenter.MessageReq
+	(*MessageResp)(nil),         // 6: messagecenter.MessageResp
+	(*SaveMessageResp)(nil),     // 7: messagecenter.SaveMessageResp
+	(*MessageEntity)(nil),       // 8: messagecenter.MessageEntity
+	(*ChatSessionReq)(nil),      // 9: messagecenter.ChatSessionReq
+	(*CloseSessionReq)(nil),     // 10: messagecenter.CloseSessionReq
+	(*ChatSessionResp)(nil),     // 11: messagecenter.ChatSessionResp
+	(*SaveAutoReplyReq)(nil),    // 12: messagecenter.SaveAutoReplyReq
+	(*ReadStateReq)(nil),        // 13: messagecenter.ReadStateReq
+	(*ReadWithdrawReq)(nil),     // 14: messagecenter.ReadWithdrawReq
+	(*AppraiseReq)(nil),         // 15: messagecenter.AppraiseReq
+	(*CurrencyResp)(nil),        // 16: messagecenter.CurrencyResp
+	(*ConversationReq)(nil),     // 17: messagecenter.ConversationReq
+	(*MessageSaveReq)(nil),      // 18: messagecenter.MessageSaveReq
+	(*CommonReq)(nil),           // 19: messagecenter.CommonReq
+	(*OneUserPositionReq)(nil),  // 20: messagecenter.OneUserPositionReq
+	(*OneUserPositionResp)(nil), // 21: messagecenter.OneUserPositionResp
 }
 var file_messagecenter_proto_depIdxs = []int32{
 	8,  // 0: messagecenter.CountResp.lastMessage:type_name -> messagecenter.MessageEntity
@@ -2201,20 +2348,22 @@ var file_messagecenter_proto_depIdxs = []int32{
 	15, // 13: messagecenter.messageCenter.AppraiseMessage:input_type -> messagecenter.AppraiseReq
 	17, // 14: messagecenter.messageCenter.ConversationList:input_type -> messagecenter.ConversationReq
 	18, // 15: messagecenter.messageCenter.GroupChat:input_type -> messagecenter.MessageSaveReq
-	1,  // 16: messagecenter.messageCenter.Count:output_type -> messagecenter.CountResp
-	3,  // 17: messagecenter.messageCenter.UserList:output_type -> messagecenter.UserResp
-	6,  // 18: messagecenter.messageCenter.FindMessage:output_type -> messagecenter.MessageResp
-	7,  // 19: messagecenter.messageCenter.SaveMessage:output_type -> messagecenter.SaveMessageResp
-	11, // 20: messagecenter.messageCenter.CreateChatSession:output_type -> messagecenter.ChatSessionResp
-	11, // 21: messagecenter.messageCenter.CloseChatSession:output_type -> messagecenter.ChatSessionResp
-	6,  // 22: messagecenter.messageCenter.SaveAutoReplyMsg:output_type -> messagecenter.MessageResp
-	16, // 23: messagecenter.messageCenter.UpdateReadById:output_type -> messagecenter.CurrencyResp
-	16, // 24: messagecenter.messageCenter.WithdrawMessage:output_type -> messagecenter.CurrencyResp
-	16, // 25: messagecenter.messageCenter.AppraiseMessage:output_type -> messagecenter.CurrencyResp
-	3,  // 26: messagecenter.messageCenter.ConversationList:output_type -> messagecenter.UserResp
-	19, // 27: messagecenter.messageCenter.GroupChat:output_type -> messagecenter.CommonReq
-	16, // [16:28] is the sub-list for method output_type
-	4,  // [4:16] is the sub-list for method input_type
+	20, // 16: messagecenter.messageCenter.OneUserPosition:input_type -> messagecenter.OneUserPositionReq
+	1,  // 17: messagecenter.messageCenter.Count:output_type -> messagecenter.CountResp
+	3,  // 18: messagecenter.messageCenter.UserList:output_type -> messagecenter.UserResp
+	6,  // 19: messagecenter.messageCenter.FindMessage:output_type -> messagecenter.MessageResp
+	7,  // 20: messagecenter.messageCenter.SaveMessage:output_type -> messagecenter.SaveMessageResp
+	11, // 21: messagecenter.messageCenter.CreateChatSession:output_type -> messagecenter.ChatSessionResp
+	11, // 22: messagecenter.messageCenter.CloseChatSession:output_type -> messagecenter.ChatSessionResp
+	6,  // 23: messagecenter.messageCenter.SaveAutoReplyMsg:output_type -> messagecenter.MessageResp
+	16, // 24: messagecenter.messageCenter.UpdateReadById:output_type -> messagecenter.CurrencyResp
+	16, // 25: messagecenter.messageCenter.WithdrawMessage:output_type -> messagecenter.CurrencyResp
+	16, // 26: messagecenter.messageCenter.AppraiseMessage:output_type -> messagecenter.CurrencyResp
+	3,  // 27: messagecenter.messageCenter.ConversationList:output_type -> messagecenter.UserResp
+	19, // 28: messagecenter.messageCenter.GroupChat:output_type -> messagecenter.CommonReq
+	21, // 29: messagecenter.messageCenter.OneUserPosition:output_type -> messagecenter.OneUserPositionResp
+	17, // [17:30] is the sub-list for method output_type
+	4,  // [4:17] is the sub-list for method input_type
 	4,  // [4:4] is the sub-list for extension type_name
 	4,  // [4:4] is the sub-list for extension extendee
 	0,  // [0:4] is the sub-list for field type_name
@@ -2466,6 +2615,30 @@ func file_messagecenter_proto_init() {
 				return nil
 			}
 		}
+		file_messagecenter_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*OneUserPositionReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_messagecenter_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*OneUserPositionResp); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -2473,7 +2646,7 @@ func file_messagecenter_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_messagecenter_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   20,
+			NumMessages:   22,
 			NumExtensions: 0,
 			NumServices:   1,
 		},

+ 44 - 6
rpc/messagecenter/messagecenter/messagecenter_grpc.pb.go

@@ -34,11 +34,11 @@ 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)
@@ -46,6 +46,8 @@ type MessageCenterClient interface {
 	ConversationList(ctx context.Context, in *ConversationReq, opts ...grpc.CallOption) (*UserResp, error)
 	// 群聊
 	GroupChat(ctx context.Context, in *MessageSaveReq, opts ...grpc.CallOption) (*CommonReq, error)
+	// 1v1会话职位
+	OneUserPosition(ctx context.Context, in *OneUserPositionReq, opts ...grpc.CallOption) (*OneUserPositionResp, error)
 }
 
 type messageCenterClient struct {
@@ -164,6 +166,15 @@ func (c *messageCenterClient) GroupChat(ctx context.Context, in *MessageSaveReq,
 	return out, nil
 }
 
+func (c *messageCenterClient) OneUserPosition(ctx context.Context, in *OneUserPositionReq, opts ...grpc.CallOption) (*OneUserPositionResp, error) {
+	out := new(OneUserPositionResp)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/OneUserPosition", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // MessageCenterServer is the server API for MessageCenter service.
 // All implementations must embed UnimplementedMessageCenterServer
 // for forward compatibility
@@ -180,11 +191,11 @@ 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)
@@ -192,6 +203,8 @@ type MessageCenterServer interface {
 	ConversationList(context.Context, *ConversationReq) (*UserResp, error)
 	// 群聊
 	GroupChat(context.Context, *MessageSaveReq) (*CommonReq, error)
+	// 1v1会话职位
+	OneUserPosition(context.Context, *OneUserPositionReq) (*OneUserPositionResp, error)
 	mustEmbedUnimplementedMessageCenterServer()
 }
 
@@ -235,6 +248,9 @@ func (UnimplementedMessageCenterServer) ConversationList(context.Context, *Conve
 func (UnimplementedMessageCenterServer) GroupChat(context.Context, *MessageSaveReq) (*CommonReq, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GroupChat not implemented")
 }
+func (UnimplementedMessageCenterServer) OneUserPosition(context.Context, *OneUserPositionReq) (*OneUserPositionResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method OneUserPosition not implemented")
+}
 func (UnimplementedMessageCenterServer) mustEmbedUnimplementedMessageCenterServer() {}
 
 // UnsafeMessageCenterServer may be embedded to opt out of forward compatibility for this service.
@@ -464,6 +480,24 @@ func _MessageCenter_GroupChat_Handler(srv interface{}, ctx context.Context, dec
 	return interceptor(ctx, in, info, handler)
 }
 
+func _MessageCenter_OneUserPosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(OneUserPositionReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).OneUserPosition(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/OneUserPosition",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).OneUserPosition(ctx, req.(*OneUserPositionReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // MessageCenter_ServiceDesc is the grpc.ServiceDesc for MessageCenter service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -519,6 +553,10 @@ var MessageCenter_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "GroupChat",
 			Handler:    _MessageCenter_GroupChat_Handler,
 		},
+		{
+			MethodName: "OneUserPosition",
+			Handler:    _MessageCenter_OneUserPosition_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "messagecenter.proto",

+ 5 - 4
service/chat_group.go

@@ -9,7 +9,7 @@ import (
 
 type ChatGroupService struct{}
 
-//企业用户查询
+// 企业用户查询
 func EntPerson(entId int64, isAll bool) (map[string]string, map[string]string, map[int]string) {
 	phoneData := map[string]string{}
 	nameData := map[string]string{}
@@ -40,7 +40,7 @@ func EntPerson(entId int64, isAll bool) (map[string]string, map[string]string, m
 		positionList := IC.BaseMysql.SelectBySql("SELECT a.phone,b.id FROM base_user a LEFT JOIN base_position b ON a.id = b.user_id WHERE b.ent_id = ?", entId)
 		if positionList != nil && len(*positionList) > 0 {
 			for _, v := range *positionList {
-				positionData[common.IntAll(v["positionId"])] = phoneData[common.ObjToString(v["phone"])]
+				positionData[common.IntAll(v["id"])] = phoneData[common.ObjToString(v["phone"])]
 			}
 		}
 	}
@@ -48,9 +48,10 @@ func EntPerson(entId int64, isAll bool) (map[string]string, map[string]string, m
 	return phoneData, nameData, positionData
 }
 
-//用户名换取职位标识(测试)
+// 用户名换取职位标识(测试)
 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))
+	name := "and name like '%" + userName + "%'"
+	personList := IC.MainMysql.SelectBySql(fmt.Sprintf(" select GROUP_CONCAT(phone) as phone from %s where ent_id=%d %s", util.ENTNICHE_USER, entId, name))
 	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))

+ 108 - 32
service/message_mail_box.go

@@ -102,31 +102,32 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 		GroupNameSql := `(SELECT *,"" as groupMember FROM socialize_chat_group where isdismiss = 0)` //无搜索群
 		if in.NameSearch != "" {
 			serviceNameSql = " AND b.nickname like '%" + in.NameSearch + "%'"
-			GroupNameSql = "(SELECT id,name FROM socialize_chat_group  isdismiss = 0 AND name like '%" + in.NameSearch + "%')" //默认搜素群名称
+			GroupNameSql = `(SELECT id,name,"" as groupMember FROM socialize_chat_group WHERE isdismiss = 0 AND name like '%` + in.NameSearch + `%')` //默认搜素群名称
 			positionIdArr = NameToPositionIdp(in.NameSearch, in.EntId)
 			if positionIdArr != "" {
 				oneNameSql = " AND find_in_set(b.id,'" + positionIdArr + "')" //1v1搜索成员id
 				//存在满足成员名时 重新定义搜索sql 并兼容群名称不满足但成员名满足时也展示 并展示部分满足群员名
-				name := fmt.Sprintf(" AND c.position_id IN ( %s ) or b.name like '%"+in.NameSearch+"%'", positionIdArr)
+				nameSearch := " or b.name like '%" + in.NameSearch + "%')"
+				name := fmt.Sprintf(" AND (c.position_id IN ( %s ) %s", positionIdArr, nameSearch)
 				GroupNameSql = fmt.Sprintf(` (
 						SELECT
 							a.chat_group_id as id,
 							GROUP_CONCAT( distinct c.position_id ) as groupMember,
-							GROUP_CONCAT( distinct b.name ) as name,
+							GROUP_CONCAT( distinct b.name ) as name
 						FROM
 						socialize_chat_group_person a
 						INNER JOIN socialize_chat_group b ON a.position_id=%d AND a.chat_group_id = b.id AND b.isdismiss = 0 
-						INNER JOIN socialize_chat_group_person c ON AND a.chat_group_id = c.chat_group_id 	%s
+						INNER JOIN socialize_chat_group_person c ON  a.chat_group_id = c.chat_group_id 	%s
 						GROUP BY
 						a.chat_group_id)`, in.PositionId, name) //群搜索
 			}
 		}
-
+		log.Println("用户列表展示", in.NameSearch, in.EntId, oneNameSql)
 		//1v1 无搜索时 或搜索有结果时
 		if in.NameSearch == "" || oneNameSql != "" {
 			oneSql = fmt.Sprintf(`(SELECT
 							a.your_position_id AS id,
-							1 AS userType,
+							2 AS userType,
 							c.nickname AS name,
 							c.headimg,
 							d.content,
@@ -149,7 +150,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 		serviceSql := fmt.Sprintf(` (
 						SELECT
 							a.ent_id AS id,
-							2 AS userType,
+							1 AS userType,
 							b.nickname AS name,
 							b.headimage as headimg,
 							c.content,
@@ -188,9 +189,29 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 						) `, GroupNameSql, in.PositionId)
 		switch in.QueryType {
 		case 1: //分享列表
-			allSql = strings.Join(append(sqlArr, oneSql, groupSql), " UNION ALL ")
-		case 2: //历史会话列表
-			allSql = strings.Join(append(sqlArr, oneSql, groupSql, serviceSql), " UNION ALL ")
+			if oneSql != "" {
+				sqlArr = append(sqlArr, oneSql)
+			}
+			if groupSql != "" {
+				sqlArr = append(sqlArr, groupSql)
+			}
+			if len(sqlArr) > 1 {
+				allSql = strings.Join(sqlArr, " UNION ALL ")
+			} else {
+				allSql = sqlArr[0]
+			}
+		default:
+			//历史会话列表
+			if oneSql != "" {
+				sqlArr = append(sqlArr, oneSql)
+			}
+			if groupSql != "" {
+				sqlArr = append(sqlArr, groupSql)
+			}
+			if serviceSql != "" {
+				sqlArr = append(sqlArr, serviceSql)
+			}
+			allSql = strings.Join(sqlArr, " UNION ALL ")
 		}
 		sqlStr = fmt.Sprintf(`SELECT * FROM(
 						%s
@@ -303,7 +324,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 			case 2: //用户查询结果
 				phoneMap, _, positionMap := EntPerson(in.EntId, true) //获取企业架构人员名称
 				for _, v := range *data {
-					if quitl.IntAll(v["userType"]) == 1 {
+					if quitl.IntAll(v["userType"]) == 2 {
 						v["name"] = phoneMap[quitl.InterfaceToStr(v["phone"])]
 					} else if quitl.IntAll(v["userType"]) == 3 {
 						var names []string
@@ -1009,7 +1030,7 @@ func (b MessaggeService) AppraiseMessage(in *messagecenter.AppraiseReq) error {
 /*
 入参 appid,title,content,sendid,link,item,messagetype,receiverIds,groupIds
 */
-func (this *MessaggeService) Chat(in *messagecenter.MessageSaveReq) (fool bool, errorMsg string, content string, messageId, nowInt int64) {
+func (this *MessaggeService) Chat(in *messagecenter.MessageEntity) (fool bool, errorMsg string, content string, messageId, nowInt int64) {
 	now := time.Now()
 	nowTime := now.Format(date.Date_Full_Layout)
 	messageId = int64(0)
@@ -1017,7 +1038,7 @@ func (this *MessaggeService) Chat(in *messagecenter.MessageSaveReq) (fool bool,
 		isGroup := len(in.GroupIds) > 0
 		isOneToOne := len(in.ReceiverIds) > 0
 		createperson := strconv.Itoa(int(in.SendId))
-		messageId = MessageAdd(tx, in.Appid, in.Title, in.Content, createperson, in.Link, in.Item, in.MessageType)
+		messageId = MessageAdd(tx, in.Appid, in.Title, in.Content, createperson, in.Link, in.Item, in.Type)
 		//是否客服介入
 		isCustomerServiceAccess := 0
 
@@ -1026,17 +1047,15 @@ func (this *MessaggeService) Chat(in *messagecenter.MessageSaveReq) (fool bool,
 			fieids := []string{"appid", "messag_id", "type", "send_user_id", "send_user_type", "receive_user_id", "receive_user_type", "own_type", "own_id", "create_time", "chat_group_id", "isread"}
 			for _, v := range in.GroupIds {
 				args := []interface{}{}
-				summaryArgs := []interface{}{}
 				args = append(args, in.Appid, messageId, in.Type, in.SendId, 2, in.SendId, 2, 2, in.SendId, nowTime, v, 1)
 				groupUser := GetUserByGroupId(tx, v, in.SendId)
 				for _, vv := range groupUser {
 					log.Println("获取到群组下员工:", vv)
 					args = append(args, in.Appid, messageId, in.Type, in.SendId, 2, vv, 2, 2, vv, nowTime, v, 0)
 				}
-				summaryArgs = append(summaryArgs, in.SendId, nil, nil, v, messageId, nil, isCustomerServiceAccess, nowTime)
 				MessageMailBoxAdd(tx, fieids, args)
 				//最后一次聊天
-				SocializeSummaryAdd(tx, summaryArgs)
+				SocializeSummaryAddOrUpdate(tx, v, 0, 0, messageId, isCustomerServiceAccess, nowTime)
 				//更新未读消息
 				GroupUserUnReadUpdate(tx, groupUser)
 			}
@@ -1045,18 +1064,15 @@ func (this *MessaggeService) Chat(in *messagecenter.MessageSaveReq) (fool bool,
 		if isOneToOne {
 			fieids := []string{"appid", "messag_id", "type", "send_user_id", "send_user_type", "receive_user_id", "receive_user_type", "own_type", "own_id", "create_time", "isread"}
 			args := []interface{}{}
-			summaryArgs := []interface{}{}
 			args = append(args, in.Appid, messageId, in.Type, in.SendId, 2, in.SendId, 2, 2, in.SendId, nowTime, 1)
 			for _, v := range in.ReceiverIds {
 				args = append(args, in.Appid, messageId, in.Type, in.SendId, 2, v, 2, 2, v, nowTime, 0)
-				//发送方,未读消息应该是0
-				summaryArgs = append(summaryArgs, in.SendId, v, nil, nil, messageId, 0, isCustomerServiceAccess, nowTime)
-				//接收方,未读消息应该是1
-				summaryArgs = append(summaryArgs, v, in.SendId, nil, nil, messageId, 1, isCustomerServiceAccess, nowTime)
+
+				//最后一次聊天
+				SocializeSummaryAddOrUpdate(tx, 0, in.SendId, v, messageId, isCustomerServiceAccess, nowTime)
+				SocializeSummaryAddOrUpdate(tx, 0, v, in.SendId, messageId, isCustomerServiceAccess, nowTime)
 			}
 			MessageMailBoxAdd(tx, fieids, args)
-			//最后一次聊天
-			SocializeSummaryAdd(tx, summaryArgs)
 		}
 		return true
 	})
@@ -1092,7 +1108,6 @@ func MessageMailBoxAdd(tx *sql.Tx, fieids []string, args []interface{}) (int64,
 func GetUserByGroupId(tx *sql.Tx, groupId, sendId int64) []int64 {
 	arr := []int64{}
 	data := IC.BaseMysql.SelectBySqlByTx(tx, "select position_id from "+util.SOCIALIZE_CHAT_GROUP_PERSON+" where status = 1 and chat_group_id = ? AND position_id != ? ", groupId, sendId)
-	log.Println("~~~~", data)
 	if data == nil || len(*data) <= 0 {
 		return arr
 	}
@@ -1107,14 +1122,75 @@ func GetUserByGroupId(tx *sql.Tx, groupId, sendId int64) []int64 {
 }
 
 // 最后一次聊天存储
-func SocializeSummaryAdd(tx *sql.Tx, args []interface{}) (int64, int64) {
-	fieids := []string{"my_position_id", "your_position_id", "ent_id", "chat_group_id", "message_id", "unread", "customer_service_access", "timestamp"}
-
-	length, lastId := IC.BaseMysql.InsertBatchByTx(tx, util.SOCIALIZE_SUMMARY, fieids, args)
-
-	log.Println("SocializeSummaryAdd length:", length, "SocializeSummaryAdd lastId:", lastId)
-
-	return length, lastId
+func SocializeSummaryAddOrUpdate(tx *sql.Tx, groupId, myPositionId, yourPositionId, messageId int64, isCustomerServiceAccess int, timestamp string) bool {
+	//判断是否存在
+	if groupId > 0 {
+		if IC.BaseMysql.CountBySql(fmt.Sprintf(`select count(1) from %s where chat_group_id =?`, util.SOCIALIZE_SUMMARY), groupId) > 0 {
+			//存在更新
+			return IC.BaseMysql.UpdateByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
+				"chat_group_id": groupId,
+			}, map[string]interface{}{
+				"message_id": messageId,
+				"timestamp":  timestamp,
+			})
+		} else {
+			//新增
+			return IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
+				"chat_group_id": groupId,
+				"message_id":    messageId,
+				"timestamp":     timestamp,
+			}) > 0
+		}
+	}
+	if yourPositionId > 0 {
+		ok_my := true
+		ok_your := true
+		//发送方
+		if IC.BaseMysql.CountBySql(fmt.Sprintf(`select count(1) from %s where my_position_id =? and your_position_id =?`, util.SOCIALIZE_SUMMARY), myPositionId, yourPositionId) > 0 {
+			//存在更新
+			ok_my = IC.BaseMysql.UpdateByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
+				"my_position_id":   myPositionId,
+				"your_position_id": yourPositionId,
+			}, map[string]interface{}{
+				"message_id": messageId,
+				"timestamp":  timestamp,
+			})
+		} else {
+			//新增
+			ok_my = IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
+				"my_position_id":          myPositionId,
+				"your_position_id":        yourPositionId,
+				"message_id":              messageId,
+				"timestamp":               timestamp,
+				"unread":                  0,
+				"customer_service_access": isCustomerServiceAccess,
+			}) > 0
+		}
+		//接收方
+		if IC.BaseMysql.CountBySql(fmt.Sprintf(`select count(1) from %s where my_position_id =? and your_position_id =?`, util.SOCIALIZE_SUMMARY), yourPositionId, myPositionId) > 0 {
+			//存在更新
+			ok_your = IC.BaseMysql.UpdateByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
+				"my_position_id":   yourPositionId,
+				"your_position_id": myPositionId,
+			}, map[string]interface{}{
+				"message_id": messageId,
+				"timestamp":  timestamp,
+				"unread":     1,
+			})
+		} else {
+			//新增
+			ok_your = IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
+				"my_position_id":          yourPositionId,
+				"your_position_id":        myPositionId,
+				"message_id":              messageId,
+				"timestamp":               timestamp,
+				"unread":                  1,
+				"customer_service_access": isCustomerServiceAccess,
+			}) > 0
+		}
+		return ok_my && ok_your
+	}
+	return true
 }
 
 // 群组人员未读消息更新