dever 6 years ago
parent
commit
b5ca1831eb

+ 5 - 3
act/database/comment.php

@@ -29,7 +29,7 @@ return array
 		'uid'		=> array
 		(
 			'type' 		=> 'int-11',
-			'name' 		=> '用户',
+			'name' 		=> '用户',
 			'default' 	=> '0',
 			'desc' 		=> '请选择用户',
 			'match' 	=> 'is_numeric',
@@ -52,6 +52,7 @@ return array
 			'desc' 		=> '评论类别',
 			'match' 	=> 'option',
 			'option' 	=> $table,
+			'search'	=> 'select',
 			'list'		=> true,
 		),
 		
@@ -75,8 +76,9 @@ return array
 			'desc' 		=> '请输入内容',
 			'match' 	=> 'is_string',
 			'search'	=> 'fulltext',
-			'list'		=> 'table',
-			'modal'		=> '查看详情',
+			//'list'		=> 'table',
+			//'modal'		=> '查看详情',
+			'list'		=> true,
 		),
 		
 		'state'		=> array

+ 2 - 1
act/database/like.php

@@ -27,7 +27,7 @@ return array
 		'uid'		=> array
 		(
 			'type' 		=> 'int-11',
-			'name' 		=> '用户',
+			'name' 		=> '用户',
 			'default' 	=> '0',
 			'desc' 		=> '请选择用户',
 			'match' 	=> 'is_numeric',
@@ -49,6 +49,7 @@ return array
 			'default' 	=> '',
 			'desc' 		=> '评论类别',
 			'match' 	=> 'option',
+			'search'	=> 'select',
 			'option' 	=> $table,
 			'list'		=> true,
 		),

+ 5 - 3
act/database/live_comment.php

@@ -30,7 +30,7 @@ return array
 		'uid'		=> array
 		(
 			'type' 		=> 'int-11',
-			'name' 		=> '用户',
+			'name' 		=> '用户',
 			'default' 	=> '0',
 			'desc' 		=> '请选择用户',
 			'match' 	=> 'is_numeric',
@@ -53,6 +53,7 @@ return array
 			'desc' 		=> '评论类别',
 			'match' 	=> 'option',
 			'option' 	=> $table,
+			'search'	=> 'select',
 			'list'		=> true,
 		),
 		
@@ -76,8 +77,9 @@ return array
 			'desc' 		=> '请输入内容',
 			'match' 	=> 'is_string',
 			'search'	=> 'fulltext',
-			'list'		=> 'table',
-			'modal'		=> '查看详情',
+			//'list'		=> 'table',
+			//'modal'		=> '查看详情',
+			'list'		=> true,
 		),
 		
 		'state'		=> array

+ 7 - 6
act/database/share.php

@@ -27,7 +27,7 @@ return array
 		'uid'		=> array
 		(
 			'type' 		=> 'int-11',
-			'name' 		=> '用户',
+			'name' 		=> '用户',
 			'default' 	=> '0',
 			'desc' 		=> '请选择用户',
 			'match' 	=> 'is_numeric',
@@ -45,12 +45,13 @@ return array
 		'type' 		=> array
 		(
 			'type' 		=> 'tinyint-1',
-			'name' 		=> '评论类别',
+			'name' 		=> '分享类别',
 			'default' 	=> '',
-			'desc' 		=> '评论类别',
+			'desc' 		=> '分享类别',
 			'match' 	=> 'option',
 			'option' 	=> $table,
 			'list'		=> true,
+			'search'	=> 'select',
 		),
 		
 		'data_id' 		=> array
@@ -72,9 +73,9 @@ return array
 			'default' 	=> '',
 			'desc' 		=> '请输入内容',
 			'match' 	=> 'is_string',
-			'search'	=> 'fulltext',
-			'list'		=> 'table',
-			'modal'		=> '查看详情',
+			//'search'	=> 'fulltext',
+			//'list'		=> 'table',
+			//'modal'		=> '查看详情',
 		),
 
 		'num' 		=> array

+ 3 - 2
act/database/share_reflux.php

