|
@@ -5,12 +5,14 @@ namespace app\api\controller;
|
|
|
use app\common\controller\Api;
|
|
|
use think\Db;
|
|
|
use app\common\library\Keyworld;
|
|
|
+use think\Exception;
|
|
|
+
|
|
|
/**
|
|
|
* 圈子动态
|
|
|
*/
|
|
|
class Topicdongtai extends Api
|
|
|
{
|
|
|
- protected $noNeedLogin = ['info','floor_info','topic_list'];
|
|
|
+ protected $noNeedLogin = [];
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
//发布动态
|
|
@@ -30,8 +32,7 @@ class Topicdongtai extends Api
|
|
|
'user_id' => $this->auth->id,
|
|
|
'content' => $content,
|
|
|
'images' => $images,
|
|
|
- 'longitude' => input('longitude',''),
|
|
|
- 'latitude' => input('latitude',''),
|
|
|
+ 'type' => input('type',1),
|
|
|
'createtime' => time(),
|
|
|
'updatetime' => time(),
|
|
|
];
|
|
@@ -42,17 +43,9 @@ class Topicdongtai extends Api
|
|
|
//圈子新增一个贴
|
|
|
$rs = Db::name('topic_hub')->where('id',$topic_id)->setInc('t_number');
|
|
|
|
|
|
- //tag任务赠送金币
|
|
|
- //发动态奖励
|
|
|
- $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,16);
|
|
|
- if($task_rs === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error('完成任务赠送奖励失败');
|
|
|
- }
|
|
|
-
|
|
|
Db::commit();
|
|
|
|
|
|
- $this->success('success',$id);
|
|
|
+ $this->success('发布成功',$id);
|
|
|
}
|
|
|
|
|
|
//自己看列表
|
|
@@ -60,35 +53,70 @@ class Topicdongtai extends Api
|
|
|
public function my_lists(){
|
|
|
|
|
|
$uid = input('uid',$this->auth->id);
|
|
|
+ if (empty($uid)) {
|
|
|
+ $uid = $this->auth->id;
|
|
|
+ }
|
|
|
$list = Db::name('topic_dongtai')->alias('dt')
|
|
|
->join('user','dt.user_id = user.id','LEFT')
|
|
|
- ->field('dt.*,user.nickname,user.avatar')
|
|
|
+ ->join('topic_hub topic','dt.topic_id = topic.id','LEFT')
|
|
|
+ ->field('dt.*,user.nickname,user.avatar,user.gender,topic.name as topic_name')
|
|
|
->where('dt.user_id',$uid)
|
|
|
->order('dt.id desc')->autopage()->select();
|
|
|
$list = list_domain_image($list,['images','avatar']);
|
|
|
|
|
|
if(!empty($list)){
|
|
|
- foreach($list as $key => $val){
|
|
|
- $list[$key]['isgood'] = $this->is_good($val['id'],$this->auth->id);
|
|
|
+ foreach($list as $key => &$val){
|
|
|
+
|
|
|
+ //追加点赞
|
|
|
+ $val['isgood'] = $this->is_good($val['id'],$this->auth->id);
|
|
|
+
|
|
|
+ //创建视频缩略图
|
|
|
+ $val['images_thumb'] = '';
|
|
|
+ if ($val['type'] == 2) {
|
|
|
+ $images_url = explode('.', $val['images']);
|
|
|
+ unset($images_url[count($images_url) - 1]);
|
|
|
+ $val['images_thumb'] = join('.', $images_url) . '_0.jpg';
|
|
|
+ }
|
|
|
+
|
|
|
+ //时间
|
|
|
+ $val['createtime_text'] = get_last_time($val['createtime']);
|
|
|
+
|
|
|
+ //关注
|
|
|
+ $val['is_follow'] = $this->is_follow($val['user_id'],$this->auth->id);
|
|
|
+
|
|
|
+ //评论
|
|
|
+ $val['answernumber'] = Db::name('topic_dongtai_answer')->where(['dt_id'=>$val['id'],'level'=>1])->count();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$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.id as dt_id,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);
|
|
|
+ //动态删除
|
|
|
+ public function delete(){
|
|
|
+ try {
|
|
|
+ $id = input('id',0);
|
|
|
+ $where['id'] = $id;
|
|
|
+ $where['user_id'] = $this->auth->id;
|
|
|
+ $dongtai = Db::name('topic_dongtai')->field('id,topic_id')->where($where)->find();
|
|
|
+ if (empty($dongtai)) {
|
|
|
+ throw new Exception('未找到动态信息');
|
|
|
+ }
|
|
|
+ $delRes = Db::name('topic_dongtai')->where('id',$id)->where('user_id',$this->auth->id)->delete();
|
|
|
+ if (!$delRes) {
|
|
|
+ throw new Exception('动态删除失败');
|
|
|
+ }
|
|
|
+ //圈子新增一个贴
|
|
|
+ if (!empty($dongtai['topic_id'])) {
|
|
|
+ $res = Db::name('topic_hub')->where('id',$dongtai['topic_id'])->setDec('t_number');
|
|
|
+ if (!$res) {
|
|
|
+ throw new Exception('更新话题数量失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->success('删除成功');
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//是否点赞
|
|
@@ -104,6 +132,33 @@ class Topicdongtai extends Api
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
+ //回复是否点赞
|
|
|
+ private function answer_is_good($answer_id,$uid){
|
|
|
+ $where = [
|
|
|
+ 'answer_id' => $answer_id,
|
|
|
+ 'user_id' => $uid,
|
|
|
+ ];
|
|
|
+ $check = Db::name('topic_answer_good')->where($where)->find();
|
|
|
+ if($check){
|
|
|
+ return 1;
|
|
|
+ }else{
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否关注
|
|
|
+ private function is_follow($user_id,$fans_id){
|
|
|
+ $where = [
|
|
|
+ 'user_id' => $user_id,
|
|
|
+ 'fans_id' => $fans_id,
|
|
|
+ ];
|
|
|
+ $check = Db::name('user_fans_follow')->where($where)->find();
|
|
|
+ if($check){
|
|
|
+ return 1;
|
|
|
+ }else{
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//详情
|
|
|
public function info(){
|
|
@@ -111,18 +166,33 @@ class Topicdongtai extends Api
|
|
|
|
|
|
$info = Db::name('topic_dongtai')->alias('dt')
|
|
|
->join('user','dt.user_id = user.id','LEFT')
|
|
|
- ->field('dt.*,user.nickname,user.avatar')
|
|
|
+ ->join('topic_hub topic','dt.topic_id = topic.id','LEFT')
|
|
|
+ ->field('dt.*,user.nickname,user.avatar,user.gender,topic.name as topic_name')
|
|
|
->where('dt.id',$id)->find();
|
|
|
$info = info_domain_image($info,['images','avatar']);
|
|
|
|
|
|
- //是否点赞过
|
|
|
+
|
|
|
if($info){
|
|
|
+ //是否点赞过
|
|
|
$info['isgood'] = $this->is_good($id,$this->auth->id);
|
|
|
- }
|
|
|
|
|
|
- //评论
|
|
|
- if($info){
|
|
|
- $info['answer'] = $this->answer_list($id);
|
|
|
+ //创建视频缩略图
|
|
|
+ $info['images_thumb'] = '';
|
|
|
+ if ($info['type'] == 2) {
|
|
|
+ $images_url = explode('.', $info['images']);
|
|
|
+ unset($images_url[count($images_url) - 1]);
|
|
|
+ $info['images_thumb'] = join('.', $images_url) . '_0.jpg';
|
|
|
+ }
|
|
|
+
|
|
|
+ //时间
|
|
|
+ $info['createtime_text'] = get_last_time($info['createtime']);
|
|
|
+
|
|
|
+ //关注
|
|
|
+ $info['is_follow'] = $this->is_follow($info['user_id'],$this->auth->id);
|
|
|
+
|
|
|
+ //评论
|
|
|
+ $info['answernumber'] = Db::name('topic_dongtai_answer')->where(['dt_id'=>$id,'level'=>1])->count();
|
|
|
+ //$info['answer'] = $this->answer_list($id);
|
|
|
}
|
|
|
|
|
|
$this->success('success',$info);
|
|
@@ -143,18 +213,12 @@ class Topicdongtai extends Api
|
|
|
}
|
|
|
|
|
|
Db::startTrans();
|
|
|
+ $where['createtime'] = time();
|
|
|
$rs = Db::name('topic_dongtai_good')->insertGetId($where);
|
|
|
$up = Db::name('topic_dongtai')->where('id',$id)->setInc('goodnum');
|
|
|
|
|
|
- //tag任务赠送金币
|
|
|
- //点赞奖励
|
|
|
- $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,14);
|
|
|
- if($task_rs === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error('完成任务赠送奖励失败');
|
|
|
- }
|
|
|
-
|
|
|
if($rs && $up !== false){
|
|
|
+ \app\common\model\TaskLog::tofinish($this->auth->id,"VpXtablCsZ",1);
|
|
|
Db::commit();
|
|
|
$this->success('点赞成功');
|
|
|
}
|
|
@@ -216,83 +280,158 @@ class Topicdongtai extends Api
|
|
|
Db::startTrans();
|
|
|
$rs = Db::name('topic_dongtai_answer')->insertGetId($data);
|
|
|
|
|
|
- //tag任务赠送金币
|
|
|
- //评论奖励
|
|
|
- $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,13);
|
|
|
- if($task_rs === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error('完成任务赠送奖励失败');
|
|
|
- }
|
|
|
+ Db::name('topic_dongtai')->where('id',$id)->setInc('answernum');
|
|
|
|
|
|
Db::commit();
|
|
|
$this->success('评价成功');
|
|
|
}
|
|
|
|
|
|
+ //对评论点赞
|
|
|
+ public function answer_good(){
|
|
|
+ $dt_id = input('dt_id',0);
|
|
|
+ $answer_id = input('answer_id',0);
|
|
|
+
|
|
|
+ $where = [
|
|
|
+ 'dt_id' => $dt_id,
|
|
|
+ 'answer_id' => $answer_id,
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ ];
|
|
|
+ $check = Db::name('topic_answer_good')->where($where)->find();
|
|
|
+
|
|
|
+ if($check){
|
|
|
+ $this->error('已经赞过了');
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ $where['createtime'] = time();
|
|
|
+ $rs = Db::name('topic_answer_good')->insertGetId($where);
|
|
|
+ $up = Db::name('topic_dongtai_answer')->where('id',$answer_id)->setInc('goodnum');
|
|
|
+
|
|
|
+ if($rs && $up !== false){
|
|
|
+ Db::commit();
|
|
|
+ $this->success('点赞成功');
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('点赞失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ //举报枚举
|
|
|
+ public function report_enum(){
|
|
|
+ $arr = [
|
|
|
+ '侮辱谩骂',
|
|
|
+ '色情低俗',
|
|
|
+ '整治敏感',
|
|
|
+ '违法违规',
|
|
|
+ '其他',
|
|
|
+ ];
|
|
|
+ $this->success(1,$arr);
|
|
|
+ }
|
|
|
+
|
|
|
+ //举报
|
|
|
+ /*public function report(){
|
|
|
+ $field = ['dt_id','type','content','images'];
|
|
|
+ $data = request_post_hub($field);
|
|
|
+
|
|
|
+ $check = Db::name('topic_dongtai')->where('id',$data['dt_id'])->find();
|
|
|
+
|
|
|
+ $data['user_id'] = $this->auth->id;
|
|
|
+ $data['ruser_id'] = $check['user_id'];
|
|
|
+ $data['createtime'] = time();
|
|
|
+
|
|
|
+ Db::name('topic_dongtai_report')->insertGetId($data);
|
|
|
+ $this->success('举报成功');
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //不感兴趣,屏蔽某条
|
|
|
+ public function screen(){
|
|
|
+ $data = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'dt_id' => input('dt_id',0),
|
|
|
+ ];
|
|
|
+ $check = Db::name('topic_dongtai_screen')->where($data)->find();
|
|
|
+ if($check){
|
|
|
+ $this->success('操作成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::name('topic_dongtai_screen')->insertGetId($data);
|
|
|
+
|
|
|
+ $this->success('操作成功');
|
|
|
+ }
|
|
|
+
|
|
|
//评论列表
|
|
|
- private function answer_list($dt_id){
|
|
|
+ public function answer_list(){
|
|
|
+ $dt_id = input('dt_id',0);
|
|
|
//楼
|
|
|
$floor_list = Db::name('topic_dongtai_answer')
|
|
|
->alias('a')
|
|
|
- ->field('a.*,user.nickname,user.avatar')
|
|
|
+ ->field('a.*,user.nickname,user.avatar,user.gender')
|
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
|
- ->where(['a.dt_id'=>$dt_id,'a.level'=>1])->order('id asc')->autopage()->select();
|
|
|
+ ->where(['a.dt_id'=>$dt_id,'a.level'=>1])->order('a.id desc')->autopage()->select();
|
|
|
$floor_list = list_domain_image($floor_list,['avatar']);
|
|
|
- if(empty($floor_list)){
|
|
|
- return [];
|
|
|
- }
|
|
|
|
|
|
- //层
|
|
|
- $floors = array_column($floor_list,'floor');
|
|
|
- $child_lists = Db::name('topic_dongtai_answer')->alias('a')
|
|
|
- ->field('a.*,user.nickname,user.avatar,tuser.nickname as to_nickname,tuser.avatar as to_avatar')
|
|
|
- ->join('user','a.user_id = user.id','LEFT')
|
|
|
- ->join('user tuser','a.to_user_id = tuser.id','LEFT')
|
|
|
- ->where(['a.dt_id'=>$dt_id,'a.floor'=>['IN',$floors],'a.level'=>2])->order('id asc')->select();
|
|
|
- $child_lists = list_domain_image($child_lists,['avatar','to_avatar']);
|
|
|
- /*if(empty($child_lists)){
|
|
|
- return $floor_list;
|
|
|
- }*/
|
|
|
-
|
|
|
- //合并
|
|
|
- foreach($floor_list as $key => $val){
|
|
|
- $child = [];
|
|
|
- foreach($child_lists as $k => $v){
|
|
|
- if($val['floor'] == $v['floor']){
|
|
|
- $child[] = $v;
|
|
|
+ //追加子评论
|
|
|
+ if(!empty($floor_list)){
|
|
|
+ foreach($floor_list as $key => &$val){
|
|
|
+ //下面几条子回复,字符串
|
|
|
+ $val['childremark'] = '';
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'a.dt_id' => $dt_id,
|
|
|
+ 'a.floor' => $val['floor'],
|
|
|
+ 'a.level' => 2,
|
|
|
+ ];
|
|
|
+ $number = Db::name('topic_dongtai_answer')->alias('a')->where($map)->count();
|
|
|
+ if($number > 0){
|
|
|
+ $answer_info = Db::name('topic_dongtai_answer')
|
|
|
+ ->alias('a')
|
|
|
+ ->field('user.nickname')
|
|
|
+ ->join('user','a.user_id = user.id','LEFT')
|
|
|
+ ->where($map)->order('a.id desc')->find();
|
|
|
+
|
|
|
+ $val['childremark'] = $answer_info['nickname'].'...等人,共'.$number.'条回复';
|
|
|
}
|
|
|
- }
|
|
|
- //追加到外循环
|
|
|
- $floor_list[$key]['childcount'] = 0;
|
|
|
|
|
|
- if(count($child) > 4){
|
|
|
- $floor_list[$key]['childcount'] = count($child) - 4;
|
|
|
+ //时间处理
|
|
|
+ $val['createtime_text'] = get_last_time($val['createtime']);
|
|
|
+
|
|
|
+ //回复是否已赞
|
|
|
+ $val['is_good'] = $this->answer_is_good($val['id'],$this->auth->id);
|
|
|
}
|
|
|
- $floor_list[$key]['child'] = array_slice($child,0,4);
|
|
|
}
|
|
|
|
|
|
- return $floor_list;
|
|
|
+ $this->success(1,$floor_list);
|
|
|
}
|
|
|
|
|
|
//单独某一层的详细
|
|
|
- public function floor_info(){
|
|
|
- $floor_id = input('floor_id');
|
|
|
+ public function answer_info(){
|
|
|
+ $answer_id = input('answer_id');
|
|
|
|
|
|
//楼
|
|
|
$floor_info = Db::name('topic_dongtai_answer')
|
|
|
->alias('a')
|
|
|
- ->field('a.*,user.nickname,user.avatar')
|
|
|
+ ->field('a.*,user.nickname,user.avatar,user.gender')
|
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
|
- ->where(['a.id'=>$floor_id])->find();
|
|
|
+ ->where(['a.id'=>$answer_id])->find();
|
|
|
$floor_info = info_domain_image($floor_info,['avatar']);
|
|
|
+ $floor_info['createtime_text'] = get_last_time($floor_info['createtime']);
|
|
|
+ //回复是否已赞
|
|
|
+ $floor_info['is_good'] = $this->answer_is_good($answer_id,$this->auth->id);
|
|
|
+ $floor_info['answernumber'] = Db::name('topic_dongtai_answer')->where(['dt_id'=>$floor_info['dt_id'],'floor'=>$floor_info['floor'],'level'=>2])->count();
|
|
|
|
|
|
//层
|
|
|
$floors = $floor_info['floor'];
|
|
|
$child_lists = Db::name('topic_dongtai_answer')->alias('a')
|
|
|
- ->field('a.*,user.nickname,user.avatar,tuser.nickname as to_nickname,tuser.avatar as to_avatar')
|
|
|
+ ->field('a.*,user.nickname,user.avatar,user.gender,tuser.nickname as to_nickname,tuser.avatar as to_avatar,tuser.gender as to_gender')
|
|
|
->join('user','a.user_id = user.id','LEFT')
|
|
|
->join('user tuser','a.to_user_id = tuser.id','LEFT')
|
|
|
- ->where(['a.floor'=>$floors,'a.level'=>2])->order('id asc')->autopage()->select();
|
|
|
+ ->where(['a.dt_id'=>$floor_info['dt_id'],'a.floor'=>$floors,'a.level'=>2])->order('a.id desc')->autopage()->select();
|
|
|
$child_lists = list_domain_image($child_lists,['avatar','to_avatar']);
|
|
|
+ if(!empty($child_lists)){
|
|
|
+ foreach($child_lists as $key => &$answer){
|
|
|
+ $answer['is_good'] = $this->answer_is_good($answer['id'],$this->auth->id);
|
|
|
+ $answer['createtime_text'] = get_last_time($answer['createtime']);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//合并
|
|
|
$floor_info['child'] = $child_lists;
|
|
@@ -301,7 +440,7 @@ class Topicdongtai extends Api
|
|
|
|
|
|
}
|
|
|
|
|
|
- //某个圈子里的动态列表,全部,最新,最热
|
|
|
+ //某个圈子里的动态列表,最新,推荐
|
|
|
public function topic_list(){
|
|
|
$topic_id = input('topic_id',0);
|
|
|
$order = input('orderby','new');
|
|
@@ -311,30 +450,60 @@ class Topicdongtai extends Api
|
|
|
$orderby = 'dt.goodnum desc';
|
|
|
}
|
|
|
|
|
|
+ $where = [];
|
|
|
+ if($topic_id){
|
|
|
+ $where['dt.topic_id'] = $topic_id;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($order == 'follow'){
|
|
|
+ $follow_user_ids = Db::name('user_fans_follow')->where(['fans_id'=>$this->auth->id])->column('user_id');
|
|
|
+ $where['dt.user_id'] = ['IN',$follow_user_ids];
|
|
|
+ }
|
|
|
+
|
|
|
+ //排除屏蔽的
|
|
|
+ $screen_ids = Db::name('topic_dongtai_screen')->where('user_id',$this->auth->id)->column('dt_id');
|
|
|
+ if(!empty($screen_ids)){
|
|
|
+ $where['dt.id'] = ['NOTIN',$screen_ids];
|
|
|
+ }
|
|
|
+ //排除黑名单的
|
|
|
+ $where2 = [];
|
|
|
+ $black_ids = Db::name('user_blacklist')->where('user_id',$this->auth->id)->column('black_user_id');
|
|
|
+ if(!empty($black_ids)){
|
|
|
+ $where2['dt.user_id'] = ['NOTIN',$black_ids];
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
$list = Db::name('topic_dongtai')->alias('dt')
|
|
|
->join('user','dt.user_id = user.id','LEFT')
|
|
|
- ->field('dt.*,user.nickname,user.avatar')
|
|
|
- ->where('dt.topic_id',$topic_id)
|
|
|
+ ->join('topic_hub topic','dt.topic_id = topic.id','LEFT')
|
|
|
+ ->field('dt.*,user.nickname,user.avatar,user.gender,topic.name as topic_name')
|
|
|
+ ->where($where)
|
|
|
+ ->where($where2)
|
|
|
->order($orderby)->autopage()->select();
|
|
|
$list = list_domain_image($list,['images','avatar']);
|
|
|
|
|
|
- //追加是否点赞
|
|
|
if(!empty($list)){
|
|
|
- $ids = array_column($list,'id');
|
|
|
- $map = [
|
|
|
- 'dt_id' => ['IN',$ids],
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- ];
|
|
|
- $good_list = Db::name('topic_dongtai_good')->where('dt_id','IN',$ids)->select();
|
|
|
-
|
|
|
- foreach($list as $key => $val){
|
|
|
- $list[$key]['isgood'] = 0;
|
|
|
-
|
|
|
- foreach($good_list as $k => $v){
|
|
|
- if($val['id'] == $v['dt_id']){
|
|
|
- $list[$key]['isgood'] = 1;
|
|
|
- }
|
|
|
+ foreach($list as $key => &$val){
|
|
|
+
|
|
|
+ //追加点赞
|
|
|
+ $val['isgood'] = $this->is_good($val['id'],$this->auth->id);
|
|
|
+
|
|
|
+ //创建视频缩略图
|
|
|
+ $val['images_thumb'] = '';
|
|
|
+ if ($val['type'] == 2) {
|
|
|
+ $images_url = explode('.', $val['images']);
|
|
|
+ unset($images_url[count($images_url) - 1]);
|
|
|
+ $val['images_thumb'] = join('.', $images_url) . '_0.jpg';
|
|
|
}
|
|
|
+
|
|
|
+ //时间
|
|
|
+ $val['createtime_text'] = get_last_time($val['createtime']);
|
|
|
+
|
|
|
+ //关注
|
|
|
+ $val['is_follow'] = $this->is_follow($val['user_id'],$this->auth->id);
|
|
|
+
|
|
|
+ //评论
|
|
|
+ $val['answernumber'] = Db::name('topic_dongtai_answer')->where(['dt_id'=>$val['id'],'level'=>1])->count();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -343,6 +512,53 @@ class Topicdongtai extends Api
|
|
|
$this->success('success',$list);
|
|
|
}
|
|
|
|
|
|
+ ////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+ //消息-互动消息-评论
|
|
|
+ //谁评论了我
|
|
|
+ public function msg_answer(){
|
|
|
+ $map = [
|
|
|
+ 'dt.user_id' => $this->auth->id,
|
|
|
+ 'a.level' => 1,
|
|
|
+ ];
|
|
|
+ $list = Db::name('topic_dongtai_answer')->alias('a')
|
|
|
+ ->field('a.id,a.createtime,user.nickname,user.gender,user.avatar')
|
|
|
+ ->join('topic_dongtai dt','a.dt_id = dt.id','LEFT')
|
|
|
+ ->join('user','a.user_id = user.id','LEFT')
|
|
|
+ ->where($map)->order('a.id desc')->autopage()->select();
|
|
|
+ $list = list_domain_image($list,['avatar']);
|
|
|
+ if(!empty($list)){
|
|
|
+ foreach($list as $key => &$val){
|
|
|
+ //时间
|
|
|
+ $val['createtime_text'] = get_last_time($val['createtime']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //消息-互动消息-获赞
|
|
|
+ //谁赞了我
|
|
|
+ public function msg_good(){
|
|
|
+ $map = [
|
|
|
+ 'dt.user_id' => $this->auth->id,
|
|
|
+ ];
|
|
|
+ $list = Db::name('topic_dongtai_good')->alias('g')
|
|
|
+ ->field('g.id,g.createtime,user.nickname,user.gender,user.avatar')
|
|
|
+ ->join('topic_dongtai dt','g.dt_id = dt.id','LEFT')
|
|
|
+ ->join('user','g.user_id = user.id','LEFT')
|
|
|
+ ->where($map)->order('g.id desc')->autopage()->select();
|
|
|
+ $list = list_domain_image($list,['avatar']);
|
|
|
+ if(!empty($list)){
|
|
|
+ foreach($list as $key => &$val){
|
|
|
+ //时间
|
|
|
+ $val['createtime_text'] = get_last_time($val['createtime']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|