setter
parent
13dd86109c
commit
bf262e41cf
|
@ -6,7 +6,7 @@ use app\exception\RepositoryException;
|
|||
use app\model\Comment as CommentModel;
|
||||
use app\repository\AccountRepository;
|
||||
use app\repository\CommentRepository;
|
||||
use app\repository\CouponRepository;
|
||||
use app\validate\Comment as VComment;
|
||||
use think\Exception;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
|
@ -23,7 +23,7 @@ class Comment extends Base
|
|||
];
|
||||
|
||||
/**
|
||||
* 群聊列表 开发中
|
||||
* 群聊列表
|
||||
* */
|
||||
public function myCommentZone()
|
||||
{
|
||||
|
@ -48,23 +48,32 @@ class Comment extends Base
|
|||
});
|
||||
|
||||
if (empty($account)) {
|
||||
throw new ValidateException('用户无效!');
|
||||
throw new RepositoryException('用户无效!');
|
||||
}
|
||||
|
||||
//检测评论规则
|
||||
|
||||
|
||||
$param = [
|
||||
"comment" => input("comment/s", ""),//评论内容 图片类型放入地址 语音类型放置语音文件地址
|
||||
"user_code" => $account['user_code'],
|
||||
"create_time" => date("Y-m-d H:i:s"),
|
||||
"url" => input("url/s", ""),//图片地址 仅图片评论才有
|
||||
//"url" => input("url/s", ""),//图片地址 仅图片评论才有
|
||||
"state" => CommentModel::state_default,
|
||||
"type" => input("type/d",0),//评论类型
|
||||
"lng" => input("lng/s"),//经度
|
||||
"lat" => input("lat/s"),//纬度
|
||||
"location" => input("location/s"),
|
||||
];
|
||||
//如果是图片或者语音 加上域名信息
|
||||
if(in_array($param['type'],[CommentModel::type_img,CommentModel::type_voice])){
|
||||
$comment = $param['comment'];
|
||||
$param['url'] = $this->request->domain() . $comment;
|
||||
$param['comment'] = $this->request->domain() . $comment;
|
||||
|
||||
}
|
||||
|
||||
//检测评论规则
|
||||
validate(VComment::class)->check($param);
|
||||
|
||||
CommentModel::create($param);
|
||||
return $this->json(0,"评论成功,等待审核");
|
||||
} catch (ValidateException $e) {
|
||||
|
|
|
@ -58,7 +58,7 @@ class Index extends Base
|
|||
{
|
||||
$res = [];
|
||||
$res['homeInfo'] = ['title' => '控制台', 'href' => "manager/index/dashboard"];
|
||||
$res['logoInfo'] = ['title' => '恒美植发', 'href' => "", 'image' => '/static/manager/image/logo.png'];
|
||||
$res['logoInfo'] = ['title' => '优惠券', 'href' => "", 'image' => '/static/manager/image/logo.png'];
|
||||
|
||||
$menus = CmsRepository::getInstance()->getMenuList(Menu::TYPE_MENU, Menu::SHOW_YES)->toArray();
|
||||
$userId = $this->auth['user_id'] ?? 0;
|
||||
|
|
|
@ -36,6 +36,7 @@ class CommentRepository extends Repository
|
|||
"a.user_code as userCode",
|
||||
"a.business_code as businessCode",
|
||||
"b.nick_name as consumerName",
|
||||
"b.avatar_url as avator",
|
||||
"a.create_time as createTime",
|
||||
"a.url",
|
||||
"a.type",
|
||||
|
@ -45,4 +46,7 @@ class CommentRepository extends Repository
|
|||
->select();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -2,13 +2,14 @@
|
|||
|
||||
namespace app\validate;
|
||||
|
||||
use app\model\CommentRule;
|
||||
use think\Validate;
|
||||
use app\model\Comment as CommentModel;
|
||||
|
||||
class Comment extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'comment|评论内容' => 'require|max:1024',
|
||||
'comment|评论内容' => 'require|checkComment|max:1024',
|
||||
'user_code|用户' => 'require|length:32',
|
||||
'url|图片文件地址' => 'length:0,255',
|
||||
'type|类型' => 'require|checkType',
|
||||
|
@ -25,4 +26,28 @@ class Comment extends Validate
|
|||
{
|
||||
return isset(CommentModel::allType()[$value]) ? true : '评论类型错误';
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查评论规则
|
||||
* */
|
||||
protected function checkComment($value,$rule,$data=[])
|
||||
{
|
||||
$rule = CommentRule::where("state",CommentRule::COMMON_ON)->select();
|
||||
if($rule->isEmpty()){
|
||||
return true;
|
||||
}
|
||||
foreach ($rule as $item){
|
||||
$font = explode("|",$item["rule"]);
|
||||
foreach ($font as $ruleItem){
|
||||
if(empty(trim($ruleItem))){
|
||||
continue;
|
||||
}
|
||||
if(strpos($value,trim($ruleItem))!=false){
|
||||
return "评论内容不能包含敏感词语";
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@
|
|||
<div class="main-body">
|
||||
<div class="login-main">
|
||||
<div class="login-top">
|
||||
<span>恒美植发后台登录</span>
|
||||
<span>优惠券后台登录</span>
|
||||
<span class="bg1"></span>
|
||||
<span class="bg2"></span>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue