今天在写接口的时候,用postman测试,返回数据与数据库一一对应,但是给前端返回的结果,除了主键id以外,其他都一样,如下
postman:
{
"unitPrice": null,
"shoppingId": 898341460864172032,
"userId": 255,
"leadTime": null,
"buyNumber": 2,
"materialId": 106000001,
"materialCode": "0106000001",
"materialName": "油墨",
"brandId": 456,
"brandCode": "000246",
"brandName": "得力",
"materialPropertyFixed": "7521||40ml||号码机专用",
"unitId": 55,
"unitCode": "dascm055",
"unitName": "瓶",
"packageUnitId": null,
"packageUnitCode": null,
"packageUnitName": null,
"packageNumber": null,
"materialSetId": 10602010001,
"materialSetCode": "010602010001",
"materialSetName": "油墨",
"materialPhoteFile": "/dms/image/010602010001/XL_001.jpg",
"memo": null
}
前端结果:
{
"unitPrice": null,
"shoppingId": 898341460864172000,
"userId": 255,
"leadTime": null,
"buyNumber": 2,
"materialId": 106000001,
"materialCode": "0106000001",
"materialName": "油墨",
"brandId": 456,
"brandCode": "000246",
"brandName": "得力",
"materialPropertyFixed": "7521||40ml||号码机专用",
"unitId": 55,
"unitCode": "dascm055",
"unitName": "瓶",
"packageUnitId": null,
"packageUnitCode": null,
"packageUnitName": null,
"packageNumber": null,
"materialSetId": 10602010001,
"materialSetCode": "010602010001",
"materialSetName": "油墨",
"materialPhoteFile": "/dms/image/010602010001/XL_001.jpg",
"memo": null
}
postman的shoppingId是 898341460864172032,前端的shoppingId是898341460864172000。
解决方案是:
@JsonSerialize(using = ToStringSerializer.class)
private Long shoppingId;
serialize a long as a string: