@POST @Path("/profile") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addProfile(Profile profile) { // http://localhost:8080/CitoServer/rest/profileService/add if (profile.getId() > 0) { dao.updateProfile(mapper.mapToDb(profile)); } else { int id = dao.addProfile(mapper.mapToDb(profile)); profile.setId(id); } ReturnId returnId = new ReturnId(profile.getId()); return Response.status(200).entity(returnId).build(); }
@GET @Path("/getMaxId") @Produces(MediaType.APPLICATION_JSON) public ReturnId getMaxId() { // http://localhost:8080/CitoServer/rest/profileService/getMaxId int id = dao.getMaxId(); return new ReturnId(id); }
@GET @Path("/profile") @Produces(MediaType.APPLICATION_JSON) public Profile[] getAllProfiles() { // http://localhost:8080/CitoServer/rest/profileService/getAll ProfileDb[] allProfiles = dao.getAllProfiles(); return mapper.mapFromDb(allProfiles); }
@DELETE @Path("/profile/{id}") // @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public ReturnId deleteProfile(@PathParam("id") int id) { // http://localhost:8080/CitoServer/rest/profileService/delete/1 System.out.println("id = " + id); dao.deleteProfile(id); return new ReturnId(id); }