0

我在 node.js 上使用 GRPCv3

我有一个带有以下消息的 .proto 文件:

message ProductAvailabilityWithRatesResponse {
    // How many slots are available for this day/time. Mandatory.
    int32 capacity = 1;
    // Date for when this product is available. Mandatory.
    Date date = 2;
    // When does this event start? Unset if this product does not support times.
    Time time = 3;
    // When does a pickup for this product start? Unset if this product does not support times or pickups.
    Time pickupTime = 4;
    // Rates with prices. Mandatory (should at least have one entry).
    repeated RateWithPrice rates = 5;
}

在使用 console.log 的服务器上,我看到了这个输出:

{ capacity: 1,
  date: { year: 2019, month: 7, day: 1 },
  rates: [ { rateId: 1, pricePerPerson: [Object] } ],
  time: { hour: 9, minute: 0 } }

在使用 node.js 的客户端上:

{ rates:
   [ { rateId: '1',
       pricePerPerson: [Object],
       pricingOptions: 'pricePerPerson' } ],
  capacity: 0,
  date: { year: 2019, month: 7, day: 1 },
  time: { hour: 9, minute: 0 },
  pickupTime: null }

但是另一个使用 java 客户端的人告诉我他看到了:

2019-06-26 10:59:39,442  ← getProductAvailability::grpc response {date { year: 2019 month: 7 day: 1 } time { hour: 9 } rates { rateId: "1" pricePerPerson { pricingCategoryWithPrice { pricingCategoryId: "30" price { currency: "EUR" amount: "145" } } pricingCategoryWithPrice { pricingCategoryId: "31" price { currency: "EUR" amount: "150" } } } }}

未设置容量的地方。如果它的值是 1 而不是 0,那么一切都很好。可能吗?我如何强制服务器输出值?我已经尝试过使用 capacity = parseInt(capacity)

4

0 回答 0