From 96dfea25d320acfb89d8080702d2fe9ec50b5cfd Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Tue, 12 Aug 2025 16:13:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B8=85=E9=99=A4=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8E=A5=E5=8F=A3=EF=BC=8C=E7=BE=A4=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=B8=85=E9=99=A4=E6=B6=88=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/enterprise/controller/Friend.php | 25 ++++++++++++++++++++++++- app/enterprise/controller/Group.php | 25 +++++++++++++++++++++++++ public/sql/database.sql | 4 +++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/app/enterprise/controller/Friend.php b/app/enterprise/controller/Friend.php index 1625971..0f8a066 100644 --- a/app/enterprise/controller/Friend.php +++ b/app/enterprise/controller/Friend.php @@ -250,7 +250,30 @@ class Friend extends BaseController 'create_user' => $this->uid, 'status' => 1 ]; - $friend_user = FriendModel::where($where)->field('is_notice,is_top,is_blacklist')->find(); + $friend_user = FriendModel::where($where)->field('is_notice,is_top,is_blacklist,clear_msg_day')->find(); return success('', $friend_user); } + + // 用户设置聊天清除日期 + public function setClearMsgDay() + { + $to_user = $this->request->param('to_user'); + $day = $this->request->param('day', 0); + $uid = $this->userInfo['id']; + if (!is_numeric($day)) return error(lang('system.fail')); + if (!is_numeric($to_user)) return error(lang('system.fail')); + + $friendWhere = [ + 'friend_user_id' => $to_user, + 'create_user' => $uid + ]; + $friend = \app\enterprise\model\Friend::where($friendWhere)->find(); + if (!$friend) { + return error(lang('system.fail')); + } + $friend->clear_msg_day = $day; + $friend->save(); + + return success(''); + } } diff --git a/app/enterprise/controller/Group.php b/app/enterprise/controller/Group.php index 12c3ae9..2e27562 100644 --- a/app/enterprise/controller/Group.php +++ b/app/enterprise/controller/Group.php @@ -78,6 +78,7 @@ class Group extends BaseController $group['avatar']=avatarUrl($group['avatar'],$group['name'],$group['group_id'],120); $group['setting']=$group['setting']?json_decode($group['setting'],true):['manage' => 0, 'invite' => 1, 'nospeak' => 0]; $group['isJoin']=GroupUser::where(['group_id'=>$group_id,'user_id'=>$this->uid])->value('role') ?: 0; + $group['clear_msg_day']=GroupUser::where(['group_id'=>$group_id,'user_id'=>$this->uid])->value('clear_msg_day') ?: 0; return success('', $group); } catch (Exception $e) { return error($e->getMessage()); @@ -540,4 +541,28 @@ class Group extends BaseController return warning(''); } } + + // 用户设置群聊天清除日期 + public function setClearMsgDay() + { + $id = $this->request->param('id'); + $group_id = explode('-', $id)[1]; + $day = $this->request->param('day', 0); + $uid = $this->userInfo['id']; + if (!is_numeric($day)) return error(lang('system.fail')); + if (!is_numeric($group_id)) return error(lang('system.fail')); + + $groupUserWhere = [ + 'group_id' => $group_id, + 'user_id' => $uid + ]; + $groupUser = GroupUser::where($groupUserWhere)->find(); + if (!$groupUser) { + return error(lang('system.fail')); + } + $groupUser->clear_msg_day = $day; + $groupUser->save(); + + return success(''); + } } diff --git a/public/sql/database.sql b/public/sql/database.sql index d9f538c..71a6b7a 100644 --- a/public/sql/database.sql +++ b/public/sql/database.sql @@ -76,6 +76,7 @@ CREATE TABLE `yu_friend` ( `remark` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '申请备注', `status` tinyint(1) NOT NULL DEFAULT '1', `is_blacklist` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否拉入黑名单', + `clear_msg_day` INT(10) UNSIGNED DEFAULT '0' NOT NULL COMMENT '清除消息日期' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='联系人置顶表'; -- -------------------------------------------------------- @@ -118,7 +119,8 @@ CREATE TABLE `yu_group_user` ( `is_top` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否置顶', `no_speak_time` int(11) NOT NULL DEFAULT '0' COMMENT '禁言到期时间', `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态 0 ,未同意邀请,1,同意', - `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间' + `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', + `clear_msg_day` int(10) UNSIGNED DEFAULT '0' NOT NULL COMMENT '清除消息时间' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- --------------------------------------------------------