Good day, I am currently developing an api rest with Spring Boot :: (v1.5.9.RELEASE) to control the handling of a table called File, which persists with other entities,
The driver to call the service is the following:
@RestController
public class ExpedientController {
@Autowired
protected ExpedientService expedientService;
@Autowired
protected ExpedientSubserviceService expedientSubserviceService;
protected UserService userService;
protected ObjectMapper mapper;
@CrossOrigin(origins = "*")
@RequestMapping(value = "/api/expedient/saveOrUpdate",method = RequestMethod.POST)
public RestResponse saveOrUpdate(@RequestBody String expedientJSON) throws JsonParseException, JsonMappingException, IOException {
this.mapper= new ObjectMapper();
Expedient expedient=this.mapper.readValue(expedientJSON,Expedient.class);
this.expedientService.save(expedient);
String message = Integer.toString(expedient.getId())+" "+Integer.toString(expedient.assured.getId());
return new RestResponse(HttpStatus.OK.value(), message);
}
@CrossOrigin(origins = "*")
@RequestMapping(value = "/api/expedient/getAll", method = RequestMethod.GET)
public List<Expedient> getAll() {
return this.expedientService.findAllByDeletedAt(0);
}
@RequestMapping(value = "/api/expedient/delete", method = RequestMethod.POST)
public void deleteExpedient(@RequestBody String expedientJson) throws Exception {
this.mapper = new ObjectMapper();
Expedient expedient = this.mapper.readValue(expedientJson, Expedient.class);
if (expedient.getId()==0) {
throw new Exception("El id esta nulo");
}
this.expedientService.delete(expedient.getId());
}
The Json of the query is large because of the number of objects that persist between them. Is it recommended that separate queries be made without the need to bring in the json all the information of the entities persisted? Or there is some compression method that can be used.