47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\controller\Api;
|
|
use app\common\model\FriendNotification;
|
|
use app\common\model\FriendRequests;
|
|
use fast\Easemob;
|
|
|
|
class Msg extends Api
|
|
{
|
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
/*
|
|
* 消息列表
|
|
*/
|
|
public function lists()
|
|
{
|
|
$userId = $this->auth->id;
|
|
$lists = FriendNotification::getNotificationList($userId);
|
|
$this->success('操作成功', $lists);
|
|
}
|
|
|
|
/*
|
|
* 消息设为已读
|
|
*/
|
|
public function red()
|
|
{
|
|
$userId = $this->auth->id;
|
|
$msg_id = $this->request->post('msg_id');
|
|
FriendNotification::markAsRead($msg_id, $userId);
|
|
$this->success('操作成功');
|
|
}
|
|
/*
|
|
* 获取未读消息数量
|
|
*/
|
|
public function count()
|
|
{
|
|
$userId = $this->auth->id;
|
|
$count = FriendNotification::getUnreadCount($userId);
|
|
$count_1 = FriendRequests::getNotification($userId);
|
|
|
|
|
|
$this->success('操作成功', ['msg_count'=>$count,'requests'=>$count_1]);
|
|
}
|
|
} |