From 03c379c62a37e544c80110c3df09ab3bf299001c Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Tue, 25 Apr 2023 14:04:32 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/system/SystemRouteServices.php | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/crmeb/app/services/system/SystemRouteServices.php b/crmeb/app/services/system/SystemRouteServices.php index 3eab6d611..a3ef095f2 100644 --- a/crmeb/app/services/system/SystemRouteServices.php +++ b/crmeb/app/services/system/SystemRouteServices.php @@ -170,20 +170,34 @@ class SystemRouteServices extends BaseServices * @email 136327134@qq.com * @date 2023/4/11 */ - public function topCateId(string $app, string $name = '全部权限') + public function topCateId(string $app, string $mark, string $markName, string $parent, string $cateName) { - $id = app()->make(SystemRouteCateServices::class)->value(['app_name' => $app, 'name' => $name, 'pid' => 0], 'id'); - if (!$id) { + $oneId = app()->make(SystemRouteCateServices::class)->value(['app_name' => $app, 'name' => $markName, 'mark' => $mark, 'pid' => 0], 'id'); + if (!$oneId) { $res = app()->make(SystemRouteCateServices::class)->save([ 'app_name' => $app, - 'name' => $name, + 'name' => $markName, + 'mark' => $mark, 'pid' => 0, 'add_time' => time(), ]); - $id = $res->id; + return $res->id; } - - return $id; + if ($parent != '') { + $twoId = app()->make(SystemRouteCateServices::class)->value(['app_name' => $app, 'name' => $cateName, 'mark' => $parent, ['pid', '>', 0]], 'id'); + if (!$twoId) { + $res = app()->make(SystemRouteCateServices::class)->save([ + 'app_name' => $app, + 'name' => $cateName, + 'mark' => $parent, + 'pid' => $oneId, + 'add_time' => time(), + ]); + return $res->id; + } + return $twoId; + } + return $oneId; } /** @@ -194,26 +208,14 @@ class SystemRouteServices extends BaseServices */ public function syncRoute(string $app = 'adminapi') { - $id = $this->topCateId($app); - $commmonId = $this->topCateId($app, '公共权限'); $listAll = $this->getRouteListAll($app); $list = []; foreach ($listAll as $item) { - if (isset($item['option']['is_common']) && $item['option']['is_common']) { - $cateId = $commmonId; + if (!isset($item['option']['mark']) && strstr($item['rule'], '') !== false) { + continue; } else { - if (!isset($item['option']['cate_name'])) { - if (strstr($item['rule'], '') === false) { - $rule = explode('/', $item['rule']); - $cateId = $this->topCateId($app, $rule[0]); - } else { - //miss路由不写入 - continue; - } - } else { - $cateId = $this->topCateId($app, $item['option']['cate_name']); - } + $cateId = $this->topCateId($app, $item['option']['mark'], $item['option']['mark_name'], $item['option']['parent'] ?? '', $item['option']['cate_name'] ?? ''); } $list[$cateId][] = $item; } From 264bfc8e7918e98662a82d98652afdee33962e2c Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Tue, 25 Apr 2023 14:56:26 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/v1/setting/SystemCrud.php | 8 ++- crmeb/app/dao/user/UserTaskFinishDao.php | 35 ---------- crmeb/app/model/user/UserTaskFinish.php | 68 ------------------- .../services/system/SystemCrudServices.php | 2 +- .../services/system/SystemRouteServices.php | 59 ++++++++++------ .../services/user/UserTaskFinishServices.php | 35 ---------- crmeb/crmeb/services/crud/Service.php | 3 +- 7 files changed, 47 insertions(+), 163 deletions(-) delete mode 100644 crmeb/app/dao/user/UserTaskFinishDao.php delete mode 100644 crmeb/app/model/user/UserTaskFinish.php delete mode 100644 crmeb/app/services/user/UserTaskFinishServices.php diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php index 9b6a9e527..ae9430e4d 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php @@ -82,6 +82,11 @@ class SystemCrud extends AuthController $fromField = $columnField = []; foreach ($data['tableField'] as $item) { + //判断字段长度 + if (in_array($item['field_type'], ['datetime', 'timestamp', 'time', 'date', 'year']) && $item['limit'] > 6) { + return app('json')->fail('字段' . $item['field'] . '长度不能大于6'); + } + //收集列表展示数据 if ($item['is_table'] && !in_array($item['field_type'], ['primaryKey', 'addSoftDelete', 'addSoftDelete'])) { $columnField[] = [ 'field' => $item['field'], @@ -89,6 +94,7 @@ class SystemCrud extends AuthController 'type' => $item['from_type'], ]; } + //收集表单展示数据 if ($item['from_type']) { $name = $item['table_name'] ?: $item['comment']; $option = $item['options'] ?? []; @@ -96,7 +102,7 @@ class SystemCrud extends AuthController return app('json')->fail(500056, [], ['field' => $item['field']]); } if (!$option && in_array($item['from_type'], ['radio', 'select'])) { - return app('json')->fail('表单类型为radio或select时,option字段不能为空'); + return app('json')->fail('表单类型为radio或select时,options字段不能为空'); } $fromField[] = [ 'field' => $item['field'], diff --git a/crmeb/app/dao/user/UserTaskFinishDao.php b/crmeb/app/dao/user/UserTaskFinishDao.php deleted file mode 100644 index 4bd761662..000000000 --- a/crmeb/app/dao/user/UserTaskFinishDao.php +++ /dev/null @@ -1,35 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace app\dao\user; - -use app\dao\BaseDao; -use app\model\user\UserTaskFinish; - -/** - * - * Class UserTaskFinishDao - * @package app\dao\user - */ -class UserTaskFinishDao extends BaseDao -{ - - /** - * 设置模型 - * @return string - */ - protected function setModel(): string - { - return UserTaskFinish::class; - } - -} diff --git a/crmeb/app/model/user/UserTaskFinish.php b/crmeb/app/model/user/UserTaskFinish.php deleted file mode 100644 index 701924987..000000000 --- a/crmeb/app/model/user/UserTaskFinish.php +++ /dev/null @@ -1,68 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace app\model\user; - -use crmeb\basic\BaseModel; -use crmeb\traits\ModelTrait; -use think\model; - -/** - * Class UserTaskFinish - * @package app\model\user - */ -class UserTaskFinish extends BaseModel -{ - use ModelTrait; - - /** - * 数据表主键 - * @var string - */ - protected $pk = 'id'; - - /** - * 模型名称 - * @var string - */ - protected $name = 'user_task_finish'; - - /** - * 用户uid - * @param Model $query - * @param $value - */ - public function searchUidAttr($query, $value) - { - $query->where('uid', $value); - } - - /** - * 任务id - * @param Model $query - * @param $value - */ - public function searchTaskIdAttr($query, $value) - { - $query->where('task_id', $value); - } - - /** - * 状态 - * @param Model $query - * @param $value - */ - public function searchStatusAttr($query, $value) - { - $query->where('status', $value); - } - -} diff --git a/crmeb/app/services/system/SystemCrudServices.php b/crmeb/app/services/system/SystemCrudServices.php index 92ec665be..6232e47c3 100644 --- a/crmeb/app/services/system/SystemCrudServices.php +++ b/crmeb/app/services/system/SystemCrudServices.php @@ -126,7 +126,7 @@ class SystemCrudServices extends BaseServices 'text', 'longtext', 'tinytext', - 'enum', +// 'enum', 'blob', 'binary', 'varbinary', diff --git a/crmeb/app/services/system/SystemRouteServices.php b/crmeb/app/services/system/SystemRouteServices.php index a3ef095f2..c01ab2a08 100644 --- a/crmeb/app/services/system/SystemRouteServices.php +++ b/crmeb/app/services/system/SystemRouteServices.php @@ -170,33 +170,18 @@ class SystemRouteServices extends BaseServices * @email 136327134@qq.com * @date 2023/4/11 */ - public function topCateId(string $app, string $mark, string $markName, string $parent, string $cateName) + public function topCateId(string $app, string $cateName, int $pid) { - $oneId = app()->make(SystemRouteCateServices::class)->value(['app_name' => $app, 'name' => $markName, 'mark' => $mark, 'pid' => 0], 'id'); + $oneId = app()->make(SystemRouteCateServices::class)->value(['app_name' => $app, 'name' => $cateName, 'pid' => 0], 'id'); if (!$oneId) { $res = app()->make(SystemRouteCateServices::class)->save([ 'app_name' => $app, - 'name' => $markName, - 'mark' => $mark, - 'pid' => 0, + 'name' => $cateName, + 'pid' => $pid, 'add_time' => time(), ]); return $res->id; } - if ($parent != '') { - $twoId = app()->make(SystemRouteCateServices::class)->value(['app_name' => $app, 'name' => $cateName, 'mark' => $parent, ['pid', '>', 0]], 'id'); - if (!$twoId) { - $res = app()->make(SystemRouteCateServices::class)->save([ - 'app_name' => $app, - 'name' => $cateName, - 'mark' => $parent, - 'pid' => $oneId, - 'add_time' => time(), - ]); - return $res->id; - } - return $twoId; - } return $oneId; } @@ -212,13 +197,43 @@ class SystemRouteServices extends BaseServices $list = []; foreach ($listAll as $item) { - if (!isset($item['option']['mark']) && strstr($item['rule'], '') !== false) { + if (!isset($item['option']['mark_name']) || strstr($item['rule'], '') !== false) { continue; } else { - $cateId = $this->topCateId($app, $item['option']['mark'], $item['option']['mark_name'], $item['option']['parent'] ?? '', $item['option']['cate_name'] ?? ''); + $list[$item['option']['mark_name']][] = $item; } - $list[$cateId][] = $item; } + $newsList = [];; + foreach ($list as $key => $item) { + $newItem = []; + foreach ($item as $value) { + if (isset($value['option']['cate_name'])) { + $newItem[$value['option']['cate_name']][] = $value; + } else { + $newItem[$key][] = $value; + } + } + $newsList[$key] = $newItem; + } + + $list = []; + foreach ($newsList as $key => $item) { + $keys = array_keys($item); + $pid = $this->topCateId($app, $key, 0); + if ($keys == 1 && $key == $keys[0]) { + foreach ($item[$key] as $value) { + $list[$pid][] = $value; + } + } else { + foreach ($item as $i => $k) { + $cateId = $this->topCateId($app, $i, $pid); + foreach ($k as $value) { + $list[$cateId][] = $value; + } + } + } + } + //保持新增的权限路由 $data = $this->dao->selectList(['app_name' => $app], 'path,method')->toArray(); $save = []; diff --git a/crmeb/app/services/user/UserTaskFinishServices.php b/crmeb/app/services/user/UserTaskFinishServices.php deleted file mode 100644 index 995160cd7..000000000 --- a/crmeb/app/services/user/UserTaskFinishServices.php +++ /dev/null @@ -1,35 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace app\services\user; - -use app\services\BaseServices; -use app\dao\user\UserTaskFinishDao; - -/** - * - * Class UserTaskFinishServices - * @package app\services\user - */ -class UserTaskFinishServices extends BaseServices -{ - - /** - * UserTaskFinishServices constructor. - * @param UserTaskFinishDao $dao - */ - public function __construct(UserTaskFinishDao $dao) - { - $this->dao = $dao; - } - -} diff --git a/crmeb/crmeb/services/crud/Service.php b/crmeb/crmeb/services/crud/Service.php index a9585685f..87010e28f 100644 --- a/crmeb/crmeb/services/crud/Service.php +++ b/crmeb/crmeb/services/crud/Service.php @@ -141,7 +141,8 @@ class Service extends Make if ($option) { $attOption = []; foreach ($option as $item) { - $attOption[] = $this->tab(3) . "['value'=>'{$item['value']}', 'label'=>'{$item['label']}'],"; + $value = (int)$item['value']; + $attOption[] = $this->tab(3) . "['value'=>{$value}, 'label'=>'{$item['label']}'],"; } $strOption = implode("\n", $attOption); From 89de83a4a520be38b4996849357caff6006c1f87 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Tue, 25 Apr 2023 15:13:16 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/services/system/SystemRouteServices.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crmeb/app/services/system/SystemRouteServices.php b/crmeb/app/services/system/SystemRouteServices.php index c01ab2a08..f7d72c9b3 100644 --- a/crmeb/app/services/system/SystemRouteServices.php +++ b/crmeb/app/services/system/SystemRouteServices.php @@ -170,7 +170,7 @@ class SystemRouteServices extends BaseServices * @email 136327134@qq.com * @date 2023/4/11 */ - public function topCateId(string $app, string $cateName, int $pid) + public function topCateId(string $app, string $cateName, int $pid = 0) { $oneId = app()->make(SystemRouteCateServices::class)->value(['app_name' => $app, 'name' => $cateName, 'pid' => 0], 'id'); if (!$oneId) { From 27ee5ec867513d73e63bb5bbd7d6755a0226b210 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Tue, 25 Apr 2023 15:37:12 +0800 Subject: [PATCH 4/5] =?UTF-8?q?crud=E4=BF=AE=E6=94=B9=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/system/SystemCrudServices.php | 4 +++ .../components/FoundationFor.vue | 16 +--------- .../codeGeneration/components/TableForm.vue | 17 +++++++++++ .../src/pages/system/codeGeneration/index.vue | 30 +++++++++++++++---- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/crmeb/app/services/system/SystemCrudServices.php b/crmeb/app/services/system/SystemCrudServices.php index 6232e47c3..662cbb061 100644 --- a/crmeb/app/services/system/SystemCrudServices.php +++ b/crmeb/app/services/system/SystemCrudServices.php @@ -508,6 +508,10 @@ class SystemCrudServices extends BaseServices //对比字段进行更新/删除字段 $this->diffAlter($tableName, $data['deleteField'], $tableField); } + } else { + if ($this->dao->count(['table_name' => $tableName])) { + throw new AdminException('表已经被生成过,请在列表中进行修改'); + } } //创建数据库 if ($tableField && (!$data['isTable'] || !$tableInfo)) { diff --git a/template/admin/src/pages/system/codeGeneration/components/FoundationFor.vue b/template/admin/src/pages/system/codeGeneration/components/FoundationFor.vue index f14223645..381b6abd9 100644 --- a/template/admin/src/pages/system/codeGeneration/components/FoundationFor.vue +++ b/template/admin/src/pages/system/codeGeneration/components/FoundationFor.vue @@ -1,21 +1,7 @@