[
{"id": 1, "city":
{"id":4, "name": Warsaw}
},
{"id": 2, "city":4}
]
为什么RestController
没有回复完整对象而只回复了对象id
中的id:2
?总是存在这样的情况,即同一个对象city
多次出现。
控制器:
@RequestMapping(value = "/resource/company/offer", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE,)
public ResponseEntity<?> getOfferByCompanyId(){
Company company = companyRepository.findByUserId(userService.getUserWithAuthorities().getId());
return Optional.ofNullable(offerRepository.findByCompany(company)).map(offers -> new ResponseEntity<>(offers.,HttpStatus.OK)).orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}
的Json
[
{
"id":3,
"description":"XYZ",
"experience":1,
"title":"XYZ",
"industry":{
"id":1,
"name":"IT"
},
"contractType":{
"id":1,
"name":"HHH"
},
"city":{
"id":1,
"name":"Warsaw",
"region":{
"id":1,
"name":"Mazovia"
}
},
"company":{
"id":1,
"name":"XYZ",
"description":"XYZ",
"avatar":"/user_images/70296679268537082326.png",
"phone_number":"123456789",
"post_code":"22-111",
"address":"sda 2/13",
"nip_number":"123456789",
"www_address":"www.google.com",
"city":1
},
"education":{
"id":1,
"name":"QWE"
},
"competences":[
{
"id":2,
"name":"QWE"
}
],
"jobPositions":[
{
"id":1,
"name":"Programmer"
}
]
},
{
"id":4,
"description":"XYZ",
"experience":2,
"title":"XYZ",
"industry":1,
"contractType":1,
"city":1,
"company":1,
"education":{
"id":2,
"name":"ZWE"
},
"competences":[
{
"id":1,
"name":"TYU"
}
],
"jobPositions":[
1
]
}
]