dever 6 years ago
parent
commit
6fa43c515f
7 changed files with 95 additions and 14 deletions
  1. 2 2
      act/database/like.php
  2. 10 2
      act/lib/Comment.php
  3. 1 0
      act/lib/Like.php
  4. 63 2
      doc/apidoc.php
  5. 2 2
      main/lib/Core.php
  6. 15 4
      main/src/User.php
  7. 2 2
      main/src/View.php

+ 2 - 2
act/database/like.php

@@ -104,13 +104,13 @@ return array
 			(
 				'uid' => 'yes',
 				'data_id' => 'yes',
-				'type' => 'yes',
+				'type' => array('yes', 'in'),
 				'state' => 1,
 			),
 			'type' => 'all',
 			'order' => array('id' => 'desc'),
 			'page' => array(15, 'list'),
-			'col' => 'uid,type,data_id',
+			'col' => 'uid,type,data_id,cdate',
 		),
 	)
 );

+ 10 - 2
act/lib/Comment.php

@@ -15,7 +15,7 @@ class Comment
         return $table;
     }
     # 获取评论列表
-    public function get($id, $type)
+    public function get($id, $type, $uid = false)
     {
         $where['type'] = $type;
         $where['data_id'] = $id;
@@ -27,6 +27,14 @@ class Comment
                 $user = Dever::load('passport/api')->info($v['uid']);
                 $data[$k]['username'] = $user['username'];
                 $data[$k]['avatar'] = $user['avatar'];
+                $data[$k]['cdate_time'] = date('Y-m-d H:i:s', $v['cdate']);
+
+                # 检查是否点赞
+                if ($uid > 0) {
+                    $data[$k]['up'] = Dever::load('act/lib/like')->get($uid, $v['id'], 11);
+                } else {
+                    $data[$k]['up'] = 2;
+                }
             }
         }
         return $data;
@@ -36,7 +44,7 @@ class Comment
     public function getList($uid)
     {
         $where['uid'] = $uid;
-        $info = Dever::db('act/like')->getAll($where);
+        $info = Dever::db('act/comment')->getAll($where);
 
         return $info;
     }

+ 1 - 0
act/lib/Like.php

