refactor(user): 重构用户个人信息页面并添加新功能
- 重构了用户个人信息页面,增加了权限控制和访问记录功能
This commit is contained in:
@@ -73,45 +73,6 @@ class Sys extends Base
|
||||
$this->success('Success');
|
||||
}
|
||||
|
||||
// 发送用户消息
|
||||
public function sendMsg()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
if ($params['user_id'] == $this->auth->id) {
|
||||
$this->error('不能发送给自己');
|
||||
}
|
||||
$user = auth_user();
|
||||
$target = User::get($params['user_id']);
|
||||
if (empty($target)) {
|
||||
$this->error('用户不存在');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$result = (new Message())->allowField(true)->save([
|
||||
'type' => 2,
|
||||
'name' => $user['nickname'],
|
||||
'avatar' => $user['avatar'],
|
||||
'from_id' => $user['id'],
|
||||
'target_id' => $params['user_id'],
|
||||
'content' => json_encode([
|
||||
'topic' => '好友消息',
|
||||
'time' => date('Y-m-d H:i:s'),
|
||||
'content' => $params['content']
|
||||
]),
|
||||
'status' => 0
|
||||
]);
|
||||
Db::commit();
|
||||
} catch (ValidateException | PDOException | Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result === false) {
|
||||
$this->error('操作失败');
|
||||
}
|
||||
$this->success('Success');
|
||||
}
|
||||
|
||||
public function visitor()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
|
||||
Reference in New Issue
Block a user