init: 项目初始代码
This commit is contained in:
71
app/api/validate/Goods.php
Normal file
71
app/api/validate/Goods.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
namespace app\api\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 商品模块验证器
|
||||
* Class Goods
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class Goods extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => ['require','integer','gt:0'],
|
||||
'page' => ['integer','gt:0'],
|
||||
'size' => ['integer','gt:0'],
|
||||
'site_id|选择语言' => ['integer','gt:0'],
|
||||
'goods_category_id|所属分类' => ['require','integer','gt:0'],
|
||||
'name|商品标题' => ['length:1,220','unique:goods,name^site_id'],
|
||||
'model_number|商品型号' => ['length:1,128','unique:goods,model_number^site_id'],
|
||||
'price|价格' => ['float','gt:0'],
|
||||
'details|图文介绍' => ['length:1,65534'],
|
||||
'title|标题' => ['length:1,255','unique:goods,title^site_id'],
|
||||
'keywords|关键词' => ['length:1,255'],
|
||||
'description|描述' => ['length:1,255'],
|
||||
'status|上架状态' => ['in:0,1','integer'],
|
||||
'is_new|是否新品' => ['in:0,1','integer'],
|
||||
'is_discount|是否折扣' => ['in:0,1','integer'],
|
||||
'is_hot|是否热门' => ['in:0,1','integer'],
|
||||
'is_recommend|是否推荐' => ['in:0,1','integer'],
|
||||
'sort|排序' => ['between:1,255'],
|
||||
'image|产品主图' => [
|
||||
'fileSize' => 1024 * 1024 * 1,
|
||||
'fileExt' => 'jpg,png,gif,bmp',
|
||||
'fileMime' => 'image/jpeg,image/png,image/gif'
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [];
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $scene = [
|
||||
'index' => ['page','size'],
|
||||
'read' => ['id'],
|
||||
'create' => ['site_id','goods_category_id','name','model_number','price','details','title','keywords','description','status'],
|
||||
'update' => ['id','name','goods_category_id','model_number','price','details','title','keywords','description','status'],
|
||||
'del' => ['id'],
|
||||
'changeStatus' => ['id','status'],
|
||||
'batchGoodsDel' => ['id'],
|
||||
'batchGoodsEnable' => ['id','status'],
|
||||
'batchGoodsDisable' => ['id','status'],
|
||||
'batchCategoryModify' => ['id','goods_category_id'],
|
||||
'upload' => ['image'],
|
||||
'changeSort' => ['id','sort']
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user