diff --git a/app/controller/api/Comment.php b/app/controller/api/Comment.php index 94cab7d..478b834 100644 --- a/app/controller/api/Comment.php +++ b/app/controller/api/Comment.php @@ -51,16 +51,14 @@ class Comment extends Base }); if (empty($account)) { - throw new ValidateException('用户无效!'); + throw new RepositoryException('用户无效!'); } - if(strtotime($account->blank_time) >time()){ - throw new ValidateException('用户被加入黑名单,暂时不能评论,请在' .$account->blank_time . "后评论"); + throw new RepositoryException('用户被加入黑名单,暂时不能评论,请在' .$account->blank_time . "后评论"); } - $param = [ - "comment" => json_encode(input("comment/a", []),JSON_UNESCAPED_UNICODE),//评论内容 图片类型放入地址 语音类型放置语音文件地址 + "comment" => input("comment/s", ""),//评论内容 图片类型放入地址 语音类型放置语音文件地址 "user_code" => $account['user_code'], "create_time" => date("Y-m-d H:i:s"), //"url" => input("url/s", ""),//图片地址 仅图片评论才有 @@ -71,7 +69,6 @@ class Comment extends Base "location" => input("location/s"), ]; - //如果是图片或者语音 加上域名信息 if(in_array($param['type'],[CommentModel::type_img,CommentModel::type_voice])){ $comment = $param['comment']; @@ -80,7 +77,6 @@ class Comment extends Base } - //检测评论规则 validate(VComment::class)->check($param); @@ -89,7 +85,7 @@ class Comment extends Base } catch (ValidateException $e) { return $this->json(4001, $e->getError()); } catch (RepositoryException $e) { - return $this->json(4001, $e->getMessage()); + return $this->json(4001, $e->getError()); } catch (Exception $e) { echo $e->getMessage(); return $this->json(5001, '服务器繁忙!获取用户个人信息失败'); diff --git a/app/validate/Comment.php b/app/validate/Comment.php index b817147..b9696ad 100644 --- a/app/validate/Comment.php +++ b/app/validate/Comment.php @@ -9,7 +9,7 @@ use app\model\Comment as CommentModel; class Comment extends Validate { protected $rule = [ - 'comment|评论内容' => 'require|checkComment|max:1024', + 'comment|评论内容' => 'require|checkComment', 'user_code|用户' => 'require|length:32', 'url|图片文件地址' => 'length:0,255', 'type|类型' => 'require|checkType',