|
@@ -7,13 +7,7 @@ use App\Model\ChatGroupsMember;
|
|
|
use App\Model\ChatRecords;
|
|
|
use App\Model\ChatTopic;
|
|
|
use App\Model\ChatTopicsReply;
|
|
|
-use App\Model\Contact;
|
|
|
-use App\Model\TalkGroup;
|
|
|
-use App\Model\TalkGroupMember;
|
|
|
-use App\Model\TalkRecords;
|
|
|
-use App\Model\TalkRecordsFile;
|
|
|
-use App\Model\TalkSession;
|
|
|
-use App\Model\TalkSessionAssociation;
|
|
|
+
|
|
|
use App\Model\User;
|
|
|
use App\Tools\PublicData;
|
|
|
use App\Tools\Result;
|
|
@@ -137,7 +131,7 @@ class ChatService implements ChatServiceInterface
|
|
|
public function getFriendsApplyList(array $data): array
|
|
|
{
|
|
|
var_dump($data);
|
|
|
- $result = ChatFriends::leftJoin('user', 'user.id', '=', 'chat_friends.friend_id')
|
|
|
+ $result = ChatFriends::leftJoin('user', 'user.id', '=', 'chat_friends.user_id')
|
|
|
->select(
|
|
|
'chat_friends.*',
|
|
|
'user.user_name',
|
|
@@ -175,13 +169,19 @@ class ChatService implements ChatServiceInterface
|
|
|
}
|
|
|
$data['status'] = $status;
|
|
|
$data['applied_at'] = date("Y-m-d H:i:s"); //好友审核时间操作人friend_id
|
|
|
+ unset($data['user_id']);
|
|
|
ChatFriends::where($where)->update($data);
|
|
|
- ChatFriends::updateOrInsert([
|
|
|
- 'user_id' => $fr['friend_id'],
|
|
|
- 'friend_id' => $fr['user_id'],
|
|
|
- // 'remark' => $data['remark'],
|
|
|
- 'status' => $status,
|
|
|
- ]);
|
|
|
+ Db::table('chat_friends')
|
|
|
+ ->updateOrInsert(
|
|
|
+
|
|
|
+ [
|
|
|
+ 'user_id' => $fr['friend_id'],
|
|
|
+ 'friend_id' => $fr['user_id'],
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'status' => $status,
|
|
|
+ ]
|
|
|
+ );
|
|
|
Db::commit();
|
|
|
|
|
|
} catch (\Throwable $ex) {
|
|
@@ -231,6 +231,7 @@ class ChatService implements ChatServiceInterface
|
|
|
];
|
|
|
$result = ChatFriends::where($where)
|
|
|
->orWhere($orwhere)->delete();
|
|
|
+ var_dump($result, '-0------------------');
|
|
|
if ($result) {
|
|
|
return Result::success("删除成功”");
|
|
|
} else {
|
|
@@ -387,6 +388,7 @@ class ChatService implements ChatServiceInterface
|
|
|
*/
|
|
|
public function getChatRecords(array $data): array
|
|
|
{
|
|
|
+ var_dump('222222');
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
$userId = $data['user_id'];
|
|
@@ -400,7 +402,7 @@ class ChatService implements ChatServiceInterface
|
|
|
->leftJoin('user as u1', 'chat_records.user_id', '=', 'u1.id')
|
|
|
->leftJoin('user as u2', 'chat_records.receiver_id', '=', 'u2.id')
|
|
|
->select('chat_records.*', 'u1.user_name as user_id_name', 'u1.avatar as user_avatar', 'u2.user_name as receiver_id_name', 'u2.avatar as receiver_avatar')
|
|
|
- ->orderBy('id', 'desc')->paginate(100);
|
|
|
+ ->orderBy('id', 'asc')->paginate(100);
|
|
|
//更新聊天记录已读
|
|
|
ChatRecords::where('user_id', $userId)
|
|
|
->where('receiver_id', $friendId)
|
|
@@ -658,174 +660,7 @@ class ChatService implements ChatServiceInterface
|
|
|
->get();
|
|
|
return Result::success($groupMember);
|
|
|
}
|
|
|
- /**
|
|
|
- * 群组 - 创建群
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function addTalkGroup(array $data): array
|
|
|
- {
|
|
|
- Db::beginTransaction();
|
|
|
- try {
|
|
|
- //创建群
|
|
|
- $groupData = [
|
|
|
- 'id' => PublicData::uuid(),
|
|
|
- 'creator_id' => $data['user_id'],
|
|
|
- 'group_name' => $data['group_name'],
|
|
|
- ];
|
|
|
- TalkGroup::insert($groupData);
|
|
|
-
|
|
|
- //创建群用户
|
|
|
- $groupMemberData = [];
|
|
|
- if ($data['user_id_arr']) {
|
|
|
- foreach ($data['user_id_arr'] as $key => $val) {
|
|
|
- $groupMemberData[$key] = [
|
|
|
- 'id' => PublicData::uuid(),
|
|
|
- 'group_id' => $groupData['id'],
|
|
|
- 'user_id' => $val,
|
|
|
- 'leader' => $data['user_id'] == $val ? 2 : 0,
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- TalkGroupMember::insert($groupMemberData);
|
|
|
- //创建会话
|
|
|
- $sessionData = [
|
|
|
- 'id' => PublicData::uuid(),
|
|
|
- 'talk_type' => '2',
|
|
|
- ];
|
|
|
- TalkSession::insertGetId($sessionData);
|
|
|
- //创建会话关系
|
|
|
- $talkSessionAssociationData = [];
|
|
|
- if ($data['user_id_arr']) {
|
|
|
- foreach ($data['user_id_arr'] as $key => $val) {
|
|
|
- $talkSessionAssociationData[$key] = [
|
|
|
- 'id' => PublicData::uuid(),
|
|
|
- 'user_id' => $val,
|
|
|
- 'to_user_id' => $groupData['id'],
|
|
|
- 'session_id' => $sessionData['id'],
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- TalkSessionAssociation::insert($talkSessionAssociationData);
|
|
|
- Db::commit();
|
|
|
- } catch (\Throwable $ex) {
|
|
|
- Db::rollBack();
|
|
|
- var_dump($ex->getMessage());
|
|
|
- return Result::error("创建群失败", 0);
|
|
|
- }
|
|
|
- return Result::success([]);
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 群组 - 更新群
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function updateTalkGroup(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = TalkGroup::where($where)->update($data);
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 群组 - 删除群
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function delTalkGroup(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = TalkGroup::where($where)->delete();
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 群组 - 群用户列表
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getTalkGroupMember(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'group_id' => $data['group_id'],
|
|
|
- ];
|
|
|
- $result = TalkGroupMember::where($where)->get();
|
|
|
- return Result::success($result);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 群组 - 全部群用户列表
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getAllTalkGroupMember(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'group_id' => $data['group_id'],
|
|
|
- ];
|
|
|
- $result = TalkGroupMember::where($where)->get();
|
|
|
- return Result::success($result);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 群组 - 创建群用户
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function addTalkGroupMember(array $data): array
|
|
|
- {
|
|
|
- $result = TalkGroupMember::insertGetId($data);
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 群组 - 更新群用户
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function updateTalkGroupMember(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = TalkGroupMember::where($where)->update($data);
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 群组 - 删除群用户
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function delTalkGroupMember(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = TalkGroupMember::where($where)->delete();
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
- }
|
|
|
- }
|
|
|
/**
|
|
|
* 群组 - 添加群
|
|
|
* @param array $data
|
|
@@ -979,414 +814,119 @@ class ChatService implements ChatServiceInterface
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
|
|
|
- /**------------------E
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getChatChannelList(array $data): array
|
|
|
- {
|
|
|
- $result = ChatFriends::where($data)->get();
|
|
|
- return Result::success($result);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function delChatChannel(array $data): array
|
|
|
- {
|
|
|
- $result = ChatFriends::where(['fd' => $data['fd']])->delete();
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function addChatChannel(array $data): array
|
|
|
- {
|
|
|
- $result = ChatFriends::insertGetId($data);
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
- * 好友查询
|
|
|
+ * 修改群成员
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function getContactList(array $data): array
|
|
|
+ public function updateGroupMembers(array $data): array
|
|
|
{
|
|
|
$where = [
|
|
|
- ['contact.status', '=', '1'],
|
|
|
- ['contact.user_id', '=', $data['user_id']],
|
|
|
+ 'group_id' => $data['group_id'],
|
|
|
];
|
|
|
- if (isset($data['pageSize'])) {
|
|
|
- $result = Contact::where($where)
|
|
|
- ->where(function ($query) use ($data) {
|
|
|
- $query->where('user.nickname', 'like', '%' . $data['keyWord'] . '%')
|
|
|
- ->orWhere('contact.remark', 'like', '%' . $data['keyWord'] . '%');
|
|
|
- })
|
|
|
- ->leftJoin('user', 'user.id', '=', 'contact.friend_id')
|
|
|
- ->select('contact.*', 'user.nickname', 'user.avatar')
|
|
|
- ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("contact.created_at", "desc")->get();
|
|
|
- } else {
|
|
|
- $result = Contact::where($where)
|
|
|
- ->where(function ($query) use ($data) {
|
|
|
- $query->where('user.nickname', 'like', '%' . $data['keyWord'] . '%')
|
|
|
- ->orWhere('contact.remark', 'like', '%' . $data['keyWord'] . '%');
|
|
|
- })
|
|
|
- ->leftJoin('user', 'user.id', '=', 'contact.friend_id')
|
|
|
- ->select('contact.*', 'user.nickname', 'user.avatar')
|
|
|
- ->get();
|
|
|
+ $group_id = $data['group_id'];
|
|
|
+ //先删除群成员
|
|
|
+ $result = ChatGroupsMember::where($where)
|
|
|
+ ->where([["user_id", '!=', $data['user_id']]])->delete();
|
|
|
+ $groupMemberData = [];
|
|
|
+ foreach ($data['group_member'] as $value) {
|
|
|
+ $groupMemberData[] = [
|
|
|
+ 'id' => PublicData::uuid(),
|
|
|
+ 'user_id' => $value,
|
|
|
+ 'group_id' => $group_id,
|
|
|
+ 'leader' => 0,
|
|
|
+ ];
|
|
|
}
|
|
|
+ $result = ChatGroupsMember::where($where)->insert($groupMemberData);
|
|
|
+ // 获取群信息
|
|
|
+ $groupInfo = ChatGroups::where(['id' => $group_id])->first();
|
|
|
|
|
|
- $count = Contact::where($where)
|
|
|
- ->where(function ($query) use ($data) {
|
|
|
- $query->where('user.nickname', 'like', '%' . $data['keyWord'] . '%')
|
|
|
- ->orWhere('contact.remark', 'like', '%' . $data['keyWord'] . '%');
|
|
|
- })
|
|
|
- ->leftJoin('user', 'user.id', '=', 'contact.friend_id')
|
|
|
- ->count();
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("没有数据", 0);
|
|
|
- }
|
|
|
- $rep = $result->toArray();
|
|
|
- $data = [
|
|
|
- 'rows' => $rep,
|
|
|
- 'count' => $count,
|
|
|
- ];
|
|
|
- return Result::success($data);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 添加好友
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function addContact(array $data): array
|
|
|
- {
|
|
|
- $result = Contact::insertGetId($data);
|
|
|
if ($result) {
|
|
|
- return Result::success($data);
|
|
|
+ return Result::success($groupInfo);
|
|
|
} else {
|
|
|
return Result::error($data);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新好友
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function updateContact(array $data): array
|
|
|
+ public function clearGroupRecords(array $data): array
|
|
|
{
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = Contact::where($where)->update($data);
|
|
|
+ $result = ChatRecords::where(['user_id' => $data['user_id'], 'receiver_id' => $data['id']])->delete();
|
|
|
if ($result) {
|
|
|
- return Result::success($data);
|
|
|
+ return Result::success("删除成功");
|
|
|
} else {
|
|
|
- return Result::error($data);
|
|
|
+ return Result::error("删除失败");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 会话列表
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getTalkSessionList(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'talk_session_association.status' => '1',
|
|
|
- 'talk_session_association.user_id' => $data['user_id'],
|
|
|
- ];
|
|
|
- $result = TalkSessionAssociation::where($where)
|
|
|
- ->leftJoin('talk_session', 'talk_session.id', 'talk_session_association.session_id')
|
|
|
- ->leftJoin('user', 'user.id', 'talk_session_association.to_user_id')
|
|
|
- ->leftJoin('talk_group', 'talk_group.id', 'talk_session_association.to_user_id')
|
|
|
- ->select(
|
|
|
- 'talk_session.talk_type',
|
|
|
- 'talk_group.group_name',
|
|
|
- 'talk_group.avatar as group_avatar',
|
|
|
- 'user.avatar as user_avatar',
|
|
|
- 'user.nickname',
|
|
|
- 'talk_session.last_content',
|
|
|
- 'user.user_name',
|
|
|
- 'talk_session.id as session_id',
|
|
|
- 'talk_session.talk_type',
|
|
|
- 'user.id as user_id',
|
|
|
- 'talk_group.id as group_id'
|
|
|
- )
|
|
|
- ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("talk_session.updated_at", "desc")->get();
|
|
|
- $count = TalkSessionAssociation::where($where)
|
|
|
- ->leftJoin('talk_session', 'talk_session.id', 'talk_session_association.session_id')
|
|
|
- ->leftJoin('user', 'user.id', 'talk_session_association.to_user_id')
|
|
|
- ->leftJoin('talk_group', 'talk_group.id', 'talk_session_association.to_user_id')
|
|
|
- ->count();
|
|
|
- $repData = [
|
|
|
- 'row' => $result,
|
|
|
- 'count' => $count,
|
|
|
- ];
|
|
|
- return Result::success($repData);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 添加会话
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function addTalkSession(array $data): array
|
|
|
+ public function recallRecord(array $data): array
|
|
|
{
|
|
|
- $result = TalkSession::insert($data);
|
|
|
+ //获取所有id,并删除掉
|
|
|
+ $ids = array_column($data, 'id');
|
|
|
+ $result = ChatRecords::whereIn('id', $ids)->delete();
|
|
|
if ($result) {
|
|
|
- return Result::success(['id' => $data['id']]);
|
|
|
+ return Result::success("删除成功");
|
|
|
} else {
|
|
|
- return Result::error('创建会话失败');
|
|
|
+ return Result::error("删除失败");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新会话
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function updateTalkSession(array $data): array
|
|
|
+ public function clearRecords(array $data): array
|
|
|
{
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = TalkSession::where($where)->update($data);
|
|
|
+ $result = ChatRecords::where(['user_id' => $data['user_id'], 'receiver_id' => $data['friend_id']])->delete();
|
|
|
if ($result) {
|
|
|
- return Result::success($data);
|
|
|
+ return Result::success("删除成功");
|
|
|
} else {
|
|
|
- return Result::error($data);
|
|
|
+ return Result::error("删除失败");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除会话
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function delTalkSession(array $data): array
|
|
|
+ public function getRecordByContent(array $data): array
|
|
|
{
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = TalkSession::where($where)->delete();
|
|
|
+ $result = ChatRecords::where(['chat_records.user_id' => $data['user_id'], 'chat_records.receiver_id' => $data['receiver_id'], 'chat_records.content' => $data['content']])
|
|
|
+ ->orWhere(['chat_records.receiver_id' => $data['user_id'], 'chat_records.user_id' => $data['receiver_id'], 'chat_records.content' => $data['content']])
|
|
|
+ ->all();
|
|
|
if ($result) {
|
|
|
- return Result::success($data);
|
|
|
+ return Result::success($result['id']);
|
|
|
} else {
|
|
|
- return Result::error($data);
|
|
|
+ return Result::error("没有数据");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 聊天内容-获取聊天内容列表
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getTalkRecordsList(array $data): array
|
|
|
+ public function getRecord(array $data): array
|
|
|
{
|
|
|
- $talkSessionAssociationInfo = TalkSessionAssociation::where(['session_id' => $data['session_id'], 'to_user_id' => $data['user_id']])->first();
|
|
|
- $where = [
|
|
|
- 'talk_records.session_id' => $data['session_id'],
|
|
|
- ];
|
|
|
- if ($talkSessionAssociationInfo['status'] == 2) {
|
|
|
- $where[] = ['talk_records.created_at', '>=', $talkSessionAssociationInfo['del_at']];
|
|
|
- }
|
|
|
- $result = TalkRecords::where($where)
|
|
|
- ->leftJoin('user', 'user.id', 'talk_records.user_id')
|
|
|
- ->select("user.avatar", "talk_records.*")
|
|
|
- ->limit($data['pageSize'])
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->orderBy("talk_session.updated_at", "desc")
|
|
|
+ $result = ChatRecords::where(['chat_records.id' => $data['id']])
|
|
|
+ ->leftJoin('user', 'user.id', '=', 'chat_records.user_id')
|
|
|
+ ->leftJoin('user as user2', 'user2.id', '=', 'chat_records.receiver_id')
|
|
|
+ ->select('chat_records.*', 'user.nickname', 'user.avatar', 'user.user_name', 'user2.nickname as receiver_nickname', 'user2.avatar as receiver_avatar')
|
|
|
->get();
|
|
|
-
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新聊天内容
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function updateTalkRecords(array $data): array
|
|
|
+ public function delReply(array $data): array
|
|
|
{
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = TalkRecords::where($where)->update($data);
|
|
|
+ $result = ChatTopicsReply::where(['id' => $data['id']])->delete();
|
|
|
if ($result) {
|
|
|
- return Result::success($data);
|
|
|
+ return Result::success("删除成功");
|
|
|
} else {
|
|
|
- return Result::error($data);
|
|
|
+ return Result::error("删除失败");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除聊天内容
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function delTalkRecords(array $data): array
|
|
|
+ public function delAllReply(array $data): array
|
|
|
{
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = TalkRecords::where($where)->delete();
|
|
|
+ $result = ChatTopicsReply::where(['topic_id' => $data['topicid']])->delete();
|
|
|
if ($result) {
|
|
|
- return Result::success($data);
|
|
|
+ return Result::success("删除成功");
|
|
|
} else {
|
|
|
- return Result::error($data);
|
|
|
+ return Result::error("删除失败");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 聊天内容-附件列表
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getTalkRecordsFileList(array $data): array
|
|
|
+ public function getTopicsListAdmin(array $data): array
|
|
|
{
|
|
|
- $result = TalkRecordsFile::get();
|
|
|
- return Result::success($result);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 聊天内容-添加附件
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function addTalkRecordsFile(array $data): array
|
|
|
- {
|
|
|
- $result = TalkRecordsFile::insertGetId($data);
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 聊天内容 - 更新附件
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function updateTalkRecordsFile(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = TalkRecordsFile::where($where)->update($data);
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
+ $where = [];
|
|
|
+ if (!empty($data['type'])) {
|
|
|
+ $where['type'] = $data['type'];
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 聊天内容 - 删除附件
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function delTalkRecordsFile(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = TalkRecordsFile::where($where)->delete();
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
+ if (!empty($data['title'])) {
|
|
|
+ $where['title'] = $data['title'];
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 群组 - 群列表
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getTalkGroupList(array $data): array
|
|
|
- {
|
|
|
- $result = TalkGroup::get();
|
|
|
+ $result = ChatTopic::where($where)
|
|
|
+ ->leftJoin('user', 'user.id', '=', 'chat_topics.user_id')
|
|
|
+ ->select('chat_topics.*', 'user.nickname', 'user.avatar', 'user.user_name')
|
|
|
+ ->paginate($data['page_size']);
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新 会话关系
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function updateTalkSessionAssociation(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $result = TalkSessionAssociation::where($where)->update($data);
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 添加会话关系
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function addTalkSessionAssociation(array $data): array
|
|
|
- {
|
|
|
- var_dump($data);
|
|
|
- $result = TalkSessionAssociation::insertGetId($data);
|
|
|
- if ($result) {
|
|
|
- return Result::success($data);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 修改群成员
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function updateGroupMembers(array $data): array
|
|
|
- {
|
|
|
- $where = [
|
|
|
- 'group_id' => $data['group_id'],
|
|
|
- ];
|
|
|
- $group_id = $data['group_id'];
|
|
|
- //先删除群成员
|
|
|
- $result = ChatGroupsMember::where($where)
|
|
|
- ->where([["user_id",'!=',$data['user_id']]])->delete();
|
|
|
- $groupMemberData = [];
|
|
|
- foreach ($data['group_member'] as $value) {
|
|
|
- $groupMemberData[] = [
|
|
|
- 'id' => PublicData::uuid(),
|
|
|
- 'user_id' => $value,
|
|
|
- 'group_id' => $group_id,
|
|
|
- 'leader' => 0,
|
|
|
- ];
|
|
|
- }
|
|
|
- $result = ChatGroupsMember::where($where)->insert($groupMemberData);
|
|
|
- // 获取群信息
|
|
|
- $groupInfo = ChatGroups::where(['id'=>$group_id])->first();
|
|
|
-
|
|
|
- if ($result) {
|
|
|
- return Result::success($groupInfo);
|
|
|
- } else {
|
|
|
- return Result::error($data);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
}
|