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