正在显示
1 个修改的文件
包含
38 行增加
和
3 行删除
| @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Enums\Common\Common; | 6 | use App\Enums\Common\Common; |
| 7 | use App\Exceptions\AsideGlobalException; | 7 | use App\Exceptions\AsideGlobalException; |
| 8 | use App\Http\Controllers\Controller; | 8 | use App\Http\Controllers\Controller; |
| 9 | +use App\Models\Project\Project; | ||
| 9 | use Illuminate\Http\JsonResponse; | 10 | use Illuminate\Http\JsonResponse; |
| 10 | use Illuminate\Http\Request; | 11 | use Illuminate\Http\Request; |
| 11 | use Illuminate\Http\Exceptions\HttpResponseException; | 12 | use Illuminate\Http\Exceptions\HttpResponseException; |
| @@ -32,9 +33,7 @@ class BaseController extends Controller | @@ -32,9 +33,7 @@ class BaseController extends Controller | ||
| 32 | { | 33 | { |
| 33 | $this->request = $request; | 34 | $this->request = $request; |
| 34 | $this->param = $this->request->all(); | 35 | $this->param = $this->request->all(); |
| 35 | -// if(isset($this->param['id'])){ | ||
| 36 | -// | ||
| 37 | -// } | 36 | + $this->handleIdAndProjectId(); |
| 38 | $this->token = $this->request->header('token'); | 37 | $this->token = $this->request->header('token'); |
| 39 | $this->getParam(); | 38 | $this->getParam(); |
| 40 | $info = Cache::get(Common::MANAGE_TOKEN . $this->token); | 39 | $info = Cache::get(Common::MANAGE_TOKEN . $this->token); |
| @@ -45,6 +44,42 @@ class BaseController extends Controller | @@ -45,6 +44,42 @@ class BaseController extends Controller | ||
| 45 | } | 44 | } |
| 46 | } | 45 | } |
| 47 | 46 | ||
| 47 | + /** | ||
| 48 | + * @remark :project_id+id处理 | ||
| 49 | + * @name :handleIdAndProjectId | ||
| 50 | + * @author :lyh | ||
| 51 | + * @method :post | ||
| 52 | + * @time :2025/11/6 09:16 | ||
| 53 | + */ | ||
| 54 | + public function handleIdAndProjectId() | ||
| 55 | + { | ||
| 56 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 57 | + if (preg_match('/^[A-Za-z]/', $this->param['id'])) { | ||
| 58 | + $id = Cache::get('project_'.$this->param['id']); | ||
| 59 | + if(empty($id)){ | ||
| 60 | + $projectModel = new Project(); | ||
| 61 | + $id = $projectModel->getValue(['post_id' => $this->param['id']],'id'); | ||
| 62 | + if(!empty($id)){ | ||
| 63 | + Cache::add('project_'.$this->param['id'], $id, 3600 * 12); | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + $this->param['id'] = $id; | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + if(isset($this->param['project_id']) && !empty($this->param['project_id'])){ | ||
| 70 | + if (preg_match('/^[A-Za-z]/', $this->param['project_id'])) { | ||
| 71 | + $id = Cache::get('project_'.$this->param['project_id']); | ||
| 72 | + if(empty($id)){ | ||
| 73 | + $projectModel = new Project(); | ||
| 74 | + $id = $projectModel->getValue(['post_id' => $this->param['project_id']],'id'); | ||
| 75 | + if(!empty($id)){ | ||
| 76 | + Cache::add('project_'.$this->param['project_id'], $id, 3600 * 12); | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + $this->param['id'] = $id; | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + } | ||
| 48 | 83 | ||
| 49 | /** | 84 | /** |
| 50 | * @remark :请求参数处理 | 85 | * @remark :请求参数处理 |
-
请 注册 或 登录 后发表评论