@RequestMapping( value = "/getBranchesByCardNo/{cardNo}", method = {RequestMethod.GET, RequestMethod.POST}, produces = "application/json") public List<Branch> getBranchesByCardNo(@PathVariable int cardNo) { List<Loan> loans = ldao.getLoansByCardNo(cardNo); List<Branch> branches = new ArrayList<>(); for (Loan l : loans) if (!branches.contains(l.getBranch())) branches.add(l.getBranch()); return branches; }
@RequestMapping( value = "/getBooksByCardNoAndBranchId/{cardNo}/{branchId}", method = {RequestMethod.GET, RequestMethod.POST}, produces = "application/json") public List<Book> getBooksByCardNoAndBranchId( @PathVariable int cardNo, @PathVariable int branchId) { List<Loan> loans = ldao.getLoansByCardNoAndBranchId(cardNo, branchId, -1, 5); List<Book> books = new ArrayList<>(); for (Loan l : loans) if (!books.contains(l.getBook())) books.add(l.getBook()); return books; }