예제 #1
0
  @RequestMapping(value = "/messages/{id}", method = RequestMethod.GET)
  public String messageViewGet(HttpServletRequest request, @PathVariable Long id, Model model) {

    Message message = messageService.findOne(id);
    message.setRead(true);
    messageService.save(message);

    model.addAttribute("message", message);

    return "messages/message";
  }
예제 #2
0
  @RequestMapping(value = "/messages/my_messages", method = RequestMethod.GET)
  public String messageListViewGet(HttpServletRequest request, Model model) {

    User user = (User) request.getSession().getAttribute("user");

    model.addAttribute("messages", messageService.findByReceiverId(user.getId()));

    return "messages/messagelist";
  }
예제 #3
0
  @RequestMapping(value = "/message", method = RequestMethod.POST)
  public String messageViewPost(
      HttpServletRequest request, @ModelAttribute("message") Message message, Model model) {

    User sender = (User) request.getSession().getAttribute("user");
    User receiver = userService.findOne(Long.parseLong(request.getParameter("receiver_id")));

    message.setSender(sender);
    message.setReceiver(receiver);
    message.setSendTime((new Date()).getTime());

    try {
      Ad relevantAd = adService.findOne(Long.parseLong(request.getParameter("ad_id")));
      message.setRelevantAd(relevantAd);
    } catch (Exception e) {
      System.out.println(e.getMessage());
    }

    messageService.save(message);

    model.addAttribute("receiver", receiver);

    return "messages/success";
  }