@@ -26,6 +26,7 @@ class Like
     public function getList($uid)
     {
         $where['uid'] = $uid;
+        $where['type'] = '1,2,3';
         $info = Dever::db('act/like')->getAll($where);
 
         return $info;

+ 63 - 2
doc/apidoc.php

@@ -63,6 +63,10 @@
  *
  * @apiParam {String} nickname 用户昵称
  * @apiParam {String} avatarurl 用户头像
+ * @apiParam {String} gender 性别
+ * @apiParam {String} city 城市
+ * @apiParam {String} province 省份
+ * @apiParam {String} country 县区
  * @apiParam {String} iv 微信的加密参数
  * @apiParam {String} encryptedData 微信的加密参数
  * @apiParam {Number} vid 微信id
@@ -367,6 +371,7 @@
  * @apiSuccess {String}   comment.content 内容
  * @apiSuccess {String}   comment.num_up 点赞数
  * @apiSuccess {String}   comment.cdate 时间
+ * @apiSuccess {String}   comment.up 是否点赞 1为点赞 2为未点赞
  */
 
 /**
@@ -406,7 +411,10 @@
  * @apiSuccess {String}   comment.username 用户名
  * @apiSuccess {String}   comment.avatar 头像
  * @apiSuccess {String}   comment.content 内容
+ * @apiSuccess {String}   comment.num_up 点赞数
  * @apiSuccess {String}   comment.cdate 时间
+ * @apiSuccess {String}   comment.up 是否点赞 1为点赞 2为未点赞
+
 
  *
  * @apiSuccess {Object[]} user_act 用户行为 当用户登录时有效
@@ -451,7 +459,9 @@
  * @apiSuccess {String}   comment.username 用户名
  * @apiSuccess {String}   comment.avatar 头像
  * @apiSuccess {String}   comment.content 内容
+ * @apiSuccess {String}   comment.num_up 点赞数
  * @apiSuccess {String}   comment.cdate 时间
+ * @apiSuccess {String}   comment.up 是否点赞 1为点赞 2为未点赞
 
  *
  * @apiSuccess {Object[]} user_act 用户行为 当用户登录时有效
@@ -506,7 +516,9 @@
  * @apiSuccess {String}   comment.username 用户名
  * @apiSuccess {String}   comment.avatar 头像
  * @apiSuccess {String}   comment.content 内容
+ * @apiSuccess {String}   comment.num_up 点赞数
  * @apiSuccess {String}   comment.cdate 时间
+ * @apiSuccess {String}   comment.up 是否点赞 1为点赞 2为未点赞
 
  *
  * @apiSuccess {Object[]} user_act 用户行为 当用户登录时有效
@@ -653,10 +665,30 @@
  * @apiSuccess {String}   user.avatar 头像
  * @apiSuccess {String}   user.level 等级
  * @apiSuccess {String}   user.score 积分
-
  * @apiSuccess {Number}   user_msg 用户新消息数
  */
 
+/**
+ * @api {get} wonderful/main/?l=user.my_msg 获取我的消息
+ * @apiVersion 1.0.0
+ * @apiName user.my_msg
+ * @apiGroup User
+ *
+ * @apiDescription 获取我的消息
+ *
+ * @apiParam {String} signature signature
+ *
+ * @apiSuccess {Object[]} msg 消息列表
+ * @apiSuccess {String}   msg.uid 用户id
+ * @apiSuccess {String}   msg.from_uid 消息来源uid,暂时不用管
+ * @apiSuccess {String}   msg.name 消息标题
+ * @apiSuccess {String}   msg.content 消息内容
+ * @apiSuccess {String}   msg.cdate 时间戳
+ * @apiSuccess {String}   msg.cdate_time 转换成了Y-m-d H:i:s的时间
+ * @apiSuccess {String}   msg.status 消息已读状态1未读2已读
+ * @apiSuccess {String}   msg.type 消息类型,暂时不用管
+ */
+
 
 /**
  * @api {get} wonderful/main/?l=user.my_up 获取我喜欢的信息
@@ -671,6 +703,8 @@
  * @apiSuccess {Object[]} like 用户基本信息
  * @apiSuccess {String}   like.uid 用户id
  * @apiSuccess {String}   like.data_id 数据id
+ * @apiSuccess {String}   like.cdate 时间戳
+ * @apiSuccess {String}   like.cdate_time 转换成了Y-m-d H:i:s的时间
  * @apiSuccess {String}   like.type 类型,参考公共参数中的类型设置说明中的type说明
  * @apiSuccess {Object[]}   like.info 基本信息 根据type不同,里面的字段有所不同
  * @apiSuccess {String}   like.info.id 数据id
@@ -679,4 +713,31 @@
  * @apiSuccess {String}   like.info.cate_name 栏目名称
  * @apiSuccess {String}   like.info.pic_cover 图片
  * @apiSuccess {String}   like.info.pdate 发布时间
- */
+ */
+
+/**
+ * @api {get} wonderful/main/?l=user.my_comment 获取我评论的信息
+ * @apiVersion 1.0.0
+ * @apiName user.my_comment
+ * @apiGroup User
+ *
+ * @apiDescription 获取我喜欢的信息
+ *
+ * @apiParam {String} signature signature
+ *
+ * @apiSuccess {Object[]} comment 用户基本信息
+ * @apiSuccess {String}   comment.uid 用户id
+ * @apiSuccess {String}   comment.data_id 数据id
+ * @apiSuccess {String}   comment.content 评论内容
+ * @apiSuccess {String}   comment.time 时间:x小时前
+ * @apiSuccess {String}   comment.cdate 时间戳
+ * @apiSuccess {String}   comment.cdate_time 转换成了Y-m-d H:i:s的时间
+ * @apiSuccess {String}   comment.type 类型,参考公共参数中的类型设置说明中的type说明
+ * @apiSuccess {Object[]}   comment.info 基本信息 根据type不同,里面的字段有所不同
+ * @apiSuccess {String}   comment.info.id 数据id
+ * @apiSuccess {String}   comment.info.name 名称
+ * @apiSuccess {String}   comment.info.cate_id 栏目ID
+ * @apiSuccess {String}   comment.info.cate_name 栏目名称
+ * @apiSuccess {String}   comment.info.pic_cover 图片
+ * @apiSuccess {String}   comment.info.pdate 发布时间
+ */

+ 2 - 2
main/lib/Core.php

@@ -12,11 +12,11 @@ class Core
     {
         # 获取用户信息
         if ($this->checkUser) {
-            //$this->data['uid'] = Dever::load('passport/applet')->check();
+            $this->data['uid'] = Dever::load('passport/applet')->check();
         } else {
             $this->data['uid'] = Dever::load('passport/applet')->check(false);
         }
-        $this->data['uid'] = 1;
+        //$this->data['uid'] = 1;
 
         # 获取基本配置
         $this->data['config'] = Dever::db('main/config')->one();

+ 15 - 4
main/src/User.php

@@ -32,6 +32,14 @@ class User extends Core
     # 我的消息页面
     public function my_msg()
     {
+        $this->data['msg'] = Dever::load('message/lib/data')->read($this->data['uid'], false, true, false);
+
+        if ($this->data['msg']) {
+            foreach ($this->data['msg'] as $k => $v) {
+                $this->data['msg'][$k]['cdate_time'] = date('Y-m-d H:i:s', $v['cdate']);
+            }
+        }
+
         return $this->data;
     }
 
@@ -42,6 +50,7 @@ class User extends Core
 
         if ($this->data['like']) {
             foreach ($this->data['like'] as $k => $v) {
+                $this->data['like'][$k]['cdate_time'] = date('Y-m-d H:i:s', $v['cdate']);
                 $this->data['like'][$k]['info'] = $this->content($v);
             }
         }
@@ -51,11 +60,13 @@ class User extends Core
     # 我评论的页面
     public function my_comment()
     {
-        $this->data['like'] = Dever::load('act/lib/comment')->getList($this->data['uid']);
+        $this->data['comment'] = Dever::load('act/lib/comment')->getList($this->data['uid']);
 
-        if ($this->data['like']) {
-            foreach ($this->data['like'] as $k => $v) {
-                $this->data['like'][$k]['info'] = $this->content($v);
+        if ($this->data['comment']) {
+            foreach ($this->data['comment'] as $k => $v) {
+                $this->data['comment'][$k]['cdate_time'] = date('Y-m-d H:i:s', $v['cdate']);
+                $this->data['comment'][$k]['time'] = Dever::mdate($v['cdate'], 2);
+                $this->data['comment'][$k]['info'] = $this->content($v);
             }
         }
         return $this->data;

+ 2 - 2
main/src/View.php

@@ -19,7 +19,7 @@ class View extends Core
             Dever::alert('错误的类型');
         }
 
-        $this->data['comment'] = Dever::load('act/lib/comment')->get($id, $type);
+        $this->data['comment'] = Dever::load('act/lib/comment')->get($id, $type, $this->data['uid']);
 
         return $this->data;
     }
@@ -52,7 +52,7 @@ class View extends Core
         }
 
         # 获取评论列表
-        $this->data['comment'] = Dever::load('act/lib/comment')->get($id, $type);
+        $this->data['comment'] = Dever::load('act/lib/comment')->get($id, $type, $this->data['uid']);
 
         # 获取相关推荐
         $this->data['relation'] = Dever::load($method)->getRelation($this->data['info']);