This commit is contained in:
JaguarJack
2020-09-04 16:21:18 +08:00
parent 2e67214032
commit 9a5e7010b1
3 changed files with 47 additions and 3 deletions

View File

@@ -42,7 +42,7 @@ class DataDictionary extends CatchController
$tables = $tables->where('engine', $engine)->values();
}
return CatchResponse::paginate(Paginator::make($tables->toArray(), $request->get('limit') ?? 10, $request->get('page') ?? 1, $tables->count(), false, []));
return CatchResponse::paginate(Paginator::make(array_slice($tables->toArray(), ($request->get('page') ?? 1) - 1,$request->get('limit') ?? 10), $request->get('limit') ?? 10, $request->get('page') ?? 1, $tables->count(), false, []));
}
/**

View File

@@ -2,6 +2,7 @@
namespace catchAdmin\system\model;
use catcher\base\CatchModel;
use catcher\exceptions\FailedException;
use thans\jwt\exception\UserNotDefinedException;
use think\Model;
@@ -55,6 +56,47 @@ class Config extends CatchModel
return true;
}
$parent = $data['parent'] ?? false;
if (!$parent) {
throw new FailedException('父配置丢失');
}
unset($data['parent']);
$parentConfig = $this->where('key', $parent)->find();
$config = [];
foreach ($data as $key => $item) {
foreach ($item as $k => $value) {
if ($value) {
$config[$key . '.' .$k] = [
'pid' => $parentConfig['id'],
'key' => $key . '.' . $k,
'value' => $value,
'created_at' => time(),
'updated_at' => time(),
];
}
}
}
$this->where('pid', $parentConfig->id)
->select()
->each(function ($item) use (&$config){
if (isset($config[$item['key']])) {
if ($config[$item['key']]['value'] != $item->value) {
$item['value'] = $config[$item['key']]['value'];
$item->save();
}
unset($config[$item['key']]);
}
});
if (count($config)) {
return $this->insertAll($config);
}
return true;
// 子配置
if ($data['pid'] ?? false) {
$config = \json_decode($data['config'], true);
@@ -67,6 +109,7 @@ class Config extends CatchModel
'k' => 'v'
]*/
/**
foreach ($config as $key => $value) {
if (empty($value)) {
continue;
@@ -136,6 +179,7 @@ class Config extends CatchModel
}
}
}
*/
return true;
}

View File

@@ -5,8 +5,8 @@ $router->group(function () use ($router) {
$router->delete('loginLog/empty', '\catchAdmin\system\controller\LoginLog@empty');
// 操作日志
$router->get('log/operate', '\catchAdmin\system\controller\OperateLog@list');
$router->delete('operateLog/empty', '\catchAdmin\system\controller\OperateLog@empty');
$router->delete('operateLog/delete', '\catchAdmin\system\controller\OperateLog@delete');
// $router->delete('empty/log/operate', '\catchAdmin\system\controller\OperateLog@empty');
$router->delete('log/operate/<id>', '\catchAdmin\system\controller\OperateLog@delete');
// 数据字典
$router->get('tables', '\catchAdmin\system\controller\DataDictionary@tables');