From 521a35a0a0fa2bcee9d11ed68a0d52cddb4acecf Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Wed, 12 Apr 2023 14:06:32 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E6=B0=B4=E5=8D=B0=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=9B=BE=E7=89=87=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/crmeb/services/upload/storage/Local.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crmeb/crmeb/services/upload/storage/Local.php b/crmeb/crmeb/services/upload/storage/Local.php index 460fc1939..dc690c81c 100644 --- a/crmeb/crmeb/services/upload/storage/Local.php +++ b/crmeb/crmeb/services/upload/storage/Local.php @@ -313,7 +313,7 @@ class Local extends BaseUpload $savePath = public_path() . $filePath; try { $Image = Image::open(app()->getRootPath() . 'public' . $filePath); - $Image->water($watermark_image, $waterConfig['watermark_position'] ?: 1, $waterConfig['watermark_opacity'])->save($savePath); + $Image->water($watermark_image, $waterConfig['watermark_position'] ?: 1, (int)$waterConfig['watermark_opacity'])->save($savePath); } catch (\Throwable $e) { throw new AdminException($e->getMessage()); } @@ -344,7 +344,7 @@ class Local extends BaseUpload if (strlen($waterConfig['watermark_text_color']) > 7) { $waterConfig['watermark_text_color'] = substr($waterConfig['watermark_text_color'], 0, 7); } - $Image->text($waterConfig['watermark_text'], $waterConfig['watermark_text_font'], $waterConfig['watermark_text_size'], $waterConfig['watermark_text_color'], $waterConfig['watermark_position'], [$waterConfig['watermark_x'], $waterConfig['watermark_y'], $waterConfig['watermark_text_angle']])->save($savePath); + $Image->text($waterConfig['watermark_text'], $waterConfig['watermark_text_font'], (float)$waterConfig['watermark_text_size'], $waterConfig['watermark_text_color'], $waterConfig['watermark_position'], [$waterConfig['watermark_x'], $waterConfig['watermark_y'], $waterConfig['watermark_text_angle']])->save($savePath); } catch (\Throwable $e) { throw new AdminException($e->getMessage() . $e->getLine()); } From 6dfa7545af2cf134aea38e03a93590359632222a Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Wed, 12 Apr 2023 14:07:30 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E7=9A=84=E6=97=B6=E5=80=99=E7=9A=84=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/adminapi/controller/v1/setting/SystemConfig.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php b/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php index ff4de7ddb..4b3ac6c54 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php @@ -311,15 +311,6 @@ class SystemConfig extends AuthController return app('json')->fail(500029); } - //支付接口类型选择,如果有订单就不能再进行切换 -// if (isset($post['pay_wechat_type'])) { -// /** @var StoreOrderServices $orderServices */ -// $orderServices = app()->make(StoreOrderServices::class); -// if ($post['pay_wechat_type'] != -1 && $orderServices->count()) { -// return app('json')->fail('支付接口类型已经选择,不能再次进行切换,切换后会导致无法退款等问题。'); -// } -// } - if (isset($post['weixin_ckeck_file'])) { $from = public_path() . $post['weixin_ckeck_file']; $to = public_path() . array_reverse(explode('/', $post['weixin_ckeck_file']))[0]; From fc192329e820beb8a076d03292acd568e8e8175d Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Wed, 12 Apr 2023 14:07:54 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BF=90=E8=B4=B9?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/services/order/StoreOrderComputedServices.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crmeb/app/services/order/StoreOrderComputedServices.php b/crmeb/app/services/order/StoreOrderComputedServices.php index 75f19060a..a9aad3db2 100644 --- a/crmeb/app/services/order/StoreOrderComputedServices.php +++ b/crmeb/app/services/order/StoreOrderComputedServices.php @@ -480,7 +480,7 @@ class StoreOrderComputedServices extends BaseServices $tempId = $item['productInfo']['temp_id'] ?? 0; $tempPostage = $truePostageArr[$tempId] ?? 0; $tempNumber = $temp_num[$tempId]['number'] ?? 0; - if (!$tempId || !$tempPostage || !$tempNumber) continue; + if (!$tempId || !$tempPostage) continue; $type = $temp_num[$tempId]['type']; From 82676ead469dcc6795ba5b138dd925f82f4f5ca9 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Wed, 12 Apr 2023 15:49:18 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9crud=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/v1/setting/SystemCrud.php | 13 ++ .../services/system/SystemCrudServices.php | 210 ++++++++++-------- crmeb/crmeb/services/crud/Controller.php | 5 +- crmeb/crmeb/services/crud/Make.php | 17 +- crmeb/crmeb/services/crud/Model.php | 7 + crmeb/crmeb/services/crud/Route.php | 16 +- crmeb/crmeb/services/crud/Service.php | 6 +- crmeb/crmeb/services/crud/ViewApi.php | 7 +- crmeb/crmeb/services/crud/ViewPages.php | 6 +- crmeb/crmeb/services/crud/ViewRouter.php | 3 +- .../crud/stubs/controller/CrudController.stub | 4 +- .../services/crud/stubs/dao/CrudDao.stub | 4 +- .../services/crud/stubs/model/CrudModel.stub | 4 +- .../crud/stubs/service/CrudService.stub | 4 +- .../crud/stubs/validate/crudValidate.stub | 4 +- 15 files changed, 182 insertions(+), 128 deletions(-) diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php index 219e1f959..1a2372000 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php @@ -72,8 +72,13 @@ class SystemCrud extends AuthController ['fromField', []], ['columnField', []], ['filePath', []], + ['isTable', 0], ]); + if (!$data['tableName']) { + return app('json')->fail('缺少表名'); + } + $this->services->createCrud($data); return app('json')->success('创建成功'); @@ -96,6 +101,14 @@ class SystemCrud extends AuthController ['columnField', []], ], true); + if (!$tableName) { + return app('json')->fail('缺少表名'); + } + + if (in_array($tableName, SystemCrudServices::NOT_CRUD_TABANAME)) { + return app('json')->fail('不能生成系统自带数据表'); + } + $routeName = 'crud/' . Str::snake($tableName); $make = $this->services->makeFile($tableName, $routeName, false, [ diff --git a/crmeb/app/services/system/SystemCrudServices.php b/crmeb/app/services/system/SystemCrudServices.php index e8efc38bc..72cc4097c 100644 --- a/crmeb/app/services/system/SystemCrudServices.php +++ b/crmeb/app/services/system/SystemCrudServices.php @@ -42,6 +42,18 @@ use Phinx\Db\Adapter\MysqlAdapter; class SystemCrudServices extends BaseServices { + //不能生成的系统自带表 + const NOT_CRUD_TABANAME = [ + 'system_config', 'system_attachment', 'system_attachment_category', 'system_config_tab', + 'system_admin', 'eb_system_city', 'system_log', 'system_menus', 'system_notice', + 'system_notice_admin', 'system_notification', 'system_role', 'system_route', + 'system_route_cate', 'system_storage', 'system_timer', 'system_user_level', + 'system_crud', 'wechat_key', 'user_label_relation', 'user_brokerage_frozen', + 'user_brokerage', 'store_product_cate', 'store_bargain_user_help', 'shipping_templates_region', + 'shipping_templates_no_delivery', 'shipping_templates_free', 'other_order_status', 'lang_code', + 'lang_country', 'app_version', + ]; + /** * SystemCrudServices constructor. * @param SystemCrudDao $dao @@ -151,10 +163,14 @@ class SystemCrudServices extends BaseServices $filePath = $data['filePath']; //创建数据库 - if ($tableField) { + if ($tableField && !$data['isTable']) { $this->makeDatebase($tableName, $tableComment, $tableField); } + if (in_array($tableName, self::NOT_CRUD_TABANAME)) { + throw new ValidateException('不能生成系统自带数据表'); + } + //读取表结构 $column = $this->getColumnNamesList($tableName); if (!$column) { @@ -164,16 +180,19 @@ class SystemCrudServices extends BaseServices $routeName = 'crud/' . Str::snake($tableName); $uniqueAuth = $routeName . '-index-list'; - $make = $this->makeFile($tableName, $routeName, true, $data, $filePath); - $makePath = []; - foreach ($make as $key => $item) { - $makePath[$key] = $item['path']; + foreach ($filePath as $k => $i) { + if (in_array($k, ['pages', 'router', 'api'])) { + $filePath[$k] = Make::adminTemplatePath() . $i; + } else { + $filePath[$k] = app()->getRootPath() . $i; + } } + //创建菜单 if (!$data['menuName']) { $data['menuName'] = $tableName; } - $data = [ + $dataMenu = [ 'pid' => $data['pid'], 'menu_name' => $data['menuName'], 'menu_path' => '', @@ -183,81 +202,94 @@ class SystemCrudServices extends BaseServices 'unique_auth' => $uniqueAuth, 'is_header' => $data['pid'] ? 0 : 1, ]; - $menuInfo = app()->make(SystemMenusServices::class)->save($data); - //写入路由权限 - $cateId = app()->make(SystemRouteServices::class)->topCateId('adminapi'); - $ruleData = [ - [ - 'path' => $routeName, - 'method' => 'GET', - 'name' => $data['menuName'] . '列表接口', - 'app_name' => 'adminapi', - 'cate_id' => $cateId, - 'add_time' => date('Y-m-d H:i:s') - ], - [ - 'path' => $routeName . '/create', - 'method' => 'GET', - 'name' => $data['menuName'] . '获取创建表单接口', - 'app_name' => 'adminapi', - 'cate_id' => $cateId, - 'add_time' => date('Y-m-d H:i:s') - ], - [ - 'path' => $routeName, - 'method' => 'POST', - 'name' => $data['menuName'] . '保存数据接口', - 'app_name' => 'adminapi', - 'cate_id' => $cateId, - 'add_time' => date('Y-m-d H:i:s') - ], - [ - 'path' => $routeName . '//edit', - 'method' => 'GET', - 'name' => $data['menuName'] . '获取修改表单接口', - 'app_name' => 'adminapi', - 'cate_id' => $cateId, - 'add_time' => date('Y-m-d H:i:s') - ], - [ - 'path' => $routeName . '/', - 'method' => 'PUT', - 'name' => $data['menuName'] . '修改数据接口', - 'app_name' => 'adminapi', - 'cate_id' => $cateId, - 'add_time' => date('Y-m-d H:i:s') - ], - [ - 'path' => $routeName . '/', - 'method' => 'DELETE', - 'name' => $data['menuName'] . '删除数据接口', - 'app_name' => 'adminapi', - 'cate_id' => $cateId, - 'add_time' => date('Y-m-d H:i:s') - ], - ]; - app()->make(SystemRouteServices::class)->saveAll($ruleData); - //记录权限加入菜单表 - $menuData = []; - foreach ($ruleData as $item) { - $menuData[] = [ - 'pid' => $menuInfo->id, - 'method' => $item['method'], - 'api_url' => $item['path'], - 'name' => $item['name'], - 'is_del' => 0, + + $res = $this->transaction(function () use ($filePath, $tableName, $routeName, $data, $dataMenu) { + $menuInfo = app()->make(SystemMenusServices::class)->save($dataMenu); + //写入路由权限 + $cateId = app()->make(SystemRouteServices::class)->topCateId('adminapi'); + $ruleData = [ + [ + 'path' => $routeName, + 'method' => 'GET', + 'name' => $data['menuName'] . '列表接口', + 'app_name' => 'adminapi', + 'cate_id' => $cateId, + 'add_time' => date('Y-m-d H:i:s') + ], + [ + 'path' => $routeName . '/create', + 'method' => 'GET', + 'name' => $data['menuName'] . '获取创建表单接口', + 'app_name' => 'adminapi', + 'cate_id' => $cateId, + 'add_time' => date('Y-m-d H:i:s') + ], + [ + 'path' => $routeName, + 'method' => 'POST', + 'name' => $data['menuName'] . '保存数据接口', + 'app_name' => 'adminapi', + 'cate_id' => $cateId, + 'add_time' => date('Y-m-d H:i:s') + ], + [ + 'path' => $routeName . '//edit', + 'method' => 'GET', + 'name' => $data['menuName'] . '获取修改表单接口', + 'app_name' => 'adminapi', + 'cate_id' => $cateId, + 'add_time' => date('Y-m-d H:i:s') + ], + [ + 'path' => $routeName . '/', + 'method' => 'PUT', + 'name' => $data['menuName'] . '修改数据接口', + 'app_name' => 'adminapi', + 'cate_id' => $cateId, + 'add_time' => date('Y-m-d H:i:s') + ], + [ + 'path' => $routeName . '/', + 'method' => 'DELETE', + 'name' => $data['menuName'] . '删除数据接口', + 'app_name' => 'adminapi', + 'cate_id' => $cateId, + 'add_time' => date('Y-m-d H:i:s') + ], ]; - } - app()->make(SystemMenusServices::class)->saveAll($menuData); - //记录crud生成 - $res = $this->dao->save([ - 'pid' => $data['pid'], - 'name' => $data['menuName'], - 'table_name' => $tableName, - 'field' => json_encode($data), - 'make_path' => json_encode($makePath), - 'add_time' => time() - ]); + app()->make(SystemRouteServices::class)->saveAll($ruleData); + //记录权限加入菜单表 + $menuData = []; + foreach ($ruleData as $item) { + $menuData[] = [ + 'pid' => $menuInfo->id, + 'method' => $item['method'], + 'api_url' => $item['path'], + 'name' => $item['name'], + 'is_del' => 0, + ]; + } + app()->make(SystemMenusServices::class)->saveAll($menuData); + + $make = $this->makeFile($tableName, $routeName, true, $data, $filePath); + $makePath = []; + foreach ($make as $key => $item) { + $makePath[$key] = $item['path']; + } + + //记录crud生成 + $res = $this->dao->save([ + 'pid' => $data['pid'], + 'name' => $data['menuName'], + 'table_name' => $tableName, + 'field' => json_encode($data), + 'make_path' => json_encode($makePath), + 'add_time' => time() + ]); + + return $res; + }); + return $res->toArray(); } @@ -323,41 +355,41 @@ class SystemCrudServices extends BaseServices $options['columnField'] = is_array($options['columnField']) ? $options['columnField'] : []; //生成控制器 $controller = app()->make(Controller::class); - [$controllerContent, $controllerPath] = $controller->setFilePathName($filePath['controller'] ?? '')->isMake($isMake)->handle($tableName, '/'); + [$controllerContent, $controllerPath] = $controller->setFilePathName($filePath['controller'] ?? '')->isMake($isMake)->handle($tableName); //生成模型 $model = app()->make(Model::class); - [$modelContent, $modelPath] = $model->setFilePathName($filePath['model'] ?? '')->isMake($isMake)->handle($tableName, '/'); + [$modelContent, $modelPath] = $model->setFilePathName($filePath['model'] ?? '')->isMake($isMake)->handle($tableName); //生成dao $dao = app()->make(Dao::class); - [$daoContent, $daoPath] = $dao->setFilePathName($filePath['dao'] ?? '')->isMake($isMake)->handle($tableName, '/'); + [$daoContent, $daoPath] = $dao->setFilePathName($filePath['dao'] ?? '')->isMake($isMake)->handle($tableName); //生成路由 $route = app()->make(Route::class); - [$routeContent, $routePath] = $route->setFilePathName($filePath['route'] ?? '')->isMake($isMake)->handle($tableName, '/', [ + [$routeContent, $routePath] = $route->setFilePathName($filePath['route'] ?? '')->isMake($isMake)->handle($tableName, [ 'menus' => $options['menuName'], 'route' => $routeName ]); //生成service $service = app()->make(Service::class); - [$serviceContent, $servicePath] = $service->setFilePathName($filePath['service'] ?? '')->isMake($isMake)->handle($tableName, '/', [ + [$serviceContent, $servicePath] = $service->setFilePathName($filePath['service'] ?? '')->isMake($isMake)->handle($tableName, [ 'field' => $options['fromField'], ]); //生成验证器 $validate = app()->make(Validate::class); - [$validateContent, $validatePath] = $validate->setFilePathName($filePath['validate'] ?? '')->isMake($isMake)->handle($tableName, '/'); + [$validateContent, $validatePath] = $validate->setFilePathName($filePath['validate'] ?? '')->isMake($isMake)->handle($tableName); //生成前台路由 $viewRouter = app()->make(ViewRouter::class); - [$routerContent, $routerPath] = $viewRouter->setFilePathName($filePath['router'] ?? '')->isMake($isMake)->handle($tableName, '/', [ + [$routerContent, $routerPath] = $viewRouter->setFilePathName($filePath['router'] ?? '')->isMake($isMake)->handle($tableName, [ 'route' => $routeName, ]); //生成前台接口 $viewApi = app()->make(ViewApi::class); - [$apiContent, $apiPath] = $viewApi->setFilePathName($filePath['api'] ?? '')->isMake($isMake)->handle($tableName, '/', [ + [$apiContent, $apiPath] = $viewApi->setFilePathName($filePath['api'] ?? '')->isMake($isMake)->handle($tableName, [ 'route' => $routeName, ]); //生成前台页面 $viewPages = app()->make(ViewPages::class); - [$pagesContent, $pagesPath] = $viewPages->setFilePathName($filePath['pages'] ?? '')->isMake($isMake)->handle($tableName, '/', [ + [$pagesContent, $pagesPath] = $viewPages->setFilePathName($filePath['pages'] ?? '')->isMake($isMake)->handle($tableName, [ 'field' => $options['columnField'] ]); diff --git a/crmeb/crmeb/services/crud/Controller.php b/crmeb/crmeb/services/crud/Controller.php index ce3e19a51..68926aab1 100644 --- a/crmeb/crmeb/services/crud/Controller.php +++ b/crmeb/crmeb/services/crud/Controller.php @@ -49,8 +49,9 @@ class Controller extends Make * @email 136327134@qq.com * @date 2023/3/13 */ - public function handle(string $name, string $path, array $options = []) + public function handle(string $name, array $options = []) { + $path = $options['path'] ?? ''; $contentPhp = ''; $var = ["{%date%}"]; $fieldPhp = [$this->value['date']]; @@ -98,7 +99,7 @@ class Controller extends Make $filePath = $this->getFilePathName($path, $this->value['nameCamel']); - return [$this->makeFile($filePath, $contentStr), $filePath]; + return [$this->makeFile($filePath, $contentStr), $this->filePathName ?: $filePath]; } /** diff --git a/crmeb/crmeb/services/crud/Make.php b/crmeb/crmeb/services/crud/Make.php index a69813615..77716f0cb 100644 --- a/crmeb/crmeb/services/crud/Make.php +++ b/crmeb/crmeb/services/crud/Make.php @@ -219,9 +219,9 @@ abstract class Make * @email 136327134@qq.com * @date 2023/3/13 */ - public function handle(string $name, string $path, array $options = []) + public function handle(string $name, array $options = []) { - + $path = $options['path'] ?? ''; [$nameData, $content] = $this->getStubContent($name); $this->value['name'] = $nameData; @@ -236,7 +236,7 @@ abstract class Make $filePath = $this->getFilePathName($path, $this->value['nameCamel']); - return [$this->makeFile($filePath, $contentStr), $filePath]; + return [$this->makeFile($filePath, $contentStr), $this->filePathName ?: $filePath]; } /** @@ -343,14 +343,15 @@ abstract class Make */ protected function getfolderPath(string $path) { + $path = $path ?: $this->filePathName; + $path = str_replace([$this->basePath, $this->baseDir], '', $path); $path = ltrim(str_replace('\\', '/', $path), '/'); $pathArr = explode('/', $path); - $count = count($pathArr); - $res = $pathArr[$count - 1] ?? null; - if ($pathArr && $res && $res == $this->name) { - return ''; + array_pop($pathArr); + if ($pathArr) { + return '\\' . implode('\\', $pathArr); } else { - return '\\' . $res; + return ''; } } diff --git a/crmeb/crmeb/services/crud/Model.php b/crmeb/crmeb/services/crud/Model.php index 4e427ec1a..8ad46680d 100644 --- a/crmeb/crmeb/services/crud/Model.php +++ b/crmeb/crmeb/services/crud/Model.php @@ -40,6 +40,13 @@ class Model extends Make return 'app' . DS . 'model' . DS . 'crud'; } + protected function getFilePathName(string $path, string $name): string + { + $path = ltrim(str_replace('\\', '/', $path), '/'); + + return $this->getBasePath($path) . $name . '.' . $this->fileMime; + } + /** * 模板文件 * @param string $type diff --git a/crmeb/crmeb/services/crud/Route.php b/crmeb/crmeb/services/crud/Route.php index e4ce0f438..9c75a930f 100644 --- a/crmeb/crmeb/services/crud/Route.php +++ b/crmeb/crmeb/services/crud/Route.php @@ -36,12 +36,12 @@ class Route extends Make /** * @param string $name - * @param string $path * @param array $options * @return mixed|void */ - public function handle(string $name, string $path, array $options = []) + public function handle(string $name, array $options = []) { + $path = $options['path'] ?? ''; $action = $options['action'] ?? []; $route = $options['route'] ?? ''; $controller = $options['controller'] ?? ''; @@ -67,14 +67,14 @@ class Route extends Make $routeContent = ""; foreach ($action as $item) { - $routeContent .= $this->getStub($item) . "\r\n"; + $routeContent .= file_get_contents($this->getStub($item)) . "\r\n"; } if ($var && $value) { $routeContent = str_replace($var, $value, $routeContent); } - $content = $this->getStub(); + $content = file_get_contents($this->getStub()); $this->value['content-php'] = $routeContent; @@ -82,16 +82,16 @@ class Route extends Make $filePath = $this->getFilePathName($path, strtolower($name)); - return [$this->makeFile($filePath, $contentStr), $filePath]; + return [$this->makeFile($filePath, $contentStr), $this->filePathName ?: $filePath]; } /** - * @author 等风来 - * @email 136327134@qq.com - * @date 2023/4/11 * @param string $path * @param string $name * @return string + * @author 等风来 + * @email 136327134@qq.com + * @date 2023/4/11 */ protected function getFilePathName(string $path, string $name): string { diff --git a/crmeb/crmeb/services/crud/Service.php b/crmeb/crmeb/services/crud/Service.php index de1af91c8..b18d95c9a 100644 --- a/crmeb/crmeb/services/crud/Service.php +++ b/crmeb/crmeb/services/crud/Service.php @@ -36,15 +36,15 @@ class Service extends Make /** * @param string $name - * @param string $path * @param array $options * @return mixed|void * @author 等风来 * @email 136327134@qq.com * @date 2023/3/23 */ - public function handle(string $name, string $path, array $options = []) + public function handle(string $name, array $options = []) { + $path = $options['path'] ?? ''; $this->value['use-php'] = $this->getDaoClassName($name, $path); @@ -92,7 +92,7 @@ class Service extends Make $filePath = $this->getFilePathName($path, $this->value['nameCamel']); - return [$this->makeFile($filePath, $contentStr), $filePath]; + return [$this->makeFile($filePath, $contentStr), $this->filePathName ?: $filePath]; } /** diff --git a/crmeb/crmeb/services/crud/ViewApi.php b/crmeb/crmeb/services/crud/ViewApi.php index 7ee1c914d..ba535d0d8 100644 --- a/crmeb/crmeb/services/crud/ViewApi.php +++ b/crmeb/crmeb/services/crud/ViewApi.php @@ -60,16 +60,15 @@ class ViewApi extends Make /** * @param string $name - * @param string $path * @param array $options * @return array * @author 等风来 * @email 136327134@qq.com * @date 2023/4/4 */ - public function handle(string $name, string $path, array $options = []) + public function handle(string $name, array $options = []) { - + $path = $options['path'] ?? ''; $action = $options['action'] ?? []; if (!$action) { $action = ['index', 'create', 'save', 'edit', 'update']; @@ -103,7 +102,7 @@ class ViewApi extends Make $content = $this->makeFile($filePath, $contentStr); - return [$content, $filePath]; + return [$content, $this->filePathName ?: $filePath]; } /** diff --git a/crmeb/crmeb/services/crud/ViewPages.php b/crmeb/crmeb/services/crud/ViewPages.php index 8869e7148..d60b092ad 100644 --- a/crmeb/crmeb/services/crud/ViewPages.php +++ b/crmeb/crmeb/services/crud/ViewPages.php @@ -66,20 +66,20 @@ class ViewPages extends Make * @email 136327134@qq.com * @date 2023/4/3 */ - public function handle(string $name, string $path, array $options = []) + public function handle(string $name, array $options = []) { $field = $options['field'] ?? []; $columnStr = []; foreach ($field as $item) { - $columnStr[] = "{\n\"title:\"{$item['name']},\n\"key:\"{$item['field']}\n}"; + $columnStr[] = $this->tab() . "{\ntitle:\"{$item['name']}\",\nkey:\"{$item['field']}\"\n}"; } $this->value['auth'] = Str::snake($name); $this->value['content-vue'] = "\n" . implode(',', $columnStr); $this->value['pathApiJs'] = $options['pathApiJs'] ?? ''; $this->value['nameCamel'] = Str::snake($name, '-'); - return parent::handle($name, $path, $options); + return parent::handle($name, $options); } /** diff --git a/crmeb/crmeb/services/crud/ViewRouter.php b/crmeb/crmeb/services/crud/ViewRouter.php index e7ab628f7..bc8aae408 100644 --- a/crmeb/crmeb/services/crud/ViewRouter.php +++ b/crmeb/crmeb/services/crud/ViewRouter.php @@ -66,8 +66,9 @@ class ViewRouter extends Make * @email 136327134@qq.com * @date 2023/4/4 */ - public function handle(string $name, string $path, array $options = []) + public function handle(string $name, array $options = []) { + $path = $options['path'] ?? ''; [$nameData, $content] = $this->getStubContent($name); $menus = $options['menus'] ?? $name; diff --git a/crmeb/crmeb/services/crud/stubs/controller/CrudController.stub b/crmeb/crmeb/services/crud/stubs/controller/CrudController.stub index 7da581dbf..8bebff6ba 100644 --- a/crmeb/crmeb/services/crud/stubs/controller/CrudController.stub +++ b/crmeb/crmeb/services/crud/stubs/controller/CrudController.stub @@ -16,7 +16,7 @@ * @date {%time%} */ -namespace app\adminapi\controller\v1{%path%}; +namespace app\adminapi\controller\crud{%path%}; use app\adminapi\controller\AuthController; use think\facade\App; @@ -24,7 +24,7 @@ use think\facade\App; /** * Class {%nameCamel%} * @date {%date%} - * @package app\adminapi\controller\v1{%path%} + * @package app\adminapi\controller\crud{%path%} */ class {%nameCamel%} extends AuthController { diff --git a/crmeb/crmeb/services/crud/stubs/dao/CrudDao.stub b/crmeb/crmeb/services/crud/stubs/dao/CrudDao.stub index e1968469e..eed5b1b2e 100644 --- a/crmeb/crmeb/services/crud/stubs/dao/CrudDao.stub +++ b/crmeb/crmeb/services/crud/stubs/dao/CrudDao.stub @@ -16,7 +16,7 @@ * @date {%time%} */ -namespace app\dao{%path%}; +namespace app\dao\crub{%path%}; use app\dao\BaseDao; @@ -24,7 +24,7 @@ use app\dao\BaseDao; /** * Class {%nameCamel%}Dao * @date {%date%} - * @package app\dao{%path%} + * @package app\dao\crub{%path%} */ class {%nameCamel%}Dao extends BaseDao { diff --git a/crmeb/crmeb/services/crud/stubs/model/CrudModel.stub b/crmeb/crmeb/services/crud/stubs/model/CrudModel.stub index e7947bf36..d6e871d99 100644 --- a/crmeb/crmeb/services/crud/stubs/model/CrudModel.stub +++ b/crmeb/crmeb/services/crud/stubs/model/CrudModel.stub @@ -16,7 +16,7 @@ * @date {%time%} */ -namespace app\model{%path%}; +namespace app\model\crud{%path%}; use crmeb\basic\BaseModel; @@ -24,7 +24,7 @@ use crmeb\basic\BaseModel; /** * Class {%nameCamel%} * @date {%date%} - * @package app\model{%path%} + * @package app\model\crud{%path%} */ class {%nameCamel%} extends BaseModel { diff --git a/crmeb/crmeb/services/crud/stubs/service/CrudService.stub b/crmeb/crmeb/services/crud/stubs/service/CrudService.stub index fc929e8d9..8eb66a2d9 100644 --- a/crmeb/crmeb/services/crud/stubs/service/CrudService.stub +++ b/crmeb/crmeb/services/crud/stubs/service/CrudService.stub @@ -16,7 +16,7 @@ * @date {%time%} */ -namespace app\services{%path%}; +namespace app\services\crub{%path%}; use app\services\BaseServices; use think\exception\ValidateException; @@ -25,7 +25,7 @@ use think\exception\ValidateException; /** * Class CrudService * @date {%date%} - * @package app\services{%path%} + * @package app\services\crub{%path%} */ class {%nameCamel%}Service extends BaseServices { diff --git a/crmeb/crmeb/services/crud/stubs/validate/crudValidate.stub b/crmeb/crmeb/services/crud/stubs/validate/crudValidate.stub index 7df4bd47d..553e07b9c 100644 --- a/crmeb/crmeb/services/crud/stubs/validate/crudValidate.stub +++ b/crmeb/crmeb/services/crud/stubs/validate/crudValidate.stub @@ -16,7 +16,7 @@ * @date {%time%} */ -namespace app\adminapi\validate{%path%}; +namespace app\adminapi\validate\crub{%path%}; use think\Validate; @@ -24,7 +24,7 @@ use think\Validate; /** * Class CrudValidate * @date {%date%} - * @package app\adminapi\validate{%path%} + * @package app\adminapi\validate\crub{%path%} */ class {%nameCamel%}Validate extends Validate { From 37e969378edae1fbad7d8f943cf03ef81e46f954 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Wed, 12 Apr 2023 15:52:38 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/vendor/overtrue/wechat/src/Staff/Staff.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crmeb/vendor/overtrue/wechat/src/Staff/Staff.php b/crmeb/vendor/overtrue/wechat/src/Staff/Staff.php index bf9801340..5ebe751a4 100644 --- a/crmeb/vendor/overtrue/wechat/src/Staff/Staff.php +++ b/crmeb/vendor/overtrue/wechat/src/Staff/Staff.php @@ -105,11 +105,6 @@ class Staff extends AbstractAPI */ public function delete($account) { - // XXX: 微信那帮搞技术的都 TM 是 SB,url上的文本居然不 TM urlencode, - // 这里客服账号因为有 @ 符,而微信不接收urlencode的账号。。 - // 简直是日了... - // #222 - // PS: 如果你是微信做接口的,奉劝你们,尊重技术,不会别乱搞,笨不是你们的错,你们出来坑人就是大错特错。 $accessTokenField = sprintf('%s=%s', $this->accessToken->getQueryName(), $this->accessToken->getToken()); $url = sprintf(self::API_DELETE.'?%s&kf_account=%s', $accessTokenField, $account); From da9bacdc9f51c99e51a3980b31352c50b667939e Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Wed, 12 Apr 2023 16:59:17 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9F=A5=E7=9C=8Bcrud?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/v1/setting/SystemCrud.php | 36 +++++++++++++++++++ crmeb/app/adminapi/route/system.php | 2 ++ crmeb/app/model/system/SystemCrud.php | 5 +++ .../services/system/SystemCrudServices.php | 2 +- crmeb/crmeb/services/crud/Make.php | 7 ++-- 5 files changed, 48 insertions(+), 4 deletions(-) diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php index 1a2372000..e62f10b6c 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php @@ -136,6 +136,42 @@ class SystemCrud extends AuthController return app('json')->success(compact('makePath', 'tableField')); } + /** + * @param $id + * @return \think\Response + * @author 等风来 + * @email 136327134@qq.com + * @date 2023/4/12 + */ + public function read($id) + { + if (!$id) { + return app('json')->fail('缺少参数'); + } + + $info = $this->services->get($id); + if (!$info) { + return app('json')->fail('查看的生成的文件不存在'); + } + + $routeName = 'crud/' . Str::snake($info->table_name); + + $make = $this->services->makeFile($info->table_name, $routeName, false, [ + 'menuName' => $info->name, + 'fromField' => $info->field['fromField'] ?? [], + 'columnField' => $info->field['columnField'] ?? [], + ]); + + $data = []; + foreach ($make as $item) { + $item['name'] = pathinfo($item['path'])['basename'] ?? ''; + $data[] = $item; + } + + return app('json')->success($data); + + } + /** * 获取tree菜单 * @return \think\Response diff --git a/crmeb/app/adminapi/route/system.php b/crmeb/app/adminapi/route/system.php index 12b83cff3..749e9dd26 100644 --- a/crmeb/app/adminapi/route/system.php +++ b/crmeb/app/adminapi/route/system.php @@ -141,6 +141,8 @@ Route::group('system', function () { Route::post('crud/file_path', 'v1.setting.SystemCrud/getFilePath')->option(['real_name' => '获取CRUD文件存放']); //删除CRUD Route::delete('crud/:id', 'v1.setting.SystemCrud/delete')->option(['real_name' => '删除CRUD']); + //查看CRUD + Route::get('crud/:id', 'v1.setting.SystemCrud/read')->option(['real_name' => '查看CRUD']); //获取CRUD列表 Route::get('crud', 'v1.setting.SystemCrud/index')->option(['real_name' => '获取CRUD列表']); //保存生成CRUD diff --git a/crmeb/app/model/system/SystemCrud.php b/crmeb/app/model/system/SystemCrud.php index 8f386053a..173d68dc5 100644 --- a/crmeb/app/model/system/SystemCrud.php +++ b/crmeb/app/model/system/SystemCrud.php @@ -35,4 +35,9 @@ class SystemCrud extends BaseModel * @var string */ protected $pk = 'id'; + + public function getAddTimeAttr($value) + { + return date('Y-m-d H:i:s', $value); + } } diff --git a/crmeb/app/services/system/SystemCrudServices.php b/crmeb/app/services/system/SystemCrudServices.php index 72cc4097c..a0cfba82a 100644 --- a/crmeb/app/services/system/SystemCrudServices.php +++ b/crmeb/app/services/system/SystemCrudServices.php @@ -72,7 +72,7 @@ class SystemCrudServices extends BaseServices public function getList() { [$page, $limit] = $this->getPageValue(); - $list = $this->dao->selectList([], '*', $page, $limit, 'id desc'); + $list = $this->dao->selectList([], 'add_time,id,name,table_name', $page, $limit, 'id desc'); $count = $this->dao->count(); return compact('list', 'count'); diff --git a/crmeb/crmeb/services/crud/Make.php b/crmeb/crmeb/services/crud/Make.php index 77716f0cb..765154a2e 100644 --- a/crmeb/crmeb/services/crud/Make.php +++ b/crmeb/crmeb/services/crud/Make.php @@ -422,14 +422,15 @@ abstract class Make $pathname = $this->filePathName ?: $pathname; - if (is_file($pathname)) { - throw new CrudException($this->name . ':' . $pathname . ' already exists!'); - } $content = str_replace('', '', $content); if ($this->isMake) { + if (is_file($pathname)) { + throw new CrudException($this->name . ':' . $pathname . ' already exists!'); + } + try { if (!is_dir(dirname($pathname))) { mkdir(dirname($pathname), 0755, true); From 91ae0c4edc756264b61ebd9aad2892f2c7681433 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Wed, 12 Apr 2023 17:37:35 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/adminapi/controller/Common.php | 2 +- .../v1/notification/sms/SmsConfig.php | 14 +++++---- .../controller/v1/setting/SystemConfig.php | 22 +++++++------ .../system/config/SystemConfigServices.php | 31 +++++++++++++------ .../services/yihaotong/SmsAdminServices.php | 7 ++--- crmeb/crmeb/services/SystemConfigService.php | 22 +++++++------ 6 files changed, 57 insertions(+), 41 deletions(-) diff --git a/crmeb/app/adminapi/controller/Common.php b/crmeb/app/adminapi/controller/Common.php index e32274043..b6803edce 100644 --- a/crmeb/app/adminapi/controller/Common.php +++ b/crmeb/app/adminapi/controller/Common.php @@ -402,7 +402,7 @@ class Common extends AuthController 'info' => '' ]); } - \crmeb\services\CacheService::clear(); + $services->cacheDriver()->clear(); return app('json')->success(100000); } diff --git a/crmeb/app/adminapi/controller/v1/notification/sms/SmsConfig.php b/crmeb/app/adminapi/controller/v1/notification/sms/SmsConfig.php index 1b38c220b..5d513f886 100644 --- a/crmeb/app/adminapi/controller/v1/notification/sms/SmsConfig.php +++ b/crmeb/app/adminapi/controller/v1/notification/sms/SmsConfig.php @@ -10,9 +10,9 @@ // +---------------------------------------------------------------------- namespace app\adminapi\controller\v1\notification\sms; +use app\services\system\config\SystemConfigServices; use app\services\yihaotong\SmsAdminServices; use app\services\serve\ServeServices; -use crmeb\services\CacheService; use app\adminapi\controller\AuthController; use think\facade\App; @@ -64,7 +64,8 @@ class SmsConfig extends AuthController */ public function is_login(ServeServices $services) { - $sms_info = CacheService::get('sms_account'); + $configServices = app()->make(SystemConfigServices::class); + $sms_info = $configServices->cacheDriver()->get('sms_account'); $data = ['status' => false, 'info' => '']; if ($sms_info) { try { @@ -80,14 +81,14 @@ class SmsConfig extends AuthController } return app('json')->success($data); } else { - CacheService::clear(); + $configServices->cacheDriver()->clear(); $account = sys_config('sms_account'); $password = sys_config('sms_token'); //没有退出登录 清空这两个数据 自动登录 if ($account && $password) { $res = $services->user()->login($account, $password); if ($res) { - CacheService::set('sms_account', $account); + $configServices->cacheDriver()->set('sms_account', $account); $data['status'] = true; $data['info'] = $account; } @@ -103,9 +104,10 @@ class SmsConfig extends AuthController */ public function logout() { - CacheService::delete('sms_account'); + $configServices = app()->make(SystemConfigServices::class); + $configServices->cacheDriver()->delete('sms_account'); $this->services->updateSmsConfig('', ''); - CacheService::clear(); + $configServices->cacheDriver()->clear(); return app('json')->success(100042); } diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php b/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php index 4b3ac6c54..d2716ad7c 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemConfig.php @@ -12,7 +12,6 @@ namespace app\adminapi\controller\v1\setting; use app\adminapi\controller\AuthController; use app\Request; -use app\services\order\StoreOrderServices; use app\services\system\config\SystemConfigServices; use app\services\system\config\SystemConfigTabServices; use think\facade\App; @@ -38,8 +37,10 @@ class SystemConfig extends AuthController /** * 显示资源列表 - * * @return \think\Response + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function index() { @@ -58,8 +59,11 @@ class SystemConfig extends AuthController /** * 显示创建资源表单页. - * @param $type * @return \think\Response + * @throws \FormBuilder\Exception\FormBuilderException + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function create() { @@ -72,7 +76,6 @@ class SystemConfig extends AuthController /** * 保存新建的资源 - * * @return \think\Response */ public function save() @@ -120,7 +123,7 @@ class SystemConfig extends AuthController } else { $this->services->save($data); } - \crmeb\services\CacheService::clear(); + $this->services->cacheDriver()->clear(); return app('json')->success(400284); } @@ -186,13 +189,12 @@ class SystemConfig extends AuthController } $data['value'] = json_encode($data['value']); $this->services->update($id, $data); - \crmeb\services\CacheService::clear(); + $this->services->cacheDriver()->clear(); return app('json')->success(100001); } /** * 删除指定资源 - * * @param int $id * @return \think\Response */ @@ -201,7 +203,7 @@ class SystemConfig extends AuthController if (!$this->services->delete($id)) return app('json')->fail(100008); else { - \crmeb\services\CacheService::clear(); + $this->services->cacheDriver()->clear(); return app('json')->success(100002); } } @@ -218,7 +220,7 @@ class SystemConfig extends AuthController return app('json')->fail(100100); } $this->services->update($id, ['status' => $status]); - \crmeb\services\CacheService::clear(); + $this->services->cacheDriver()->clear(); return app('json')->success(100014); } @@ -336,7 +338,7 @@ class SystemConfig extends AuthController $this->services->update($k, ['value' => json_encode($v)], 'menu_name'); } } - \crmeb\services\CacheService::clear(); + $this->services->cacheDriver()->clear(); return app('json')->success(100001); } diff --git a/crmeb/app/services/system/config/SystemConfigServices.php b/crmeb/app/services/system/config/SystemConfigServices.php index ddffe6169..934910ad9 100644 --- a/crmeb/app/services/system/config/SystemConfigServices.php +++ b/crmeb/app/services/system/config/SystemConfigServices.php @@ -185,6 +185,7 @@ class SystemConfigServices extends BaseServices /** * SystemConfigServices constructor. * @param SystemConfigDao $dao + * @param FormBuilder $builder */ public function __construct(SystemConfigDao $dao, FormBuilder $builder) { @@ -192,6 +193,12 @@ class SystemConfigServices extends BaseServices $this->builder = $builder; } + /** + * @return array|int[]|string[] + * @author 吴汐 + * @email 442384644@qq.com + * @date 2023/04/12 + */ public function getSonConfig() { $sonConfig = []; @@ -214,6 +221,7 @@ class SystemConfigServices extends BaseServices * @param string $configName * @param null $default * @return mixed|null + * @throws \ReflectionException */ public function getConfigValue(string $configName, $default = null) { @@ -225,6 +233,7 @@ class SystemConfigServices extends BaseServices * 获取全部配置 * @param array $configName * @return array + * @throws \ReflectionException */ public function getConfigAll(array $configName = []) { @@ -575,14 +584,12 @@ class SystemConfigServices extends BaseServices /** * 获取系统配置表单 - * @param int $id - * @param array $formData + * @param $data + * @param bool $control + * @param array $controle_two * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException + * @throws \FormBuilder\Exception\FormBuilderException */ - public function formTypeShine($data, $control = false, $controle_two = []) { @@ -813,6 +820,7 @@ class SystemConfigServices extends BaseServices /** * 系统配置form表单创建 + * @param $url * @param int $tabId * @return array * @throws \FormBuilder\Exception\FormBuilderException @@ -982,6 +990,10 @@ class SystemConfigServices extends BaseServices * @param int $type * @param int $tab_id * @return array + * @throws \FormBuilder\Exception\FormBuilderException + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function createFormRule(int $type, int $tab_id): array { @@ -1115,7 +1127,8 @@ class SystemConfigServices extends BaseServices } } - /**保存平台电子面单打印信息 + /** + * 保存平台电子面单打印信息 * @param array $data * @return bool */ @@ -1132,7 +1145,7 @@ class SystemConfigServices extends BaseServices foreach ($data as $key => $value) { $this->dao->update(['menu_name' => 'config_export_' . $key], ['value' => json_encode($value)]); } - \crmeb\services\CacheService::clear(); + $this->cacheDriver()->clear(); return true; } @@ -1149,7 +1162,7 @@ class SystemConfigServices extends BaseServices if ($banner) { $banner = array_column($banner, 'pic'); $this->dao->update(['menu_name' => 'spread_banner'], ['value' => json_encode($banner)]); - \crmeb\services\CacheService::clear(); + $this->cacheDriver()->clear(); } } return $banner; diff --git a/crmeb/app/services/yihaotong/SmsAdminServices.php b/crmeb/app/services/yihaotong/SmsAdminServices.php index 1d01187e2..46312d7ca 100644 --- a/crmeb/app/services/yihaotong/SmsAdminServices.php +++ b/crmeb/app/services/yihaotong/SmsAdminServices.php @@ -15,7 +15,6 @@ namespace app\services\yihaotong; use app\dao\system\config\SystemConfigDao; use app\services\BaseServices; use crmeb\exceptions\AdminException; -use crmeb\services\CacheService; use crmeb\services\HttpService; use crmeb\services\sms\Sms; @@ -47,7 +46,7 @@ class SmsAdminServices extends BaseServices return $this->transaction(function () use ($account, $password) { $this->dao->update('sms_account', ['value' => json_encode($account)], 'menu_name'); $this->dao->update('sms_token', ['value' => json_encode($password)], 'menu_name'); - CacheService::clear(); + $this->cacheDriver()->clear(); }); } @@ -70,7 +69,6 @@ class SmsAdminServices extends BaseServices throw new AdminException(400462, ['msg' => $status['msg']]); } $this->updateSmsConfig($account, $password); - CacheService::clear(); return $status; } @@ -120,8 +118,7 @@ class SmsAdminServices extends BaseServices $sms->use($v['id'], $v['templateid']); } } - CacheService::clear(); - CacheService::set('sms_account', $account); + $this->cacheDriver()->set('sms_account', $account); return true; } else { return false; diff --git a/crmeb/crmeb/services/SystemConfigService.php b/crmeb/crmeb/services/SystemConfigService.php index a2adacf32..8f7a9696c 100644 --- a/crmeb/crmeb/services/SystemConfigService.php +++ b/crmeb/crmeb/services/SystemConfigService.php @@ -24,16 +24,17 @@ class SystemConfigService /** * 获取单个配置效率更高 - * @param $key - * @param string $default + * @param string $key + * @param $default * @param bool $isCaChe 是否获取缓存配置 * @return bool|mixed|string */ public static function get(string $key, $default = '', bool $isCaChe = false) { - $callable = function () use ($key) { - /** @var SystemConfigServices $service */ - $service = app()->make(SystemConfigServices::class); + /** @var SystemConfigServices $service */ + $service = app()->make(SystemConfigServices::class); + + $callable = function () use ($service, $key) { return $service->getConfigValue($key); }; @@ -41,7 +42,7 @@ class SystemConfigService if ($isCaChe) { return $callable(); } - return CacheService::remember(self::CACHE_SYSTEM . ':' . $key, $callable); + return $service->cacheDriver()->remember(self::CACHE_SYSTEM . ':' . $key, $callable); } catch (\Throwable $e) { return $default; } @@ -55,16 +56,17 @@ class SystemConfigService */ public static function more(array $keys, bool $isCaChe = false) { - $callable = function () use ($keys) { - /** @var SystemConfigServices $service */ - $service = app()->make(SystemConfigServices::class); + /** @var SystemConfigServices $service */ + $service = app()->make(SystemConfigServices::class); + + $callable = function () use ($service, $keys) { return Arr::getDefaultValue($keys, $service->getConfigAll($keys)); }; try { if ($isCaChe) return $callable(); - return CacheService::remember(self::CACHE_SYSTEM . ':' . md5(implode(',', $keys)), $callable); + return $service->cacheDriver()->remember(self::CACHE_SYSTEM . ':' . md5(implode(',', $keys)), $callable); } catch (\Throwable $e) { return Arr::getDefaultValue($keys); } From e22fa80e7c381927e6d3a86a736935c67e9a10f3 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Wed, 12 Apr 2023 18:00:01 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=89=E8=A3=85.env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/public/install/.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crmeb/public/install/.env b/crmeb/public/install/.env index bfac354fe..cb3527c1e 100755 --- a/crmeb/public/install/.env +++ b/crmeb/public/install/.env @@ -1 +1 @@ -APP_DEBUG = true [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = #DB_HOST# HOSTPORT = #DB_PORT# USERNAME = #DB_USER# PASSWORD = #DB_PWD# DATABASE = #DB_NAME# PREFIX = #DB_PREFIX# CHARSET = utf8mb4 DEBUG = true [LANG] default_lang = zh-cn [CACHE] DRIVER = #CACHE_TYPE# CACHE_PREFIX = #CACHE_PREFIX# CACHE_TAG_PREFIX = #CACHE_TAG_PREFIX# [REDIS] REDIS_HOSTNAME = #RB_HOST# PORT = #RB_PORT# REDIS_PASSWORD = '#RB_PWD#' SELECT = #RB_SELECT# [QUEUE] QUEUE_NAME = #QUEUE_NAME# \ No newline at end of file +APP_DEBUG = true [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = #DB_HOST# HOSTPORT = #DB_PORT# USERNAME = #DB_USER# PASSWORD = #DB_PWD# DATABASE = #DB_NAME# PREFIX = #DB_PREFIX# CHARSET = utf8mb4 DEBUG = true [LANG] default_lang = zh-cn [CACHE] DRIVER = #CACHE_TYPE# CACHE_PREFIX = #CACHE_PREFIX# CACHE_TAG_PREFIX = #CACHE_TAG_PREFIX# [REDIS] REDIS_HOSTNAME = #RB_HOST# PORT = #RB_PORT# REDIS_PASSWORD = #RB_PWD# SELECT = #RB_SELECT# [QUEUE] QUEUE_NAME = #QUEUE_NAME# \ No newline at end of file From 26ed236e2e0a306bb031be068f1567f256054805 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Wed, 12 Apr 2023 18:01:21 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index db28e6ace..b0ddf0c33 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ *.log *.DS_Store /crmeb/.env +/crmeb/.constant +/crmeb/.version /crmeb/runtime/cache /crmeb/runtime/log /crmeb/runtime/session From cd71ded5cc77c70e640d95fe8fd64aa0e89423ec Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Wed, 12 Apr 2023 18:06:16 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index b0ddf0c33..8295ea5c7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,6 @@ /.idea *.log *.DS_Store -/crmeb/.env -/crmeb/.constant -/crmeb/.version /crmeb/runtime/cache /crmeb/runtime/log /crmeb/runtime/session