pull/218/head
wangchuxiao 3 years ago
parent e252a00d55
commit dc1a0f050e

@ -72,6 +72,7 @@ endpoints:
rpc_statistic: openim_rpc_statistic rpc_statistic: openim_rpc_statistic
rpc_admin_cms: openim_rpc_admin_cms rpc_admin_cms: openim_rpc_admin_cms
rpc_message_cms: openim_rpc_admin_cms rpc_message_cms: openim_rpc_admin_cms
rpc_office: openim_rpc_office
api: api:
openImApiPort: [ 10000 ] #api服务端口默认即可需要开放此端口或做nginx转发 openImApiPort: [ 10000 ] #api服务端口默认即可需要开放此端口或做nginx转发
@ -106,6 +107,7 @@ rpcport: #rpc服务端口 默认即可
openImStatisticsPort: [ 10800 ] openImStatisticsPort: [ 10800 ]
openImMessageCmsPort: [ 10900 ] openImMessageCmsPort: [ 10900 ]
openImAdminCmsPort: [ 11000 ] openImAdminCmsPort: [ 11000 ]
openImOfficePort: [ 11100 ]
c2c: c2c:
callbackBeforeSendMsg: callbackBeforeSendMsg:
switch: false switch: false
@ -127,6 +129,7 @@ rpcregistername: #rpc注册服务名默认即可
OpenImStatisticsName: Statistics OpenImStatisticsName: Statistics
OpenImMessageCMSName: MessageCMS OpenImMessageCMSName: MessageCMS
openImAdminCMSName: AdminCMS openImAdminCMSName: AdminCMS
openImOfficeName: Office
log: log:
storageLocation: ../logs/ storageLocation: ../logs/

@ -4,8 +4,10 @@ import (
apistruct "Open_IM/pkg/base_info" apistruct "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/grpc-etcdv3/getcdv3"
pbOffice "Open_IM/pkg/proto/office" pbOffice "Open_IM/pkg/proto/office"
pbCommon "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -25,9 +27,14 @@ func GetUserTags(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()}) c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return return
} }
if err := utils.CopyStructFields(&reqPb, req); err != nil { ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
} }
reqPb.UserID = userID
reqPb.OperationID = req.OperationID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn) client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.GetUserTags(context.Background(), &reqPb) respPb, err := client.GetUserTags(context.Background(), &reqPb)
@ -58,6 +65,13 @@ func CreateTag(c *gin.Context) {
if err := utils.CopyStructFields(&reqPb, req); err != nil { if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
} }
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.UserID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn) client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.CreateTag(context.Background(), &reqPb) respPb, err := client.CreateTag(context.Background(), &reqPb)
@ -87,6 +101,13 @@ func DeleteTag(c *gin.Context) {
if err := utils.CopyStructFields(&reqPb, req); err != nil { if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
} }
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.UserID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn) client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.DeleteTag(context.Background(), &reqPb) respPb, err := client.DeleteTag(context.Background(), &reqPb)
@ -116,6 +137,13 @@ func SetTag(c *gin.Context) {
if err := utils.CopyStructFields(&reqPb, req); err != nil { if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
} }
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.UserID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn) client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.SetTag(context.Background(), &reqPb) respPb, err := client.SetTag(context.Background(), &reqPb)
@ -145,6 +173,13 @@ func SendMsg2Tag(c *gin.Context) {
if err := utils.CopyStructFields(&reqPb, req); err != nil { if err := utils.CopyStructFields(&reqPb, req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
} }
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.SendID = userID
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn) client := pbOffice.NewOfficeServiceClient(etcdConn)
respPb, err := client.SendMsg2Tag(context.Background(), &reqPb) respPb, err := client.SendMsg2Tag(context.Background(), &reqPb)
@ -171,8 +206,17 @@ func GetTagSendLogs(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()}) c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
return return
} }
if err := utils.CopyStructFields(&reqPb, req); err != nil { ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) if !ok {
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return
}
reqPb.UserID = userID
reqPb.OperationID = req.OperationID
reqPb.Pagination = &pbCommon.RequestPagination{
PageNumber: req.PageNumber,
ShowNumber: req.ShowNumber,
} }
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
client := pbOffice.NewOfficeServiceClient(etcdConn) client := pbOffice.NewOfficeServiceClient(etcdConn)

@ -2,11 +2,10 @@ package base_info
import ( import (
pbOffice "Open_IM/pkg/proto/office" pbOffice "Open_IM/pkg/proto/office"
server_api_params "Open_IM/pkg/proto/sdk_ws"
) )
type GetUserTagsReq struct { type GetUserTagsReq struct {
pbOffice.GetUserTagsReq OperationID string `json:"operationID"`
} }
type GetUserTagsResp struct { type GetUserTagsResp struct {
@ -17,7 +16,9 @@ type GetUserTagsResp struct {
} }
type CreateTagReq struct { type CreateTagReq struct {
pbOffice.CreateTagReq TagName string `json:"tagName" binding:"required"`
UserIDList []string `json:"userIDList" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
} }
type CreateTagResp struct { type CreateTagResp struct {
@ -25,7 +26,8 @@ type CreateTagResp struct {
} }
type DeleteTagReq struct { type DeleteTagReq struct {
pbOffice.DeleteTagReq TagID string `json:"tagID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
} }
type DeleteTagResp struct { type DeleteTagResp struct {
@ -33,7 +35,11 @@ type DeleteTagResp struct {
} }
type SetTagReq struct { type SetTagReq struct {
pbOffice.SetTagReq TagID string `json:"tagID" binding:"required"`
NewName string `json:"newName" binding:"required"`
IncreaseUserIDList []string `json:"increaseUserIDList" binding:"required"`
ReduceUserIDList []string `json:"reduceUserIDList" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
} }
type SetTagResp struct { type SetTagResp struct {
@ -41,7 +47,11 @@ type SetTagResp struct {
} }
type SendMsg2TagReq struct { type SendMsg2TagReq struct {
pbOffice.SendMsg2TagReq TagID string `json:"tagID" binding:"required"`
SenderPlatformID int32 `json:"senderPlatformID" binding:"required"`
Content string `json:"content" binding:"required"`
ContentType int32 `json:"contentType" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
} }
type SendMsg2TagResp struct { type SendMsg2TagResp struct {
@ -49,9 +59,9 @@ type SendMsg2TagResp struct {
} }
type GetTagSendLogsReq struct { type GetTagSendLogsReq struct {
server_api_params.RequestPagination PageNumber int32 `json:"pageNumber" binding:"required"`
UserID string `json:"userID"` ShowNumber int32 `json:"showNumber" binding:"required"`
OperationID string `json:"operationID"` OperationID string `json:"operationID" binding:"required"`
} }
type GetTagSendLogsResp struct { type GetTagSendLogsResp struct {

Loading…
Cancel
Save