示例#1
0
 @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";
 }
示例#2
0
  @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";
  }
示例#3
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";
  }
示例#4
0
 @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;
 }
示例#5
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";
  }
示例#6
0
 @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";
 }
示例#7
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";
 }