rabin 7 年之前
父节点
当前提交
14dd8d0c0a
共有 2 个文件被更改,包括 42 次插入3 次删除
  1. 28 3
      content/database/course.php
  2. 14 0
      content/v1/Course.php

+ 28 - 3
content/database/course.php

@@ -125,7 +125,7 @@ return array
 			'desc' 		=> '请填写赞数',
 			'match' 	=> 'option',
 			//'search'	=> 'order',
-			'list'		=> '"赞数:{num_up}<br />浏览量:{num_view}+{num_add_view}<br />回复数:{num_review}<br />"',
+			'list'		=> '"赞数:{num_up}<br />浏览量:{num_view}+{num_add_view}<br />观看人数:{num_watch}<br />回复数:{num_review}<br />"',
 			'list_name'	=> '统计数字',
 		),
 		
@@ -136,7 +136,18 @@ return array
 			'default' 	=> '0',
 			'desc' 		=> '请填写浏览量pv',
 			'match' 	=> 'option',
-			'search'	=> 'order',
+			//'search'	=> 'order',
+			//'list'		=> '{num_view}+{num_add_view}',
+		),
+
+		'num_watch'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '观看数',
+			'default' 	=> '0',
+			'desc' 		=> '观看数',
+			'match' 	=> 'option',
+			//'search'	=> 'order',
 			//'list'		=> '{num_view}+{num_add_view}',
 		),
 		
@@ -146,7 +157,7 @@ return array
 			'name' 		=> '回复数',
 			'default' 	=> '0',
 			'desc' 		=> '请填写回复数',
-			'search'	=> 'order',
+			//'search'	=> 'order',
 			'match' 	=> 'option',
 			//'list'		=> true,
 		),
@@ -297,6 +308,20 @@ return array
 				'num_up' => array('1', '+='),
 			),
 		),
+
+		# 更新观看数
+		'addWatch' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'num_watch' => array('1', '+='),
+			),
+		),
 		
 		# 更新点赞数
 		'desUp' => array

+ 14 - 0
content/v1/Course.php

@@ -95,6 +95,11 @@ class Course extends Base
      * @apiSuccess {String}   course.author.name  作者姓名
      * @apiSuccess {String}   course.author.pic  作者头像
      *
+     * @apiSuccess {Object[]} course.user 观看用户信息
+     * @apiSuccess {Number}   course.user.id  用户id
+     * @apiSuccess {String}   course.user.name  用户姓名
+     * @apiSuccess {String}   course.user.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"},"course":{"id":"1","name":"\u662f\u662f\u662f","info_id":"1","author_id":"1","video":"123123","audio":"3232","num_add_view":"0","num_up":"0","num_view":"1","num_review":"0","pic":["http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg"],"top":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg","content":"<p>23132323<\/p>","reorder":"1","state":"1","cdate":"42\u79d2\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"}}}}
      *
@@ -110,6 +115,15 @@ class Course extends Base
 
             if ($news) {
                 $this->data['course'] = $this->one($news);
+
+                $watch = Dever::load('comment/watch-state', array('option_info_id' => $this->data['info']['id'], 'option_course_id' => $id));
+                $this->data['course']['user'] = array();
+                if ($watch) {
+                    foreach($watch as $k => $v) {
+                        $this->data['course']['user'][] = Dever::load('passport/user-one', $v['uid']);
+                    }
+                }
+
                 # 增加阅读量
                 Dever::load('content/course-addView', $id);
             } else {