Browse Source

用户清除消息接口,群用户清除消息接口

master
wanghongjun 6 months ago
parent
commit
96dfea25d3
  1. 25
      app/enterprise/controller/Friend.php
  2. 25
      app/enterprise/controller/Group.php
  3. 4
      public/sql/database.sql

25
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('');
}
}

25
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('');
}
}

4
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;
-- --------------------------------------------------------

Loading…
Cancel
Save