Ejemplo n.º 1
0
  @RequestMapping("/self/item/add")
  public String addItem(
      Item item, Model model, HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    String[] picUrls = request.getParameterValues("picUrl");
    String[] picUrlSmalls = request.getParameterValues("picUrlSmall");

    User user = getCurrentUser();
    item.setUserId(user.getUserId());
    item.setNickName(user.getNickName());
    item.setEmail(user.getEmail());
    item.setCreateDate(DateUtils.now());
    Integer itemId = itemMng.add(item);

    for (int i = 0; i < picUrls.length; i++) {
      ItemPic itemPic = new ItemPic();
      itemPic.setItemId(itemId);
      itemPic.setCreateDate(DateUtils.now());
      itemPic.setPicUrl(picUrls[i]);
      itemPic.setPicUrlSmall(picUrlSmalls[i]);
      itemPicMng.add(itemPic);
    }
    return "redirect:/self";
  }
Ejemplo n.º 2
0
 @RequestMapping("/self/item/delete/{id}")
 public String deleteItem(
     @PathVariable("id") Integer itemId,
     Model model,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   itemMng.deleteById(itemId);
   return "redirect:/self/item/list";
 }
Ejemplo n.º 3
0
  @RequestMapping("/self/item/list")
  public String listItem(
      Integer pageNum, Model model, HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    User user = getCurrentUser();
    EntityView ev = new EntityView();
    ev.add(Restrictions.eq("userId", user.getUserId()));
    PageContext<Item> pageCtx = itemMng.queryUsePage(ev, pageNum, 6);
    model.addAttribute("pageCtx", pageCtx);
    return "self/item_list";
  }
Ejemplo n.º 4
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";
 }