Commit 28e5a25b authored by zhuwei's avatar zhuwei

开盘广场 验证

parent a938962f
...@@ -30,8 +30,9 @@ class Square extends Basic ...@@ -30,8 +30,9 @@ class Square extends Basic
$params = $this->params; $params = $this->params;
if (!isset($params['title']) or !isset($params['content']) or !isset($params['site_id']) or !isset($params['cover_img']) or !isset($params['district_lable_id'])) { $checkResult = $this->validate($params, "SquareValidate.create");
return $this->response("101", "参数不全"); if (true !== $checkResult) {
return $this->response("101", $checkResult);
} }
$res= $this->s_square->saveSquare($this->userId,$params['title'],$params['house_id'],$params['content'],$params['cover_img'],$params['site_id'],$params['district_lable_id']); $res= $this->s_square->saveSquare($this->userId,$params['title'],$params['house_id'],$params['content'],$params['cover_img'],$params['site_id'],$params['district_lable_id']);
...@@ -103,8 +104,9 @@ class Square extends Basic ...@@ -103,8 +104,9 @@ class Square extends Basic
$params = $this->params; $params = $this->params;
if (!isset($params['id']) ) { $checkResult = $this->validate($params, "SquareValidate.create");
return $this->response("101", "参数不全"); if (true !== $checkResult) {
return $this->response("101", $checkResult);
} }
$this->s_square->editSquare($params); $this->s_square->editSquare($params);
......
<?php
namespace app\index\validate;
use think\Validate;
/**
* Created by PhpStorm.
* User: zhuwei
* Date: 2019-04-29
* Time: 15:28:53
*/
class SquareValidate extends Validate
{
protected $rule = [
'id' => 'require|between:1,9999999999',
'title' => 'require',
'content' => 'require',
'site_id' => 'require|number',
'cover_img' => 'require',
'district_lable_id' => 'require|number',
];
protected $message = [
'id.require' => 'id必填',
'id.between' => 'id参数错误',
'title.require' => '标题不能为空',
'content.require' => '内容不能为空',
'site_id.require' => '城市标签不能为空',
'cover_img.require' => '图片不能为空',
'district_lable_id.require' => '部门标签不能为空',
'site_id.number' => '城市标签参数错误',
'district_lable_id.number' => '部门标签参数错误',
];
protected $scene = [
'addSquare' => [ 'title', 'content', 'site_id', 'cover_img' ,'district_lable_id'],
'editSquare' => [ 'id'],
];
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment