Compare commits
10 Commits
39c0de87b7
...
1798f6ea8c
| Author | SHA1 | Date | |
|---|---|---|---|
| 1798f6ea8c | |||
| d39df73150 | |||
| 8582d93678 | |||
| 7bfb0cca1e | |||
| 2227390f77 | |||
| d3594feabd | |||
| 1724bf8afb | |||
| 94572876fb | |||
| d469a2c9f2 | |||
| a16e1a0ff1 |
@@ -8,6 +8,9 @@ use app\admin\validate\v1\ArticleValidate;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
/**
|
||||
* 文章管理控制器
|
||||
*/
|
||||
class Article
|
||||
{
|
||||
// 文章列表
|
||||
@@ -75,7 +78,7 @@ class Article
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
])
|
||||
->id(request()->param('id'))
|
||||
->bypk(request()->param('id'))
|
||||
->find();
|
||||
if (is_null($article)) {
|
||||
return error('文章不存在');
|
||||
@@ -143,7 +146,7 @@ class Article
|
||||
return error($validate->getError());
|
||||
}
|
||||
|
||||
$article = ArticleModel::id($id)->find();
|
||||
$article = ArticleModel::bypk($id)->find();
|
||||
if (is_null($article)) {
|
||||
return error('请确认操作对象是否存在');
|
||||
}
|
||||
@@ -154,11 +157,31 @@ class Article
|
||||
return success('操作成功');
|
||||
}
|
||||
|
||||
// 设置排序值
|
||||
public function sort()
|
||||
{
|
||||
$id = request()->param('id');
|
||||
$sort = request()->post('sort');
|
||||
|
||||
$article = ArticleModel::bypk($id)->find();
|
||||
if (empty($article)) {
|
||||
return error('请确认操作对象是否存在');
|
||||
}
|
||||
if ($sort != $article->sort) {
|
||||
$article->sort = $sort;
|
||||
if (!$article->save()) {
|
||||
return error('操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
return success('操作成功');
|
||||
}
|
||||
|
||||
// 删除文章
|
||||
public function delete()
|
||||
{
|
||||
$id = request()->param('id');
|
||||
$article = ArticleModel::id($id)->find();
|
||||
$article = ArticleModel::bypk($id)->find();
|
||||
if (is_null($article)) {
|
||||
return error('请确认操作对象是否存在');
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ namespace app\admin\controller\v1;
|
||||
use app\admin\model\v1\ArticleCategoryModel;
|
||||
use app\admin\validate\v1\ArticleCategoryValidate;
|
||||
|
||||
/**
|
||||
* 文章分类管理控制器
|
||||
*/
|
||||
class ArticleCategory
|
||||
{
|
||||
// 分类列表
|
||||
@@ -58,8 +61,8 @@ class ArticleCategory
|
||||
public function read()
|
||||
{
|
||||
$id = request()->param('id');
|
||||
$category = ArticleCategoryModel::where('id', '=', $id)
|
||||
->withoutField(['language_id', 'deleted_at'])
|
||||
$category = ArticleCategoryModel::withoutField(['language_id', 'deleted_at'])
|
||||
->bypk($id)
|
||||
->find();
|
||||
if (is_null($category)) {
|
||||
return error('文章分类不存在');
|
||||
@@ -111,8 +114,8 @@ class ArticleCategory
|
||||
return error($valiate->getError());
|
||||
}
|
||||
|
||||
$category = ArticleCategoryModel::where('id', '=', $id)->find();
|
||||
if (is_null($category)) {
|
||||
$category = ArticleCategoryModel::bypk($id)->find();
|
||||
if (empty($category)) {
|
||||
return error('请确认操作对象是否存在');
|
||||
}
|
||||
if (!$category->save($data)) {
|
||||
@@ -122,11 +125,31 @@ class ArticleCategory
|
||||
return success('操作成功');
|
||||
}
|
||||
|
||||
// 设置排序值
|
||||
public function sort()
|
||||
{
|
||||
$id = request()->param('id');
|
||||
$sort = request()->post('sort');
|
||||
|
||||
$category = ArticleCategoryModel::bypk($id)->find();
|
||||
if (empty($category)) {
|
||||
return error('请确认操作对象是否存在');
|
||||
}
|
||||
if ($sort != $category->sort) {
|
||||
$category->sort = $sort;
|
||||
if (!$category->save()) {
|
||||
return error('操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
return success('操作成功');
|
||||
}
|
||||
|
||||
// 删除分类
|
||||
public function delete()
|
||||
{
|
||||
$id = request()->param('id');
|
||||
$category = ArticleCategoryModel::where('id', '=', $id)->find();
|
||||
$category = ArticleCategoryModel::bypk($id)->find();
|
||||
if (is_null($category)) {
|
||||
return error('请确认操作对象是否存在');
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ use app\admin\model\v1\ArticleLeaveMessageModel;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
/**
|
||||
* 文章留言(评论)管理控制器
|
||||
*/
|
||||
class ArticleLeaveMessage
|
||||
{
|
||||
// 文章留言分页列表
|
||||
@@ -56,7 +59,7 @@ class ArticleLeaveMessage
|
||||
$id = request()->param('id');
|
||||
|
||||
// 审核/反审核
|
||||
$message = ArticleLeaveMessageModel::id($id)->find();
|
||||
$message = ArticleLeaveMessageModel::bypk($id)->find();
|
||||
if (is_null($message)) {
|
||||
return error('请确认操作对象');
|
||||
}
|
||||
@@ -75,7 +78,7 @@ class ArticleLeaveMessage
|
||||
$id = request()->param('id');
|
||||
|
||||
// 删除
|
||||
$message = ArticleLeaveMessageModel::id($id)->find();
|
||||
$message = ArticleLeaveMessageModel::bypk($id)->find();
|
||||
if (is_null($message)) {
|
||||
return error('请确认操作对象');
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ namespace app\admin\controller\v1;
|
||||
|
||||
use app\admin\model\v1\ArticleModel;
|
||||
|
||||
/**
|
||||
* 文章回收站管理控制器
|
||||
*/
|
||||
class ArticleTrash
|
||||
{
|
||||
// 文章回收站分页列表
|
||||
@@ -50,7 +53,7 @@ class ArticleTrash
|
||||
return error('参数错误');
|
||||
}
|
||||
|
||||
$article = ArticleModel::onlyTrashed()->id($id)->find();
|
||||
$article = ArticleModel::onlyTrashed()->bypk($id)->find();
|
||||
if (is_null($article)) {
|
||||
return error('请确认操作对象');
|
||||
}
|
||||
@@ -69,7 +72,7 @@ class ArticleTrash
|
||||
return error('参数错误');
|
||||
}
|
||||
|
||||
$article = ArticleModel::onlyTrashed()->id($id)->find();
|
||||
$article = ArticleModel::onlyTrashed()->bypk($id)->find();
|
||||
if (is_null($article)) {
|
||||
return error('请确认操作对象');
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ namespace app\admin\controller\v1;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 验证码控制器
|
||||
*/
|
||||
class Captcha
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,9 @@ use app\admin\model\v1\ImageModel;
|
||||
use Intervention\Image\ImageManager;
|
||||
use think\facade\Filesystem;
|
||||
|
||||
/**
|
||||
* 图片管理控制器
|
||||
*/
|
||||
class Images
|
||||
{
|
||||
// 上传
|
||||
|
||||
@@ -7,6 +7,9 @@ use app\admin\model\v1\LanguageModel;
|
||||
use think\facade\Cookie;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 语言管理控制器
|
||||
*/
|
||||
class Language
|
||||
{
|
||||
// 语言列表
|
||||
@@ -32,7 +35,7 @@ class Language
|
||||
public function cutover()
|
||||
{
|
||||
$id = request()->param('id');
|
||||
$language = LanguageModel::id($id)->find();
|
||||
$language = LanguageModel::bypk($id)->find();
|
||||
if (is_null($language)) {
|
||||
return error('语言不存在');
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ use app\admin\validate\v1\LoginValidate;
|
||||
use thans\jwt\facade\JWTAuth;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 登录控制器
|
||||
*/
|
||||
class Login
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -6,10 +6,15 @@ namespace app\admin\controller\v1;
|
||||
use app\admin\model\v1\ProductModel;
|
||||
use app\admin\model\v1\ProductParamsModel;
|
||||
use app\admin\model\v1\ProductRelatedModel;
|
||||
use app\admin\model\v1\ProductSkuAttrModel;
|
||||
use app\admin\model\v1\ProductSkuModel;
|
||||
use app\admin\validate\v1\ProductValidate;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
/**
|
||||
* 产品管理控制器
|
||||
*/
|
||||
class Product
|
||||
{
|
||||
// 分页列表
|
||||
@@ -88,6 +93,15 @@ class Product
|
||||
}
|
||||
$product->params = implode(PHP_EOL, $params);
|
||||
|
||||
// 获取sku数据
|
||||
$product->skus = ProductSkuModel::withoutField(['created_at', 'updated_at'])
|
||||
->with(['attrs' => function($query) {
|
||||
$query->hidden(['sku_id']);
|
||||
}])
|
||||
->productId($product->id)
|
||||
->select()
|
||||
->hidden(['id', 'product_id']);
|
||||
|
||||
// 获取关联产品
|
||||
$product->related = ProductRelatedModel::field([
|
||||
'related_product_id',
|
||||
@@ -124,18 +138,21 @@ class Product
|
||||
'sort',
|
||||
'detail',
|
||||
'params' => '',
|
||||
'skus' => '',
|
||||
'related' => '',
|
||||
'status' => 1,
|
||||
'seo_title',
|
||||
'seo_keywords',
|
||||
'seo_desc'
|
||||
]);
|
||||
$put = array_merge(
|
||||
$put,
|
||||
['skus' => json_decode($put['skus'], true)],
|
||||
['related' => json_decode($put['related'], true)],
|
||||
);
|
||||
|
||||
$validate = new ProductValidate();
|
||||
$check_data = array_merge($put, [
|
||||
'id' => $id,
|
||||
'language_id' => request()->lang_id
|
||||
]);
|
||||
$check_data = array_merge($put, ['id' => $id, 'language_id' => request()->lang_id]);
|
||||
if (!$validate->scene('update')->check($check_data)) {
|
||||
return error($validate->getError());
|
||||
}
|
||||
@@ -160,24 +177,92 @@ class Product
|
||||
'value' => $match_result[2][$i]
|
||||
];
|
||||
}
|
||||
if (!empty($params)) ProductParamsModel::insertAll($params);
|
||||
if (!empty($params)) {
|
||||
ProductParamsModel::insertAll($params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新SKU
|
||||
if (!empty($put['skus'])) {
|
||||
$skus = [];
|
||||
$attrs_group = [];
|
||||
foreach ($put['skus'] as $val) {
|
||||
$skus[] = [
|
||||
'product_id' => $id,
|
||||
'sku' => $val['sku'],
|
||||
'main_image' => $val['main_image'],
|
||||
'photo_album' => $val['photo_album'],
|
||||
'sort' => $val['sort']
|
||||
];
|
||||
foreach ($val['attrs'] as $v) {
|
||||
$attrs_group[$val['sku']][] = [
|
||||
'attr_id' => $v['attr_id'],
|
||||
'attr_value' => $v['attr_value']
|
||||
];
|
||||
}
|
||||
}
|
||||
if (!empty($skus)) {
|
||||
$sku_model = new ProductSkuModel;
|
||||
// 删除原有SKU
|
||||
$sku_model->productId($id)->delete();
|
||||
// 添加SKU
|
||||
$save_ret = $sku_model->saveAll($skus);
|
||||
if (!$save_ret->isEmpty()) {
|
||||
$sku_map = [];
|
||||
foreach ($save_ret as $val) {
|
||||
$sku_map[$val->sku] = $val->id;
|
||||
}
|
||||
$attrs = [];
|
||||
foreach ($attrs_group as $sku => $sku_attrs) {
|
||||
if (empty($sku_map[$sku])) {
|
||||
unset($attrs_group[$sku]);
|
||||
continue;
|
||||
}
|
||||
foreach ($sku_attrs as $k => $v) {
|
||||
$attrs[] = array_merge($v, ['sku_id' => $sku_map[$sku]]);
|
||||
}
|
||||
}
|
||||
(new ProductSkuAttrModel)->saveAll($attrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新关联产品
|
||||
if ($put['related'] != "") {
|
||||
if (!empty($put['related'])) {
|
||||
// 删除原有关联产品
|
||||
ProductRelatedModel::productId($id)->delete();
|
||||
$encode_result = json_decode($put['related'], true);
|
||||
if (!empty($encode_result)) {
|
||||
// 添加关联产品
|
||||
$related = [];
|
||||
foreach ($encode_result as $val) {
|
||||
foreach ($put['related'] as $val) {
|
||||
$related[] = [
|
||||
'product_id' => $id,
|
||||
'related_product_id' => $val['related_product_id'],
|
||||
'sort' => $val['sort']
|
||||
];
|
||||
}
|
||||
if (!empty($related)) ProductRelatedModel::insertAll($related);
|
||||
if (!empty($related)) {
|
||||
ProductRelatedModel::insertAll($related);
|
||||
}
|
||||
}
|
||||
|
||||
return success('操作成功');
|
||||
}
|
||||
|
||||
// 设置排序值
|
||||
public function sort()
|
||||
{
|
||||
$id = request()->param('id');
|
||||
$sort = request()->post('sort');
|
||||
|
||||
$product = ProductModel::bypk($id)->find();
|
||||
if (empty($product)) {
|
||||
return error('请确认操作对象是否存在');
|
||||
}
|
||||
if ($sort != $product->sort) {
|
||||
$product->sort = $sort;
|
||||
if (!$product->save()) {
|
||||
return error('操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ use app\admin\model\v1\ProductAttrModel;
|
||||
use app\admin\model\v1\ProductAttrPropModel;
|
||||
use app\admin\validate\v1\ProductAttrValidate;
|
||||
|
||||
/**
|
||||
* 产品属性管理控制器
|
||||
*/
|
||||
class ProductAttr
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,9 @@ namespace app\admin\controller\v1;
|
||||
use app\admin\model\v1\ProductCategoryModel;
|
||||
use app\admin\validate\v1\ProductCategoryValidate;
|
||||
|
||||
/**
|
||||
* 产品分类管理控制器
|
||||
*/
|
||||
class ProductCategory
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -22,12 +22,6 @@ class ArticleLeaveMessageModel extends ArticleLeaveMessageBaseModel
|
||||
return $this->belongsTo(ArticleModel::class, 'article_id', 'id');
|
||||
}
|
||||
|
||||
// 根据id查询
|
||||
public function scopeId($query, $value)
|
||||
{
|
||||
$query->where('id', '=', $value);
|
||||
}
|
||||
|
||||
// 审核状态查询
|
||||
public function scopeIsAudited($query, $is_audited)
|
||||
{
|
||||
|
||||
@@ -40,12 +40,6 @@ class ArticleModel extends ArticleBaseModel
|
||||
}
|
||||
}
|
||||
|
||||
// 主键查询
|
||||
public function scopeId($query, $value)
|
||||
{
|
||||
$query->where('id', '=', $value);
|
||||
}
|
||||
|
||||
// 语言查询
|
||||
public function scopeLanguage($query, $value)
|
||||
{
|
||||
|
||||
@@ -15,10 +15,4 @@ class LanguageModel extends LanguageBaseModel
|
||||
{
|
||||
return $this->belongsTo(CountryModel::class, 'country_id', 'id');
|
||||
}
|
||||
|
||||
// 根据id查询
|
||||
public function scopeId($query, $value)
|
||||
{
|
||||
$query->where('id', '=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
15
app/admin/model/v1/ProductSkuAttrModel.php
Normal file
15
app/admin/model/v1/ProductSkuAttrModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\model\v1;
|
||||
|
||||
use app\common\model\ProductSkuAttrBaseModel;
|
||||
|
||||
/**
|
||||
* 产品 - sku属性模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ProductSkuAttrModel extends ProductSkuAttrBaseModel
|
||||
{
|
||||
//
|
||||
}
|
||||
30
app/admin/model/v1/ProductSkuModel.php
Normal file
30
app/admin/model/v1/ProductSkuModel.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\model\v1;
|
||||
|
||||
use app\common\model\ProductSkuBaseModel;
|
||||
|
||||
/**
|
||||
* 产品 - sku模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ProductSkuModel extends ProductSkuBaseModel
|
||||
{
|
||||
// 设置json类型字段
|
||||
protected $json = ['photo_album'];
|
||||
// 设置JSON数据返回数组
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
// 关联产品sku属性
|
||||
public function attrs()
|
||||
{
|
||||
return $this->hasMany(ProductSkuAttrModel::class, 'sku_id', 'id');
|
||||
}
|
||||
|
||||
// 所属产品查询
|
||||
public function scopeProductId($query, $id)
|
||||
{
|
||||
$query->where('product_id', '=', $id);
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,9 @@ Route::group('v1', function () {
|
||||
// 文章更新
|
||||
Route::put('update/:id', 'Article/update');
|
||||
|
||||
// 设置排序值
|
||||
Route::post('sort/:id', 'Article/sort');
|
||||
|
||||
// 文章删除
|
||||
Route::delete('delete/:id', 'Article/delete');
|
||||
|
||||
@@ -78,6 +81,9 @@ Route::group('v1', function () {
|
||||
// 分类更新
|
||||
Route::put('update/:id', 'ArticleCategory/update');
|
||||
|
||||
// 设置排序值
|
||||
Route::post('sort/:id', 'ArticleCategory/sort');
|
||||
|
||||
// 分类删除
|
||||
Route::delete('delete/:id', 'ArticleCategory/delete');
|
||||
});
|
||||
@@ -121,6 +127,9 @@ Route::group('v1', function () {
|
||||
// 产品更新
|
||||
Route::put('update/:id', 'Product/update');
|
||||
|
||||
// 设置排序值
|
||||
Route::post('sort/:id', 'Product/sort');
|
||||
|
||||
// 上/下架操作
|
||||
Route::get('updown_shelves/:id', 'Product/updownShelves');
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace app\admin\validate\v1;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
use function PHPSTORM_META\type;
|
||||
|
||||
class ProductValidate extends Validate
|
||||
{
|
||||
/**
|
||||
@@ -26,13 +28,20 @@ class ProductValidate extends Validate
|
||||
'is_sale' => 'in:0,1',
|
||||
'is_new' => 'in:0,1',
|
||||
'is_hot' => 'in:0,1',
|
||||
'is_show' => 'in:0,1',
|
||||
'sort' => 'integer',
|
||||
'detail' => 'max:65535',
|
||||
'status' => 'in:-1,1',
|
||||
'seo_title' => 'max:255',
|
||||
'seo_keywords' => 'max:255',
|
||||
'seo_desc' => 'max:255',
|
||||
'created_at' => 'checkFormatDatetimeRange'
|
||||
'created_at' => 'checkFormatDatetimeRange',
|
||||
'skus.*.sku' => 'max:125',
|
||||
'skus.*.main_image' => 'max:255',
|
||||
'skus.*.sort' => 'integer',
|
||||
'skus.*.attrs' => 'checkSkusAttrsItemType:attr_id,integer|checkSkusAttrsItemMax:attr_value,64',
|
||||
'related.*.related_product_id' => 'integer',
|
||||
'related.*.sort' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -54,16 +63,24 @@ class ProductValidate extends Validate
|
||||
'desc.max' => '描述不能超过255个字符',
|
||||
'video_img.max' => '视频封面图不能超过255个字符',
|
||||
'video_url.max' => '视频地址不能超过255个字符',
|
||||
'is_sale.in' => '上架状态值错误',
|
||||
'is_sale.in' => '在售状态值错误',
|
||||
'is_new.in' => '新品状态值错误',
|
||||
'is_hot.in' => '热门状态值错误',
|
||||
'is_show.in' => '上下架状态值错误',
|
||||
'sort.integer' => '排序值类型错误',
|
||||
'detail.max' => '详情不能超过65535个字符',
|
||||
'status.in' => '状态值错误',
|
||||
'seo_title.max' => 'seo标题不能超过255个字符',
|
||||
'seo_keywords.max' => 'seo关键字不能超过255个字符',
|
||||
'seo_desc.max' => 'seo描述不能超过255个字符',
|
||||
'created_at.checkFormatDatetimeRange' => '添加时间格式错误'
|
||||
'created_at.checkFormatDatetimeRange' => '添加时间格式错误',
|
||||
'skus.*.sku.max' => 'sku不能超过125个字符',
|
||||
'skus.*.main_image.max' => 'sku主图不能超过255个字符',
|
||||
'skus.*.sort.integer' => 'sku排序值类型错误',
|
||||
'skus.*.attrs.checkSkusAttrsItemType' => 'sku属性值错误',
|
||||
'skus.*.attrs.checkSkusAttrsItemMax' => 'sku属性值错误',
|
||||
'related.*.related_product_id.integer' => '关联产品ID格式错误',
|
||||
'related.*.sort.integer' => '关联产品排序值类型错误',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -71,7 +88,7 @@ class ProductValidate extends Validate
|
||||
*/
|
||||
public function sceneIndex()
|
||||
{
|
||||
return $this->only(['created_id', 'is_sale', 'created_at']);
|
||||
return $this->only(['categroy_id', 'is_show', 'created_at']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,12 +109,19 @@ class ProductValidate extends Validate
|
||||
'is_sale',
|
||||
'is_new',
|
||||
'is_hot',
|
||||
'is_show',
|
||||
'sort',
|
||||
'detail',
|
||||
'status',
|
||||
'seo_title',
|
||||
'seo_keywords',
|
||||
'seo_desc',
|
||||
'skus.*.sku',
|
||||
'skus.*.main_image',
|
||||
'skus.*.sort',
|
||||
'skus.*.attrs',
|
||||
'related.*.related_product_id',
|
||||
'related.*.sort'
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -116,4 +140,32 @@ class ProductValidate extends Validate
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function checkSkusAttrsItemType($value, $rule, $data)
|
||||
{
|
||||
$rule = explode(',', $rule);
|
||||
foreach ($value as $v) {
|
||||
if (!array_key_exists($rule[0], $v)) {
|
||||
return 'sku属性值错误';
|
||||
}
|
||||
if ($rule[1] == gettype($rule[0])) {
|
||||
return "sku中{$rule[0]}类型错误";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function checkSkusAttrsItemMax($value, $rule, $data)
|
||||
{
|
||||
$rule = explode(',', $rule);
|
||||
foreach ($value as $v) {
|
||||
if (!array_key_exists($rule[0], $v)) {
|
||||
return 'sku属性值错误';
|
||||
}
|
||||
if (intval($rule[1]) < mb_strlen($v[$rule[0]], 'utf8')) {
|
||||
return "sku属性{$rule[0]}不能超过{$rule[1]}个字符";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,10 @@ declare (strict_types = 1);
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ArticleBaseModel extends Model
|
||||
class ArticleBaseModel extends BaseModel
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'article';
|
||||
|
||||
@@ -3,12 +3,10 @@ declare (strict_types = 1);
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ArticleCategoryBaseModel extends Model
|
||||
class ArticleCategoryBaseModel extends BaseModel
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'article_category';
|
||||
|
||||
@@ -3,12 +3,10 @@ declare (strict_types = 1);
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class ArticleLeaveMessageBaseModel extends Model
|
||||
class ArticleLeaveMessageBaseModel extends BaseModel
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'article_leave_message';
|
||||
|
||||
@@ -3,12 +3,10 @@ declare (strict_types = 1);
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class LanguageBaseModel extends Model
|
||||
class LanguageBaseModel extends BaseModel
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'sys_language';
|
||||
|
||||
@@ -18,6 +18,6 @@ class ProductSkuAttrBaseModel extends Model
|
||||
protected $schema = [
|
||||
'sku_id' => 'int',
|
||||
'attr_id' => 'int',
|
||||
'prop_id' => 'int',
|
||||
'attr_value' => 'string',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class CreateProductSkuAttr extends Migrator
|
||||
$table = $this->table('product_sku_attr', ['id' => false,'engine' => 'InnoDB', 'comment' => '产品SKU属性表']);
|
||||
$table->addColumn('sku_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '产品SKU ID'])
|
||||
->addColumn('attr_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '属性ID'])
|
||||
->addColumn('prop_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '属性特征ID'])
|
||||
->addColumn('attr_value', 'string', ['limit' => 64, 'null' => false, 'default' => '', 'comment' => '属性值'])
|
||||
->addForeignKey('sku_id', 'product_sku', 'id', ['update' => 'CASCADE', 'delete' => 'CASCADE'])
|
||||
->create();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user