Exemple #1
0
  @RequestMapping("/self/message/list")
  public String listMessage(
      String type,
      Integer pageNum,
      Integer pageSize,
      Model model,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    User user = getCurrentUser();
    EntityView ev = new EntityView();
    Boolean sendbox = false;
    if (StringUtils.isNotBlank(type) && type.equals("send")) {
      sendbox = true;
      ev.add(Restrictions.eq("sender", user.getUserId()));
    } else {
      ev.add(Restrictions.eq("receiver", user.getUserId()));
    }

    PageContext<Message> pageCtx = messageMng.queryUsePage(ev, pageNum, 10);
    model.addAttribute("pageCtx", pageCtx);
    model.addAttribute("sendbox", sendbox);
    return "self/message/list";
  }
Exemple #2
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";
  }
Exemple #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";
  }
Exemple #4
0
  @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";
  }
Exemple #5
0
 @RequestMapping("/self/message/{id}")
 public String messageDetail(
     @PathVariable("id") Integer id,
     Model model,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   Message message = messageMng.findById(id);
   User user = getCurrentUser();
   if (!message.getSender().equals(user.getUserId())) {
     model.addAttribute("replyAble", true);
   }
   model.addAttribute("message", message);
   return "self/message/detail";
 }
Exemple #6
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";
 }
Exemple #7
0
  @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";
  }