feat: 新增产品分类用于下拉框场景列表树接口
This commit is contained in:
@@ -17,6 +17,7 @@ class ProductCategory
|
||||
public function index()
|
||||
{
|
||||
$params = request()->param([
|
||||
'is_show',
|
||||
'keywords' => '',
|
||||
]);
|
||||
|
||||
@@ -30,8 +31,13 @@ class ProductCategory
|
||||
])
|
||||
->language(request()->lang_id)
|
||||
->withSearch(['name_nullable'], [
|
||||
'name_nullable' => $params['keywords']
|
||||
'name_nullable' => $params['keywords']??null
|
||||
])
|
||||
->where(function($query) use($params) {
|
||||
if (!empty($params['is_show'])) {
|
||||
$query->where('is_show', '=', $params['is_show']);
|
||||
}
|
||||
})
|
||||
->select();
|
||||
if ($ret->isEmpty()) {
|
||||
return success('获取成功');
|
||||
|
||||
@@ -29,9 +29,17 @@ class ProductCategoryModel extends ProductCategoryBaseModel
|
||||
$query->where('language_id', '=', $value);
|
||||
}
|
||||
|
||||
// 根据是否显示查询
|
||||
public function scopeIsShow($query, bool $value)
|
||||
/**
|
||||
* 根据是否显示查询
|
||||
* @param $query
|
||||
* @param \Closure:bool|bool $value
|
||||
*/
|
||||
public function scopeIsShow($query, \Closure|bool $value)
|
||||
{
|
||||
if (is_callable($value)) {
|
||||
$query->where('is_show', '=', $value());
|
||||
return;
|
||||
}
|
||||
$query->where('is_show', '=', (int)$value);
|
||||
}
|
||||
|
||||
|
||||
@@ -286,6 +286,7 @@ Route::group('v1', function () {
|
||||
});
|
||||
|
||||
// 产品分类
|
||||
Route::get('categorys', 'ProductCategory/index')->append(['is_show' => '1']);
|
||||
Route::group('category', function () {
|
||||
// tco分类树
|
||||
Route::get('tco/tree', 'ProductTcoCategory/tree');
|
||||
|
||||
Reference in New Issue
Block a user