From fc00ef97280629c1f3f7134bdd0b50d2593afa4c Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Wed, 21 Aug 2024 17:33:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=BD=E5=90=8D=E7=A9=BA?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/LocalStore.php | 4 ++-- app/api/validate/LocalStoreGoodsValidate.php | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/api/controller/LocalStore.php b/app/api/controller/LocalStore.php index 1c8776eb..5d4bf6b1 100755 --- a/app/api/controller/LocalStore.php +++ b/app/api/controller/LocalStore.php @@ -12,7 +12,7 @@ use app\api\logic\LocalStoreLogic; use EasyWeChat\Factory; use think\facade\Db; use think\facade\Config as FileConfig; -use app\api\validate\LocalStoreGoodsValidate; +use app\api\validate\LocalStoreGoods; class LocalStore extends Api { @@ -270,6 +270,6 @@ class LocalStore extends Api public function addGoods() { $form = $this->request->post(); - (new LocalStoreGoodsValidate())->goCheck(); + (new LocalStoreGoods())->goCheck(); } } \ No newline at end of file diff --git a/app/api/validate/LocalStoreGoodsValidate.php b/app/api/validate/LocalStoreGoodsValidate.php index 039c598a..1fe814e6 100755 --- a/app/api/validate/LocalStoreGoodsValidate.php +++ b/app/api/validate/LocalStoreGoodsValidate.php @@ -3,7 +3,7 @@ namespace app\api\validate; use think\Validate; -class LocalStoreGoodsValidate extends Validate +class LocalStoreGoods extends Validate { protected $rule = [ 'lstore_id' => 'require', @@ -18,9 +18,12 @@ class LocalStoreGoodsValidate extends Validate 'url.require' => '商品图片不能为空', ]; + protected $scene = [ + 'add' => ['lstore_id', 'title', 'price', 'url'], + ]; + public function checkPrice($value) { - dump($value);die; $pattern = '/^\d+(\.\d{1,2})?$/'; if (!preg_match($pattern, $value)) { return "价格或金额格式不正确";