diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index b6d00f690..e7203c54d 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -7,6 +7,7 @@ import ( "Open_IM/internal/api/friend" "Open_IM/internal/api/group" "Open_IM/internal/api/manage" + "Open_IM/internal/api/office" apiThird "Open_IM/internal/api/third" "Open_IM/internal/api/user" "Open_IM/pkg/common/log" @@ -106,7 +107,23 @@ func main() { conversationGroup.POST("/set_conversation", conversation.SetConversation) conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations) conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt) + + // Deprecated + conversationGroup.POST("/set_receive_message_opt", conversation.SetReceiveMessageOpt) //1 + conversationGroup.POST("/get_receive_message_opt", conversation.GetReceiveMessageOpt) //1 + conversationGroup.POST("/get_all_conversation_message_opt", conversation.GetAllConversationMessageOpt) //1 } + // office + officeGroup := r.Group("/office") + { + officeGroup.POST("/get_user_tags", office.GetUserTags) + officeGroup.POST("/create_tag", office.CreateTag) + officeGroup.POST("/delete_tag", office.DeleteTag) + officeGroup.POST("/set_tag", office.SetTag) + officeGroup.POST("/send_msg_to_tag", office.SendMsg2Tag) + officeGroup.POST("/get_send_tag_log", office.GetSendTagLogs) + } + apiThird.MinioInit() log.NewPrivateLog("api") ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port") diff --git a/cmd/rpc/open_im_admin_cms/Makefile b/cmd/rpc/open_im_admin_cms/Makefile index f6efc1c08..b86230c64 100644 --- a/cmd/rpc/open_im_admin_cms/Makefile +++ b/cmd/rpc/open_im_admin_cms/Makefile @@ -1,6 +1,6 @@ .PHONY: all build run gotool install clean help -BINARY_NAME=open_im_admin_cms +BINARY_NAME=open_im_office BIN_DIR=../../../bin/ all: gotool build diff --git a/cmd/rpc/open_im_office/Makefile b/cmd/rpc/open_im_office/Makefile new file mode 100644 index 000000000..0ae4189a3 --- /dev/null +++ b/cmd/rpc/open_im_office/Makefile @@ -0,0 +1,23 @@ +.PHONY: all build run gotool install clean help + +BINARY_NAME=office +BIN_DIR=../../../bin/ + +all: gotool build + +build: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" + +run: + @go run ./ + +gotool: + go fmt ./ + go vet ./ + +install: + make build + mv ${BINARY_NAME} ${BIN_DIR} + +clean: + @if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi diff --git a/cmd/rpc/open_im_office/main.go b/cmd/rpc/open_im_office/main.go new file mode 100644 index 000000000..c4d80cf68 --- /dev/null +++ b/cmd/rpc/open_im_office/main.go @@ -0,0 +1,13 @@ +package main + +import ( + rpc "Open_IM/internal/rpc/office" + "flag" +) + +func main() { + rpcPort := flag.Int("port", 11100, "rpc listening port") + flag.Parse() + rpcServer := rpc.NewOfficeServer(*rpcPort) + rpcServer.Run() +} diff --git a/internal/api/conversation/conversation.go b/internal/api/conversation/conversation.go index 591ea3a0a..5c06ecaf5 100644 --- a/internal/api/conversation/conversation.go +++ b/internal/api/conversation/conversation.go @@ -201,3 +201,18 @@ func SetRecvMsgOpt(c *gin.Context) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp) c.JSON(http.StatusOK, resp) } + +//Deprecated +func SetReceiveMessageOpt(c *gin.Context) { + +} + +//Deprecated +func GetReceiveMessageOpt(c *gin.Context) { + +} + +//Deprecated +func GetAllConversationMessageOpt(c *gin.Context) { + +} diff --git a/internal/api/office/tag.go b/internal/api/office/tag.go new file mode 100644 index 000000000..4644a27ed --- /dev/null +++ b/internal/api/office/tag.go @@ -0,0 +1,189 @@ +package office + +import ( + apistruct "Open_IM/pkg/base_info" + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/log" + "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbOffice "Open_IM/pkg/proto/office" + "Open_IM/pkg/utils" + "context" + "github.com/gin-gonic/gin" + "net/http" + "strings" +) + +func GetUserTags(c *gin.Context) { + var ( + req apistruct.GetUserTagsReq + resp apistruct.GetUserTagsResp + reqPb pbOffice.GetUserTagsReq + respPb *pbOffice.GetUserTagsResp + ) + if err := c.BindJSON(&req); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()}) + return + } + if err := utils.CopyStructFields(&reqPb, req); err != nil { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) + client := pbOffice.NewOfficeServiceClient(etcdConn) + respPb, err := client.GetUserTags(context.Background(), &reqPb) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserTags rpc server failed" + err.Error()}) + return + } + if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + resp.Data.Tags = respPb.Tags + c.JSON(http.StatusOK, resp) +} + +func CreateTag(c *gin.Context) { + var ( + req apistruct.CreateTagReq + resp apistruct.CreateTagResp + reqPb pbOffice.CreateTagReq + respPb *pbOffice.CreateTagResp + ) + if err := c.BindJSON(&req); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()}) + return + } + if err := utils.CopyStructFields(&reqPb, req); err != nil { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) + client := pbOffice.NewOfficeServiceClient(etcdConn) + respPb, err := client.CreateTag(context.Background(), &reqPb) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()}) + return + } + if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + c.JSON(http.StatusOK, resp) +} + +func DeleteTag(c *gin.Context) { + var ( + req apistruct.DeleteTagReq + resp apistruct.DeleteTagResp + reqPb pbOffice.DeleteTagReq + respPb *pbOffice.DeleteTagResp + ) + if err := c.BindJSON(&req); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()}) + return + } + if err := utils.CopyStructFields(&reqPb, req); err != nil { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) + client := pbOffice.NewOfficeServiceClient(etcdConn) + respPb, err := client.DeleteTag(context.Background(), &reqPb) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()}) + return + } + if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + c.JSON(http.StatusOK, resp) +} + +func SetTag(c *gin.Context) { + var ( + req apistruct.SetTagReq + resp apistruct.SetTagResp + reqPb pbOffice.SetTagReq + respPb *pbOffice.SetTagResp + ) + if err := c.BindJSON(&req); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()}) + return + } + if err := utils.CopyStructFields(&reqPb, req); err != nil { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) + client := pbOffice.NewOfficeServiceClient(etcdConn) + respPb, err := client.SetTag(context.Background(), &reqPb) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()}) + return + } + if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + c.JSON(http.StatusOK, resp) +} + +func SendMsg2Tag(c *gin.Context) { + var ( + req apistruct.SendMsg2TagReq + resp apistruct.SendMsg2TagResp + reqPb pbOffice.SendMsg2TagReq + respPb *pbOffice.SendMsg2TagResp + ) + if err := c.BindJSON(&req); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()}) + return + } + if err := utils.CopyStructFields(&reqPb, req); err != nil { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) + client := pbOffice.NewOfficeServiceClient(etcdConn) + respPb, err := client.SendMsg2Tag(context.Background(), &reqPb) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()}) + return + } + if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + c.JSON(http.StatusOK, resp) +} + +func GetSendTagLogs(c *gin.Context) { + var ( + req apistruct.SendMsg2TagReq + resp apistruct.SendMsg2TagResp + reqPb pbOffice.SendMsg2TagReq + respPb *pbOffice.SendMsg2TagResp + ) + if err := c.BindJSON(&req); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()}) + return + } + if err := utils.CopyStructFields(&reqPb, req); err != nil { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) + client := pbOffice.NewOfficeServiceClient(etcdConn) + respPb, err := client.SendMsg2Tag(context.Background(), &reqPb) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()}) + return + } + if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + c.JSON(http.StatusOK, resp) +} diff --git a/internal/api/third/minio_storage_credential.go b/internal/api/third/minio_storage_credential.go index b9d311815..50ab64eb2 100644 --- a/internal/api/third/minio_storage_credential.go +++ b/internal/api/third/minio_storage_credential.go @@ -33,8 +33,15 @@ func MinioUploadFile(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return } + ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) + if !ok { + log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token")) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) + return + } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req) switch req.FileType { + // videoType upload snapShot case constant.VideoType: snapShotFile, err := c.FormFile("snapShot") if err != nil { diff --git a/internal/rpc/msg/tag_notification.go b/internal/rpc/msg/tag_notification.go new file mode 100644 index 000000000..8a6356bb4 --- /dev/null +++ b/internal/rpc/msg/tag_notification.go @@ -0,0 +1,20 @@ +package msg + +import ( + "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/log" + "Open_IM/pkg/utils" +) + +func SetTagNotification(operationID, sendID, recvID, content string, contentType int32) { + log.NewInfo(operationID, utils.GetSelfFuncName(), "args: ", sendID, recvID, content, contentType) + var n NotificationMsg + n.SendID = sendID + n.RecvID = recvID + n.ContentType = contentType + n.SessionType = constant.SingleChatType + n.MsgFrom = constant.UserMsgType + n.OperationID = operationID + n.Content = []byte(content) + Notification(&n) +} diff --git a/internal/rpc/office/office.go b/internal/rpc/office/office.go new file mode 100644 index 000000000..9e297531d --- /dev/null +++ b/internal/rpc/office/office.go @@ -0,0 +1,163 @@ +package office + +import ( + "Open_IM/internal/rpc/msg" + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/db" + "Open_IM/pkg/common/log" + "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbOffice "Open_IM/pkg/proto/office" + pbCommon "Open_IM/pkg/proto/sdk_ws" + "Open_IM/pkg/utils" + "context" + "google.golang.org/grpc" + "net" + "strconv" + "strings" +) + +type officeServer struct { + rpcPort int + rpcRegisterName string + etcdSchema string + etcdAddr []string +} + +func NewOfficeServer(port int) *officeServer { + log.NewPrivateLog("officeServer") + return &officeServer{ + rpcPort: port, + rpcRegisterName: config.Config.RpcRegisterName.OpenImMessageCMSName, + etcdSchema: config.Config.Etcd.EtcdSchema, + etcdAddr: config.Config.Etcd.EtcdAddr, + } +} + +func (s *officeServer) Run() { + log.NewInfo("0", "officeServer rpc start ") + ip := utils.ServerIP + registerAddress := ip + ":" + strconv.Itoa(s.rpcPort) + //listener network + listener, err := net.Listen("tcp", registerAddress) + if err != nil { + log.NewError("0", "Listen failed ", err.Error(), registerAddress) + return + } + log.NewInfo("0", "listen network success, ", registerAddress, listener) + defer listener.Close() + //grpc server + srv := grpc.NewServer() + defer srv.GracefulStop() + //Service registers with etcd + pbOffice.RegisterOfficeServiceServer(srv, s) + err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10) + if err != nil { + log.NewError("0", "RegisterEtcd failed ", err.Error()) + return + } + err = srv.Serve(listener) + if err != nil { + log.NewError("0", "Serve failed ", err.Error()) + return + } + log.NewInfo("0", "message cms rpc success") +} + +func (s *officeServer) GetUserTags(_ context.Context, req *pbOffice.GetUserTagsReq) (resp *pbOffice.GetUserTagsResp, err error) { + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req ", req.String()) + resp = &pbOffice.GetUserTagsResp{ + CommonResp: &pbOffice.CommonResp{}, + Tags: []*pbOffice.Tag{}, + } + tags, err := db.DB.GetUserTags(req.UserID) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error()) + resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + resp.CommonResp.ErrCode = constant.ErrDB.ErrCode + return resp, nil + } + if err := utils.CopyStructFields(resp.Tags, tags); err != nil { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + for _, v := range resp.Tags { + + } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp ", resp.String()) + return resp, nil +} + +func (s *officeServer) CreateTag(_ context.Context, req *pbOffice.CreateTagReq) (resp *pbOffice.CreateTagResp, err error) { + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "CreateTag req", req.String()) + resp = &pbOffice.CreateTagResp{CommonResp: &pbOffice.CommonResp{}} + if err := db.DB.CreateTag(req.UserID, req.TagName, req.UserIDList); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error()) + resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + resp.CommonResp.ErrCode = constant.ErrDB.ErrCode + return resp, nil + } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp", resp.String()) + return resp, nil +} + +func (s *officeServer) DeleteTag(_ context.Context, req *pbOffice.DeleteTagReq) (resp *pbOffice.DeleteTagResp, err error) { + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) + resp = &pbOffice.DeleteTagResp{CommonResp: &pbOffice.CommonResp{}} + if err := db.DB.DeleteTag(req.UserID, req.TagID); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "DeleteTag failed", err.Error()) + resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + resp.CommonResp.ErrCode = constant.ErrDB.ErrCode + return resp, nil + } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + return resp, nil +} + +func (s *officeServer) SetTag(_ context.Context, req *pbOffice.SetTagReq) (resp *pbOffice.SetTagResp, err error) { + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) + resp = &pbOffice.SetTagResp{CommonResp: &pbOffice.CommonResp{}} + if err := db.DB.SetTag(req.UserID, req.TagID, req.NewName, req.ReduceUserIDList, req.ReduceUserIDList); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetTag failed", err.Error()) + resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + resp.CommonResp.ErrCode = constant.ErrDB.ErrCode + return resp, nil + } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + return resp, err +} + +func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagReq) (resp *pbOffice.SendMsg2TagResp, err error) { + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) + resp = &pbOffice.SendMsg2TagResp{CommonResp: &pbOffice.CommonResp{}} + userIDList, err := db.DB.GetUserIDListByTagID(req.SendID, req.TagID) + for _, userID := range userIDList { + msg.SetTagNotification(req.OperationID, req.SendID, userID, req.Content, req.ContentType) + } + if err := db.DB.SaveTagSendLog(req); err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "SaveTagSendLog failed", err.Error()) + } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + return resp, err +} + +func (s *officeServer) GetTagSendLogs(_ context.Context, req *pbOffice.GetTagSendLogsReq) (resp *pbOffice.GetTagSendLogsResp, err error) { + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) + resp = &pbOffice.GetTagSendLogsResp{ + CommonResp: &pbOffice.CommonResp{}, + } + tagSendLogs, err := db.DB.GetTagSendLogs(req.UserID, req.Pagination.ShowNumber, req.Pagination.PageNumber) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTagSendLogs", err.Error()) + resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + resp.CommonResp.ErrCode = constant.ErrDB.ErrCode + } + if err := utils.CopyStructFields(resp.TagSendLogs, tagSendLogs); err != nil { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) + } + resp.Pagination = &pbCommon.ResponsePagination{ + CurrentPage: req.Pagination.PageNumber, + ShowNumber: req.Pagination.ShowNumber, + } + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + return resp, nil +} diff --git a/pkg/base_info/minio_api_struct.go b/pkg/base_info/minio_api_struct.go index 51e062c67..6d3b0ecac 100644 --- a/pkg/base_info/minio_api_struct.go +++ b/pkg/base_info/minio_api_struct.go @@ -13,8 +13,8 @@ type MiniostorageCredentialResp struct { } type MinioUploadFileReq struct { - OperationID string `form:"operationID"` - FileType int `form:"fileType"` + OperationID string `form:"operationID" binding:"required"` + FileType int `form:"fileType" binding:"required"` } type MinioUploadFileResp struct { diff --git a/pkg/base_info/office_struct.go b/pkg/base_info/office_struct.go new file mode 100644 index 000000000..2c6dd84c1 --- /dev/null +++ b/pkg/base_info/office_struct.go @@ -0,0 +1,46 @@ +package base_info + +import pbOffice "Open_IM/pkg/proto/office" + +type GetUserTagsReq struct { + pbOffice.GetUserTagsReq +} + +type GetUserTagsResp struct { + CommResp + Data struct { + Tags []*pbOffice.Tag `json:"tags"` + } `json:"data"` +} + +type CreateTagReq struct { + pbOffice.CreateTagReq +} + +type CreateTagResp struct { + CommResp +} + +type DeleteTagReq struct { + pbOffice.DeleteTagReq +} + +type DeleteTagResp struct { + CommResp +} + +type SetTagReq struct { + pbOffice.SetTagReq +} + +type SetTagResp struct { + CommResp +} + +type SendMsg2TagReq struct { + pbOffice.SendMsg2TagReq +} + +type SendMsg2TagResp struct { + CommResp +} diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 2a57344e8..f1af2e714 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -103,6 +103,7 @@ type config struct { OpenImAuthName string `yaml:"openImAuthName"` OpenImMessageCMSName string `yaml:"openImMessageCMSName"` OpenImAdminCMSName string `yaml:"openImAdminCMSName"` + OpenImOfficeName string `yaml:"openImOfficeName"` } Etcd struct { EtcdSchema string `yaml:"etcdSchema"` diff --git a/pkg/common/db/mongoModel.go b/pkg/common/db/mongoModel.go index 3f8d1b88b..370d1acd3 100644 --- a/pkg/common/db/mongoModel.go +++ b/pkg/common/db/mongoModel.go @@ -5,12 +5,14 @@ import ( "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" pbMsg "Open_IM/pkg/proto/chat" + officePb "Open_IM/pkg/proto/office" open_im_sdk "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" "context" "errors" "fmt" "github.com/gogo/protobuf/sortkeys" + "math/rand" //"github.com/garyburd/redigo/redis" "github.com/golang/protobuf/proto" @@ -22,6 +24,8 @@ import ( const cChat = "msg" const cGroup = "group" +const cTag = "tag" +const cSendLog = "sendLog" const singleGocMsgNum = 5000 type MsgInfo struct { @@ -430,9 +434,135 @@ func (d *DataBases) DelGroupMember(groupID, uid string) error { //return nil } +type Tag struct { + TagID string `bson:"tagID"` + TagName string `bson:"tagName"` + UserList []string `bson:"userList"` +} + +type TagsStruct struct { + Uid string `bson:"uid"` + Tags map[string]Tag `bson:"tags"` +} + +type TagSendLogStruct struct { +} + +func (d *DataBases) GetUserTags(userID string) ([]Tag, error) { + ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second) + c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag) + var tagStruct TagsStruct + var tags []Tag + _ = c.FindOne(ctx, bson.M{"uid": userID}).Decode(&tagStruct) + for _, v := range tagStruct.Tags { + tags = append(tags, v) + } + return tags, nil +} + +func (d *DataBases) CreateTag(userID, tagName string, userList []string) error { + ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second) + c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag) + tagID := generateTagID(tagName, userID) + tag := Tag{ + TagID: tagID, + TagName: tagName, + UserList: userList, + } + _, err := c.InsertOne(ctx, TagsStruct{ + Uid: userID, + Tags: map[string]Tag{tagID: tag}, + }) + return err +} + +func (d *DataBases) DeleteTag(userID, tagID string) error { + ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second) + c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag) + _, err := c.DeleteOne(ctx, bson.M{"uid": userID, "tags": bson.M{"$unset": tagID}}) + return err +} + +func (d *DataBases) SetTag(userID, tagID, newName string, increaseUserList []string, reduceUserIDList []string) error { + ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second) + c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag) + _, err := c.UpdateOne(ctx, bson.M{"uid": userID, "tags": tagID}, bson.M{"tagName": newName}) + if err != nil { + return err + } + _, err = c.InsertOne(ctx, bson.M{"uid": userID, "tags": bson.M{tagID: ""}}) + if err != nil { + return err + } + //_, err = c.InsertOne(ctx) + //if err != nil { + // return err + //} + return nil +} + +func (d *DataBases) GetUserIDListByTagID(userID, tagID string) ([]string, error) { + var tagIDList []string + var tagStruct TagsStruct + ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second) + c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag) + _ = c.FindOne(ctx, bson.M{"uid": userID}).Decode(&tagStruct) + for k, tag := range tagStruct.Tags { + if k == tagID { + tagIDList = tag.UserList + } + } + return tagIDList, nil +} + +type TagSendLog struct { + TagID string `bson:"tagID"` + SendID string `bson:"sendID"` + SenderPlatformID int32 `bson:"senderPlatformID"` + Content string `bson:"content"` + ContentType int32 `bson:"contentType"` + SendTime int64 `bson:"sendTime"` + UserList []string `bson:"userList"` +} + +func (d *DataBases) SaveTagSendLog(sendReq *officePb.SendMsg2TagReq) error { + ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second) + c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSendLog) + tagSendLog := TagSendLog{ + TagID: sendReq.TagID, + SendID: sendReq.SendID, + SenderPlatformID: sendReq.SenderPlatformID, + Content: sendReq.Content, + ContentType: sendReq.ContentType, + SendTime: time.Now().Unix(), + } + _, err := c.InsertOne(ctx, tagSendLog) + return err +} + +func (d *DataBases) GetTagSendLogs(userID string, showNumber, pageNumber int32) ([]*TagSendLog, error) { + var tagSendLogs []*TagSendLog + ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second) + c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSendLog) + cursor, err := c.Find(ctx, bson.M{"sendID": userID}) + if err != nil { + return tagSendLogs, err + } + err = cursor.Decode(&tagSendLogs) + if err != nil { + return tagSendLogs, err + } + return tagSendLogs, nil +} + +func generateTagID(tagName, userID string) string { + return utils.Md5(tagName + userID + strconv.Itoa(rand.Int())) +} + func getCurrentTimestampByMill() int64 { return time.Now().UnixNano() / 1e6 } + func getSeqUid(uid string, seq uint32) string { seqSuffix := seq / singleGocMsgNum return indexGen(uid, seqSuffix) diff --git a/pkg/common/db/mysql_model/im_mysql_model/user_model.go b/pkg/common/db/mysql_model/im_mysql_model/user_model.go index cfe340dc3..d6726ea9f 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/user_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/user_model.go @@ -74,6 +74,19 @@ func GetUserByUserID(userID string) (*db.User, error) { return &user, nil } +func GetUserNameByUserID(userID string) (string, error) { + dbConn, err := db.DB.MysqlDB.DefaultGormDB() + if err != nil { + return "", err + } + var userName string + err = dbConn.Table("users").Select("name").Where("user_id=?", userID).Find(&userName).Error + if err != nil { + return "", err + } + return userName, nil +} + func UpdateUserInfo(user db.User) error { dbConn, err := db.DB.MysqlDB.DefaultGormDB() if err != nil { diff --git a/pkg/proto/office/office.pb.go b/pkg/proto/office/office.pb.go new file mode 100644 index 000000000..6f1ae7157 --- /dev/null +++ b/pkg/proto/office/office.pb.go @@ -0,0 +1,1183 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: office/office.proto + +package office // import "./office" + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import sdk_ws "Open_IM/pkg/proto/sdk_ws" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type CommonResp struct { + ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` + ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CommonResp) Reset() { *m = CommonResp{} } +func (m *CommonResp) String() string { return proto.CompactTextString(m) } +func (*CommonResp) ProtoMessage() {} +func (*CommonResp) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{0} +} +func (m *CommonResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CommonResp.Unmarshal(m, b) +} +func (m *CommonResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CommonResp.Marshal(b, m, deterministic) +} +func (dst *CommonResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommonResp.Merge(dst, src) +} +func (m *CommonResp) XXX_Size() int { + return xxx_messageInfo_CommonResp.Size(m) +} +func (m *CommonResp) XXX_DiscardUnknown() { + xxx_messageInfo_CommonResp.DiscardUnknown(m) +} + +var xxx_messageInfo_CommonResp proto.InternalMessageInfo + +func (m *CommonResp) GetErrCode() int32 { + if m != nil { + return m.ErrCode + } + return 0 +} + +func (m *CommonResp) GetErrMsg() string { + if m != nil { + return m.ErrMsg + } + return "" +} + +type TagUser struct { + UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` + UserName string `protobuf:"bytes,2,opt,name=userName" json:"userName,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TagUser) Reset() { *m = TagUser{} } +func (m *TagUser) String() string { return proto.CompactTextString(m) } +func (*TagUser) ProtoMessage() {} +func (*TagUser) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{1} +} +func (m *TagUser) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TagUser.Unmarshal(m, b) +} +func (m *TagUser) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TagUser.Marshal(b, m, deterministic) +} +func (dst *TagUser) XXX_Merge(src proto.Message) { + xxx_messageInfo_TagUser.Merge(dst, src) +} +func (m *TagUser) XXX_Size() int { + return xxx_messageInfo_TagUser.Size(m) +} +func (m *TagUser) XXX_DiscardUnknown() { + xxx_messageInfo_TagUser.DiscardUnknown(m) +} + +var xxx_messageInfo_TagUser proto.InternalMessageInfo + +func (m *TagUser) GetUserID() string { + if m != nil { + return m.UserID + } + return "" +} + +func (m *TagUser) GetUserName() string { + if m != nil { + return m.UserName + } + return "" +} + +type Tag struct { + TagID string `protobuf:"bytes,1,opt,name=tagID" json:"tagID,omitempty"` + TagName string `protobuf:"bytes,2,opt,name=tagName" json:"tagName,omitempty"` + UserList []*TagUser `protobuf:"bytes,3,rep,name=userList" json:"userList,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Tag) Reset() { *m = Tag{} } +func (m *Tag) String() string { return proto.CompactTextString(m) } +func (*Tag) ProtoMessage() {} +func (*Tag) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{2} +} +func (m *Tag) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Tag.Unmarshal(m, b) +} +func (m *Tag) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Tag.Marshal(b, m, deterministic) +} +func (dst *Tag) XXX_Merge(src proto.Message) { + xxx_messageInfo_Tag.Merge(dst, src) +} +func (m *Tag) XXX_Size() int { + return xxx_messageInfo_Tag.Size(m) +} +func (m *Tag) XXX_DiscardUnknown() { + xxx_messageInfo_Tag.DiscardUnknown(m) +} + +var xxx_messageInfo_Tag proto.InternalMessageInfo + +func (m *Tag) GetTagID() string { + if m != nil { + return m.TagID + } + return "" +} + +func (m *Tag) GetTagName() string { + if m != nil { + return m.TagName + } + return "" +} + +func (m *Tag) GetUserList() []*TagUser { + if m != nil { + return m.UserList + } + return nil +} + +type GetUserTagsReq struct { + UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` + OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetUserTagsReq) Reset() { *m = GetUserTagsReq{} } +func (m *GetUserTagsReq) String() string { return proto.CompactTextString(m) } +func (*GetUserTagsReq) ProtoMessage() {} +func (*GetUserTagsReq) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{3} +} +func (m *GetUserTagsReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetUserTagsReq.Unmarshal(m, b) +} +func (m *GetUserTagsReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetUserTagsReq.Marshal(b, m, deterministic) +} +func (dst *GetUserTagsReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetUserTagsReq.Merge(dst, src) +} +func (m *GetUserTagsReq) XXX_Size() int { + return xxx_messageInfo_GetUserTagsReq.Size(m) +} +func (m *GetUserTagsReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetUserTagsReq.DiscardUnknown(m) +} + +var xxx_messageInfo_GetUserTagsReq proto.InternalMessageInfo + +func (m *GetUserTagsReq) GetUserID() string { + if m != nil { + return m.UserID + } + return "" +} + +func (m *GetUserTagsReq) GetOperationID() string { + if m != nil { + return m.OperationID + } + return "" +} + +type GetUserTagsResp struct { + CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` + Tags []*Tag `protobuf:"bytes,2,rep,name=tags" json:"tags,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetUserTagsResp) Reset() { *m = GetUserTagsResp{} } +func (m *GetUserTagsResp) String() string { return proto.CompactTextString(m) } +func (*GetUserTagsResp) ProtoMessage() {} +func (*GetUserTagsResp) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{4} +} +func (m *GetUserTagsResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetUserTagsResp.Unmarshal(m, b) +} +func (m *GetUserTagsResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetUserTagsResp.Marshal(b, m, deterministic) +} +func (dst *GetUserTagsResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetUserTagsResp.Merge(dst, src) +} +func (m *GetUserTagsResp) XXX_Size() int { + return xxx_messageInfo_GetUserTagsResp.Size(m) +} +func (m *GetUserTagsResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetUserTagsResp.DiscardUnknown(m) +} + +var xxx_messageInfo_GetUserTagsResp proto.InternalMessageInfo + +func (m *GetUserTagsResp) GetCommonResp() *CommonResp { + if m != nil { + return m.CommonResp + } + return nil +} + +func (m *GetUserTagsResp) GetTags() []*Tag { + if m != nil { + return m.Tags + } + return nil +} + +type CreateTagReq struct { + TagName string `protobuf:"bytes,1,opt,name=tagName" json:"tagName,omitempty"` + UserID string `protobuf:"bytes,2,opt,name=userID" json:"userID,omitempty"` + UserIDList []string `protobuf:"bytes,3,rep,name=userIDList" json:"userIDList,omitempty"` + OperationID string `protobuf:"bytes,4,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CreateTagReq) Reset() { *m = CreateTagReq{} } +func (m *CreateTagReq) String() string { return proto.CompactTextString(m) } +func (*CreateTagReq) ProtoMessage() {} +func (*CreateTagReq) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{5} +} +func (m *CreateTagReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CreateTagReq.Unmarshal(m, b) +} +func (m *CreateTagReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CreateTagReq.Marshal(b, m, deterministic) +} +func (dst *CreateTagReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateTagReq.Merge(dst, src) +} +func (m *CreateTagReq) XXX_Size() int { + return xxx_messageInfo_CreateTagReq.Size(m) +} +func (m *CreateTagReq) XXX_DiscardUnknown() { + xxx_messageInfo_CreateTagReq.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateTagReq proto.InternalMessageInfo + +func (m *CreateTagReq) GetTagName() string { + if m != nil { + return m.TagName + } + return "" +} + +func (m *CreateTagReq) GetUserID() string { + if m != nil { + return m.UserID + } + return "" +} + +func (m *CreateTagReq) GetUserIDList() []string { + if m != nil { + return m.UserIDList + } + return nil +} + +func (m *CreateTagReq) GetOperationID() string { + if m != nil { + return m.OperationID + } + return "" +} + +type CreateTagResp struct { + CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CreateTagResp) Reset() { *m = CreateTagResp{} } +func (m *CreateTagResp) String() string { return proto.CompactTextString(m) } +func (*CreateTagResp) ProtoMessage() {} +func (*CreateTagResp) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{6} +} +func (m *CreateTagResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CreateTagResp.Unmarshal(m, b) +} +func (m *CreateTagResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CreateTagResp.Marshal(b, m, deterministic) +} +func (dst *CreateTagResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateTagResp.Merge(dst, src) +} +func (m *CreateTagResp) XXX_Size() int { + return xxx_messageInfo_CreateTagResp.Size(m) +} +func (m *CreateTagResp) XXX_DiscardUnknown() { + xxx_messageInfo_CreateTagResp.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateTagResp proto.InternalMessageInfo + +func (m *CreateTagResp) GetCommonResp() *CommonResp { + if m != nil { + return m.CommonResp + } + return nil +} + +type DeleteTagReq struct { + UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` + TagID string `protobuf:"bytes,2,opt,name=tagID" json:"tagID,omitempty"` + OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DeleteTagReq) Reset() { *m = DeleteTagReq{} } +func (m *DeleteTagReq) String() string { return proto.CompactTextString(m) } +func (*DeleteTagReq) ProtoMessage() {} +func (*DeleteTagReq) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{7} +} +func (m *DeleteTagReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DeleteTagReq.Unmarshal(m, b) +} +func (m *DeleteTagReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DeleteTagReq.Marshal(b, m, deterministic) +} +func (dst *DeleteTagReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteTagReq.Merge(dst, src) +} +func (m *DeleteTagReq) XXX_Size() int { + return xxx_messageInfo_DeleteTagReq.Size(m) +} +func (m *DeleteTagReq) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteTagReq.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteTagReq proto.InternalMessageInfo + +func (m *DeleteTagReq) GetUserID() string { + if m != nil { + return m.UserID + } + return "" +} + +func (m *DeleteTagReq) GetTagID() string { + if m != nil { + return m.TagID + } + return "" +} + +func (m *DeleteTagReq) GetOperationID() string { + if m != nil { + return m.OperationID + } + return "" +} + +type DeleteTagResp struct { + CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DeleteTagResp) Reset() { *m = DeleteTagResp{} } +func (m *DeleteTagResp) String() string { return proto.CompactTextString(m) } +func (*DeleteTagResp) ProtoMessage() {} +func (*DeleteTagResp) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{8} +} +func (m *DeleteTagResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DeleteTagResp.Unmarshal(m, b) +} +func (m *DeleteTagResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DeleteTagResp.Marshal(b, m, deterministic) +} +func (dst *DeleteTagResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteTagResp.Merge(dst, src) +} +func (m *DeleteTagResp) XXX_Size() int { + return xxx_messageInfo_DeleteTagResp.Size(m) +} +func (m *DeleteTagResp) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteTagResp.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteTagResp proto.InternalMessageInfo + +func (m *DeleteTagResp) GetCommonResp() *CommonResp { + if m != nil { + return m.CommonResp + } + return nil +} + +type SetTagReq struct { + UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` + TagID string `protobuf:"bytes,2,opt,name=tagID" json:"tagID,omitempty"` + NewName string `protobuf:"bytes,3,opt,name=newName" json:"newName,omitempty"` + IncreaseUserIDList []string `protobuf:"bytes,4,rep,name=increaseUserIDList" json:"increaseUserIDList,omitempty"` + ReduceUserIDList []string `protobuf:"bytes,5,rep,name=reduceUserIDList" json:"reduceUserIDList,omitempty"` + OperationID string `protobuf:"bytes,6,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SetTagReq) Reset() { *m = SetTagReq{} } +func (m *SetTagReq) String() string { return proto.CompactTextString(m) } +func (*SetTagReq) ProtoMessage() {} +func (*SetTagReq) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{9} +} +func (m *SetTagReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SetTagReq.Unmarshal(m, b) +} +func (m *SetTagReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SetTagReq.Marshal(b, m, deterministic) +} +func (dst *SetTagReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetTagReq.Merge(dst, src) +} +func (m *SetTagReq) XXX_Size() int { + return xxx_messageInfo_SetTagReq.Size(m) +} +func (m *SetTagReq) XXX_DiscardUnknown() { + xxx_messageInfo_SetTagReq.DiscardUnknown(m) +} + +var xxx_messageInfo_SetTagReq proto.InternalMessageInfo + +func (m *SetTagReq) GetUserID() string { + if m != nil { + return m.UserID + } + return "" +} + +func (m *SetTagReq) GetTagID() string { + if m != nil { + return m.TagID + } + return "" +} + +func (m *SetTagReq) GetNewName() string { + if m != nil { + return m.NewName + } + return "" +} + +func (m *SetTagReq) GetIncreaseUserIDList() []string { + if m != nil { + return m.IncreaseUserIDList + } + return nil +} + +func (m *SetTagReq) GetReduceUserIDList() []string { + if m != nil { + return m.ReduceUserIDList + } + return nil +} + +func (m *SetTagReq) GetOperationID() string { + if m != nil { + return m.OperationID + } + return "" +} + +type SetTagResp struct { + CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SetTagResp) Reset() { *m = SetTagResp{} } +func (m *SetTagResp) String() string { return proto.CompactTextString(m) } +func (*SetTagResp) ProtoMessage() {} +func (*SetTagResp) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{10} +} +func (m *SetTagResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SetTagResp.Unmarshal(m, b) +} +func (m *SetTagResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SetTagResp.Marshal(b, m, deterministic) +} +func (dst *SetTagResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetTagResp.Merge(dst, src) +} +func (m *SetTagResp) XXX_Size() int { + return xxx_messageInfo_SetTagResp.Size(m) +} +func (m *SetTagResp) XXX_DiscardUnknown() { + xxx_messageInfo_SetTagResp.DiscardUnknown(m) +} + +var xxx_messageInfo_SetTagResp proto.InternalMessageInfo + +func (m *SetTagResp) GetCommonResp() *CommonResp { + if m != nil { + return m.CommonResp + } + return nil +} + +type SendMsg2TagReq struct { + TagID string `protobuf:"bytes,1,opt,name=tagID" json:"tagID,omitempty"` + SendID string `protobuf:"bytes,2,opt,name=sendID" json:"sendID,omitempty"` + SenderPlatformID int32 `protobuf:"varint,3,opt,name=senderPlatformID" json:"senderPlatformID,omitempty"` + Content string `protobuf:"bytes,4,opt,name=content" json:"content,omitempty"` + ContentType int32 `protobuf:"varint,5,opt,name=contentType" json:"contentType,omitempty"` + OperationID string `protobuf:"bytes,6,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SendMsg2TagReq) Reset() { *m = SendMsg2TagReq{} } +func (m *SendMsg2TagReq) String() string { return proto.CompactTextString(m) } +func (*SendMsg2TagReq) ProtoMessage() {} +func (*SendMsg2TagReq) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{11} +} +func (m *SendMsg2TagReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SendMsg2TagReq.Unmarshal(m, b) +} +func (m *SendMsg2TagReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SendMsg2TagReq.Marshal(b, m, deterministic) +} +func (dst *SendMsg2TagReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_SendMsg2TagReq.Merge(dst, src) +} +func (m *SendMsg2TagReq) XXX_Size() int { + return xxx_messageInfo_SendMsg2TagReq.Size(m) +} +func (m *SendMsg2TagReq) XXX_DiscardUnknown() { + xxx_messageInfo_SendMsg2TagReq.DiscardUnknown(m) +} + +var xxx_messageInfo_SendMsg2TagReq proto.InternalMessageInfo + +func (m *SendMsg2TagReq) GetTagID() string { + if m != nil { + return m.TagID + } + return "" +} + +func (m *SendMsg2TagReq) GetSendID() string { + if m != nil { + return m.SendID + } + return "" +} + +func (m *SendMsg2TagReq) GetSenderPlatformID() int32 { + if m != nil { + return m.SenderPlatformID + } + return 0 +} + +func (m *SendMsg2TagReq) GetContent() string { + if m != nil { + return m.Content + } + return "" +} + +func (m *SendMsg2TagReq) GetContentType() int32 { + if m != nil { + return m.ContentType + } + return 0 +} + +func (m *SendMsg2TagReq) GetOperationID() string { + if m != nil { + return m.OperationID + } + return "" +} + +type SendMsg2TagResp struct { + CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SendMsg2TagResp) Reset() { *m = SendMsg2TagResp{} } +func (m *SendMsg2TagResp) String() string { return proto.CompactTextString(m) } +func (*SendMsg2TagResp) ProtoMessage() {} +func (*SendMsg2TagResp) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{12} +} +func (m *SendMsg2TagResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SendMsg2TagResp.Unmarshal(m, b) +} +func (m *SendMsg2TagResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SendMsg2TagResp.Marshal(b, m, deterministic) +} +func (dst *SendMsg2TagResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_SendMsg2TagResp.Merge(dst, src) +} +func (m *SendMsg2TagResp) XXX_Size() int { + return xxx_messageInfo_SendMsg2TagResp.Size(m) +} +func (m *SendMsg2TagResp) XXX_DiscardUnknown() { + xxx_messageInfo_SendMsg2TagResp.DiscardUnknown(m) +} + +var xxx_messageInfo_SendMsg2TagResp proto.InternalMessageInfo + +func (m *SendMsg2TagResp) GetCommonResp() *CommonResp { + if m != nil { + return m.CommonResp + } + return nil +} + +type GetTagSendLogsReq struct { + Pagination *sdk_ws.RequestPagination `protobuf:"bytes,1,opt,name=Pagination" json:"Pagination,omitempty"` + UserID string `protobuf:"bytes,2,opt,name=userID" json:"userID,omitempty"` + OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetTagSendLogsReq) Reset() { *m = GetTagSendLogsReq{} } +func (m *GetTagSendLogsReq) String() string { return proto.CompactTextString(m) } +func (*GetTagSendLogsReq) ProtoMessage() {} +func (*GetTagSendLogsReq) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{13} +} +func (m *GetTagSendLogsReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetTagSendLogsReq.Unmarshal(m, b) +} +func (m *GetTagSendLogsReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetTagSendLogsReq.Marshal(b, m, deterministic) +} +func (dst *GetTagSendLogsReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTagSendLogsReq.Merge(dst, src) +} +func (m *GetTagSendLogsReq) XXX_Size() int { + return xxx_messageInfo_GetTagSendLogsReq.Size(m) +} +func (m *GetTagSendLogsReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetTagSendLogsReq.DiscardUnknown(m) +} + +var xxx_messageInfo_GetTagSendLogsReq proto.InternalMessageInfo + +func (m *GetTagSendLogsReq) GetPagination() *sdk_ws.RequestPagination { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *GetTagSendLogsReq) GetUserID() string { + if m != nil { + return m.UserID + } + return "" +} + +func (m *GetTagSendLogsReq) GetOperationID() string { + if m != nil { + return m.OperationID + } + return "" +} + +type TagSendLog struct { + TagID string `protobuf:"bytes,1,opt,name=tagID" json:"tagID,omitempty"` + TagName string `protobuf:"bytes,2,opt,name=tagName" json:"tagName,omitempty"` + ContentType int32 `protobuf:"varint,3,opt,name=contentType" json:"contentType,omitempty"` + Content string `protobuf:"bytes,4,opt,name=content" json:"content,omitempty"` + SendTime int64 `protobuf:"varint,5,opt,name=sendTime" json:"sendTime,omitempty"` + UserList []string `protobuf:"bytes,6,rep,name=userList" json:"userList,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TagSendLog) Reset() { *m = TagSendLog{} } +func (m *TagSendLog) String() string { return proto.CompactTextString(m) } +func (*TagSendLog) ProtoMessage() {} +func (*TagSendLog) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{14} +} +func (m *TagSendLog) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TagSendLog.Unmarshal(m, b) +} +func (m *TagSendLog) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TagSendLog.Marshal(b, m, deterministic) +} +func (dst *TagSendLog) XXX_Merge(src proto.Message) { + xxx_messageInfo_TagSendLog.Merge(dst, src) +} +func (m *TagSendLog) XXX_Size() int { + return xxx_messageInfo_TagSendLog.Size(m) +} +func (m *TagSendLog) XXX_DiscardUnknown() { + xxx_messageInfo_TagSendLog.DiscardUnknown(m) +} + +var xxx_messageInfo_TagSendLog proto.InternalMessageInfo + +func (m *TagSendLog) GetTagID() string { + if m != nil { + return m.TagID + } + return "" +} + +func (m *TagSendLog) GetTagName() string { + if m != nil { + return m.TagName + } + return "" +} + +func (m *TagSendLog) GetContentType() int32 { + if m != nil { + return m.ContentType + } + return 0 +} + +func (m *TagSendLog) GetContent() string { + if m != nil { + return m.Content + } + return "" +} + +func (m *TagSendLog) GetSendTime() int64 { + if m != nil { + return m.SendTime + } + return 0 +} + +func (m *TagSendLog) GetUserList() []string { + if m != nil { + return m.UserList + } + return nil +} + +type GetTagSendLogsResp struct { + CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` + Pagination *sdk_ws.ResponsePagination `protobuf:"bytes,2,opt,name=Pagination" json:"Pagination,omitempty"` + TagSendLogs []*TagSendLog `protobuf:"bytes,3,rep,name=tagSendLogs" json:"tagSendLogs,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetTagSendLogsResp) Reset() { *m = GetTagSendLogsResp{} } +func (m *GetTagSendLogsResp) String() string { return proto.CompactTextString(m) } +func (*GetTagSendLogsResp) ProtoMessage() {} +func (*GetTagSendLogsResp) Descriptor() ([]byte, []int) { + return fileDescriptor_office_4149f396a2012e50, []int{15} +} +func (m *GetTagSendLogsResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetTagSendLogsResp.Unmarshal(m, b) +} +func (m *GetTagSendLogsResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetTagSendLogsResp.Marshal(b, m, deterministic) +} +func (dst *GetTagSendLogsResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTagSendLogsResp.Merge(dst, src) +} +func (m *GetTagSendLogsResp) XXX_Size() int { + return xxx_messageInfo_GetTagSendLogsResp.Size(m) +} +func (m *GetTagSendLogsResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetTagSendLogsResp.DiscardUnknown(m) +} + +var xxx_messageInfo_GetTagSendLogsResp proto.InternalMessageInfo + +func (m *GetTagSendLogsResp) GetCommonResp() *CommonResp { + if m != nil { + return m.CommonResp + } + return nil +} + +func (m *GetTagSendLogsResp) GetPagination() *sdk_ws.ResponsePagination { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *GetTagSendLogsResp) GetTagSendLogs() []*TagSendLog { + if m != nil { + return m.TagSendLogs + } + return nil +} + +func init() { + proto.RegisterType((*CommonResp)(nil), "office.CommonResp") + proto.RegisterType((*TagUser)(nil), "office.TagUser") + proto.RegisterType((*Tag)(nil), "office.Tag") + proto.RegisterType((*GetUserTagsReq)(nil), "office.GetUserTagsReq") + proto.RegisterType((*GetUserTagsResp)(nil), "office.GetUserTagsResp") + proto.RegisterType((*CreateTagReq)(nil), "office.CreateTagReq") + proto.RegisterType((*CreateTagResp)(nil), "office.CreateTagResp") + proto.RegisterType((*DeleteTagReq)(nil), "office.DeleteTagReq") + proto.RegisterType((*DeleteTagResp)(nil), "office.DeleteTagResp") + proto.RegisterType((*SetTagReq)(nil), "office.SetTagReq") + proto.RegisterType((*SetTagResp)(nil), "office.SetTagResp") + proto.RegisterType((*SendMsg2TagReq)(nil), "office.SendMsg2TagReq") + proto.RegisterType((*SendMsg2TagResp)(nil), "office.SendMsg2TagResp") + proto.RegisterType((*GetTagSendLogsReq)(nil), "office.GetTagSendLogsReq") + proto.RegisterType((*TagSendLog)(nil), "office.TagSendLog") + proto.RegisterType((*GetTagSendLogsResp)(nil), "office.GetTagSendLogsResp") +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// Client API for OfficeService service + +type OfficeServiceClient interface { + GetUserTags(ctx context.Context, in *GetUserTagsReq, opts ...grpc.CallOption) (*GetUserTagsResp, error) + CreateTag(ctx context.Context, in *CreateTagReq, opts ...grpc.CallOption) (*CreateTagResp, error) + DeleteTag(ctx context.Context, in *DeleteTagReq, opts ...grpc.CallOption) (*DeleteTagResp, error) + SetTag(ctx context.Context, in *SetTagReq, opts ...grpc.CallOption) (*SetTagResp, error) + SendMsg2Tag(ctx context.Context, in *SendMsg2TagReq, opts ...grpc.CallOption) (*SendMsg2TagResp, error) + GetTagSendLogs(ctx context.Context, in *GetTagSendLogsReq, opts ...grpc.CallOption) (*GetTagSendLogsResp, error) +} + +type officeServiceClient struct { + cc *grpc.ClientConn +} + +func NewOfficeServiceClient(cc *grpc.ClientConn) OfficeServiceClient { + return &officeServiceClient{cc} +} + +func (c *officeServiceClient) GetUserTags(ctx context.Context, in *GetUserTagsReq, opts ...grpc.CallOption) (*GetUserTagsResp, error) { + out := new(GetUserTagsResp) + err := grpc.Invoke(ctx, "/office.OfficeService/GetUserTags", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *officeServiceClient) CreateTag(ctx context.Context, in *CreateTagReq, opts ...grpc.CallOption) (*CreateTagResp, error) { + out := new(CreateTagResp) + err := grpc.Invoke(ctx, "/office.OfficeService/CreateTag", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *officeServiceClient) DeleteTag(ctx context.Context, in *DeleteTagReq, opts ...grpc.CallOption) (*DeleteTagResp, error) { + out := new(DeleteTagResp) + err := grpc.Invoke(ctx, "/office.OfficeService/DeleteTag", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *officeServiceClient) SetTag(ctx context.Context, in *SetTagReq, opts ...grpc.CallOption) (*SetTagResp, error) { + out := new(SetTagResp) + err := grpc.Invoke(ctx, "/office.OfficeService/SetTag", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *officeServiceClient) SendMsg2Tag(ctx context.Context, in *SendMsg2TagReq, opts ...grpc.CallOption) (*SendMsg2TagResp, error) { + out := new(SendMsg2TagResp) + err := grpc.Invoke(ctx, "/office.OfficeService/SendMsg2Tag", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *officeServiceClient) GetTagSendLogs(ctx context.Context, in *GetTagSendLogsReq, opts ...grpc.CallOption) (*GetTagSendLogsResp, error) { + out := new(GetTagSendLogsResp) + err := grpc.Invoke(ctx, "/office.OfficeService/GetTagSendLogs", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for OfficeService service + +type OfficeServiceServer interface { + GetUserTags(context.Context, *GetUserTagsReq) (*GetUserTagsResp, error) + CreateTag(context.Context, *CreateTagReq) (*CreateTagResp, error) + DeleteTag(context.Context, *DeleteTagReq) (*DeleteTagResp, error) + SetTag(context.Context, *SetTagReq) (*SetTagResp, error) + SendMsg2Tag(context.Context, *SendMsg2TagReq) (*SendMsg2TagResp, error) + GetTagSendLogs(context.Context, *GetTagSendLogsReq) (*GetTagSendLogsResp, error) +} + +func RegisterOfficeServiceServer(s *grpc.Server, srv OfficeServiceServer) { + s.RegisterService(&_OfficeService_serviceDesc, srv) +} + +func _OfficeService_GetUserTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUserTagsReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OfficeServiceServer).GetUserTags(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/office.OfficeService/GetUserTags", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OfficeServiceServer).GetUserTags(ctx, req.(*GetUserTagsReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _OfficeService_CreateTag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateTagReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OfficeServiceServer).CreateTag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/office.OfficeService/CreateTag", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OfficeServiceServer).CreateTag(ctx, req.(*CreateTagReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _OfficeService_DeleteTag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteTagReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OfficeServiceServer).DeleteTag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/office.OfficeService/DeleteTag", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OfficeServiceServer).DeleteTag(ctx, req.(*DeleteTagReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _OfficeService_SetTag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetTagReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OfficeServiceServer).SetTag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/office.OfficeService/SetTag", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OfficeServiceServer).SetTag(ctx, req.(*SetTagReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _OfficeService_SendMsg2Tag_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendMsg2TagReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OfficeServiceServer).SendMsg2Tag(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/office.OfficeService/SendMsg2Tag", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OfficeServiceServer).SendMsg2Tag(ctx, req.(*SendMsg2TagReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _OfficeService_GetTagSendLogs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetTagSendLogsReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OfficeServiceServer).GetTagSendLogs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/office.OfficeService/GetTagSendLogs", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OfficeServiceServer).GetTagSendLogs(ctx, req.(*GetTagSendLogsReq)) + } + return interceptor(ctx, in, info, handler) +} + +var _OfficeService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "office.OfficeService", + HandlerType: (*OfficeServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetUserTags", + Handler: _OfficeService_GetUserTags_Handler, + }, + { + MethodName: "CreateTag", + Handler: _OfficeService_CreateTag_Handler, + }, + { + MethodName: "DeleteTag", + Handler: _OfficeService_DeleteTag_Handler, + }, + { + MethodName: "SetTag", + Handler: _OfficeService_SetTag_Handler, + }, + { + MethodName: "SendMsg2Tag", + Handler: _OfficeService_SendMsg2Tag_Handler, + }, + { + MethodName: "GetTagSendLogs", + Handler: _OfficeService_GetTagSendLogs_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "office/office.proto", +} + +func init() { proto.RegisterFile("office/office.proto", fileDescriptor_office_4149f396a2012e50) } + +var fileDescriptor_office_4149f396a2012e50 = []byte{ + // 762 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xc1, 0x6e, 0xd3, 0x4c, + 0x10, 0x96, 0x93, 0x26, 0x6d, 0x26, 0x6d, 0xf3, 0x77, 0xff, 0x52, 0x82, 0x0f, 0x10, 0x2c, 0x90, + 0x2a, 0x90, 0x12, 0x29, 0x70, 0x40, 0x42, 0x54, 0x88, 0xa4, 0xaa, 0x8a, 0x5a, 0x5a, 0x6d, 0xd3, + 0x0b, 0x07, 0xa2, 0x6d, 0x32, 0xb1, 0xac, 0x36, 0xb6, 0xbb, 0xbb, 0x6d, 0xc5, 0x95, 0x57, 0xe0, + 0x45, 0x78, 0x09, 0x24, 0xae, 0x3c, 0x10, 0x12, 0xf2, 0x7a, 0x6d, 0xaf, 0x9d, 0x44, 0x40, 0x4e, + 0xd9, 0x99, 0x9d, 0x99, 0x7c, 0xdf, 0x37, 0xbb, 0xb3, 0x86, 0xff, 0x83, 0xc9, 0xc4, 0x1b, 0x61, + 0x27, 0xfe, 0x69, 0x87, 0x3c, 0x90, 0x01, 0xa9, 0xc6, 0x96, 0xfd, 0xf8, 0x24, 0x44, 0x7f, 0x78, + 0x78, 0xdc, 0x09, 0x2f, 0xdd, 0x8e, 0xda, 0xea, 0x88, 0xf1, 0xe5, 0xf0, 0x4e, 0x74, 0xee, 0x44, + 0x1c, 0xea, 0xec, 0x01, 0xf4, 0x82, 0xe9, 0x34, 0xf0, 0x29, 0x8a, 0x90, 0x34, 0x61, 0x15, 0x39, + 0xef, 0x05, 0x63, 0x6c, 0x5a, 0x2d, 0x6b, 0xb7, 0x42, 0x13, 0x93, 0xec, 0x40, 0x15, 0x39, 0x3f, + 0x16, 0x6e, 0xb3, 0xd4, 0xb2, 0x76, 0x6b, 0x54, 0x5b, 0xce, 0x1b, 0x58, 0x1d, 0x30, 0xf7, 0x5c, + 0x20, 0x8f, 0x42, 0x6e, 0x04, 0xf2, 0xc3, 0xbe, 0xca, 0xad, 0x51, 0x6d, 0x11, 0x1b, 0xd6, 0xa2, + 0xd5, 0x07, 0x36, 0x45, 0x9d, 0x9c, 0xda, 0xce, 0x05, 0x94, 0x07, 0xcc, 0x25, 0xdb, 0x50, 0x91, + 0xcc, 0x4d, 0x33, 0x63, 0x23, 0x42, 0x23, 0x99, 0x6b, 0xe4, 0x25, 0x26, 0x79, 0x1e, 0x97, 0x3c, + 0xf2, 0x84, 0x6c, 0x96, 0x5b, 0xe5, 0xdd, 0x7a, 0xb7, 0xd1, 0xd6, 0x0a, 0x68, 0x34, 0x34, 0x0d, + 0x70, 0xde, 0xc3, 0xe6, 0x01, 0xca, 0xc8, 0x39, 0x60, 0xae, 0xa0, 0x78, 0xbd, 0x10, 0x69, 0x0b, + 0xea, 0x41, 0x88, 0x9c, 0x49, 0x2f, 0xf0, 0x0f, 0xfb, 0xfa, 0x4f, 0x4d, 0x97, 0x33, 0x81, 0x46, + 0xae, 0x96, 0x08, 0x49, 0x17, 0x60, 0x94, 0x2a, 0xa8, 0x0a, 0xd6, 0xbb, 0x24, 0x41, 0x93, 0x69, + 0x4b, 0x8d, 0x28, 0xf2, 0x08, 0x56, 0x24, 0x73, 0x45, 0xb3, 0xa4, 0xb0, 0xd7, 0x0d, 0xec, 0x54, + 0x6d, 0x38, 0x5f, 0x2c, 0x58, 0xef, 0x71, 0x64, 0x12, 0x23, 0x1f, 0x5e, 0x9b, 0x5a, 0x58, 0x79, + 0x2d, 0x32, 0x32, 0xa5, 0x1c, 0x99, 0x87, 0x00, 0xf1, 0x2a, 0x55, 0xa9, 0x46, 0x0d, 0x4f, 0x91, + 0xec, 0xca, 0x2c, 0xd9, 0x1e, 0x6c, 0x18, 0x18, 0x96, 0xa3, 0xea, 0x7c, 0x82, 0xf5, 0x3e, 0x5e, + 0x61, 0x4a, 0x64, 0x91, 0xf6, 0xe9, 0x11, 0x28, 0x99, 0x47, 0xa0, 0x00, 0xb2, 0x3c, 0x17, 0xa4, + 0x51, 0x7f, 0x49, 0x90, 0x3f, 0x2d, 0xa8, 0x9d, 0xa1, 0x5c, 0x0a, 0x62, 0x13, 0x56, 0x7d, 0xbc, + 0x53, 0x9d, 0x89, 0xe1, 0x25, 0x26, 0x69, 0x03, 0xf1, 0xfc, 0x11, 0x47, 0x26, 0xf0, 0x3c, 0xeb, + 0xc4, 0x8a, 0xea, 0xc4, 0x9c, 0x1d, 0xf2, 0x0c, 0xfe, 0xe3, 0x38, 0xbe, 0x19, 0x99, 0xd1, 0x15, + 0x15, 0x3d, 0xe3, 0x2f, 0x0a, 0x53, 0x9d, 0x15, 0xe6, 0x2d, 0x40, 0x42, 0x69, 0x49, 0x55, 0x7e, + 0x58, 0xb0, 0x79, 0x86, 0xfe, 0xf8, 0x58, 0xb8, 0x5d, 0x2d, 0xcd, 0xfc, 0x8b, 0xba, 0x03, 0x55, + 0x81, 0xfe, 0x38, 0x3b, 0x82, 0xb1, 0x15, 0x11, 0x8a, 0x56, 0xc8, 0x4f, 0xaf, 0x98, 0x9c, 0x04, + 0x7c, 0xaa, 0x5b, 0x58, 0xa1, 0x33, 0xfe, 0x48, 0xc6, 0x51, 0xe0, 0x4b, 0xf4, 0xa5, 0x3e, 0x8a, + 0x89, 0x19, 0x51, 0xd5, 0xcb, 0xc1, 0xe7, 0x10, 0x9b, 0x15, 0x55, 0xc0, 0x74, 0xfd, 0x85, 0x18, + 0xfb, 0xd0, 0xc8, 0x31, 0x59, 0x52, 0x91, 0xaf, 0x16, 0x6c, 0x1d, 0x28, 0x51, 0xa3, 0x6a, 0x47, + 0x41, 0x3c, 0x4e, 0xfa, 0x00, 0xa7, 0xcc, 0xf5, 0x7c, 0xf5, 0x67, 0xba, 0xd2, 0x93, 0xb6, 0x40, + 0x7e, 0x8b, 0x7c, 0xc8, 0x42, 0x6f, 0x18, 0x32, 0xce, 0xa6, 0xa2, 0x4d, 0xf1, 0xfa, 0x06, 0x85, + 0xcc, 0x62, 0xa9, 0x91, 0xb7, 0xf0, 0x1e, 0xff, 0xf9, 0x0a, 0x7c, 0xb3, 0x00, 0x32, 0x48, 0xff, + 0x3c, 0x4c, 0x0b, 0xfa, 0x96, 0x67, 0xf5, 0x5d, 0xdc, 0x1b, 0x1b, 0xd6, 0xa2, 0x4e, 0x0e, 0xbc, + 0x69, 0xdc, 0x98, 0x32, 0x4d, 0xed, 0x64, 0xee, 0xab, 0x63, 0x5c, 0x55, 0xc7, 0x38, 0x9b, 0xc9, + 0xdf, 0x2d, 0x20, 0x45, 0x21, 0x97, 0x9c, 0xa5, 0xfb, 0x39, 0xf5, 0x4b, 0x2a, 0xe7, 0xe9, 0x5c, + 0xf5, 0x45, 0x18, 0xf8, 0x02, 0x17, 0xc8, 0xff, 0x12, 0xea, 0x32, 0x43, 0xa3, 0x5f, 0x15, 0x62, + 0x4c, 0x66, 0xbd, 0x45, 0xcd, 0xb0, 0xee, 0xaf, 0x12, 0x6c, 0x9c, 0xa8, 0x90, 0x33, 0xe4, 0xb7, + 0xde, 0x08, 0xc9, 0x1e, 0xd4, 0x8d, 0x17, 0x82, 0xec, 0x24, 0x15, 0xf2, 0x4f, 0x90, 0x7d, 0x7f, + 0xae, 0x5f, 0x84, 0xe4, 0x15, 0xd4, 0xd2, 0xa1, 0x4b, 0xb6, 0x53, 0xee, 0xc6, 0x5b, 0x60, 0xdf, + 0x9b, 0xe3, 0x8d, 0x33, 0xd3, 0x49, 0x98, 0x65, 0x9a, 0xc3, 0x37, 0xcb, 0xcc, 0x8f, 0xcc, 0x0e, + 0x54, 0xe3, 0x51, 0x41, 0xb6, 0x92, 0x80, 0x74, 0x1a, 0xda, 0xa4, 0xe8, 0x12, 0x61, 0x44, 0xd2, + 0xb8, 0x4e, 0x19, 0xc9, 0xfc, 0xb4, 0xc8, 0x48, 0x16, 0xef, 0xde, 0x81, 0x7a, 0x92, 0x8d, 0xee, + 0x93, 0x07, 0x86, 0x1e, 0xf9, 0xeb, 0x65, 0xdb, 0x8b, 0xb6, 0x44, 0xf8, 0x6e, 0xeb, 0x63, 0xa3, + 0xad, 0xbf, 0x7d, 0x5e, 0xc7, 0x3f, 0x17, 0x55, 0xf5, 0x61, 0xf3, 0xe2, 0x77, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x62, 0x7d, 0x95, 0x4e, 0x1a, 0x09, 0x00, 0x00, +} diff --git a/pkg/proto/office/office.proto b/pkg/proto/office/office.proto new file mode 100644 index 000000000..0e675a25a --- /dev/null +++ b/pkg/proto/office/office.proto @@ -0,0 +1,108 @@ +syntax = "proto3"; +import "Open_IM/pkg/proto/sdk_ws/ws.proto"; +option go_package = "./office;office"; +package office; + +message CommonResp{ + int32 errCode = 1; + string errMsg = 2; +} + +message TagUser { + string userID = 1; + string userName = 2; +} + +message Tag { + string tagID = 1; + string tagName = 2; + repeated TagUser userList = 3; +} + +message GetUserTagsReq{ + string userID = 1; + string operationID = 2; +} + +message GetUserTagsResp{ + CommonResp commonResp = 1; + repeated Tag tags = 2; +} + +message CreateTagReq { + string tagName = 1; + string userID = 2; + repeated string userIDList = 3; + string operationID = 4; +} + +message CreateTagResp { + CommonResp commonResp = 1; +} + +message DeleteTagReq { + string userID = 1; + string tagID = 2; + string operationID = 3; +} + +message DeleteTagResp { + CommonResp commonResp = 1; +} + +message SetTagReq { + string userID = 1; + string tagID = 2; + string newName = 3; + repeated string increaseUserIDList = 4; + repeated string reduceUserIDList = 5; + string operationID = 6; +} + +message SetTagResp { + CommonResp commonResp = 1; +} + +message SendMsg2TagReq { + string tagID = 1; + string sendID = 2; + int32 senderPlatformID = 3; + string content = 4; + int32 contentType = 5; + string operationID = 6; +} + +message SendMsg2TagResp { + CommonResp commonResp = 1; +} + +message GetTagSendLogsReq { + server_api_params.RequestPagination Pagination = 1; + string userID = 2; + string operationID = 3; +} + +message TagSendLog { + string tagID = 1; + string tagName = 2; + int32 contentType = 3; + string content = 4; + int64 sendTime = 5; + repeated string userList = 6; +} + +message GetTagSendLogsResp { + CommonResp commonResp = 1; + server_api_params.ResponsePagination Pagination = 2; + repeated TagSendLog tagSendLogs = 3; +} + +service OfficeService { + rpc GetUserTags(GetUserTagsReq) returns(GetUserTagsResp); + rpc CreateTag(CreateTagReq) returns(CreateTagResp); + rpc DeleteTag(DeleteTagReq) returns(DeleteTagResp); + rpc SetTag(SetTagReq) returns(SetTagResp); + rpc SendMsg2Tag(SendMsg2TagReq) returns(SendMsg2TagResp); + rpc GetTagSendLogs(GetTagSendLogsReq) returns(GetTagSendLogsResp); +} + diff --git a/pkg/proto/tag/tag.proto b/pkg/proto/tag/tag.proto deleted file mode 100644 index e69de29bb..000000000 diff --git a/script/check_all.sh b/script/check_all.sh index d0f48597b..1d55dff65 100644 --- a/script/check_all.sh +++ b/script/check_all.sh @@ -19,6 +19,7 @@ service_port_name=( openImAdminCmsPort openImMessageCmsPort openImStatisticsPort + openImOfficePort ) switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}') for i in ${service_port_name[*]}; do diff --git a/script/path_info.cfg b/script/path_info.cfg index 88cf33e6a..f9038d11f 100644 --- a/script/path_info.cfg +++ b/script/path_info.cfg @@ -48,6 +48,7 @@ service_source_root=( ../cmd/rpc/open_im_admin_cms/ ../cmd/rpc/open_im_message_cms/ ../cmd/rpc/open_im_statistics/ + ../cmd/rpc/open_im_office/ ${msg_gateway_source_root} ${msg_transfer_source_root} ${msg_source_root} @@ -68,6 +69,7 @@ service_names=( open_im_admin_cms open_im_message_cms open_im_statistics + open_im_office ${msg_gateway_name} ${msg_transfer_name} ${msg_name} diff --git a/script/start_rpc_service.sh b/script/start_rpc_service.sh index bc5f41e3d..b9e3c9f92 100644 --- a/script/start_rpc_service.sh +++ b/script/start_rpc_service.sh @@ -17,6 +17,7 @@ service_filename=( open_im_admin_cms open_im_message_cms open_im_statistics + open_im_office ${msg_name} ) @@ -34,6 +35,7 @@ service_port_name=( openImMessageCmsPort openImStatisticsPort openImOfflineMessagePort + openImOfficePort ) for ((i = 0; i < ${#service_filename[*]}; i++)); do