初始化提交
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?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');
|
||||
$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/";
|
||||
}
|
||||
|
||||
// 获取用户数据
|
||||
$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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user