Esempio n. 1
0
 @RequestMapping(
     value = "/edit",
     method = RequestMethod.POST,
     produces = "application/json",
     consumes = "application/json")
 @ResponseBody
 public Map update(@RequestBody Map request, HttpSession session) throws TapWisdomException {
   Map response = new HashMap();
   TwUser twUser = getTwUser(session);
   User user = new User();
   user.setId(twUser.getId());
   if (request.containsKey("user")) {
     String userJson = (String) request.get("user");
     user = Utils.getObjectFromString(userJson, User.class);
     user.setId(twUser.getId());
     Boolean update = userService.updateUser(user);
     user = userService.getUser(user.getId());
     UserView userView = CommonUtils.filterSensitiveData(user);
     session.setAttribute("user", twUser);
     response.put("success", update);
     response.put("user", userView);
     return getResponse(update ? 0 : 1, response);
   } else {
     throw new TapWisdomException(1, "user field is mandatory");
   }
 }
Esempio n. 2
0
 @RequestMapping(method = RequestMethod.DELETE, produces = "application/json")
 @ResponseBody
 public Map delete(HttpSession session) throws TapWisdomException {
   Map response = new HashMap();
   TwUser twUser = getTwUser(session);
   int statusCode = 0;
   User user = new User();
   user.setId(twUser.getId());
   user.setStatus(UserStatus.del);
   if (userService.updateUser(user)) {
     response.put("success", true);
   } else {
     response.put("success", false);
     statusCode = 1;
   }
   return getResponse(statusCode, response);
 }