parent
38542f9888
commit
b6944c4308
@ -1,194 +1,192 @@
|
||||
package conversation
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsSetReceiveMessageOpt struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Option *int32 `json:"option" binding:"required"`
|
||||
ConversationIdList []string `json:"conversationIdList" binding:"required"`
|
||||
}
|
||||
|
||||
type OptResult struct {
|
||||
ConversationId string `json:"conversationId" binding:"required"`
|
||||
Result int32 `json:"result" binding:"required"`
|
||||
}
|
||||
|
||||
type SetReceiveMessageOptResp struct {
|
||||
ErrCode int32 `json:"errCode"`
|
||||
ErrMsg string `json:"errMsg"`
|
||||
Data []OptResult `json:"data"`
|
||||
}
|
||||
|
||||
type paramGetReceiveMessageOpt struct {
|
||||
ConversationIdList []string `json:"conversationIdList" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type GetReceiveMessageOptResp struct {
|
||||
SetReceiveMessageOptResp
|
||||
}
|
||||
|
||||
type paramGetAllConversationMessageOpt struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type GetAllConversationMessageOptResp struct {
|
||||
SetReceiveMessageOptResp
|
||||
}
|
||||
|
||||
//CopyStructFields
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
//
|
||||
//type paramsSetReceiveMessageOpt struct {
|
||||
// OperationID string `json:"operationID" binding:"required"`
|
||||
// Option *int32 `json:"option" binding:"required"`
|
||||
// ConversationIdList []string `json:"conversationIdList" binding:"required"`
|
||||
//}
|
||||
//
|
||||
//type OptResult struct {
|
||||
// ConversationId string `json:"conversationId" binding:"required"`
|
||||
// Result int32 `json:"result" binding:"required"`
|
||||
//}
|
||||
//
|
||||
//type SetReceiveMessageOptResp struct {
|
||||
// ErrCode int32 `json:"errCode"`
|
||||
// ErrMsg string `json:"errMsg"`
|
||||
// Data []OptResult `json:"data"`
|
||||
//}
|
||||
//
|
||||
//type paramGetReceiveMessageOpt struct {
|
||||
// ConversationIdList []string `json:"conversationIdList" binding:"required"`
|
||||
// OperationID string `json:"operationID" binding:"required"`
|
||||
//}
|
||||
//
|
||||
//type GetReceiveMessageOptResp struct {
|
||||
// SetReceiveMessageOptResp
|
||||
//}
|
||||
//
|
||||
//type paramGetAllConversationMessageOpt struct {
|
||||
// OperationID string `json:"operationID" binding:"required"`
|
||||
//}
|
||||
//
|
||||
//type GetAllConversationMessageOptResp struct {
|
||||
// SetReceiveMessageOptResp
|
||||
//}
|
||||
//
|
||||
////CopyStructFields
|
||||
|
||||
func GetAllConversationMessageOpt(c *gin.Context) {
|
||||
params := paramGetAllConversationMessageOpt{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req := &user.GetAllConversationMsgOptReq{
|
||||
UId: claims.UID,
|
||||
OperationID: params.OperationID,
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetAllConversationMsgOpt req: ", req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := user.NewUserClient(etcdConn)
|
||||
resp, err := client.GetAllConversationMsgOpt(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "GetAllConversationMsgOpt rpc failed, ", req, err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
var ginResp GetAllConversationMessageOptResp
|
||||
ginResp.ErrCode = resp.ErrCode
|
||||
ginResp.ErrMsg = resp.ErrMsg
|
||||
for _, v := range resp.ConversationOptResult {
|
||||
var opt OptResult
|
||||
err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
|
||||
continue
|
||||
}
|
||||
ginResp.Data = append(ginResp.Data, opt)
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetAllConversationMsgOpt resp: ", ginResp, req)
|
||||
c.JSON(http.StatusOK, ginResp)
|
||||
}
|
||||
|
||||
func GetReceiveMessageOpt(c *gin.Context) {
|
||||
params := paramGetReceiveMessageOpt{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req := &user.GetReceiveMessageOptReq{
|
||||
UId: claims.UID,
|
||||
ConversationId: params.ConversationIdList,
|
||||
OperationID: params.OperationID,
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetReceiveMessageOptReq req: ", req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := user.NewUserClient(etcdConn)
|
||||
resp, err := client.GetReceiveMessageOpt(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "GetReceiveMessageOpt rpc failed, ", req, err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "GetReceiveMessageOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetReceiveMessageOptReq req: ", req, resp)
|
||||
var ginResp GetReceiveMessageOptResp
|
||||
ginResp.ErrCode = resp.ErrCode
|
||||
ginResp.ErrMsg = resp.ErrMsg
|
||||
|
||||
for _, v := range resp.ConversationOptResult {
|
||||
var opt OptResult
|
||||
log.NewInfo("CopyStructFields begin ", v, req.OperationID)
|
||||
err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
|
||||
log.NewInfo("CopyStructFields end ", v, req.OperationID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
|
||||
continue
|
||||
}
|
||||
ginResp.Data = append(ginResp.Data, opt)
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetReceiveMessageOpt resp: ", ginResp)
|
||||
c.JSON(http.StatusOK, ginResp)
|
||||
}
|
||||
|
||||
//func GetAllConversationMessageOpt(c *gin.Context) {
|
||||
// params := paramGetAllConversationMessageOpt{}
|
||||
// if err := c.BindJSON(¶ms); err != nil {
|
||||
// log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
|
||||
// if err != nil {
|
||||
// log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// req := &user.GetAllConversationMsgOptReq{
|
||||
// UId: claims.UID,
|
||||
// OperationID: params.OperationID,
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, "GetAllConversationMsgOpt req: ", req)
|
||||
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
// client := user.NewUserClient(etcdConn)
|
||||
// resp, err := client.GetAllConversationMsgOpt(context.Background(), req)
|
||||
// if err != nil {
|
||||
// log.NewError(params.OperationID, "GetAllConversationMsgOpt rpc failed, ", req, err.Error())
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
// return
|
||||
// }
|
||||
// var ginResp GetAllConversationMessageOptResp
|
||||
// ginResp.ErrCode = resp.ErrCode
|
||||
// ginResp.ErrMsg = resp.ErrMsg
|
||||
// for _, v := range resp.ConversationOptResult {
|
||||
// var opt OptResult
|
||||
// err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
|
||||
// if err != nil {
|
||||
// log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
|
||||
// continue
|
||||
// }
|
||||
// ginResp.Data = append(ginResp.Data, opt)
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, "GetAllConversationMsgOpt resp: ", ginResp, req)
|
||||
// c.JSON(http.StatusOK, ginResp)
|
||||
//}
|
||||
//
|
||||
//func GetReceiveMessageOpt(c *gin.Context) {
|
||||
// params := paramGetReceiveMessageOpt{}
|
||||
// if err := c.BindJSON(¶ms); err != nil {
|
||||
// log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
|
||||
// if err != nil {
|
||||
// log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// req := &user.GetReceiveMessageOptReq{
|
||||
// UId: claims.UID,
|
||||
// ConversationId: params.ConversationIdList,
|
||||
// OperationID: params.OperationID,
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, "GetReceiveMessageOptReq req: ", req)
|
||||
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
// client := user.NewUserClient(etcdConn)
|
||||
// resp, err := client.GetReceiveMessageOpt(context.Background(), req)
|
||||
// if err != nil {
|
||||
// log.NewError(params.OperationID, "GetReceiveMessageOpt rpc failed, ", req, err.Error())
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "GetReceiveMessageOpt rpc failed, " + err.Error()})
|
||||
// return
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, "GetReceiveMessageOptReq req: ", req, resp)
|
||||
// var ginResp GetReceiveMessageOptResp
|
||||
// ginResp.ErrCode = resp.ErrCode
|
||||
// ginResp.ErrMsg = resp.ErrMsg
|
||||
//
|
||||
// for _, v := range resp.ConversationOptResult {
|
||||
// var opt OptResult
|
||||
// log.NewInfo("CopyStructFields begin ", v, req.OperationID)
|
||||
// err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
|
||||
// log.NewInfo("CopyStructFields end ", v, req.OperationID)
|
||||
// if err != nil {
|
||||
// log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
|
||||
// continue
|
||||
// }
|
||||
// ginResp.Data = append(ginResp.Data, opt)
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, "GetReceiveMessageOpt resp: ", ginResp)
|
||||
// c.JSON(http.StatusOK, ginResp)
|
||||
//}
|
||||
//
|
||||
func SetReceiveMessageOpt(c *gin.Context) {
|
||||
params := paramsSetReceiveMessageOpt{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req := &user.SetReceiveMessageOptReq{
|
||||
UId: claims.UID,
|
||||
Opt: *params.Option,
|
||||
ConversationId: params.ConversationIdList,
|
||||
OperationID: params.OperationID,
|
||||
}
|
||||
log.NewInfo(req.OperationID, "SetReceiveMessageOpt req: ", req)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := user.NewUserClient(etcdConn)
|
||||
resp, err := client.SetReceiveMessageOpt(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "SetReceiveMessageOpt rpc failed, ", req, err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "SetReceiveMessageOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "SetReceiveMessageOpt req: ", req, resp)
|
||||
ginResp := SetReceiveMessageOptResp{
|
||||
ErrCode: resp.ErrCode,
|
||||
ErrMsg: resp.ErrMsg,
|
||||
}
|
||||
|
||||
for _, v := range resp.OptResult {
|
||||
var opt OptResult
|
||||
log.NewDebug("CopyStructFields begin ", v, req.OperationID)
|
||||
err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
|
||||
log.NewDebug("CopyStructFields end ", v, req.OperationID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
|
||||
continue
|
||||
}
|
||||
ginResp.Data = append(ginResp.Data, opt)
|
||||
}
|
||||
log.NewInfo(req.OperationID, "SetReceiveMessageOpt resp: ", ginResp)
|
||||
c.JSON(http.StatusOK, ginResp)
|
||||
}
|
||||
|
||||
//func SetReceiveMessageOpt(c *gin.Context) {
|
||||
// params := paramsSetReceiveMessageOpt{}
|
||||
// if err := c.BindJSON(¶ms); err != nil {
|
||||
// log.NewError(params.OperationID, "bind json failed ", err.Error(), c)
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// claims, err := token_verify.ParseToken(c.Request.Header.Get("token"))
|
||||
// if err != nil {
|
||||
// log.NewError(params.OperationID, "ParseToken failed, ", err.Error(), c.Request.Header.Get("token"))
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "ParseToken failed, " + err.Error()})
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// req := &user.SetReceiveMessageOptReq{
|
||||
// UId: claims.UID,
|
||||
// Opt: *params.Option,
|
||||
// ConversationId: params.ConversationIdList,
|
||||
// OperationID: params.OperationID,
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, "SetReceiveMessageOpt req: ", req)
|
||||
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
// client := user.NewUserClient(etcdConn)
|
||||
// resp, err := client.SetReceiveMessageOpt(context.Background(), req)
|
||||
// if err != nil {
|
||||
// log.NewError(params.OperationID, "SetReceiveMessageOpt rpc failed, ", req, err.Error())
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "SetReceiveMessageOpt rpc failed, " + err.Error()})
|
||||
// return
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, "SetReceiveMessageOpt req: ", req, resp)
|
||||
// ginResp := SetReceiveMessageOptResp{
|
||||
// ErrCode: resp.ErrCode,
|
||||
// ErrMsg: resp.ErrMsg,
|
||||
// }
|
||||
//
|
||||
// for _, v := range resp.OptResult {
|
||||
// var opt OptResult
|
||||
// log.NewDebug("CopyStructFields begin ", v, req.OperationID)
|
||||
// err := utils.CopyStructFields(&opt, *v, "ConversationId", "Result")
|
||||
// log.NewDebug("CopyStructFields end ", v, req.OperationID)
|
||||
// if err != nil {
|
||||
// log.NewError(req.OperationID, "CopyStructFields failed ", err.Error())
|
||||
// continue
|
||||
// }
|
||||
// ginResp.Data = append(ginResp.Data, opt)
|
||||
// }
|
||||
// log.NewInfo(req.OperationID, "SetReceiveMessageOpt resp: ", ginResp)
|
||||
// c.JSON(http.StatusOK, ginResp)
|
||||
//}
|
||||
|
@ -0,0 +1 @@
|
||||
package base_info
|
@ -0,0 +1,98 @@
|
||||
package base_info
|
||||
|
||||
import open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
|
||||
type paramsManagementSendMsg struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
RecvID string `json:"recvID" `
|
||||
GroupID string `json:"groupID" `
|
||||
SenderNickName string `json:"senderNickName" `
|
||||
SenderFaceURL string `json:"senderFaceURL" `
|
||||
SenderPlatformID int32 `json:"senderPlatformID"`
|
||||
ForceList []string `json:"forceList" `
|
||||
Content map[string]interface{} `json:"content" binding:"required"`
|
||||
ContentType int32 `json:"contentType" binding:"required"`
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||
OfflinePushInfo *open_im_sdk.OfflinePushInfo `json:"offlinePushInfo"`
|
||||
}
|
||||
|
||||
type PictureBaseInfo struct {
|
||||
UUID string `mapstructure:"uuid"`
|
||||
Type string `mapstructure:"type" validate:"required"`
|
||||
Size int64 `mapstructure:"size" validate:"required"`
|
||||
Width int32 `mapstructure:"width" validate:"required"`
|
||||
Height int32 `mapstructure:"height" validate:"required"`
|
||||
Url string `mapstructure:"url" validate:"required"`
|
||||
}
|
||||
|
||||
type PictureElem struct {
|
||||
SourcePath string `mapstructure:"sourcePath"`
|
||||
SourcePicture PictureBaseInfo `mapstructure:"sourcePicture" validate:"required"`
|
||||
BigPicture PictureBaseInfo `mapstructure:"bigPicture" `
|
||||
SnapshotPicture PictureBaseInfo `mapstructure:"snapshotPicture"`
|
||||
}
|
||||
type SoundElem struct {
|
||||
UUID string `mapstructure:"uuid"`
|
||||
SoundPath string `mapstructure:"soundPath"`
|
||||
SourceURL string `mapstructure:"sourceUrl"`
|
||||
DataSize int64 `mapstructure:"dataSize"`
|
||||
Duration int64 `mapstructure:"duration"`
|
||||
}
|
||||
type VideoElem struct {
|
||||
VideoPath string `mapstructure:"videoPath"`
|
||||
VideoUUID string `mapstructure:"videoUUID"`
|
||||
VideoURL string `mapstructure:"videoUrl"`
|
||||
VideoType string `mapstructure:"videoType"`
|
||||
VideoSize int64 `mapstructure:"videoSize"`
|
||||
Duration int64 `mapstructure:"duration"`
|
||||
SnapshotPath string `mapstructure:"snapshotPath"`
|
||||
SnapshotUUID string `mapstructure:"snapshotUUID"`
|
||||
SnapshotSize int64 `mapstructure:"snapshotSize"`
|
||||
SnapshotURL string `mapstructure:"snapshotUrl"`
|
||||
SnapshotWidth int32 `mapstructure:"snapshotWidth"`
|
||||
SnapshotHeight int32 `mapstructure:"snapshotHeight"`
|
||||
}
|
||||
type FileElem struct {
|
||||
FilePath string `mapstructure:"filePath"`
|
||||
UUID string `mapstructure:"uuid"`
|
||||
SourceURL string `mapstructure:"sourceUrl"`
|
||||
FileName string `mapstructure:"fileName"`
|
||||
FileSize int64 `mapstructure:"fileSize"`
|
||||
}
|
||||
|
||||
type paramsDeleteUsers struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
DeleteUidList []string `json:"deleteUidList" binding:"required"`
|
||||
}
|
||||
type paramsGetAllUsersUid struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
type paramsGetUsersOnlineStatus struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UserIDList []string `json:"userIDList" binding:"required,lte=200"`
|
||||
}
|
||||
type paramsAccountCheck struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UserIDList []string `json:"userIDList" binding:"required,lte=100"`
|
||||
}
|
||||
|
||||
type AtElem struct {
|
||||
Text string `mapstructure:"text"`
|
||||
AtUserList []string `mapstructure:"atUserList"`
|
||||
IsAtSelf bool `mapstructure:"isAtSelf"`
|
||||
}
|
||||
type LocationElem struct {
|
||||
Description string `mapstructure:"description"`
|
||||
Longitude float64 `mapstructure:"longitude"`
|
||||
Latitude float64 `mapstructure:"latitude"`
|
||||
}
|
||||
type CustomElem struct {
|
||||
Data string `mapstructure:"data" validate:"required"`
|
||||
Description string `mapstructure:"description"`
|
||||
Extension string `mapstructure:"extension"`
|
||||
}
|
||||
type TextElem struct {
|
||||
Text string `mapstructure:"text" validate:"required"`
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func OperationIDGenerator() string {
|
||||
return strconv.FormatInt(time.Now().UnixNano()+int64(rand.Uint32()), 10)
|
||||
}
|
||||
|
||||
func FriendOpenIMCopyDB(dst *imdb.Friend, src open_im_sdk.FriendInfo) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
dst.FriendUserID = src.FriendUser.UserID
|
||||
}
|
||||
|
||||
func FriendDBCopyOpenIM(dst *open_im_sdk.FriendInfo, src imdb.Friend) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
user, _ := imdb.GetUserByUserID(src.FriendUserID)
|
||||
if user != nil {
|
||||
utils.CopyStructFields(dst.FriendUser, user)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
func FriendRequestOpenIMCopyDB(dst *imdb.FriendRequest, src open_im_sdk.FriendRequest) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
}
|
||||
|
||||
func FriendRequestDBCopyOpenIM(dst *open_im_sdk.FriendRequest, src imdb.FriendRequest) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
}
|
||||
|
||||
func GroupOpenIMCopyDB(dst *imdb.Group, src open_im_sdk.GroupInfo) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
}
|
||||
|
||||
func GroupDBCopyOpenIM(dst *open_im_sdk.GroupInfo, src imdb.Group) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
user, _ := imdb.GetGroupOwnerInfoByGroupID(src.GroupID)
|
||||
if user != nil {
|
||||
dst.OwnerUserID = user.UserID
|
||||
}
|
||||
dst.MemberCount = imdb.GetGroupMemberNumByGroupID(src.GroupID)
|
||||
}
|
||||
|
||||
func GroupMemberOpenIMCopyDB(dst *imdb.GroupMember, src open_im_sdk.GroupMemberFullInfo) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
}
|
||||
|
||||
func GroupMemberDBCopyOpenIM(dst *open_im_sdk.GroupMemberFullInfo, src imdb.GroupMember) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
if token_verify.IsMangerUserID(src.UserID) {
|
||||
u, _ := imdb.GetUserByUserID(src.UserID)
|
||||
if u != nil {
|
||||
utils.CopyStructFields(dst, u)
|
||||
}
|
||||
dst.AppMangerLevel = 1
|
||||
}
|
||||
}
|
||||
|
||||
func GroupRequestOpenIMCopyDB(dst *imdb.GroupRequest, src open_im_sdk.GroupRequest) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
}
|
||||
|
||||
func GroupRequestDBCopyOpenIM(dst *open_im_sdk.GroupRequest, src imdb.GroupRequest) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
}
|
||||
|
||||
func UserOpenIMCopyDB(dst *imdb.User, src open_im_sdk.UserInfo) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
}
|
||||
|
||||
func UserDBCopyOpenIM(dst *open_im_sdk.UserInfo, src imdb.User) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
}
|
||||
|
||||
func BlackOpenIMCopyDB(dst *imdb.Black, src open_im_sdk.BlackInfo) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
dst.BlockUserID = src.BlackUserInfo.UserID
|
||||
}
|
||||
|
||||
func BlackDBCopyOpenIM(dst *open_im_sdk.BlackInfo, src imdb.Black) {
|
||||
utils.CopyStructFields(dst, src)
|
||||
dst.CreateTime = src.CreateTime.Unix()
|
||||
user, _ := imdb.GetUserByUserID(src.BlockUserID)
|
||||
if user != nil {
|
||||
utils.CopyStructFields(dst.BlackUserInfo, user)
|
||||
}
|
||||
}
|
Loading…
Reference in new issue