|
@@ -50,12 +50,42 @@ class Topicdongtai extends Api
|
|
|
->order('dt.id desc')->autopage()->select();
|
|
|
$list = list_domain_image($list,['images','avatar']);
|
|
|
|
|
|
+ if(!empty($list)){
|
|
|
+ foreach($list as $key => $val){
|
|
|
+ $list[$key]['is_good'] = $this->is_good($val['id'],$this->auth->id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$this->success('success',$list);
|
|
|
}
|
|
|
|
|
|
//我回复的帖子列表
|
|
|
public function answer_dt_lists(){
|
|
|
-
|
|
|
+ $map = [
|
|
|
+ 'answer.user_id' => $this->auth->id,
|
|
|
+ 'answer.level' => 1,
|
|
|
+ ];
|
|
|
+ $lists = Db::name('topic_dongtai_answer')->alias('answer')
|
|
|
+ ->field('answer.id,answer.content as answer_content,answer.createtime,user.nickname,user.avatar,dt.content as dt_content')
|
|
|
+ ->join('user','answer.user_id = user.id','LEFT')
|
|
|
+ ->join('topic_dongtai dt','answer.dt_id = dt.id','LEFT')
|
|
|
+ ->where($map)->autopage()->select();
|
|
|
+
|
|
|
+ $this->success('success',$lists);
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否点赞
|
|
|
+ private function is_good($dt_id,$uid){
|
|
|
+ $where = [
|
|
|
+ 'dt_id' => $dt_id,
|
|
|
+ 'user_id' => $uid,
|
|
|
+ ];
|
|
|
+ $check = Db::name('topic_dongtai_good')->where($where)->find();
|
|
|
+ if($check){
|
|
|
+ return 1;
|
|
|
+ }else{
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//详情
|
|
@@ -70,17 +100,7 @@ class Topicdongtai extends Api
|
|
|
|
|
|
//是否点赞过
|
|
|
if($info){
|
|
|
- $where = [
|
|
|
- 'dt_id' => $id,
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- ];
|
|
|
- $check = Db::name('topic_dongtai_good')->where($where)->find();
|
|
|
-
|
|
|
- if($check){
|
|
|
- $info['isgood'] = 1;
|
|
|
- }else{
|
|
|
- $info['isgood'] = 0;
|
|
|
- }
|
|
|
+ $info['isgood'] = $this->is_good($id,$this->auth->id);
|
|
|
}
|
|
|
|
|
|
//评论
|
|
@@ -204,6 +224,7 @@ class Topicdongtai extends Api
|
|
|
}
|
|
|
//追加到外循环
|
|
|
$floor_list[$key]['childcount'] = 0;
|
|
|
+
|
|
|
if(count($child) > 4){
|
|
|
$floor_list[$key]['childcount'] = count($child) - 4;
|
|
|
}
|