|
|
@@ -20,12 +20,12 @@ class BaseController extends PublicController
|
|
|
public $isLogin = false;
|
|
|
public $withoutLogin = [];//不需要登陆的方法名
|
|
|
public $validate = true;
|
|
|
-
|
|
|
+
|
|
|
// Service 模型实例
|
|
|
- protected $service;
|
|
|
- // 设置允许与不允许方法 shizq 2019-12-05
|
|
|
- protected $allowActions = [];
|
|
|
- protected $notAllowActions = [];
|
|
|
+ protected $service;
|
|
|
+ // 设置允许与不允许方法 shizq 2019-12-05
|
|
|
+ protected $allowActions = [];
|
|
|
+ protected $notAllowActions = [];
|
|
|
|
|
|
public function beforeAction($action)
|
|
|
{
|
|
|
@@ -35,12 +35,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->notAllowActions)) {
|
|
|
+ util::fail($action->id . ' not allow');
|
|
|
+ }
|
|
|
+
|
|
|
//游客可以访问的方法
|
|
|
if (in_array($action->id, $this->withoutLogin)) {
|
|
|
$this->validate = true;
|
|
|
@@ -52,8 +52,7 @@ class BaseController extends PublicController
|
|
|
if (empty($admin)) {
|
|
|
util::fail('没有找到管理员');
|
|
|
}
|
|
|
- $merchantId = 12358;
|
|
|
- //$merchantId = AdminToMerchantService::getDefaultMerchant($adminId);
|
|
|
+ $merchantId = $admin['merchantId'];
|
|
|
if (empty($merchantId)) {
|
|
|
util::fail('没有找到商家信息');
|
|
|
}
|
|
|
@@ -74,59 +73,59 @@ class BaseController extends PublicController
|
|
|
$this->merchantAsset = $merchantAsset;
|
|
|
return parent::beforeAction($action);
|
|
|
}
|
|
|
-
|
|
|
- public function actionList()
|
|
|
- {
|
|
|
- $numargs = func_num_args();
|
|
|
- $select = $numargs >= 1 ? func_get_arg(0) : '*';
|
|
|
- $where = $numargs >= 2 ? func_get_arg(1) : null;
|
|
|
- $order = $numargs >= 3 ? func_get_arg(2) : '';
|
|
|
- $with = $numargs >= 4 ? func_get_arg(3) : '';
|
|
|
-
|
|
|
- $service = $this->service;
|
|
|
- $list = $service::getList($select, $where, $order, $with);
|
|
|
- util::success($list);
|
|
|
- }
|
|
|
-
|
|
|
- public function actionAdd()
|
|
|
- {
|
|
|
- $data = Yii::$app->request->post();
|
|
|
- $service = $this->service;
|
|
|
- $re = $service::add($data);
|
|
|
- util::success($re);
|
|
|
- }
|
|
|
-
|
|
|
- public function actionDetail()
|
|
|
- {
|
|
|
- $id = Yii::$app->request->get('id');
|
|
|
- $service = $this->service;
|
|
|
- $data = $service::getById($id);
|
|
|
- if(!empty($data)){
|
|
|
- util::success($data);
|
|
|
- }
|
|
|
-
|
|
|
- util::fail('');
|
|
|
- }
|
|
|
-
|
|
|
- public function actionUpdate()
|
|
|
- {
|
|
|
- $data = Yii::$app->request->post();
|
|
|
- $id = $data['id'];
|
|
|
- $service = $this->service;
|
|
|
- $re = $service::updateById($id, $data);
|
|
|
- if($re['status'] === true){
|
|
|
- util::success($re);
|
|
|
- }
|
|
|
-
|
|
|
- util::fail();
|
|
|
- }
|
|
|
-
|
|
|
- public function actionDelete()
|
|
|
- {
|
|
|
- $id = Yii::$app->request->get('id');
|
|
|
- $service = $this->service;
|
|
|
- $service::deleteById($id);
|
|
|
- util::success([],'删除成功');
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ public function actionList()
|
|
|
+ {
|
|
|
+ $numargs = func_num_args();
|
|
|
+ $select = $numargs >= 1 ? func_get_arg(0) : '*';
|
|
|
+ $where = $numargs >= 2 ? func_get_arg(1) : null;
|
|
|
+ $order = $numargs >= 3 ? func_get_arg(2) : '';
|
|
|
+ $with = $numargs >= 4 ? func_get_arg(3) : '';
|
|
|
+
|
|
|
+ $service = $this->service;
|
|
|
+ $list = $service::getList($select, $where, $order, $with);
|
|
|
+ util::success($list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function actionAdd()
|
|
|
+ {
|
|
|
+ $data = Yii::$app->request->post();
|
|
|
+ $service = $this->service;
|
|
|
+ $re = $service::add($data);
|
|
|
+ util::success($re);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function actionDetail()
|
|
|
+ {
|
|
|
+ $id = Yii::$app->request->get('id');
|
|
|
+ $service = $this->service;
|
|
|
+ $data = $service::getById($id);
|
|
|
+ if (!empty($data)) {
|
|
|
+ util::success($data);
|
|
|
+ }
|
|
|
+
|
|
|
+ util::fail('');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function actionUpdate()
|
|
|
+ {
|
|
|
+ $data = Yii::$app->request->post();
|
|
|
+ $id = $data['id'];
|
|
|
+ $service = $this->service;
|
|
|
+ $re = $service::updateById($id, $data);
|
|
|
+ if ($re['status'] === true) {
|
|
|
+ util::success($re);
|
|
|
+ }
|
|
|
+
|
|
|
+ util::fail();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function actionDelete()
|
|
|
+ {
|
|
|
+ $id = Yii::$app->request->get('id');
|
|
|
+ $service = $this->service;
|
|
|
+ $service::deleteById($id);
|
|
|
+ util::success([], '删除成功');
|
|
|
+ }
|
|
|
+
|
|
|
}
|