示例#1
0
 @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();
 }
示例#2
0
 @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);
 }
示例#3
0
 @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);
 }
示例#4
0
 @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);
 }