Pārlūkot izejas kodu

修改同步路由

liaofei 2 gadi atpakaļ
vecāks
revīzija
264bfc8e79

+ 7 - 1
crmeb/app/adminapi/controller/v1/setting/SystemCrud.php

@@ -82,6 +82,11 @@ class SystemCrud extends AuthController
 
 
         $fromField = $columnField = [];
         $fromField = $columnField = [];
         foreach ($data['tableField'] as $item) {
         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'])) {
             if ($item['is_table'] && !in_array($item['field_type'], ['primaryKey', 'addSoftDelete', 'addSoftDelete'])) {
                 $columnField[] = [
                 $columnField[] = [
                     'field' => $item['field'],
                     'field' => $item['field'],
@@ -89,6 +94,7 @@ class SystemCrud extends AuthController
                     'type' => $item['from_type'],
                     'type' => $item['from_type'],
                 ];
                 ];
             }
             }
+            //收集表单展示数据
             if ($item['from_type']) {
             if ($item['from_type']) {
                 $name = $item['table_name'] ?: $item['comment'];
                 $name = $item['table_name'] ?: $item['comment'];
                 $option = $item['options'] ?? [];
                 $option = $item['options'] ?? [];
@@ -96,7 +102,7 @@ class SystemCrud extends AuthController
                     return app('json')->fail(500056, [], ['field' => $item['field']]);
                     return app('json')->fail(500056, [], ['field' => $item['field']]);
                 }
                 }
                 if (!$option && in_array($item['from_type'], ['radio', 'select'])) {
                 if (!$option && in_array($item['from_type'], ['radio', 'select'])) {
-                    return app('json')->fail('表单类型为radio或select时,option字段不能为空');
+                    return app('json')->fail('表单类型为radio或select时,options字段不能为空');
                 }
                 }
                 $fromField[] = [
                 $fromField[] = [
                     'field' => $item['field'],
                     'field' => $item['field'],

+ 0 - 35
crmeb/app/dao/user/UserTaskFinishDao.php

@@ -1,35 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
-// | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
-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;
-    }
-
-}

+ 0 - 68
crmeb/app/model/user/UserTaskFinish.php

@@ -1,68 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
-// | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
-
-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);
-    }
-
-}

+ 1 - 1
crmeb/app/services/system/SystemCrudServices.php

@@ -126,7 +126,7 @@ class SystemCrudServices extends BaseServices
                 'text',
                 'text',
                 'longtext',
                 'longtext',
                 'tinytext',
                 'tinytext',
-                'enum',
+//                'enum',
                 'blob',
                 'blob',
                 'binary',
                 'binary',
                 'varbinary',
                 'varbinary',

+ 37 - 22
crmeb/app/services/system/SystemRouteServices.php

@@ -170,33 +170,18 @@ class SystemRouteServices extends BaseServices
      * @email 136327134@qq.com
      * @email 136327134@qq.com
      * @date 2023/4/11
      * @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) {
         if (!$oneId) {
             $res = app()->make(SystemRouteCateServices::class)->save([
             $res = app()->make(SystemRouteCateServices::class)->save([
                 'app_name' => $app,
                 'app_name' => $app,
-                'name' => $markName,
-                'mark' => $mark,
-                'pid' => 0,
+                'name' => $cateName,
+                'pid' => $pid,
                 'add_time' => time(),
                 'add_time' => time(),
             ]);
             ]);
             return $res->id;
             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;
         return $oneId;
     }
     }
 
 
@@ -212,13 +197,43 @@ class SystemRouteServices extends BaseServices
 
 
         $list = [];
         $list = [];
         foreach ($listAll as $item) {
         foreach ($listAll as $item) {
-            if (!isset($item['option']['mark']) && strstr($item['rule'], '<MISS>') !== false) {
+            if (!isset($item['option']['mark_name']) || strstr($item['rule'], '<MISS>') !== false) {
                 continue;
                 continue;
             } else {
             } 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;
+            }
+        }
+        $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;
+                }
             }
             }
-            $list[$cateId][] = $item;
+            $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();
         $data = $this->dao->selectList(['app_name' => $app], 'path,method')->toArray();
         $save = [];
         $save = [];

+ 0 - 35
crmeb/app/services/user/UserTaskFinishServices.php

@@ -1,35 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
-// | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
-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;
-    }
-
-}

+ 2 - 1
crmeb/crmeb/services/crud/Service.php

@@ -141,7 +141,8 @@ class Service extends Make
         if ($option) {
         if ($option) {
             $attOption = [];
             $attOption = [];
             foreach ($option as $item) {
             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);
             $strOption = implode("\n", $attOption);