ソースを参照

设置允许与不允许方法

shishao-home 6 年 前
コミット
55687c0d64

+ 2 - 0
app/business/controllers/AdController.php

@@ -3,5 +3,7 @@ namespace business\controllers;
 
 class AdController extends BaseController
 {
+    //list,view,create,update,delete,options
     protected $service = '\biz\ad\services\AdService';
+    protected $notAllowActions = ['delete'];
 }

+ 9 - 0
app/business/controllers/BaseController.php

@@ -39,6 +39,9 @@ class BaseController extends PublicController
 	public $validate = true;
 
     protected $service;
+    // 设置允许与不允许方法 shizq 2019-12-05
+    protected $allowActions = [];
+    protected $notAllowActions = [];
 	
 	public function beforeAction($action)
 	{
@@ -48,6 +51,12 @@ class BaseController extends PublicController
 		if (empty($adminId)) {
 			$this->validate = false;
 		}
+
+		//方法开放设置 shizq 2019-12-05
+        if (in_array($action->id, $this->notAllowActions)) {
+            util::fail($action->id . ' not allow');
+        }
+
 		//游客可以访问的方法
 		if (in_array($action->id, $this->withoutLogin)) {
 			$this->validate = true;