예제 #1
0
 /** GET /accountings -> get all the accountings. */
 @RequestMapping(
     value = "/accountings",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public List<Accounting> getAllAccountings() {
   log.debug("REST request to get all Accountings");
   return accountingRepository.findAll();
 }
예제 #2
0
 /** GET /accountings/:id -> get the "id" accounting. */
 @RequestMapping(
     value = "/accountings/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Accounting> getAccounting(@PathVariable Long id) {
   log.debug("REST request to get Accounting : {}", id);
   return Optional.ofNullable(accountingRepository.findOne(id))
       .map(accounting -> new ResponseEntity<>(accounting, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
예제 #3
0
 /** DELETE /accountings/:id -> delete the "id" accounting. */
 @RequestMapping(
     value = "/accountings/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> deleteAccounting(@PathVariable Long id) {
   log.debug("REST request to delete Accounting : {}", id);
   accountingRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("accounting", id.toString()))
       .build();
 }
예제 #4
0
 /** PUT /accountings -> Updates an existing accounting. */
 @RequestMapping(
     value = "/accountings",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Accounting> updateAccounting(@RequestBody Accounting accounting)
     throws URISyntaxException {
   log.debug("REST request to update Accounting : {}", accounting);
   if (accounting.getId() == null) {
     return createAccounting(accounting);
   }
   Accounting result = accountingRepository.save(accounting);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityUpdateAlert("accounting", accounting.getId().toString()))
       .body(result);
 }
예제 #5
0
 /** POST /accountings -> Create a new accounting. */
 @RequestMapping(
     value = "/accountings",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Accounting> createAccounting(@RequestBody Accounting accounting)
     throws URISyntaxException {
   log.debug("REST request to save Accounting : {}", accounting);
   if (accounting.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new accounting cannot already have an ID")
         .body(null);
   }
   Accounting result = accountingRepository.save(accounting);
   return ResponseEntity.created(new URI("/api/accountings/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("accounting", result.getId().toString()))
       .body(result);
 }