Exemplo n.º 1
0
 @RequestMapping(value = "/card/add", method = RequestMethod.POST, consumes = "application/json")
 public @ResponseBody ResponseEntity<Void> doAdd(@Valid @RequestBody Card card) {
   if (service.add(card)) {
     return new ResponseEntity<Void>(HttpStatus.OK);
   } else {
     return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
   }
 }
Exemplo n.º 2
0
 @RequestMapping(value = "/card/getBySeri/{seri}", method = RequestMethod.GET)
 public @ResponseBody ResponseEntity<Card> doGetById(@PathVariable("seri") String seri) {
   Card card = null;
   try {
     card = service.getBySeri(seri);
   } catch (Exception e) {
     return new ResponseEntity<Card>(HttpStatus.NOT_FOUND);
   }
   if (card != null) {
     return new ResponseEntity<Card>(card, HttpStatus.OK);
   } else {
     return new ResponseEntity<Card>(HttpStatus.NOT_FOUND);
   }
 }
Exemplo n.º 3
0
 /**
  * *
  *
  * @return
  */
 @RequestMapping(value = "/card/all/unused", method = RequestMethod.GET)
 public @ResponseBody ResponseEntity<List<Card>> doGetAllUnused() {
   List<Card> cards = null;
   try {
     cards = service.allUnused();
   } catch (Exception e) {
     return new ResponseEntity<List<Card>>(HttpStatus.NOT_FOUND);
   }
   if (cards != null) {
     return new ResponseEntity<List<Card>>(cards, HttpStatus.OK);
   } else {
     return new ResponseEntity<List<Card>>(HttpStatus.NOT_FOUND);
   }
 }
Exemplo n.º 4
0
  @RequestMapping(value = "/card/add/{value}", method = RequestMethod.GET)
  public @ResponseBody ResponseEntity<Integer> doAddCard(@PathVariable("value") int value) {
    int added = 0;
    for (int i = 0; i < 10; i++) {
      Card card = new Card();
      // card.setIsUsed(false);
      card.setValue(value);
      card.setSeri(randomSeri());
      try {
        service.add(card);
        added++;
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    return new ResponseEntity<Integer>(added, HttpStatus.OK);
  }