Kirin 1 주 전
부모
커밋
891f3f7a10
2개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      app/common/AdminBaseController.php
  2. 1 0
      qiniu/command/stubs/controller.stub

+ 4 - 2
app/common/AdminBaseController.php

@@ -51,6 +51,8 @@ abstract class AdminBaseController extends BaseController
 
     protected $service = null;
 
+    protected $with = [];
+
     /**
      * 初始化
      */
@@ -76,7 +78,7 @@ abstract class AdminBaseController extends BaseController
         }
         $where = $this->request->getMore($this->searchable, false, $this->searchDeal);
         list($page, $limit) = $this->service->getPageValue();
-        $list = $this->service->getList($where, '*', $page, $limit);
+        $list = $this->service->getList($where, '*', $page, $limit, $this->with);
         $count = $this->service->getCount($where);
         return $this->success(compact('list', 'count'));
     }
@@ -87,7 +89,7 @@ abstract class AdminBaseController extends BaseController
         if (!$this->service) {
             throw new AdminException('接口不存在');
         }
-        $info = $this->service->get($id);
+        $info = $this->service->get($id, '*', $this->with);
         if (!$info)
             return $this->error('数据不存在');
         return $this->success('ok', $info->toArray());

+ 1 - 0
qiniu/command/stubs/controller.stub

@@ -31,6 +31,7 @@ class {%controllerName%} extends AdminBaseController
         parent::__construct($request);
         $this->service = $services;
         $this->validate = $validate;
+        $this->with = [];
         $this->searchable = [
     {%searchFieldAttr%}
         ];