dever 6 years ago
parent
commit
0e59028bc9
3 changed files with 24 additions and 9 deletions
  1. 9 1
      doc/apidoc.php
  2. 1 1
      journal/database/cate.php
  3. 14 7
      main/src/Journal.php

+ 9 - 1
doc/apidoc.php

@@ -931,7 +931,7 @@
  * @apiDescription 小刊列表,按照分类读取
  *
  * @apiParam {String} signature signature
- * @apiParam {String} system 分类id
+ * @apiParam {String} system 分类id,默认为1,传入-1就是获取全部
  *
  * @apiSuccess {Object[]} journal 小刊数据列表
  * @apiSuccess {String}   journal.id 小刊id
@@ -952,6 +952,14 @@
  * @apiSuccess {String}   push.id 小刊id
  * @apiSuccess {String}   push.name 名称
  * @apiSuccess {String}   push.num_ding 订阅数
+
+ * @apiSuccess {Object[]} cate 当前分类
+ * @apiSuccess {String}   cate.id 分类id
+ * @apiSuccess {String}   cate.name 名称
+
+ * @apiSuccess {Object[]} cateList 分类列表
+ * @apiSuccess {String}   cateList.id 分类id
+ * @apiSuccess {String}   cateList.name 名称
  */
 
 /**

+ 1 - 1
journal/database/cate.php

@@ -240,7 +240,7 @@ return array
             ),
             'type' => 'all',
             'order' => array('reorder' => 'desc','id' => 'desc'),
-            'col' => '*',
+            'col' => 'id,name',
         ),
 
         'getIds' => array

+ 14 - 7
main/src/Journal.php

@@ -14,13 +14,11 @@ class Journal extends Core
         $cate = array();
         if ($id > 0) {
             $cate = Dever::db('journal/cate')->one($id);
+            $this->data['cate'] = $cate;
         }
 
-        if (!$cate) {
-            Dever::alert('分类错误');
-        }
-
-        $this->data['cate'] = $cate;
+        $cateList = Dever::db('journal/cate')->getAll();
+        $this->data['cateList'] = $cateList;
 
         return $cate;
     }
@@ -35,7 +33,9 @@ class Journal extends Core
 
         # 小刊列表
         $where = array();
-        $where['cate_id'] = $cate['id'];
+        if (isset($cate['id'])) {
+            $where['cate_id'] = $cate['id'];
+        }
         if (checkVersion()->journal_buy == 2) {
             # 隐藏支付的小刊
             //$where['buy'] = 2;
@@ -64,7 +64,10 @@ class Journal extends Core
 
         # 小刊列表
         $where = array();
-        $where['cate_id'] = $cate['id'];
+        if (isset($cate['id'])) {
+            $where['cate_id'] = $cate['id'];
+        }
+        
         $data = Dever::db('journal/info')->getAllByPage($where);
         if ($data) {
             foreach ($data as $k => $v) {
@@ -87,6 +90,10 @@ class Journal extends Core
 
         $cate = $this->getCate();
 
+        if (!$cate) {
+            Dever::alert('错误的信息');
+        }
+
         $this->data['push'] = Dever::db('journal/info')->getOne($cate['journal_id']);
 
         $this->data['push'] = $this->ding($this->data['push']);