|
@@ -672,6 +672,35 @@ class Topicdongtai extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //动态是否收藏
|
|
|
+ private function is_collect($dt_id,$uid){
|
|
|
+ $where = [
|
|
|
+ 'user_id' => $uid,
|
|
|
+ 'table' => 'topic_dongtai',
|
|
|
+ 'table_id' => $dt_id,
|
|
|
+ ];
|
|
|
+ $check = Db::name('user_collect')->where($where)->find();
|
|
|
+ if($check){
|
|
|
+ return 1;
|
|
|
+ }else{
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //用户是否拉黑
|
|
|
+ private function is_balck($uid,$black_uid){
|
|
|
+ $where = [
|
|
|
+ 'uid' => $uid,
|
|
|
+ 'black_uid' => $black_uid,
|
|
|
+ ];
|
|
|
+ $check = Db::name('user_black')->where($where)->find();
|
|
|
+ if($check){
|
|
|
+ return 1;
|
|
|
+ }else{
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//我的评论
|
|
|
public function my_answer(){
|
|
@@ -709,7 +738,32 @@ class Topicdongtai extends Api
|
|
|
//删除我的某个评论
|
|
|
public function delete_answer(){
|
|
|
$id = input('id',0);
|
|
|
- Db::name('topic_dongtai_answer')->where('id',$id)->where('user_id',$this->auth->id)->delete();
|
|
|
+ if(!$id){
|
|
|
+ $this->error();
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ $info = Db::name('topic_dongtai_answer')->where('id',$id)->where('user_id',$this->auth->id)->find();
|
|
|
+ if(!$info){
|
|
|
+ $this->error('不存在的动态评论');
|
|
|
+ }
|
|
|
+
|
|
|
+ if($info['level'] == 1){
|
|
|
+ Db::name('topic_dongtai')->where('id',$info['dt_id'])->setDec('answernum');//回复数减1
|
|
|
+
|
|
|
+ //楼层内都删
|
|
|
+ $louceng_id = Db::name('topic_dongtai_answer')->where('dt_id',$info['dt_id'])->where('level',2)->where('floor',$info['floor'])->column('id');
|
|
|
+ if(!empty($louceng_id)){
|
|
|
+ Db::name('topic_dongtai_answer')->where('id','IN',$louceng_id)->delete();//评论删掉
|
|
|
+ Db::name('topic_answer_good')->where('answer_id','IN',$louceng_id)->delete();//评论点赞删掉
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::name('topic_dongtai_answer')->where('id',$id)->delete(); //评论删掉
|
|
|
+ Db::name('topic_answer_good')->where('answer_id',$id)->delete();//评论点赞删掉
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
|
|
|
$this->success();
|
|
|
}
|