auth($token); if(mb_strlen($comment,'UTF8')>255){ $this->set_message(1036,"评论最多可以输入255个字符"); } $model = D("Comment"); $result = $model->add_comment(USER_ACCOUNT,$game_id,$comment); if($result !== false){ $this->set_message(200,"添加成功"); }else{ $this->set_message(1036,$model->getError()); } } /** * 获取评论 * @param $game_id * @param int $p * author: xmy 280564871@qq.com */ public function get_comment($game_id,$p=1){ $model = D("Comment"); $map['game_id'] = $game_id; $data = $model->getComment($map,$p); if(empty($data)){ $this->set_message(1037,"暂无评论"); }else{ $this->set_message(200,"成功",$data); } } /** * 我的评论 * @param $token * @param int $p * author: xmy 280564871@qq.com */ public function my_comment($token,$p=1,$game_name=""){ $this->auth($token); if(!empty($game_name)){ $game = D("Game")->where(['game_name'=>['like',"%".$game_name."%"]])->select(); $map['game_id'] = ['in',array_column($game,"id")]; } $model = D("Comment"); $map['account'] = USER_ACCOUNT; $data = $model->getComment($map,$p); if(empty($data['data'])){ $this->set_message(1037,"暂无评论"); }else{ $this->set_message(200,"成功",$data); } } /** * 我的评论 * @param $token * @param int $p * author: xmy 280564871@qq.com */ public function my_comment_all($token,$p=1,$game_name=""){ $this->auth($token); $model = D("Comment"); $map['account'] = USER_ACCOUNT; $data = $model->getCommentall($map,$p); if(empty($data['data'])){ $this->set_message(1037,"暂无评论"); }else{ $this->set_message(200,"成功",$data); } } }