|
@@ -26,9 +26,42 @@ class Topichub extends Api
|
|
|
$info = Db::name('topic_hub')->where(['status'=>1,'id'=>$id])->find();
|
|
|
$info = info_domain_image($info,['image']);
|
|
|
|
|
|
+ //是否关注
|
|
|
+ $is_follow = Db::name('user_follow_topic')->where(['uid'=>$this->auth->id,'topic_id'=>$id])->find();
|
|
|
+ $info['is_follow'] = !empty($is_follow) ? 1 : 0;
|
|
|
+
|
|
|
$this->success('success',$info);
|
|
|
}
|
|
|
|
|
|
+ //关注某人
|
|
|
+ public function follow_one(){
|
|
|
+ $topic_id = input('topic_id',0);
|
|
|
+ if(!$topic_id){
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $topic_hub = Db::name('topic_hub')->find($topic_id);
|
|
|
+ if(empty($topic_hub)){
|
|
|
+ $this->error('此话题不存在');
|
|
|
+ }
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'uid' => $this->auth->id,
|
|
|
+ 'topic_id' => $topic_id,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $check = Db::name('user_follow_topic')->where($map)->find();
|
|
|
+ if($check){
|
|
|
+ //取关
|
|
|
+ $rs = Db::name('user_follow_topic')->where($map)->delete();
|
|
|
+ $this->success('操作成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ $id = Db::name('user_follow_topic')->insertGetId($map);
|
|
|
+
|
|
|
+ $this->success('操作成功',$id);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|