1
我如何可以結合兩種不同的responseEntity並返回如何結合2 responseEntity和返回?
public ResponseEntity<?> getObject(@PathVariable("shopId") String shopId,
@PathVariable("delearId") String delearId) {
Shop objectToSave = (shopId.equalsIgnoreCase("0")) ? (null) : shopService.findOne(shopId);
Delear objectName = (delearId.equalsIgnoreCase("0")) ? null : delearService.findOne(delearId);
ResponseEntity<?> responseEntity = new ResponseEntity<>(objectName && objectToSave , HttpStatus.OK);// i want to combine both delear and shop
if (objectName == null && objectToSave == null) {
responseEntity = new ResponseEntity<>(objectName,objectToSave , HttpStatus.NOT_FOUND);
}
return responseEntity;
}
將它們組合成一個DTO – Optio