rabin 7 years ago
parent
commit
a40a04dcda

+ 2 - 58
content/database/focus.php

@@ -220,64 +220,8 @@ return array
 			),
 			'type' => 'all',
 			'order' => array('reorder' => 'desc', 'id' => 'desc'),
-			'page' => array(10, 'list'),
-			'col' => 'id, name, pic, top, cate_id, info_id, author_id, content, (num_view+num_add_view) as num_view, cdate',
-		),
-		
-		# 更新浏览量
-		'addView' => array
-		(
-			'type' => 'update',
-			'where' => array
-			(
-				'id' => 'yes',
-			),
-			'set' => array
-			(
-				'num_view' => array('1', '+='),
-			),
-		),
-		
-		# 更新回复数
-		'addReview' => array
-		(
-			'type' => 'update',
-			'where' => array
-			(
-				'id' => 'yes',
-			),
-			'set' => array
-			(
-				'num_review' => array('1', '+='),
-			),
-		),
-		
-		# 更新点赞数
-		'addUp' => array
-		(
-			'type' => 'update',
-			'where' => array
-			(
-				'id' => 'yes',
-			),
-			'set' => array
-			(
-				'num_up' => array('1', '+='),
-			),
-		),
-		
-		# 更新点赞数
-		'desUp' => array
-		(
-			'type' => 'update',
-			'where' => array
-			(
-				'id' => 'yes',
-			),
-			'set' => array
-			(
-				'num_up' => array('1', '-='),
-			),
+			'limit' => '0,3',
+			'col' => '*',
 		),
 	),
 );

+ 15 - 0
content/database/meeting.php

@@ -201,11 +201,26 @@ return array
 			'option' => array
 			(
 				'info_id' => 'yes',
+				'ids' => array('yes', '!='),
 			),
 			'type' => 'all',
 			'order' => array('reorder' => 'desc', 'id' => 'desc'),
 			'page' => array(10, 'list'),
 			'col' => '*',
 		),
+
+		'getCur' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'info_id' => 'yes',
+				'start' => array('yes-sdate', '>='),
+				'end' => array('yes-edate', '<='),
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'col' => '*',
+		),
 	),
 );

+ 2 - 2
content/v1/Course.php

