@Transactional(rollbackForClassName = "java.lang.Exception") @RequestMapping( value = "addSticky", method = {RequestMethod.POST}) public @ResponseBody Map<String, String> addSticky( HttpServletRequest request, HttpServletResponse response) throws IllegalRequestException { Integer userId = new Integer(request.getParameter("userId")); Integer positionTop = new Integer(request.getParameter("positionTop")); Integer positionLeft = new Integer(request.getParameter("positionLeft")); Integer height = new Integer(request.getParameter("height")); Integer width = new Integer(request.getParameter("width")); String content = (String) request.getParameter("content"); System.out.println("content=" + content + ", pTop=" + positionTop + ", pLft=" + positionLeft); UserSticky userSticky = new UserSticky(); userSticky.setId(userStickyMapper.newId(userId)); userSticky.setUserId(userId); userSticky.setPositionTop(positionTop); userSticky.setPositionLeft(positionLeft); userSticky.setHeight(height); userSticky.setWidth(width); userSticky.setContent(content); userStickyMapper.create(userSticky); Map<String, String> map = new HashMap<String, String>(1); map.put("msg", "OK"); return map; }
@Transactional(rollbackForClassName = "java.lang.Exception") @RequestMapping( value = "updateMyPage", method = {RequestMethod.POST}) public ModelAndView updateMyPage( @Valid UserProfile userProfile, BindingResult result, HttpServletRequest request) throws IllegalRequestException { Integer authUserId = userCookieGenerator.getUserId(request); if (!authUserId.equals(userProfile.getUserId())) throw new IllegalRequestException(); try { if (result.hasErrors()) { throw new InvalidInputException(); } if (!userProfile.validForEditingProfile()) { Map<String, String> rejectValueMap = userProfile.getRejectValueMap(); for (Map.Entry<String, String> entry : rejectValueMap.entrySet()) { result.rejectValue(entry.getKey(), entry.getValue()); } throw new InvalidInputException(); } } catch (InvalidInputException e) { ModelAndView modelAndView = new ModelAndView(); modelAndView.addObject( "userProfileDisplay", userProfileMapper.getUserProfileById(authUserId)); modelAndView.addObject("userProfile", userProfile); modelAndView.addObject("userStickyList", userStickyMapper.listByUserId(authUserId)); modelAndView.addObject("editMode", true); modelAndView.setViewName("user/show"); return modelAndView; } userProfileMapper.updateUserProfile(userProfile); userProfile = userProfileMapper.getUserProfileById(authUserId); ModelAndView modelAndView = new ModelAndView(); modelAndView.addObject("userProfileDisplay", userProfile); modelAndView.addObject("userProfile", userProfile); modelAndView.addObject("userStickyList", userStickyMapper.listByUserId(authUserId)); modelAndView.addObject("editMode", true); modelAndView.addObject("updated", true); modelAndView.setViewName("user/show"); return modelAndView; }
@Transactional(rollbackForClassName = "java.lang.Exception") @RequestMapping( value = "gotoMyPage", method = {RequestMethod.GET}) public ModelAndView gotoMyPage(HttpServletRequest request) throws IllegalRequestException { Integer authUserId = userCookieGenerator.getUserId(request); UserProfile userProfile = userProfileMapper.getUserProfileById(authUserId); if (userProfile == null) throw new IllegalRequestException(); ModelAndView modelAndView = new ModelAndView(); modelAndView.addObject("userProfileDisplay", userProfile); modelAndView.addObject("userProfile", userProfile); modelAndView.addObject("userStickyList", userStickyMapper.listByUserId(authUserId)); modelAndView.addObject("editMode", true); modelAndView.setViewName("user/mypage"); return modelAndView; }