public MessageCodeResponse AddFriend(Guid managerId, string name, bool hasTask) { var byManager = ManagerCore.Instance.GetManagerByName(name); if (byManager == null) { return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.FriendNotExistsName)); } if (managerId == byManager.Idx) { return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.FriendNotSelf)); } var manager = ManagerCore.Instance.GetManager(managerId); var friend = FriendManagerMgr.GetOne(managerId, byManager.Idx); if (friend != null) { if (friend.Status == 0) { return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.FriendHasExists)); } if (friend.Status == 2) { return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.FriendIsByBlack)); } } int returnCode = 0; FriendManagerMgr.AddFriend(managerId, byManager.Idx, _friendMaxCount, (int)MessageCode.FriendCountOver, (int)MessageCode.FriendHasExists, ref returnCode); if (returnCode == 1) //自己已在对方好友列表 { returnCode = 0; } else { InformationHelper.SendAddFriendPop(byManager.Idx, manager.Name); } if (returnCode == 0) { var response = ResponseHelper.CreateSuccess <MessageCodeResponse>(); response.Data = new MessageDataEntity(); if (hasTask) { //response.Data.PopMsg = TaskHandler.Instance.FriendAdd(managerId); } return(response); } else { return(ResponseHelper.Create <MessageCodeResponse>(returnCode)); } }