@RequestMapping("/self/collect/{id}") @ResponseBody public String collect( @PathVariable("id") Integer itemId, Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { User user = getCurrentUser(); collectionMng.toggleCollect(user, itemId); return SUCC; }
@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"; }