Ver código fonte

feat: 入参类型转换

zhangxinlei1996 2 anos atrás
pai
commit
2f6461f7f3

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

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

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

@@ -31,20 +31,20 @@ type UserReq struct {
 }
 
 type MessageEntity struct {
-	OwnType     int64   `json:"ownType"`
-	Title       string  `json:"title"`
-	Content     string  `json:"content"`
-	Item        int64   `json:"item"`
-	Type        int64   `json:"type"`
-	Link        string  `json:"link"`
-	Appid       string  `header:"appId"`
-	ItemType    int64   `json:"itemType"`
-	SendId      string  `json:"sendId,optional"`
-	EntUserId   int64   `header:"entUserId,optional"`
-	NewUserId   int64   `header:"newUserId"`
-	ReceiveId   string  `json:"receiveId,optional"`
-	ReceiverIds []int64 `json:"receiverIds,optional"` //个人[可多个]
-	GroupIds    []int64 `json:"groupIds,optional"`    //群聊[可多个]
+	OwnType     int64    `json:"ownType"`
+	Title       string   `json:"title"`
+	Content     string   `json:"content"`
+	Item        int64    `json:"item"`
+	Type        int64    `json:"type"`
+	Link        string   `json:"link"`
+	Appid       string   `header:"appId"`
+	ItemType    int64    `json:"itemType"`
+	SendId      string   `json:"sendId,optional"`
+	EntUserId   int64    `header:"entUserId,optional"`
+	NewUserId   int64    `header:"newUserId"`
+	ReceiveId   string   `json:"receiveId,optional"`
+	ReceiverIds []string `json:"receiverIds,optional"` //个人[可多个]
+	GroupIds    []string `json:"groupIds,optional"`    //群聊[可多个]
 }
 
 type MessageReq struct {

+ 14 - 14
api/messagecenter/messagecenter.api

@@ -27,20 +27,20 @@ type UserReq {
 	NameSearch   string `json:"nameSearch,optional"`
 }
 type MessageEntity {
-	OwnType     int64   `json:"ownType"`
-	Title       string  `json:"title"`
-	Content     string  `json:"content"`
-	Item        int64   `json:"item"`
-	Type        int64   `json:"type"`
-	Link        string  `json:"link"`
-	Appid       string  `header:"appId"`
-	ItemType    int64   `json:"itemType"`
-	SendId      string  `json:"sendId,optional"`
-	EntUserId   int64   `header:"entUserId,optional"`
-	NewUserId   int64   `header:"newUserId"`
-	ReceiveId   string  `json:"receiveId,optional"`
-	ReceiverIds []int64 `json:"receiverIds,optional"` //个人[可多个]
-	GroupIds    []int64 `json:"groupIds,optional"`    //群聊[可多个]
+	OwnType     int64    `json:"ownType"`
+	Title       string   `json:"title"`
+	Content     string   `json:"content"`
+	Item        int64    `json:"item"`
+	Type        int64    `json:"type"`
+	Link        string   `json:"link"`
+	Appid       string   `header:"appId"`
+	ItemType    int64    `json:"itemType"`
+	SendId      string   `json:"sendId,optional"`
+	EntUserId   int64    `header:"entUserId,optional"`
+	NewUserId   int64    `header:"newUserId"`
+	ReceiveId   string   `json:"receiveId,optional"`
+	ReceiverIds []string `json:"receiverIds,optional"` //个人[可多个]
+	GroupIds    []string `json:"groupIds,optional"`    //群聊[可多个]
 }
 type MessageReq {
 	MsgType     int64  `json:"msgType"`