@@ -46,12 +46,13 @@ return array
         'type'      => array
         (
             'type'      => 'tinyint-1',
-            'name'      => '评论类别',
+            'name'      => '分享类别',
             'default'   => '',
-            'desc'      => '评论类别',
+            'desc'      => '分享类别',
             'match'     => 'option',
             'option'    => $table,
             'list'      => true,
+            'search'    => 'select',
         ),
         
         'data_id'       => array

+ 2 - 1
act/lib/Comment.php

@@ -15,7 +15,7 @@ class Comment
 
         if ($data) {
             foreach ($data as $k => $v) {
-                $user = Dever::db('passport/api')->info($v['uid']);
+                $user = Dever::load('passport/api')->info($v['uid']);
                 $data[$k]['username'] = $user['username'];
                 $data[$k]['avatar'] = $user['avatar'];
             }
@@ -39,6 +39,7 @@ class Comment
         $where = array();
         $where['data_id'] = $id;
         $where['type'] = $type;
+        $where['state'] = 1;
         $total = Dever::db('act/comment')->total($where);
         $table = Dever::config('base')->type_table[$type];
         Dever::db($table)->update(array('where_id' => $id, 'num_comment' => $total));

+ 11 - 11
act/lib/Like.php

@@ -6,21 +6,20 @@ use Dever;
 
 class Like
 {
-    # 获取评论列表
-    public function get($id, $type)
+    # 获取当前用户是否点赞
+    public function get($uid, $id, $type)
     {
+        $where['uid'] = $uid;
         $where['type'] = $type;
         $where['data_id'] = $id;
-        $data = Dever::db('act/comment')->getAll($where);
+        $where['state'] = 1;
+        $info = Dever::db('act/like')->one($where);
 
-        if ($data) {
-            foreach ($data as $k => $v) {
-                $user = Dever::db('passport/api')->info($v['uid']);
-                $data[$k]['username'] = $user['username'];
-                $data[$k]['avatar'] = $user['avatar'];
-            }
+        if ($info) {
+            return 1;
+        } else {
+            return 2;
         }
-        return $data;
     }
 
     # 点赞+喜欢
@@ -31,7 +30,7 @@ class Like
         $where['type'] = $type;
         $info = Dever::db('act/like')->one($where);
         if (!$info) {
-            Dever::db('act/live')->insert($where);
+            Dever::db('act/like')->insert($where);
         } else {
             if ($info['state'] == 1) {
                 Dever::db('act/like')->update(array('where_id' => $info['id'], 'state' => 2));
@@ -44,6 +43,7 @@ class Like
         $where = array();
         $where['data_id'] = $id;
         $where['type'] = $type;
+        $where['state'] = 1;
         $total = Dever::db('act/like')->total($where);
         $table = Dever::config('base')->type_table[$type];
         Dever::db($table)->update(array('where_id' => $id, 'num_up' => $total));

+ 12 - 4
act/lib/Share.php

@@ -39,12 +39,20 @@ class Share
     {
         $where['source_uid'] = $source_uid;
         $where['uid'] = $uid;
+        if ($where['source_uid'] == $where['uid']) {
+            //return false;
+        }
         $where['data_id'] = $id;
         $where['type'] = $type;
-        $info = Dever::db('act/share_reflux')->one($where);
-        if (!$info) {
-            Dever::db('act/share_reflux')->insert($where);
-            return true;
+
+        $share = Dever::db('act/share')->one($where);
+        if ($share) {
+            $where['share_id'] = $share['id'];
+            $info = Dever::db('act/share_reflux')->one($where);
+            if (!$info) {
+                Dever::db('act/share_reflux')->insert($where);
+                return true;
+            }
         }
 
         return false;

+ 0 - 42
content/database/article.php

@@ -522,47 +522,5 @@ return array
 				'num_view' => array('1', '+='),
 			),
 		),
-		
-		# 更新回复数
-		'addComment' => array
-		(
-			'type' => 'update',
-			'where' => array
-			(
-				'id' => 'yes',
-			),
-			'set' => array
-			(
-				'num_comment' => 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', '-='),
-			),
-		),
 	),
 );

+ 42 - 7
doc/apidoc.php

@@ -341,6 +341,25 @@
  * @apiSuccess {String}   news.share_content 分享内容
  */
 
+/**
+ * @api {get} wonderful/main/?l=view.comment 查看评论列表
+ * @apiVersion 1.0.0
+ * @apiName view.comment
+ * @apiGroup Content
+ *
+ * @apiDescription 查看评论列表
+ *
+ * @apiParam {String} signature signature
+ * @apiParam {Number} id 图文id
+ * @apiParam {Number} type 类型,参考公共参数中的类型设置说明中的type说明
+ *
+ * @apiSuccess {Object[]} comment 评论列表
+ * @apiSuccess {String}   comment.id 
+ * @apiSuccess {String}   comment.username 用户名
+ * @apiSuccess {String}   comment.avatar 头像
+ * @apiSuccess {String}   comment.content 内容
+ * @apiSuccess {String}   comment.cdate 时间
+ */
 
 /**
  * @api {get} wonderful/main/?l=view.article 查看图文内容
@@ -376,6 +395,11 @@
  * @apiSuccess {String}   comment.avatar 头像
  * @apiSuccess {String}   comment.content 内容
  * @apiSuccess {String}   comment.cdate 时间
+
+ *
+ * @apiSuccess {Object[]} user_act 用户行为 当用户登录时有效
+ * @apiSuccess {String}   user_act.share 用户分享数 
+ * @apiSuccess {String}   user_act.up 是否点赞1为点赞,2为未点赞
  */
 
 /**
@@ -412,6 +436,11 @@
  * @apiSuccess {String}   comment.avatar 头像
  * @apiSuccess {String}   comment.content 内容
  * @apiSuccess {String}   comment.cdate 时间
+
+ *
+ * @apiSuccess {Object[]} user_act 用户行为 当用户登录时有效
+ * @apiSuccess {String}   user_act.share 用户分享数 
+ * @apiSuccess {String}   user_act.up 是否点赞1为点赞,2为未点赞
  */
 
 /**
@@ -448,6 +477,11 @@
  * @apiSuccess {String}   comment.avatar 头像
  * @apiSuccess {String}   comment.content 内容
  * @apiSuccess {String}   comment.cdate 时间
+
+ *
+ * @apiSuccess {Object[]} user_act 用户行为 当用户登录时有效
+ * @apiSuccess {String}   user_act.share 用户分享数 
+ * @apiSuccess {String}   user_act.up 是否点赞1为点赞,2为未点赞
  */
 
 
@@ -463,7 +497,7 @@
  * @apiParam {Number} type type类型
  * @apiParam {Number} id 当前的数据id
  *
- * @apiSuccess {String}  data ok
+ * @apiSuccess {Number}  id 当前的数据id
  */
 
 /**
@@ -477,8 +511,9 @@
  * @apiParam {String} signature signature
  * @apiParam {Number} type type类型
  * @apiParam {Number} id 当前的数据id
+ * @apiParam {String} desc 说明:这是分享的说明介绍,请不要传入该参数,底层页分享时,请把路径path设置为首页的path?scene=signature,type,id  signature:当前邀请者的signature | type:当前分享的类型 图文等 | id:当前分享的图文的id,小程序中请判断,如果首页有scene参数,请在正常请求首页数据之后,先发起分享回流接口的请求,然后根据scene参数中的type和id的值,跳转到type所对应的path的详情页即可。
  *
- * @apiSuccess {String}  data ok
+ * @apiSuccess {Number}  id 当前的数据id
  */
 
 /**
@@ -490,11 +525,11 @@
  * @apiDescription 分享回流
  *
  * @apiParam {String} signature signature
- * @apiParam {Number} type type类型
- * @apiParam {Number} id 当前的数据id
- * @apiParam {String} source_signature 回流的源用户id
+ * @apiParam {Number} type type类型 scene参数中的第二个值
+ * @apiParam {Number} id 当前的数据id scene参数中的第三个值
+ * @apiParam {String} source_signature 回流的源用户id,scene参数中的第一个值
  *
- * @apiSuccess {String}  data ok
+ * @apiSuccess {Number}  id 当前的数据id
  */
 
 /**
@@ -510,6 +545,6 @@
  * @apiParam {Number} id 当前的数据id
  * @apiParam {String} content 评论内容
  *
- * @apiSuccess {String}  data ok
+ * @apiSuccess {Number}  id 当前的数据id
  */
 

+ 8 - 7
main/src/User.php

@@ -7,7 +7,7 @@ use Main\Lib\Core;
 
 class User extends Core
 {
-    protected $checkUser = true;
+    //protected $checkUser = true;
 
     # 我的页面
     public function my()
@@ -27,7 +27,7 @@ class User extends Core
 
         Dever::load('act/lib/share')->submit($this->data['uid'], $id, $type);
 
-        return 'ok';
+        return array('id' => $id, 'type' => $type);
     }
 
     # 回流
@@ -40,10 +40,11 @@ class User extends Core
         }
         $user = Dever::loginResult($source_signature, false);
         if (!isset($user['uid'])) {
-            Dever::alert('错误的来源uid');
+            //Dever::alert('错误的来源uid');
         }
 
         $source_uid = $user['uid'];
+        $source_uid = 1;
 
         $id = Dever::input('id');
         if (!$id) {
@@ -54,9 +55,9 @@ class User extends Core
             Dever::alert('错误的类型');
         }
 
-        Dever::load('act/lib/share')->submit($source_uid, $id, $type, $this->data['uid']);
+        Dever::load('act/lib/share')->submit_reflux($source_uid, $id, $type, $this->data['uid']);
 
-        return 'ok';
+        return array('id' => $id, 'type' => $type);
     }
 
 
@@ -74,7 +75,7 @@ class User extends Core
 
         Dever::load('act/lib/like')->submit($this->data['uid'], $id, $type);
 
-        return 'ok';
+        return array('id' => $id, 'type' => $type);
     }
 
 
