Exemplo n.º 1
0
 @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;
 }
Exemplo n.º 2
0
 @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";
 }