コード例 #1
0
 @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);
 }
コード例 #2
0
 /** 同意好友请求 */
 @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));
 }