@@ -96,6 +97,6 @@ class User extends Core
 
         Dever::load('act/lib/comment')->submit($this->data['uid'], $id, $type, $content);
 
-        return 'ok';
+        return array('id' => $id, 'type' => $type);
     }
 }

+ 10 - 2
main/src/View.php

@@ -46,11 +46,19 @@ class View extends Core
             }
         }
 
+        # 用户行为数据
+        $this->data['user_act'] = array();
+
         # 获取当前用户分享数
         if ($this->data['uid'] > 0) {
-            $this->data['share'] = Dever::load('act/lib/share')->getRefluxNum($this->data['uid'], $id, $type);
+            $this->data['user_act']['share'] = Dever::load('act/lib/share')->getRefluxNum($this->data['uid'], $id, $type);
+
+            # 当前用户是否点赞
+            $this->data['user_act']['up'] = Dever::load('act/lib/like')->get($this->data['uid'], $id, $type);
+            
         } else {
-            $this->data['share'] = 0;
+            $this->data['user_act']['share'] = 0;
+            $this->data['user_act']['up'] = 2;
         }
         
 

+ 0 - 42
video/database/live.php

@@ -539,47 +539,5 @@ return array
 				'num_view' => array('1', '+='),
 			),
 		),
-		
-		# 更新回复数
-		'addComment' => array
-		(
-			'type' => 'update',
-			'where' => array
-			(
-				'id' => 'yes',
-			),
-			'set' => array
-			(
-				'num_comment' => 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', '-='),
-			),
-		),
 	),
 );

+ 0 - 42
video/database/vod.php

@@ -496,47 +496,5 @@ return array
 				'num_view' => array('1', '+='),
 			),
 		),
-		
-		# 更新回复数
-		'addComment' => array
-		(
-			'type' => 'update',
-			'where' => array
-			(
-				'id' => 'yes',
-			),
-			'set' => array
-			(
-				'num_comment' => 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', '-='),
-			),
-		),
 	),
 );