Beispiel #1
0
 @RequestMapping(value = "/user", method = RequestMethod.GET)
 public String getUsers(@RequestParam(value = "id", defaultValue = "-1") int id) {
   if (id == -1) {
     List<User> users = Database.getUsers();
     JSONArray array = new JSONArray();
     for (User user : users) {
       array.put(user.toJSON());
     }
     return array.toString();
   } else {
     return Database.getUser(id).toJSON().toString();
   }
 }
Beispiel #2
0
 @RequestMapping(value = "/user", method = RequestMethod.POST)
 public String createUser(@RequestBody User user) {
   System.out.println("\n\n\n" + user.toString() + "\n\n\n");
   int newuserid = Database.createUser(user);
   JSONObject object = new JSONObject();
   object.put("userid", newuserid);
   return object.toString();
 }