dever 6 年之前
父節點
當前提交
8b8e34b2bb
共有 7 個文件被更改,包括 79 次插入6 次删除
  1. 2 2
      act/database/like.php
  2. 19 0
      act/database/live_comment.php
  3. 14 4
      act/lib/Comment.php
  4. 16 0
      doc/apidoc.php
  5. 17 0
      main/src/User.php
  6. 10 0
      main/src/View.php
  7. 1 0
      video/lib/Live.php

+ 2 - 2
act/database/like.php

@@ -45,9 +45,9 @@ return array
 		'type' 		=> array
 		(
 			'type' 		=> 'tinyint-1',
-			'name' 		=> '评论类别',
+			'name' 		=> '喜欢类别',
 			'default' 	=> '',
-			'desc' 		=> '评论类别',
+			'desc' 		=> '喜欢类别',
 			'match' 	=> 'option',
 			'search'	=> 'select',
 			'option' 	=> $table,

+ 19 - 0
act/database/live_comment.php

@@ -109,4 +109,23 @@ return array
 		'insert' => false,
 		'edit' => false,
 	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'data_id' => 'yes',
+				'type' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('id' => 'desc'),
+			'page' => array(50, 'list'),
+			'col' => '*',
+		),
+	)
 );

+ 14 - 4
act/lib/Comment.php

@@ -6,12 +6,21 @@ use Dever;
 
 class Comment
 {
+    private function table($type) {
+        if ($type == 3) {
+            $table = 'act/live_comment';
+        } else {
+            $table = 'act/comment';
+        }
+        return $table;
+    }
     # 获取评论列表
     public function get($id, $type)
     {
         $where['type'] = $type;
         $where['data_id'] = $id;
-        $data = Dever::db('act/comment')->getAll($where);
+        $table = $this->table($type);
+        $data = Dever::db($table)->getAll($where);
 
         if ($data) {
             foreach ($data as $k => $v) {
@@ -30,9 +39,10 @@ class Comment
         $where['data_id'] = $id;
         $where['type'] = $type;
         $where['content'] = $content;
-        $info = Dever::db('act/comment')->one($where);
+        $table = $this->table($type);
+        $info = Dever::db($table)->one($where);
         if (!$info) {
-            Dever::db('act/comment')->insert($where);
+            Dever::db($table)->insert($where);
         }
 
         # 更新评论数
@@ -40,7 +50,7 @@ class Comment
         $where['data_id'] = $id;
         $where['type'] = $type;
         $where['state'] = 1;
-        $total = Dever::db('act/comment')->total($where);
+        $total = Dever::db($table)->total($where);
         $table = Dever::config('base')->type_table[$type];
         Dever::db($table)->update(array('where_id' => $id, 'num_comment' => $total));
 

+ 16 - 0
doc/apidoc.php

@@ -482,6 +482,7 @@
  * @apiSuccess {Object[]} user_act 用户行为 当用户登录时有效
  * @apiSuccess {String}   user_act.share 用户分享数 
  * @apiSuccess {String}   user_act.up 是否点赞1为点赞,2为未点赞
+ * @apiSuccess {String}   user_act.note 是否预约提醒1为已预约,2为未预约
  */
 
 
@@ -500,6 +501,21 @@
  * @apiSuccess {Number}  id 当前的数据id
  */
 
+/**
+ * @api {get} wonderful/main/?l=user.submit_note 直播预约提醒
+ * @apiVersion 1.0.0
+ * @apiName user.submit_note
+ * @apiGroup UserAction
+ *
+ * @apiDescription 直播预约提醒
+ *
+ * @apiParam {String} signature signature
+ * @apiParam {Number} type type类型
+ * @apiParam {Number} id 当前的数据id
+ *
+ * @apiSuccess {Number}  id 当前的数据id
+ */
+
 /**
  * @api {get} wonderful/main/?l=user.submit_share 分享
  * @apiVersion 1.0.0

+ 17 - 0
main/src/User.php

@@ -78,6 +78,23 @@ class User extends Core
         return array('id' => $id, 'type' => $type);
     }
 
+    # 预约提醒
+    public function submit_note()
+    {
+        $id = Dever::input('id');
+        if (!$id) {
+            Dever::alert('错误的ID');
+        }
+        $type = Dever::input('type');
+        if (!$type) {
+            Dever::alert('错误的类型');
+        }
+
+        Dever::load('act/lib/note')->submit($this->data['uid'], $id, $type);
+
+        return array('id' => $id, 'type' => $type);
+    }
+
 
     # 发布评论
     public function submit_comment()

+ 10 - 0
main/src/View.php

@@ -60,6 +60,16 @@ class View extends Core
             $this->data['user_act']['share'] = 0;
             $this->data['user_act']['up'] = 2;
         }
+
+        # 用户预约
+        if ($type == 3) {
+            if ($this->data['uid'] > 0) {
+                $this->data['user_act']['note'] = Dever::load('act/lib/note')->get($this->data['uid'], $id, $type);
+                
+            } else {
+                $this->data['user_act']['note'] = 2;
+            }
+        }
         
 
         # 浏览量+1

+ 1 - 0
video/lib/Live.php

@@ -18,6 +18,7 @@ class Live
     
         //embed
         $time = time();
+        $data['stream'] = '';
         if ($data['sdate'] <= $time && $time <= $data['edate']) {
             $stream = Dever::db('live/stream')->one($data['stream_id']);
             $data['stream'] = $stream['live'];