作者 lyh

变更数据

... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Exceptions\AsideGlobalException;
use App\Http\Controllers\Controller;
use App\Models\Project\Project;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Exceptions\HttpResponseException;
... ... @@ -32,9 +33,7 @@ class BaseController extends Controller
{
$this->request = $request;
$this->param = $this->request->all();
// if(isset($this->param['id'])){
//
// }
$this->handleIdAndProjectId();
$this->token = $this->request->header('token');
$this->getParam();
$info = Cache::get(Common::MANAGE_TOKEN . $this->token);
... ... @@ -45,6 +44,42 @@ class BaseController extends Controller
}
}
/**
* @remark :project_id+id处理
* @name :handleIdAndProjectId
* @author :lyh
* @method :post
* @time :2025/11/6 09:16
*/
public function handleIdAndProjectId()
{
if(isset($this->param['id']) && !empty($this->param['id'])){
if (preg_match('/^[A-Za-z]/', $this->param['id'])) {
$id = Cache::get('project_'.$this->param['id']);
if(empty($id)){
$projectModel = new Project();
$id = $projectModel->getValue(['post_id' => $this->param['id']],'id');
if(!empty($id)){
Cache::add('project_'.$this->param['id'], $id, 3600 * 12);
}
}
$this->param['id'] = $id;
}
}
if(isset($this->param['project_id']) && !empty($this->param['project_id'])){
if (preg_match('/^[A-Za-z]/', $this->param['project_id'])) {
$id = Cache::get('project_'.$this->param['project_id']);
if(empty($id)){
$projectModel = new Project();
$id = $projectModel->getValue(['post_id' => $this->param['project_id']],'id');
if(!empty($id)){
Cache::add('project_'.$this->param['project_id'], $id, 3600 * 12);
}
}
$this->param['id'] = $id;
}
}
}
/**
* @remark :请求参数处理
... ...