@@ -47,9 +47,9 @@ class Course extends Base
      */
     public function list_api()
     {
-        $course = Dever::load('content/course-getAll', array('option_info_id' => $this->data['info']['id']));
+        $this->data['course'] = Dever::load('content/course-getAll', array('option_info_id' => $this->data['info']['id']));
 
-        if ($course) {
+        if ($this->data['course']) {
             foreach ($course as $k => $v) {
                 $this->data['course'][$k] = $this->one($v);
             }

+ 28 - 0
content/v1/Login.php

@@ -6,6 +6,34 @@ use Dever;
 
 class Login
 {
+    /**
+     * @api {get} common 公共参数
+     * @apiVersion 1.0.0
+     * @apiName common
+     * @apiGroup Common
+     *
+     * @apiDescription 介绍公共参数
+     *
+     * @apiParam {Number} json 是否返回json格式的数据1为返回2为不返回
+     *
+     * @apiSuccess {Number}   status  状态,1为有效2为无效
+     * @apiSuccess {String}   msg 请求的数据是否成功的提示
+     * @apiSuccess {String}   data 如果status为1,data有值
+     * @apiSuccess {Object[]}   page 分页信息
+     * @apiSuccess {Number}   page.total 分页总数
+     * @apiSuccess {Number}   page.current_page 当前页
+     * @apiSuccess {Number}   page.total_page 总页数
+     * @apiSuccess {Number}   page.next_page 下一页
+     * @apiSuccess {Number}   page.prev_page 上一页
+     * @apiSuccess {Number}   page.status 是否有下一页数据,0为没有
+     *
+     * @apiSuccessExample 操作成功
+     * {"status":1,"code":1,"msg":"success","data":{"uid":1,"session":"111"}}
+     *
+     * @apiErrorExample 操作失败
+     * {"status":2,"code":1,"msg":"\u9519\u8bef\u7684\u5c0f\u7a0b\u5e8fid"}
+     */
+
     /**
      * @api {get} v1/login.bind 用户登录
      * @apiVersion 1.0.0

+ 21 - 3
content/v1/Meeting.php

@@ -25,6 +25,13 @@ class Meeting extends Base
      * @apiSuccess {String}   info.title  首页标题
      * @apiSuccess {String}   info.pic  首页头图
      *
+     * @apiSuccess {Object[]} focus 正在进行的听课信息
+     * @apiSuccess {Number}   focus.id  正在进行的听课id
+     * @apiSuccess {String}   focus.name  正在进行的听课标题
+     * @apiSuccess {String}   focus.content  正在进行的听课内容
+     * @apiSuccess {String}   focus.num_view  正在进行的阅读数
+     * @apiSuccess {String}   focus.cdate  时间
+     *
      * @apiSuccess {Object[]} meeting 听课信息
      * @apiSuccess {Number}   meeting.id  听课id
      * @apiSuccess {String}   meeting.name  听课标题
@@ -40,10 +47,21 @@ class Meeting extends Base
      */
     public function list_api()
     {
-        $meeting = Dever::load('content/meeting-getAll', array('option_info_id' => $this->data['info']['id']));
+        $time = time();
+        $this->data['focus'] = 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);
+                array_push($ids, $v['id']);
+            }
+        }
+
+        $this->data['meeting'] = Dever::load('content/meeting-getAll', array('option_info_id' => $this->data['info']['id'], 'option_ids' => $ids));
 
-        if ($meeting) {
-            foreach ($meeting as $k => $v) {
+        if ($this->data['meeting']) {
+            foreach ($this->data['meeting'] as $k => $v) {
                 $this->data['meeting'][$k] = $this->one($v);
             }
         }

+ 26 - 3
content/v1/News.php

@@ -31,6 +31,14 @@ class News extends Base
      * @apiSuccess {Object[]} cate 主栏目信息
      * @apiSuccess {Number}   cate.id  栏目id
      * @apiSuccess {String}   cate.name  栏目名称
+
+     * @apiSuccess {Object[]} focus 头部焦点图信息
+     * @apiSuccess {Number}   focus.id  焦点图id
+     * @apiSuccess {String}   focus.name  焦点图名称
+     * @apiSuccess {String}   focus.subname  焦点图子标题
+     * @apiSuccess {String}   focus.pic  焦点图图片
+     * @apiSuccess {Number}   focus.cate_id  栏目id
+     * @apiSuccess {Number}   focus.news_id  资讯id
      *
      * @apiSuccess {Object[]} cate_child 子栏目信息
      * @apiSuccess {Number}   cate_child.id  栏目id
@@ -61,6 +69,9 @@ class News extends Base
         $this->data['cate'] = Dever::load('set/cate-one', $this->data['info']['cate_id']);
 
         if ($this->data['cate']) {
+            # 获取焦点图
+            $this->focus($this->data['cate']['id']);
+
             $this->data['cate_child'] = Dever::load('set/cate-getAll', array('option_cate_id' => $this->data['cate']['id']));
 
             if ($this->data['cate_child'] && isset($this->data['cate_child'][0])) {
@@ -77,6 +88,17 @@ class News extends Base
         return $this->data;
     }
 
+    private function focus($cate)
+    {
+        $this->data['focus'] = Dever::load('content/focus-getAll', array('option_cate_id_parent' => $cate));
+
+        if ($this->data['focus']) {
+            foreach ($this->data['focus'] as $k => $v) {
+                $this->data['focus'][$k]['pic'] = $this->replacePic($v['pic']);
+            }
+        } 
+    }
+
     /**
      * @api {get} v1/news.list 资讯列表
      * @apiVersion 1.0.0
@@ -99,6 +121,7 @@ class News extends Base
      * @apiSuccess {Object[]} news 资讯信息
      * @apiSuccess {Number}   news.id  资讯id
      * @apiSuccess {String}   news.name  资讯标题
+     * @apiSuccess {String}   news.name  资讯子标题
      * @apiSuccess {String}   news.content  资讯内容
      * @apiSuccess {String}   news.num_view  阅读数
      * @apiSuccess {String}   news.cdate  时间
@@ -122,10 +145,10 @@ class News extends Base
             $cate = Dever::load('set/cate-one', $cateid);
 
             if ($cate) {
-                $news = Dever::load('content/news-getAll', array('option_info_id' => $this->data['info']['id'], 'option_cate_id' => $cate['id']));
+                $this->data['news'] = Dever::load('content/news-getAll', array('option_info_id' => $this->data['info']['id'], 'option_cate_id' => $cate['id']));
 
-                if ($news) {
-                    foreach ($news as $k => $v) {
+                if ($this->data['news']) {
+                    foreach ($this->data['news'] as $k => $v) {
                         $this->data['news'][$k] = $this->one($v);
                     }
                 }