|
@@ -1,6 +1,6 @@
|
|
|
<?php
|
|
|
namespace app\api\controller;
|
|
|
-use app\common\model\PlatformComment;
|
|
|
+use app\common\model\PressComment;
|
|
|
use app\common\model\PlatformLike;
|
|
|
use app\common\model\UserCollect;
|
|
|
use library\tools\Data;
|
|
@@ -57,7 +57,7 @@ class Press extends Base
|
|
|
if($title) $query->where('title','like','%.'.$title.'%');
|
|
|
})->order('sort desc,id desc')->limit($this->off_set,$this->page_num)->select()->toArray();
|
|
|
foreach ($list as &$v) {
|
|
|
- $v['comment_num'] = PlatformComment::where(['first_id'=>$v['id'],'type'=>1])->count();
|
|
|
+ $v['comment_num'] = PressComment::where(['first_id'=>$v['id'],'type'=>1])->count();
|
|
|
$v['is_collect'] = UserCollect::checkCollectByType($this->user_id,4,$v['id']);
|
|
|
$v['collect_num'] = UserCollect::getCollectNum(4,$v['id']);
|
|
|
$v['is_praise'] = PlatformLike::checkTags($this->user_id,$v['id'],1);
|
|
@@ -91,7 +91,7 @@ class Press extends Base
|
|
|
{
|
|
|
$sel_where[] = ['id','=',input('get.id')];
|
|
|
$detail = \app\common\model\Press::field('id,images,content,read_num,create_at,transmit_num')->where($sel_where)->find()->toArray();
|
|
|
- $detail['comment_num'] = PlatformComment::where(['first_id'=>$detail['id'],'type'=>1])->count();
|
|
|
+ $detail['comment_num'] = PressComment::where(['first_id'=>$detail['id'],'type'=>1])->count();
|
|
|
$detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,4,$detail['id']);
|
|
|
$detail['collect_num'] = UserCollect::getCollectNum(4,$detail['id']);
|
|
|
$detail['is_praise'] = PlatformLike::checkTags($this->user_id,$detail['id'],1);
|
|
@@ -127,7 +127,7 @@ class Press extends Base
|
|
|
$user_id = $this->user_id;
|
|
|
$sort_type= input('sort_type',1);
|
|
|
$order = $sort_type == 1 ? 'c.id desc' : 'c.like_times desc';
|
|
|
- $list =PlatformComment::where($where)
|
|
|
+ $list =PressComment::where($where)
|
|
|
->alias('c')
|
|
|
->field('c.*,u.name,u.headimg')
|
|
|
->leftJoin('store_member u','u.id = c.user_id')
|
|
@@ -136,7 +136,7 @@ class Press extends Base
|
|
|
->select()->toArray();
|
|
|
|
|
|
array_walk($list,function (&$val,$k)use($user_id){
|
|
|
- $children = PlatformComment::where(['c.pid'=>$val['id'],'c.is_deleted'=>0])
|
|
|
+ $children = PressComment::where(['c.pid'=>$val['id'],'c.is_deleted'=>0])
|
|
|
->alias('c')->field('c.*,u.name,u.headimg')
|
|
|
->leftJoin('store_member u','u.id = c.user_id')
|
|
|
->order('c.id asc')
|
|
@@ -144,13 +144,13 @@ class Press extends Base
|
|
|
$val['children'] = $children;
|
|
|
$val['like_num'] = PlatformLike::getPraiseNum($val['id']);
|
|
|
$val['is_like'] = PlatformLike::where(['like_id'=>$val['id'],'user_id'=>$user_id,'type'=>1])->count();
|
|
|
- $parent = PlatformComment::where(['c.id'=>$val['pid'],'c.is_deleted'=>0])
|
|
|
+ $parent = PressComment::where(['c.id'=>$val['pid'],'c.is_deleted'=>0])
|
|
|
->alias('c')->field('c.*,u.name,u.headimg')
|
|
|
->leftJoin('store_member u','u.id = c.user_id')
|
|
|
->find();
|
|
|
$val['parent'] = $parent ? $parent->toArray() : null;
|
|
|
});
|
|
|
- $total_num = PlatformComment::where($where)->alias('c')->count();
|
|
|
+ $total_num = PressComment::where($where)->alias('c')->count();
|
|
|
$this->success('ok',['list'=>$list,'total_num'=>$total_num]);
|
|
|
}
|
|
|
|
|
@@ -164,7 +164,7 @@ class Press extends Base
|
|
|
* @param name:id type:int default:1 desc:评论id
|
|
|
*/
|
|
|
public function delComment(){
|
|
|
- PlatformComment::where(['id'=>input('post.id'),'user_id'=>$this->user_id])->update(['is_deleted'=>1]);
|
|
|
+ PressComment::where(['id'=>input('post.id'),'user_id'=>$this->user_id])->update(['is_deleted'=>1]);
|
|
|
$this->success('删除成功');
|
|
|
}
|
|
|
|
|
@@ -259,8 +259,8 @@ class Press extends Base
|
|
|
$id = input('post.id');
|
|
|
$content = input('post.content',0);
|
|
|
if(!$content) $this->error('请输入评论内容');
|
|
|
- $res = PlatformComment::create(['user_id'=>$this->user_id,'content'=>$content,'first_id'=>$id,'type'=>1]);
|
|
|
- $detail =PlatformComment::where('p.id',$res->id)
|
|
|
+ $res = PressComment::create(['user_id'=>$this->user_id,'content'=>$content,'first_id'=>$id,'type'=>1]);
|
|
|
+ $detail =PressComment::where('p.id',$res->id)
|
|
|
->alias('p')
|
|
|
->field('p.id,p.content,p.create_at,u.name,u.headimg')
|
|
|
->leftJoin('store_member u','u.id = c.user_id')
|
|
@@ -273,7 +273,7 @@ class Press extends Base
|
|
|
* @desc 新闻二级评论
|
|
|
* @author qc
|
|
|
* @method POST
|
|
|
- * @url /api/Press/pressCommend
|
|
|
+ * @url /api/Press/pressSecondComment
|
|
|
* @header name:Authorization require:1 desc:Token
|
|
|
* @param name:id type:int default:1 desc:评论id
|
|
|
* @param name:content type:string default:-- desc:内容
|
|
@@ -281,9 +281,9 @@ class Press extends Base
|
|
|
* @return name:headimg type:string default:-- desc:会员头像
|
|
|
* @return name:content type:string default:-- desc:内容
|
|
|
*/
|
|
|
- public function pressCommend()
|
|
|
+ public function pressSecondComment()
|
|
|
{
|
|
|
- $comment = PlatformComment::where('id',input('post.id'))->find()->toArray();
|
|
|
+ $comment = PressComment::where('id',input('post.id'))->find()->toArray();
|
|
|
unset($comment['id']);
|
|
|
unset($comment['create_at']);
|
|
|
$comment['pid'] = input('post.id');
|
|
@@ -291,8 +291,8 @@ class Press extends Base
|
|
|
$comment['content'] = input('post.content');
|
|
|
$comment['lev']++;
|
|
|
if(!$comment['source_id']) $comment['source_id'] = input('post.id');
|
|
|
- $res = PlatformComment::create($comment);
|
|
|
- $detail = PlatformComment::where('p.id',$res->id)
|
|
|
+ $res = PressComment::create($comment);
|
|
|
+ $detail = PressComment::where('p.id',$res->id)
|
|
|
->alias('p')
|
|
|
->field('p.id,p.content,p.create_at,u.name,u.headimg')
|
|
|
->leftJoin('store_member u','u.id = c.user_id')
|