This commit is contained in:
2025-08-27 17:39:59 +08:00
parent b751975e3f
commit 280c26983f
7 changed files with 254 additions and 0 deletions
+37
View File
@@ -5,6 +5,7 @@ namespace app\admin\service;
use app\admin\validate\SysDictItemValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\SysDictItem;
use support\Request;
class SysDictItemService
{
@@ -28,4 +29,40 @@ class SysDictItemService
{
return new $this->validator;
}
/**
* 构建查询条件
*/
protected function buildQueryConfig(Request $request, string $scene = 'index'): array
{
$p = $request->all();
$config = [];
$config['model'] = $this->modelClass;
switch ($scene) {
case 'index':
// ====== ====== 排序 ====== ======
$config['order']['sort'] = 'desc';
// ====== ====== 筛选 ====== ======
$config['where']['dict_id'] = $p['id'];
// 状态
if (isset($p['status']) && in_array($p['status'], [0,1])) {
$config['where']['status'] = $p['status'];
}
break;
case 'show':
$config['where']['id'] = $p['id'];
break;
case 'update':
case 'destroy':
$config['where']['id'] = $p['id'];
break;
case 'store':
break;
}
return $config;
}
}