/**
  * 设置系统消息已读
  *
  * @return json
  */
 @RequestMapping("readSysMessage")
 @ResponseBody
 public JSONObject readSysMessage(HttpSession session) {
   User user = (User) session.getAttribute("user");
   if (user == null) {
     return AjaxReturn.Data2Ajax(0, "未登陆", null);
   }
   messageService.readSysMessage(user.getUser_id());
   return AjaxReturn.Data2Ajax(1, null, null);
 }
 /**
  * 获取用户的未读消息
  *
  * @param id 目标用户id
  * @param session 获取自己的userId
  * @return 未读消息集合
  */
 @RequestMapping("getUserUnReadTalking")
 @ResponseBody
 public JSONObject getUserUnReadTalking(int id, HttpSession session) {
   User user = (User) session.getAttribute("user");
   if (user == null) {
     return AjaxReturn.Data2Ajax(0, "未登陆", null);
   }
   JSONObject js = new JSONObject();
   js.put("userId", id);
   js.put("rows", messageService.getUserUnReadTalking(user.getUser_id(), id));
   return AjaxReturn.Data2Ajax(1, null, js);
 }
 @RequestMapping("rejectFriendRequest")
 @ResponseBody
 public JSONObject rejectFriend(HttpSession session, int userId) {
   User user = (User) session.getAttribute("user");
   if (user == null) {
     return AjaxReturn.Data2AjaxForError("未登陆");
   }
   String messageContent = MessageCreater.creatRejectFriendMessage(user.getUser_name());
   Message message = messageService.addSysMessage(0, userId, 2, messageContent, new Date(), 10);
   if (message == null) {
     return AjaxReturn.Data2AjaxForError("消息发送失败");
   }
   MessageSender.sendMessageById(userId, message.toJsonString());
   return AjaxReturn.Data2AjaxForSuccess(null);
 }
 /** 同意好友请求 */
 @RequestMapping("agreeFriendRequest")
 @ResponseBody
 public JSONObject agreeFriendRequest(HttpSession session, int userId) {
   User user = (User) session.getAttribute("user");
   if (user == null) {
     return AjaxReturn.Data2Ajax(0, "未登陆", null);
   }
   String messageContent = MessageCreater.creatAgreeFriendMessage(user.getUser_name());
   try {
     userService.agreeFriendRequest(user.getUser_id(), userId);
   } catch (Exception e) {
     return AjaxReturn.Data2AjaxForError("不能重复添加好友");
   }
   Message message =
       messageService.addSysMessage(user.getUser_id(), userId, 2, messageContent, new Date(), 10);
   if (message == null) {
     return AjaxReturn.Data2AjaxForError("消息发送失败");
   }
   MessageSender.sendMessageById(userId, message.toJsonString());
   return AjaxReturn.Data2AjaxForSuccess(userService.getUserAsFriend(user.getUser_id(), userId));
 }