You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use app\admin\service\NoticeService;
|
|
|
|
class Notice extends AdminBaseController
|
|
{
|
|
// 弹窗通知消息
|
|
public function popUp()
|
|
{
|
|
$returnData = (new NoticeService())->popUp($this->request->param());
|
|
return json($returnData);
|
|
}
|
|
|
|
// 使用Pusher服务推送系统消息
|
|
public function pushMessage()
|
|
{
|
|
$param = $this->request->param();
|
|
if (empty($param['title']) || empty($param['body'])) {
|
|
return json([
|
|
'code' => 400,
|
|
'message' => "缺少参数",
|
|
'data' => []
|
|
]);
|
|
}
|
|
|
|
$interestName = ["admin-popup-push"]; // 订阅兴趣的名称, 一次推送最多100个兴趣名称
|
|
$title = "";
|
|
$body = "";
|
|
$res = (new \app\utility\Pusher())->publishToInterest($interestName, $title, $body);
|
|
return json([
|
|
'code' => 0,
|
|
'message' => 'ok',
|
|
'data' => $res
|
|
]);
|
|
}
|
|
|
|
// 生成Beams身份验证令牌
|
|
public function generateToken()
|
|
{
|
|
$param = $this->request->param();
|
|
if (empty($param['user_id'])) {
|
|
return json([
|
|
'code' => 400,
|
|
'message' => "缺少参数",
|
|
'data' => []
|
|
]);
|
|
}
|
|
$token = (new \app\utility\Pusher())->generateToken($param['user_id']);
|
|
return json([
|
|
'code' => 0,
|
|
'message' => 'ok',
|
|
'data' => [
|
|
'token' => $token
|
|
]
|
|
]);
|
|
}
|
|
}
|