p2 project
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.

28 lines
931 B

1 month ago
<?php
namespace app\home\service;
use app\model\UserModel;
class NoticeService extends BaseHomeService
{
public function generateToken($param): array
{
try {
if (empty($param['user_id'])) {
return $this->toData('400', lang('parameter_error'));
}
// 检查用户信息
$user = UserModel::where(['user_id'=>$param['user_id']])->find();
if (empty($user)) {
return $this->toData('500', '用户信息不存在');
}
// 生成Beams身份验证令牌
$token = (new \app\utility\Pusher())->generateToken($param['user_id']);
return $this->toData('0', 'ok', [
'token' => $token
]);
} catch (\Exception $exception) {
return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]);
}
}
}