コード例 #1
0
 @RequestMapping(value = "/products", method = RequestMethod.GET)
 public List<EProduct> getProducts(@RequestParam(value = "type", required = false) Integer id) {
   EProductDAO dao = new EProductDAO();
   if (id != null) {
     List<EProduct> products = new ArrayList<>();
     for (EProduct product : dao.getAll()) {
       if (product.getProductTypeid() == id.intValue()) {
         products.add(product);
       }
     }
     return products;
   } else {
     return dao.getAll();
   }
 }
コード例 #2
0
 @RequestMapping("/product/{id}")
 public EProduct getProduct(@PathVariable int id) {
   EProductDAO dao = new EProductDAO();
   return dao.getById(id);
 }