@GET @Path("/get/{id}") @Produces(MediaType.APPLICATION_JSON) public AppResponse getPerson(@PathParam("id") int custId) { AppResponse resp = new AppResponse(); try { CustomerDAO dao = new CustomerDAO(); Customer cust = dao.getPerson(custId); resp.setPayload(cust); } catch (AppException e) { e.printStackTrace(); resp.setMessage(e.getMessage()); } return resp; }
@GET @Path("/all") @Produces(MediaType.APPLICATION_JSON) public AppResponse getAll() { AppResponse resp = new AppResponse(); try { CustomerDAO dao = new CustomerDAO(); List<Customer> custList = dao.getAll(); resp.setPayload(custList); } catch (AppException e) { e.printStackTrace(); resp.setMessage(e.getMessage()); } return resp; }
@POST @Path("/add") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public AppResponse addCustomer(Customer cust) { System.out.print("SHIVSVLMGBLXFKGLXFKGHLDKGF"); AppResponse resp = new AppResponse(); try { CustomerDAO dao = new CustomerDAO(); cust = dao.addCustomer(cust); resp.setMessage("Customer has been addded to the database"); resp.setPayload(cust); } catch (AppException e) { e.printStackTrace(); resp.setStatus(AppResponse.ERROR); resp.setMessage(e.getMessage()); } return resp; }