コード例 #1
0
 @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
 public ResponseEntity<Kriteria> deleteKriteria(@PathVariable Long id) {
   if (!kriteriaRepository.exists(id)) {
     return new ResponseEntity<Kriteria>(HttpStatus.NOT_FOUND);
   }
   kriteriaRepository.delete(id);
   return new ResponseEntity<Kriteria>(HttpStatus.OK);
 }
コード例 #2
0
 @RequestMapping(method = RequestMethod.GET)
 public Page<Kriteria> listKriteria(
     @RequestParam(name = "search") String search, Pageable pageable) {
   if (search.equals("")) {
     return kriteriaRepository.findAll(pageable);
   }
   return kriteriaRepository.findBySearch(search, pageable);
 }
コード例 #3
0
 @RequestMapping(value = "/{id}", method = RequestMethod.GET)
 public ResponseEntity<Kriteria> detailKriteria(@PathVariable Long id) {
   if (!kriteriaRepository.exists(id)) {
     return new ResponseEntity<Kriteria>(HttpStatus.NOT_FOUND);
   }
   Kriteria kriteria = kriteriaRepository.findOne(id);
   return new ResponseEntity<Kriteria>(kriteria, HttpStatus.OK);
 }
コード例 #4
0
  @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
  public ResponseEntity<Kriteria> updateKriteria(
      @PathVariable Long id, @RequestBody Kriteria kriteria, BindingResult bindingResult) {
    if (bindingResult.hasErrors()) {
      return new ResponseEntity<Kriteria>(HttpStatus.BAD_REQUEST);
    }

    Kriteria currentKriteria = kriteriaRepository.findOne(id);
    if (currentKriteria == null) {
      return new ResponseEntity<Kriteria>(HttpStatus.NOT_FOUND);
    }

    currentKriteria.setNamaKriteria(kriteria.getNamaKriteria());

    kriteriaRepository.save(currentKriteria);
    return new ResponseEntity<Kriteria>(currentKriteria, HttpStatus.OK);
  }
コード例 #5
0
  @RequestMapping(method = RequestMethod.POST)
  public ResponseEntity<Kriteria> addKriteria(
      @Validated @RequestBody Kriteria kriteria, BindingResult bindingResult) {
    if (bindingResult.hasErrors()) {
      return new ResponseEntity<Kriteria>(HttpStatus.BAD_REQUEST);
    }

    Kriteria newKriteria = kriteriaRepository.save(kriteria);
    return new ResponseEntity<Kriteria>(newKriteria, HttpStatus.OK);
  }
コード例 #6
0
 @RequestMapping(value = "/all", method = RequestMethod.GET)
 public Iterable<Kriteria> listKriteria() {
   return kriteriaRepository.findAll();
 }