diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php index b1b874a06..198e8515e 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php @@ -88,9 +88,10 @@ class SystemCrud extends AuthController */ public function getFilePath() { - [$menuName, $tableName, $fromField, $columnField] = $this->request->postMore([ + [$menuName, $tableName, $isTable, $fromField, $columnField] = $this->request->postMore([ ['menuName', ''], ['tableName', ''], + ['isTable', 0], ['fromField', []], ['columnField', []], ], true); @@ -108,7 +109,15 @@ class SystemCrud extends AuthController $makePath[$key] = $item['path']; } - return app('json')->success($makePath); + $tableField = []; + if (!$isTable) { + $field = $this->services->getColumnNamesList($tableName); + foreach ($field as $item) { + $tableField[] = ['value' => $item['name'], 'comment' => $item['comment'], 'label' => $item['name']]; + } + } + + return app('json')->success(compact('makePath', 'tableField')); } /** diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php b/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php index e00e5e15d..331888b5b 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemMenus.php @@ -256,13 +256,12 @@ class SystemMenus extends AuthController public function ruleList() { //获取所有的路由 - $ruleList = app()->make(SystemRouteServices::class)->selectList(['app_name' => 'adminapi'], 'name,path,method,type,id'); + $ruleList = app()->make(SystemRouteServices::class)->selectList(['app_name' => 'adminapi'], 'name,path,method,type,id')->toArray(); $menuApiList = $this->services->getColumn(['auth_type' => 2, 'is_del' => 0], "concat(`api_url`,'_',lower(`methods`)) as rule"); if ($menuApiList) $menuApiList = array_column($menuApiList, 'rule'); $list = []; foreach ($ruleList as $item) { - $item['path'] = str_replace('adminapi/', '', $item['path']); - if (!in_array($item['path'] . '_' . $item['method'], $menuApiList)) { + if (!in_array($item['path'] . '_' . strtolower($item['method']), $menuApiList)) { $item['real_name'] = $item['name'] ?? ''; $item['method'] = strtoupper($item['method']); $list[] = $item; diff --git a/crmeb/app/adminapi/controller/v1/system/SystemDatabackup.php b/crmeb/app/adminapi/controller/v1/system/SystemDatabackup.php index f3a428897..3d690dbd7 100644 --- a/crmeb/app/adminapi/controller/v1/system/SystemDatabackup.php +++ b/crmeb/app/adminapi/controller/v1/system/SystemDatabackup.php @@ -11,6 +11,7 @@ namespace app\adminapi\controller\v1\system; use think\facade\App; +use think\facade\Db; use think\facade\Session; use app\adminapi\controller\AuthController; use app\services\system\SystemDatabackupServices; @@ -53,6 +54,30 @@ class SystemDatabackup extends AuthController return app('json')->success($this->services->getRead($tablename)); } + /** + * 更新数据表或者表字段备注 + * @return \think\Response + * @author 吴汐 + * @email 442384644@qq.com + * @date 2023/04/11 + */ + public function updateMark() + { + [$table, $field, $type, $mark] = $this->request->postMore([ + ['table', ''], + ['field', ''], + ['type', ''], + ['mark', ''], + ], true); + if ($field == '') { + $sql = "ALTER TABLE $table COMMENT '$mark'"; + } else { + $sql = "ALTER TABLE $table MODIFY COLUMN $field $type COMMENT '$mark'"; + } + Db::execute($sql); + return app('json')->success(100024); + } + /** * 优化表 */ diff --git a/crmeb/app/adminapi/route/system.php b/crmeb/app/adminapi/route/system.php index ccb3816c3..12b83cff3 100644 --- a/crmeb/app/adminapi/route/system.php +++ b/crmeb/app/adminapi/route/system.php @@ -49,6 +49,8 @@ Route::group('system', function () { Route::get('backup', 'v1.system.SystemDatabackup/index')->option(['real_name' => '数据库所有表']); //数据备份详情 Route::get('backup/read', 'v1.system.SystemDatabackup/read')->option(['real_name' => '数据备份详情']); + //更新数据表或者表字段备注 + Route::post('database/update_mark', 'v1.system.SystemDatabackup/updateMark')->option(['real_name' => '更新数据表或者表字段备注']); //数据备份 优化表 Route::put('backup/optimize', 'v1.system.SystemDatabackup/optimize')->option(['real_name' => '数据备份优化表']); //数据备份 修复表 diff --git a/crmeb/app/services/system/SystemCrudServices.php b/crmeb/app/services/system/SystemCrudServices.php index cbd4106ec..b8c97b6b1 100644 --- a/crmeb/app/services/system/SystemCrudServices.php +++ b/crmeb/app/services/system/SystemCrudServices.php @@ -65,11 +65,39 @@ class SystemCrudServices extends BaseServices return compact('list', 'count'); } + /** + * 数据库字段类型 + * @return \string[][] + * @author 等风来 + * @email 136327134@qq.com + * @date 2023/4/11 + */ public function getTabelRule() { - $adapter = app()->make(MysqlAdapter::class); return [ - 'types' => $adapter->getColumnTypes(), + 'types' => [ + 'string', + 'char', + 'text', + 'integer', + 'biginteger', + 'float', + 'decimal', + 'datetime', + 'timestamp', + 'time', + 'date', + 'blob', + 'binary', + 'varbinary', + 'boolean', + 'uuid', + // Geospatial data types + 'geometry', + 'point', + 'linestring', + 'polygon', + ] ]; } diff --git a/crmeb/app/services/system/SystemRouteServices.php b/crmeb/app/services/system/SystemRouteServices.php index 91aa8f302..a1f1fea42 100644 --- a/crmeb/app/services/system/SystemRouteServices.php +++ b/crmeb/app/services/system/SystemRouteServices.php @@ -93,6 +93,18 @@ class SystemRouteServices extends BaseServices } ]) ->toArray(); + + foreach ($list as $key => $item) { + if (!empty($item['children'])) { + foreach ($item['children'] as $k => $v) { + if (isset($v['cate_id']) && isset($v['method']) && $v['method'] === 'DELETE') { + $v['method'] = 'DEL'; + $list[$key]['children'][$k] = $v; + } + } + } + } + return get_tree_children($list); } diff --git a/crmeb/crmeb/services/crud/Controller.php b/crmeb/crmeb/services/crud/Controller.php index f999f6044..ce3e19a51 100644 --- a/crmeb/crmeb/services/crud/Controller.php +++ b/crmeb/crmeb/services/crud/Controller.php @@ -109,7 +109,7 @@ class Controller extends Make * @email 136327134@qq.com * @date 2023/3/13 */ - protected function getStub(string $type = '') + protected function getStub(string $type = 'controller') { $controllerPath = __DIR__ . DS . 'stubs' . DS . 'controller' . DS; diff --git a/crmeb/crmeb/services/crud/Route.php b/crmeb/crmeb/services/crud/Route.php index 774ea2701..921493c61 100644 --- a/crmeb/crmeb/services/crud/Route.php +++ b/crmeb/crmeb/services/crud/Route.php @@ -80,7 +80,7 @@ class Route extends Make $contentStr = str_replace($this->var, $this->value, $content); - $filePath = $this->getFilePathName($path, $this->value['nameCamel']); + $filePath = $this->getFilePathName($path, strtolower($name)); return [$this->makeFile($filePath, $contentStr), $filePath]; } diff --git a/crmeb/public/index.html b/crmeb/public/index.html index 758521b9d..003e57d0d 100644 --- a/crmeb/public/index.html +++ b/crmeb/public/index.html @@ -1,2 +1,2 @@