コード例 #1
0
ファイル: UserController.java プロジェクト: sx0069/SWays
 @RequestMapping(value = "/editUser", method = RequestMethod.POST)
 public @ResponseBody String editUserPost(
     @ModelAttribute("user") User user,
     BindingResult result,
     Principal principal,
     @RequestParam String password,
     @RequestParam String name,
     @RequestParam String surname,
     @RequestParam String mailAddress,
     @RequestParam String img,
     @RequestParam int id) {
   String returnText;
   if (!result.hasErrors()) {
     User u = userService.getUser(id);
     if (!"".equals(name)) u.setName(name);
     if (!"".equals(surname)) u.setSurname(surname);
     if (!"".equals(img)) u.setImg(img);
     if (!"".equals(mailAddress)) u.setMailAddress(mailAddress);
     if (!"".equals(password)) {
       u.setPassword(password);
       userService.updateUser(u);
     } else {
       userService.updateUserByAdmin(u);
     }
     returnText = "Your edit was successful";
   } else {
     returnText = "Sorry, an error has occur...";
   }
   return returnText;
 }
コード例 #2
0
ファイル: GameController.java プロジェクト: remiAC3/SWays
 @RequestMapping(value = "/add", method = RequestMethod.POST)
 @ResponseBody
 public String add(HttpServletResponse response, Principal principal, @RequestParam int points)
     throws IOException {
   User user = userService.getUserByPseudo(principal.getName());
   user.setPoints(user.getPoints() + points);
   userService.updateUserByAdmin(user);
   return "" + user.getPoints();
 }