@RequestMapping("/self/message/send") public String send(Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { Integer receiver = Integer.parseInt(request.getParameter("receiver")); String title = request.getParameter("title"); String content = request.getParameter("content"); User sendUser = getCurrentUser(); User receUser = userMng.findById(receiver); messageMng.sendMessage(title, content, sendUser, receUser); return "redirect:/self"; }
@RequestMapping("/self/message/write/{id}") public String write( @PathVariable("id") Integer receiver, Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { User recUser = userMng.findById(receiver); model.addAttribute("recUser", recUser); return "self/message/write"; }
@RequestMapping("/self/profile") public String profile(Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { User user = getCurrentUser(); user = userMng.findById(user.getUserId()); List<City> citys = cityMng.findAll(); model.addAttribute("citys", citys); model.addAttribute("userId", user.getUserId()); model.addAttribute("user", user); return "self/profile"; }
@RequestMapping("/self/follow/{id}") @ResponseBody public String follow( @PathVariable("id") Integer followId, Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { User followUser = userMng.findById(followId); User user = getCurrentUser(); userFollowMng.toggleFollow(user, followUser); return SUCC; }
@RequestMapping("/self/save") public String save(Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { Integer userId = Integer.parseInt(request.getParameter("userId")); User user = userMng.findById(userId); String mobile = request.getParameter("mobile"); String qq = request.getParameter("qq"); String intro = request.getParameter("intro"); String cid = request.getParameter("cityId"); if (StringUtils.isBlank(cid) && !cid.equals("")) { Integer cityId = Integer.parseInt(cid); user.setCityId(cityId); } user.setMobile(mobile); user.setQq(qq); user.setIntro(intro); userMng.saveOrUpdate(user); return "redirect:/self"; }
@RequestMapping("/self") public String index( Integer pageNum, Integer pageSize, Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { User user = getCurrentUser(); user = userMng.findById(user.getUserId()); EntityView ev = new EntityView(); ev.add(Restrictions.eq("userId", user.getUserId())); PageContext<Item> pageCtx = itemMng.queryUsePage(ev, pageNum, 6); model.addAttribute("pageCtx", pageCtx); model.addAttribute("user", user); return "self/index"; }
@RequestMapping("/self/collection") public String collect( Integer pageNum, Integer pageSize, Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { User user = getCurrentUser(); user = userMng.findById(user.getUserId()); PageContext pageCtx = collectionMng.findByUserId(user.getUserId(), pageNum, pageSize); List<Integer> ids = new ArrayList(); List<Collection> collections = pageCtx.getItemList(); for (Collection collection : collections) { ids.add(collection.getItemId()); } Map<String, Item> itemMap = itemMng.getMapByIds(ids); model.addAttribute("pageCtx", pageCtx); model.addAttribute("itemMap", itemMap); model.addAttribute("user", user); return "self/collection"; }