|  | @@ -303,7 +303,7 @@ class Topicdongtai extends Api
 | 
	
		
			
				|  |  |          $this->success('success',$info);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    //点赞
 | 
	
		
			
				|  |  | +    //点赞,取消点赞
 | 
	
		
			
				|  |  |      public function good(){
 | 
	
		
			
				|  |  |          $id = input('id');
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -314,27 +314,30 @@ class Topicdongtai extends Api
 | 
	
		
			
				|  |  |          $check = Db::name('topic_dongtai_good')->where($where)->find();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if($check){
 | 
	
		
			
				|  |  | -            $this->error('已经赞过了');
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +            Db::name('topic_dongtai_good')->where($where)->delete();
 | 
	
		
			
				|  |  | +            $down = Db::name('topic_dongtai')->where('id',$id)->setDec('goodnum');
 | 
	
		
			
				|  |  | +            $this->success('已取消点赞');
 | 
	
		
			
				|  |  | +        }else{
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        Db::startTrans();
 | 
	
		
			
				|  |  | -        $where['createtime'] = time();
 | 
	
		
			
				|  |  | -        $rs = Db::name('topic_dongtai_good')->insertGetId($where);
 | 
	
		
			
				|  |  | -        if(!$rs){
 | 
	
		
			
				|  |  | -            Db::rollback();
 | 
	
		
			
				|  |  | -            $this->error('点赞失败');
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +            Db::startTrans();
 | 
	
		
			
				|  |  | +            $where['createtime'] = time();
 | 
	
		
			
				|  |  | +            $rs = Db::name('topic_dongtai_good')->insertGetId($where);
 | 
	
		
			
				|  |  | +            if(!$rs){
 | 
	
		
			
				|  |  | +                Db::rollback();
 | 
	
		
			
				|  |  | +                $this->error('点赞失败');
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        $up = Db::name('topic_dongtai')->where('id',$id)->setInc('goodnum');
 | 
	
		
			
				|  |  | -        if($up === false){
 | 
	
		
			
				|  |  | -            Db::rollback();
 | 
	
		
			
				|  |  | -            $this->error('点赞失败');
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +            $up = Db::name('topic_dongtai')->where('id',$id)->setInc('goodnum');
 | 
	
		
			
				|  |  | +            if($up === false){
 | 
	
		
			
				|  |  | +                Db::rollback();
 | 
	
		
			
				|  |  | +                $this->error('点赞失败');
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -//        \app\common\model\TaskLog::tofinish($this->auth->id,"VpXtablCsZ",1);
 | 
	
		
			
				|  |  | +            // \app\common\model\TaskLog::tofinish($this->auth->id,"VpXtablCsZ",1);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        Db::commit();
 | 
	
		
			
				|  |  | -        $this->success('点赞成功');
 | 
	
		
			
				|  |  | +            Db::commit();
 | 
	
		
			
				|  |  | +            $this->success('点赞成功');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      //评论
 | 
	
	
		
			
				|  | @@ -410,20 +413,23 @@ class Topicdongtai extends Api
 | 
	
		
			
				|  |  |          $check = Db::name('topic_answer_good')->where($where)->find();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if($check){
 | 
	
		
			
				|  |  | -            $this->error('已经赞过了');
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +            Db::name('topic_answer_good')->where($where)->delete();
 | 
	
		
			
				|  |  | +            Db::name('topic_dongtai_answer')->where('id',$answer_id)->setDec('goodnum');
 | 
	
		
			
				|  |  | +            $this->success('已取消点赞');
 | 
	
		
			
				|  |  | +        }else{
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        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');
 | 
	
		
			
				|  |  | +            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('点赞成功');
 | 
	
		
			
				|  |  | +            if($rs && $up !== false){
 | 
	
		
			
				|  |  | +                Db::commit();
 | 
	
		
			
				|  |  | +                $this->success('点赞成功');
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            Db::rollback();
 | 
	
		
			
				|  |  | +            $this->error('点赞失败');
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        Db::rollback();
 | 
	
		
			
				|  |  | -        $this->error('点赞失败');
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      //举报枚举
 | 
	
	
		
			
				|  | @@ -453,7 +459,7 @@ class Topicdongtai extends Api
 | 
	
		
			
				|  |  |          $this->success('举报成功');
 | 
	
		
			
				|  |  |      }*/
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    //收藏
 | 
	
		
			
				|  |  | +    //收藏,取消收藏
 | 
	
		
			
				|  |  |      public function collect(){
 | 
	
		
			
				|  |  |          $where = [
 | 
	
		
			
				|  |  |              'user_id'  => $this->auth->id,
 | 
	
	
		
			
				|  | @@ -462,7 +468,8 @@ class Topicdongtai extends Api
 | 
	
		
			
				|  |  |          ];
 | 
	
		
			
				|  |  |          $check = Db::name('user_collect')->where($where)->find();
 | 
	
		
			
				|  |  |          if($check){
 | 
	
		
			
				|  |  | -            $this->success('已经收藏过了');
 | 
	
		
			
				|  |  | +            Db::name('user_collect')->where($where)->delete();
 | 
	
		
			
				|  |  | +            $this->success('已取消收藏');
 | 
	
		
			
				|  |  |          }else{
 | 
	
		
			
				|  |  |              Db::name('user_collect')->insertGetId($where);
 | 
	
		
			
				|  |  |              $this->success('收藏成功');
 |