rabin 7 years ago
parent
commit
04e0743f68
5 changed files with 293 additions and 45 deletions
  1. 1 0
      content/database/focus.php
  2. 60 7
      content/database/meeting.php
  3. 118 0
      content/database/meeting_cate.php
  4. 98 21
      content/v1/Meeting.php
  5. 16 17
      content/v1/News.php

+ 1 - 0
content/database/focus.php

@@ -51,6 +51,7 @@ return array
 	# 显示给用户看的名称
 	'lang' => '首页焦点图',
 	'order' => 50,
+	'menu' => false,
 	# 数据结构
 	'struct' => array
 	(

+ 60 - 7
content/database/meeting.php

@@ -22,6 +22,17 @@ $info = function()
 	return $array;
 };
 
+$cate = function()
+{
+	$array = array();
+	$cate = Dever::load('content/meeting_cate-state');
+	if($cate)
+	{
+		$array += $cate;
+	}
+	return $array;
+};
+
 return array
 (
 	# 表名
@@ -69,6 +80,19 @@ return array
 			'list'		=> '{info_id} > 0 ? Dever::load("set/info-one#name", {info_id}) : "未知"',
 		),
 
+		'cate_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '会议分类',
+			'default' 	=> '1',
+			'desc' 		=> '请选择会议分类',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $cate,
+			'search'	=> 'select',
+			'list'		=> '{cate_id} > 0 ? Dever::load("content/meeting_cate-one#name", {cate_id}) : "未知"',
+		),
+
 		'desc'		=> array
 		(
 			'type' 		=> 'varchar-255',
@@ -78,7 +102,7 @@ return array
 			'match' 	=> 'option',
 			'update'	=> 'textarea',
 			'search'	=> 'fulltext',
-			'list'		=> true,
+			//'list'		=> true,
 		),
 		
 		'pic'		=> array
@@ -102,7 +126,7 @@ return array
 			'match' 	=> 'option',
 			'update'	=> 'text',
 			'search'	=> 'fulltext',
-			'list'		=> true,
+			//'list'		=> true,
 		),
 
 		'top'		=> array
@@ -124,7 +148,7 @@ return array
 			'match' 	=> 'is_numeric',
 			'desc' 		=> '开始时间',
 			'update'	=> 'date',
-			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+			'list'		=> 'date("Y-m-d H:i:s", {sdate})',
 			'callback'	=> 'maketime',
 		),
 
@@ -135,7 +159,7 @@ return array
 			'match' 	=> 'is_numeric',
 			'desc' 		=> '结束时间',
 			'update'	=> 'date',
-			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+			'list'		=> 'date("Y-m-d H:i:s", {edate})',
 			'callback'	=> 'maketime',
 		),
 
@@ -214,7 +238,23 @@ return array
 			'option' => array
 			(
 				'info_id' => 'yes',
-				'ids' => array('yes', '!='),
+				'cate_id' => 'yes',
+				'ids' => array('yes-id', '!='),
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'page' => array(10, 'list'),
+			'col' => '*',
+		),
+
+		'getOld' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'info_id' => 'yes',
+				'cate_id' => 'yes',
+				'end' => array('yes-edate', '<'),
 			),
 			'type' => 'all',
 			'order' => array('reorder' => 'desc', 'id' => 'desc'),
@@ -228,8 +268,21 @@ return array
 			'option' => array
 			(
 				'info_id' => 'yes',
-				'start' => array('yes-sdate', '>='),
-				'end' => array('yes-edate', '<='),
+				'start' => array('yes-sdate', '<='),
+				'end' => array('yes-edate', '>='),
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'col' => '*',
+		),
+
+		'getWei' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'info_id' => 'yes',
+				'start' => array('yes-sdate', '>'),
 			),
 			'type' => 'all',
 			'order' => array('reorder' => 'desc', 'id' => 'desc'),

+ 118 - 0
content/database/meeting_cate.php

@@ -0,0 +1,118 @@
+<?php
+
+$info = function()
+{
+	$array = array();
+	$info = Dever::load('set/info-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'meeting_cate',
+	# 显示给用户看的名称
+	'lang' => '会议分类管理',
+	'order' => 10,
+	# 数据结构
+	'struct' => array
+	(
+	
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '分类名称',
+			'default' 	=> '',
+			'desc' 		=> '分类名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'info_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属小程序',
+			'default' 	=> '1',
+			'desc' 		=> '请选择所属小程序',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $info,
+			'search'	=> 'select',
+			'list'		=> '{info_id} > 0 ? Dever::load("set/info-one#name", {info_id}) : "未知"',
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+	
+	# 管理功能
+	'manage' => array
+	(
+
+	),
+	
+	# request 请求接口定义
+	'request' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'col' => '*',
+		),
+	),
+);

