zhou.xiaoning 3 лет назад
Родитель
Сommit
39995b269c
3 измененных файлов с 331 добавлено и 15 удалено
  1. 14 14
      global/topic.go
  2. 313 1
      model/mq/request/mq.go
  3. 4 0
      service/mq/mq.go

+ 14 - 14
global/topic.go

@@ -1,24 +1,24 @@
 package global
 
 var (
-	TOPIC_REQ_QKERNEL string = "query_req" // 查询相关请求
-	TOPIC_RSP_QKERNEL string = "query_rsp" // 查询相关回应
+	TOPIC_REQ_QKERNEL = "query_req" // 查询相关请求
+	TOPIC_RSP_QKERNEL = "query_rsp" // 查询相关回应
 
-	TOPIC_MANAGE_REQ string = "manage_req" // 管理服务请求
-	TOPIC_MANAGE_RSP string = "manage_rsp" // 管理服务响应
+	TOPIC_MANAGE_REQ = "manage_req" // 管理服务请求
+	TOPIC_MANAGE_RSP = "manage_rsp" // 管理服务响应
 
-	TOPIC_REQ_BANK string = "bank_req" // 银行请求
-	TOPIC_RSP_BANK string = "bank_rsp" // 银行回应
+	TOPIC_REQ_BANK = "bank_req" // 银行请求
+	TOPIC_RSP_BANK = "bank_rsp" // 银行回应
 
-	TOPIC_PERFORMANCE_REQ string = "performance_req" // 履约请求
-	TOPIC_PERFORMANCE_RSP string = "performance_rsp" // 履约回应
+	TOPIC_PERFORMANCE_REQ = "performance_req" // 履约请求
+	TOPIC_PERFORMANCE_RSP = "performance_rsp" // 履约回应
 
-	TOPIC_WAREHOUSE_RECIEPT     string = "warehouse_reciept"     // 仓单服务消息主题
-	TOPIC_WAREHOUSE_RECIEPT_RSP string = "warehouse_reciept_rsp" // 仓单服务消息主题
+	TOPIC_WAREHOUSE_RECIEPT     = "warehouse_reciept"     // 仓单服务消息主题
+	TOPIC_WAREHOUSE_RECIEPT_RSP = "warehouse_reciept_rsp" // 仓单服务消息主题
 
-	TOPIC_REQ_WAREHOUSE_TRADE string = "warehouse_trade_req" // 仓单贸易请求
-	TOPIC_RSP_WAREHOUSE_TRADE string = "warehouse_trade_rsp" // 仓单贸易响应
+	TOPIC_REQ_WAREHOUSE_TRADE = "warehouse_trade_req" // 仓单贸易请求
+	TOPIC_RSP_WAREHOUSE_TRADE = "warehouse_trade_rsp" // 仓单贸易响应
 
-	TOPIC_REQ_WAREHOUSE_TRADE_GZ string = "warehouse_trade_gz_req" // 广钻仓单贸易请求
-	TOPIC_RSP_WAREHOUSE_TRADE_GZ string = "warehouse_trade_gz_rsp" // 广钻仓单贸易响应
+	TOPIC_REQ_WAREHOUSE_TRADE_GZ = "warehouse_trade_gz_req" // 广钻仓单贸易请求
+	TOPIC_RSP_WAREHOUSE_TRADE_GZ = "warehouse_trade_gz_rsp" // 广钻仓单贸易响应
 )

+ 313 - 1
model/mq/request/mq.go

@@ -44,7 +44,228 @@ func (r *MQBodyReq) GetProtoBytes(serialNumber *uint32) (bytes *[]byte, err erro
 
 	// JSON -> Protobuf
 	switch int(r.FunCodeReq) {
-	case global.ZSSellOrderListingReq: // 钻石卖挂牌接口请求
+	case global.ModifyPwdReq:
+		m := pb.ModifyPwdReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.UserReceiveInfoReq:
+		m := pb.UserReceiveInfoReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.DelUserReceiveInfoReq:
+		m := pb.DelUserReceiveInfoReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.UserReceiveIsDefaultReq:
+		m := pb.UserReceiveIsDefaultReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.UserReceiptInfoReq:
+		m := pb.UserReceiptInfoReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.DelUserReceiptInfoReq:
+		m := pb.DelUserReceiptInfoReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.T2bBankSignReq:
+		m := pb.T2BBankSignReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.T2bBankCancelSignReq:
+		m := pb.T2BBankCancelSignReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.T2bBankWithdrawReq:
+		m := pb.T2BBankWithdrawReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.T2bBankDepositReq:
+		m := pb.T2BBankDepositReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.WarehouseApplyReq:
+		m := pb.WarehouseApplyReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.PerformanceContractedApplyReq:
+		m := pb.PerformanceContractedApplyReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.PerformanceDelayApplyReq:
+		m := pb.PerformanceDelayApplyReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.PerformanceManualConfirmReq:
+		m := pb.PerformanceManualConfirmReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.PerformanceModifyContactReq:
+		m := pb.PerformanceModifyContactReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.GoodsFavoriteOperateReq:
+		m := pb.GoodsFavoriteOperateReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.ZSBuyOrderListingReq:
+		m := pb.ZSBuyOrderListingReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.ZSSellOrderListingReq:
 		m := pb.ZSSellOrderListingReq{}
 		if err = r.reflect(data, &m); err != nil {
 			return
@@ -57,6 +278,97 @@ func (r *MQBodyReq) GetProtoBytes(serialNumber *uint32) (bytes *[]byte, err erro
 		} else {
 			bytes = &b
 		}
+	case global.ZSBuyOrderDestingReq:
+		m := pb.ZSBuyOrderDestingReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.ZSSellOrderDestingApplyReq:
+		m := pb.ZSSellOrderDestingApplyReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.ZSSellOrderDestingApplyOperateReq:
+		m := pb.ZSSellOrderDestingApplyOperateReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.ZSBuyOrderDestingNegPriceReq:
+		m := pb.ZSBuyOrderDestingNegPriceReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.ZSBuyOrderDestingNegPriceOperateReq:
+		m := pb.ZSBuyOrderDestingNegPriceOperateReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.WRListingCancelOrderReq:
+		m := pb.WRListingCancelOrderReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
+	case global.ReceiptZSOutApplyReq:
+		m := pb.ReceiptZSOutApplyReq{}
+		if err = r.reflect(data, &m); err != nil {
+			return
+		}
+		m.Header.RequestID = serialNumber
+		if b, e := proto.Marshal(&m); e != nil {
+			global.M2A_LOG.Error(e.Error(), zap.Error(e))
+			err = errors.New("请求信息序列化失败")
+			return
+		} else {
+			bytes = &b
+		}
 	}
 
 	return

+ 4 - 0
service/mq/mq.go

@@ -39,6 +39,10 @@ func SendMQ(c *gin.Context, req *request.MQBodyReq) (err error) {
 	if err != nil {
 		return
 	}
+	if bytes == nil {
+		err = errors.New("请求信息序列化失败")
+		return
+	}
 
 	// 创建异步任务
 	key := fmt.Sprintf("%v_%v_%v", client.SessionID, req.FunCodeRsp, serialNumber)