feat: 新增产品分类用于下拉框场景列表树接口
This commit is contained in:
@@ -17,6 +17,7 @@ class ProductCategory
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$params = request()->param([
|
$params = request()->param([
|
||||||
|
'is_show',
|
||||||
'keywords' => '',
|
'keywords' => '',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -30,8 +31,13 @@ class ProductCategory
|
|||||||
])
|
])
|
||||||
->language(request()->lang_id)
|
->language(request()->lang_id)
|
||||||
->withSearch(['name_nullable'], [
|
->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();
|
->select();
|
||||||
if ($ret->isEmpty()) {
|
if ($ret->isEmpty()) {
|
||||||
return success('获取成功');
|
return success('获取成功');
|
||||||
|
|||||||
@@ -29,9 +29,17 @@ class ProductCategoryModel extends ProductCategoryBaseModel
|
|||||||
$query->where('language_id', '=', $value);
|
$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);
|
$query->where('is_show', '=', (int)$value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ Route::group('v1', function () {
|
|||||||
Route::group('banner', function() {
|
Route::group('banner', function() {
|
||||||
// 横幅(分类)列表
|
// 横幅(分类)列表
|
||||||
Route::get('list', 'Banner/list');
|
Route::get('list', 'Banner/list');
|
||||||
|
|
||||||
// 横幅(分类)分页
|
// 横幅(分类)分页
|
||||||
Route::get('index', 'Banner/index');
|
Route::get('index', 'Banner/index');
|
||||||
|
|
||||||
@@ -286,6 +286,7 @@ Route::group('v1', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 产品分类
|
// 产品分类
|
||||||
|
Route::get('categorys', 'ProductCategory/index')->append(['is_show' => '1']);
|
||||||
Route::group('category', function () {
|
Route::group('category', function () {
|
||||||
// tco分类树
|
// tco分类树
|
||||||
Route::get('tco/tree', 'ProductTcoCategory/tree');
|
Route::get('tco/tree', 'ProductTcoCategory/tree');
|
||||||
|
|||||||
Reference in New Issue
Block a user