53 lines
1.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Model\User as UserModel;
|
|
use Extend\Alibaba\Oss;
|
|
|
|
/**
|
|
* 安全服务
|
|
*/
|
|
class SafeService extends BaseService
|
|
{
|
|
/**
|
|
* 获取oss签名数据
|
|
* @return array
|
|
*/
|
|
public function getOssSign(): array
|
|
{
|
|
$user_type = $this->request->input('user_type');
|
|
$path = $this->request->input('path');
|
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
|
|
|
if (empty($user_info)){
|
|
return fail();
|
|
}
|
|
|
|
if ($user_type == 1){
|
|
$dir = "applet/patient/";
|
|
}elseif ($user_type == 2){
|
|
$dir = "applet/doctor/";
|
|
}elseif ($user_type == 3){
|
|
$dir = "applet/pharmacist/";
|
|
}
|
|
|
|
$dir = $dir . $path;
|
|
|
|
// 获取用户数据
|
|
$params = array();
|
|
$params['user_id'] = $user_info['user_id'];
|
|
$user = UserModel::getOne($params);
|
|
if (empty($user)){
|
|
return fail();
|
|
}
|
|
|
|
if ($user['user_type'] != $user_info['user_type']){
|
|
return fail();
|
|
}
|
|
|
|
$oss = new Oss();
|
|
|
|
return success($oss->signature($dir));
|
|
}
|
|
} |