+ 98 - 21
content/v1/Meeting.php

@@ -8,12 +8,12 @@ use Content\Lib\Base;
 class Meeting extends Base
 {
     /**
-     * @api {get} v1/meeting.list 会议列表
+     * @api {get} v1/meeting.index 会议首页
      * @apiVersion 1.0.0
-     * @apiName meeting.list
+     * @apiName meeting.index
      * @apiGroup Data
      *
-     * @apiDescription 小程序的会议列表接口
+     * @apiDescription 小程序的会议首页接口
      *
      * @apiParam {Number} appid 小程序id
      *
@@ -34,16 +34,19 @@ class Meeting extends Base
      * @apiSuccess {String}   focus.content  正在进行的听课内容
      * @apiSuccess {String}   focus.num_view  正在进行的阅读数
      * @apiSuccess {String}   focus.cdate  时间
+    *
+     * @apiSuccess {Object[]} cate 分类信息
+     * @apiSuccess {Number}   cate.id  分类id
+     * @apiSuccess {String}   cate.name  分类名称
      *
-     * @apiSuccess {Object[]} meeting 听课信息
-     * @apiSuccess {Number}   meeting.id  听课id
-     * @apiSuccess {String}   meeting.name  听课标题
-     * @apiSuccess {String}   meeting.num  听课人数
-     * @apiSuccess {String}   meeting.sdate  听课开始时间
-     * @apiSuccess {String}   meeting.edate  听课结束时间
-     * @apiSuccess {String}   meeting.content  听课内容
-     * @apiSuccess {String}   meeting.num_view  阅读数
-     * @apiSuccess {String}   meeting.cdate  时间
+     * @apiSuccess {Object[]} cate.meeting 会议信息
+     * @apiSuccess {Number}   cate.meeting.id  会议id
+     * @apiSuccess {String}   cate.meeting.name  会议标题
+     * @apiSuccess {String}   cate.meeting.num  会议人数
+     * @apiSuccess {String}   cate.meeting.sdate  会议开始时间
+     * @apiSuccess {String}   cate.meeting.edate  会议结束时间
+     * @apiSuccess {String}   cate.meeting.content  会议内容
+     * @apiSuccess {String}   cate.meeting.cdate  时间
      *
      * @apiSuccessExample 操作成功
      * {"status":1,"code":1,"msg":"success","data":{"info":{"id":"1","name":"\u7279\u8272\u5c0f\u9547\u600e\u4e48\u641e","cate_id":"1","logo":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg","title":"test","pic":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg","state":"1","cdate":"1521858466"},"meeting":[{"id":"1","name":"\u6d4b\u8bd5","info_id":"1","desc":"\u98a0\u4e09\u5012\u56db","pic":["http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg"],"top":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg","sdate":"1521734400","edate":"1537804800","content":"","reorder":"1","state":"1","cdate":"4\u5206\u949f\u524d"}]},"page":{"total":"1","current_page":1,"total_page":1,"next_page":1,"prev_page":1,"html":"","status":0}}
@@ -51,24 +54,98 @@ class Meeting extends Base
      * @apiErrorExample 操作失败
      * {"status":2,"code":1,"msg":"\u9519\u8bef\u7684\u5c0f\u7a0b\u5e8fid"}
      */
-    public function list_api()
+    public function index_api()
     {
         $time = time();
-        $this->data['focus'] = Dever::load('content/meeting-getCur', array('option_info_id' => $this->data['info']['id'], 'option_start' => $time, 'option_end' => $time));
+        $this->data['focus'] = array();
+
+        $wei = Dever::load('content/meeting-getWei', array('option_info_id' => $this->data['info']['id'], 'option_start' => $time));
+
+        $cur = Dever::load('content/meeting-getCur', array('option_info_id' => $this->data['info']['id'], 'option_start' => $time, 'option_end' => $time));
 
         $ids = array();
-        if ($this->data['focus']) {
-            foreach ($this->data['focus'] as $k => $v) {
-                $this->data['focus'][$k] = $this->one($v);
+        $i = 0;
+        if ($wei) {
+            foreach ($wei as $k => $v) {
+                $this->data['focus'][$i] = $this->one($v);
                 array_push($ids, $v['id']);
+                $i++;
             }
         }
 
-        $this->data['meeting'] = Dever::load('content/meeting-getAll', array('option_info_id' => $this->data['info']['id'], 'option_ids' => $ids));
+        if ($cur) {
+            foreach ($cur as $k => $v) {
+                $this->data['focus'][$i] = $this->one($v);
+                array_push($ids, $v['id']);
+                $i++;
+            }
+        }
+
+        $this->data['cate'] = Dever::load('content/meeting_cate-getAll', array('option_info_id' => $this->data['info']['id']));
+
+        if ($this->data['cate'] && isset($this->data['cate'][0])) {
+            $news = Dever::load('content/meeting-getAll', array('option_info_id' => $this->data['info']['id'], 'option_cate_id' => $this->data['cate'][0]['id'], 'option_ids' => $ids));
+
+            if ($news) {
+                foreach ($news as $k => $v) {
+                    $this->data['cate'][0]['meeting'][$k] = $this->one($v);
+                }
+            }
+        }
+
+        return $this->data;
+    }
+
+    /**
+     * @api {get} v1/meeting.list 会议列表
+     * @apiVersion 1.0.0
+     * @apiName meeting.list
+     * @apiGroup Data
+     *
+     * @apiDescription 小程序的会议列表接口
+     *
+     * @apiParam {Number} appid 小程序id
+     * @apiParam {Number} cateid 子栏目id
+     *
+     * @apiSuccess {Object[]} info 小程序基本信息
+     * @apiSuccess {Number}   info.id  小程序id
+     * @apiSuccess {String}   info.name  小程序名称
+     * @apiSuccess {Number}   info.cate_id  小程序所属栏目id
+     * @apiSuccess {String}   info.logo  小程序logo
+     * @apiSuccess {String}   info.title  首页标题
+     * @apiSuccess {String}   info.pic  首页头图
+     *
+     * @apiSuccess {Object[]} meeting 会议信息
+     * @apiSuccess {Number}   meeting.id  会议id
+     * @apiSuccess {String}   meeting.name  会议标题
+     * @apiSuccess {String}   meeting.num  会议人数
+     * @apiSuccess {String}   meeting.sdate  会议开始时间
+     * @apiSuccess {String}   meeting.edate  会议结束时间
+     * @apiSuccess {String}   meeting.content  会议内容
+     * @apiSuccess {String}   meeting.cdate  时间
+     *
+     * @apiSuccessExample 操作成功
+     * {"status":1,"code":1,"msg":"success","data":{"info":{"id":"1","name":"\u7279\u8272\u5c0f\u9547\u600e\u4e48\u641e","cate_id":"1","logo":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg","title":"test","pic":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg","state":"1","cdate":"1521858466"},"news":[{"id":"1","name":"\u4e07\u8fbe\u57ce\u521b\u65b0\u4e1a\u6001\u7814\u7a76\u62a5\u544a","pic":["http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg"],"top":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg","cate_id":"3","info_id":"1","author_id":"1","content":"<p>\u5730\u65b9\u5927\u5e45\u5ea6\u53d1<\/p>","num_view":"0","cdate":"9\u5c0f\u65f6\u524d","author":{"id":"1","name":"\u7a0b\u8302","pic":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg","state":"1","cdate":"1521858481"}}]},"page":{"total":"1","current_page":1,"total_page":1,"next_page":1,"prev_page":1,"html":"","status":0}}
+     *
+     * @apiErrorExample 操作失败
+     * {"status":2,"code":1,"msg":"\u9519\u8bef\u7684\u5c0f\u7a0b\u5e8fid"}
+     */
+    public function list_api()
+    {
+        $cateid = Dever::input('cateid');
+
+        if ($cateid > 0) {
+            $cate = Dever::load('content/meeting_cate-one', $cateid);
+
+            if ($cate) {
+                $this->data['meeting'] = Dever::load('content/meeting-getOld', array('option_info_id' => $this->data['info']['id'], 'option_cate_id' => $cate['id'], 'option_end' => time()));
+                //echo Dever::sql();die;
 
-        if ($this->data['meeting']) {
-            foreach ($this->data['meeting'] as $k => $v) {
-                $this->data['meeting'][$k] = $this->one($v);
+                if ($this->data['meeting']) {
+                    foreach ($this->data['meeting'] as $k => $v) {
+                        $this->data['meeting'][$k] = $this->one($v);
+                    }
+                }
             }
         }
 

+ 16 - 17
content/v1/News.php

@@ -45,20 +45,20 @@ class News extends Base
      * @apiSuccess {String}   cate_child.name  栏目名称
      * @apiSuccess {Number}   cate_child.cate_id  上级栏目id
      *
-     * @apiSuccess {Object[]} news 资讯信息
-     * @apiSuccess {Number}   news.id  资讯id
-     * @apiSuccess {String}   news.name  资讯标题
-     * @apiSuccess {String}   news.reading  资讯导读
-     * @apiSuccess {String}   news.content  资讯内容
-     * @apiSuccess {String}   news.num_view  阅读数
-     * @apiSuccess {String}   news.num_review  评论数
-     * @apiSuccess {String}   news.num_up  赞数
-     * @apiSuccess {String}   news.cdate  时间
-     *
-     * @apiSuccess {Object[]} news.author 作者信息
-     * @apiSuccess {Number}   news.author.id  作者id
-     * @apiSuccess {String}   news.author.name  作者姓名
-     * @apiSuccess {String}   news.author.pic  作者头像
+     * @apiSuccess {Object[]} cate_child.news 资讯信息
+     * @apiSuccess {Number}   cate_child.news.id  资讯id
+     * @apiSuccess {String}   cate_child.news.name  资讯标题
+     * @apiSuccess {String}   cate_child.news.reading  资讯导读
+     * @apiSuccess {String}   cate_child.news.content  资讯内容
+     * @apiSuccess {String}   cate_child.news.num_view  阅读数
+     * @apiSuccess {String}   cate_child.news.num_review  评论数
+     * @apiSuccess {String}   cate_child.news.num_up  赞数
+     * @apiSuccess {String}   cate_child.news.cdate  时间
+     *
+     * @apiSuccess {Object[]} cate_child.news.author 作者信息
+     * @apiSuccess {Number}   cate_child.news.author.id  作者id
+     * @apiSuccess {String}   cate_child.news.author.name  作者姓名
+     * @apiSuccess {String}   cate_child.news.author.pic  作者头像
      *
      * @apiSuccessExample 操作成功
      * {"status":1,"code":1,"msg":"success","data":{"info":{"id":"1","name":"\u7279\u8272\u5c0f\u9547\u600e\u4e48\u641e","cate_id":"1","logo":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg","title":"test","pic":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg","state":"1","cdate":"1521858466"},"cate":{"id":"1","name":"\u7279\u8272\u5c0f\u9547\u4e0d\u5f97\u4e0d\u5b66\u4e60\u7cfb\u5217","cate_id":"-1","reorder":"1","state":"1","cdate":"1521814022"},"cate_child":[{"id":"3","name":"\u5341\u5927\u6848\u4f8b","cate_id":"1","reorder":"1","state":"1","cdate":"1521858511","news":[{"id":"1","name":"\u4e07\u8fbe\u57ce\u521b\u65b0\u4e1a\u6001\u7814\u7a76\u62a5\u544a","pic":["http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg"],"top":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg","cate_id":"3","info_id":"1","author_id":"1","content":"<p>\u5730\u65b9\u5927\u5e45\u5ea6\u53d1<\/p>","num_view":"0","cdate":"9\u5c0f\u65f6\u524d","author":{"id":"1","name":"\u7a0b\u8302","pic":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg","state":"1","cdate":"1521858481"}}]},{"id":"2","name":"\u5341\u5927\u680f\u76ee","cate_id":"1","reorder":"1","state":"1","cdate":"1521858505"}]},"page":{"total":"1","current_page":1,"total_page":1,"next_page":1,"prev_page":1,"html":"","status":0}}
@@ -73,16 +73,15 @@ class News extends Base
 
         if ($this->data['cate']) {
             # 获取焦点图
-            $this->focus($this->data['cate']['id']);
+            //$this->focus($this->data['cate']['id']);
 
             $this->data['cate_child'] = Dever::load('set/cate-getAll', array('option_cate_id' => $this->data['cate']['id']));
-            $this->data['news'] = array();
             if ($this->data['cate_child'] && isset($this->data['cate_child'][0])) {
                 $news = Dever::load('content/news-getAll', array('option_info_id' => $this->data['info']['id'], 'option_cate_id' => $this->data['cate_child'][0]['id']));
 
                 if ($news) {
                     foreach ($news as $k => $v) {
-                        $this->data['news'][$k] = $this->one($v);
+                        $this->data['cate_child'][0]['news'][$k] = $this->one($v);
                     }
                 }
             }