rabin 1 år sedan
förälder
incheckning
761e705ec1

+ 36 - 35
api/Admin.php

@@ -5,36 +5,37 @@ class Admin extends Auth
 {
     public function info()
     {
-        $this->user['system']['show'] = true;
-        $this->user['system']['id'] = $this->user['select']['system_id'];
-        $this->user['system']['name'] = '当前系统';
-        $this->user['system']['list'] = $this->system();
+        $this->user['module']['show'] = true;
+        $this->user['module']['id'] = $this->user['select']['module_id'];
+        $this->user['module']['name'] = '当前模块';
+        $this->user['module']['list'] = $this->module();
+        $this->user['module']['uri'] = array('system' => $this->system['key'], 'number' => $this->system_info['number']);
         return $this->user;
     }
 
-    # 获取当前的系统列表
-    public function system()
+    # 获取当前的模块列表
+    public function module()
     {
         $where = array();
-        if ($this->user['auth']['system']) {
-            $where['id'] = array('in', $this->user['auth']['system']);
+        if ($this->user['auth']['module']) {
+            $where['id'] = array('in', $this->user['auth']['module']);
         }
         $result = array();
-        $system = Dever::db('system', 'manage')->select($where);
+        $module = Dever::db('system_module', 'manage')->select($where);
         $i = 0;
-        foreach ($system as $k => $v) {
-            $child = Dever::db($v['relation_table'])->select([]);
+        foreach ($module as $k => $v) {
+            $child = Dever::db($v['data_table'])->select([]);
             if ($child) {
                 $data = array();
                 foreach ($child as $k1 => $v1) {
                     $v1['select'] = false;
-                    if ($v['id'] == $this->user['select']['system_id'] && $v1['id'] == $this->user['select']['relation_id']) {
-                        $this->user['system']['name'] = $v1['name'];
+                    if ($v['id'] == $this->user['select']['module_id'] && $v1['id'] == $this->user['select']['data_id']) {
+                        $this->user['module']['name'] = $v1['name'];
                         $v1['select'] = true;
                     }
                     $key = $v['id'] . '-' . $v1['id'];
-                    if ($this->user['system_relation']) {
-                        if (strstr($this->user['system_relation'], $key)) {
+                    if ($this->user['module_data']) {
+                        if (strstr($this->user['module_data'], $key)) {
                             $data[] = $v1;
                         }
                     } else {
@@ -49,25 +50,25 @@ class Admin extends Auth
             }
         }
         if ($i <= 1) {
-            $this->user['system']['show'] = false;
+            $this->user['module']['show'] = false;
         }
         return $result;
     }
 
-    # 根据角色获取子系统
-    public function getSystem($value = false)
+    # 根据角色获取模块下的数据
+    public function getModuleData($value = false)
     {
         if (!$value) {
-            $result['system_relation']['option'] = array();
+            $result['module_data']['option'] = array();
             return $result;
         }
         $result = array();
-        $role = Dever::db('role', 'manage')->select(array('id' => array('in', $value)));
+        $role = Dever::db($this->system['role_table'])->select(array('id' => array('in', $value)));
         if ($role) {
-            $info = $system = array();
+            $info = $module = array();
             foreach ($role as $k => $v) {
-                if ($v['system']) {
-                    $child = Dever::db('system', 'manage')->select(array('id' => array('in', $v['system'])));
+                if ($v['module']) {
+                    $child = Dever::db('system_module', 'manage')->select(array('id' => array('in', $v['module'])));
                     if ($child) {
                         foreach ($child as $k1 => $v1) {
                             if (isset($info[$v1['id']])) {
@@ -77,31 +78,31 @@ class Admin extends Auth
                             $v1['value'] = 's-' . $v1['id'];
                             $v1['label'] = $v1['name'];
                             $v1['children'] = array();
-                            $data = Dever::db($v1['relation_table'])->select([], array('col' => 'concat('.$v1['id'].', "-", id) as value, name as label'));
+                            $data = Dever::db($v1['data_table'])->select([], array('col' => 'concat('.$v1['id'].', "-", id) as value, name as label'));
                             if ($data) {
                                 $v1['children'] = array_merge($v1['children'], $data);
                             }
-                            $system[] = $v1;
+                            $module[] = $v1;
                         }
                     }
                 }
             }
-            $result['system_relation']['option'] = $system;
+            $result['module_data']['option'] = $module;
         }
         
         return $result;
     }
 
-    # 切换系统
-    public function setSystem()
+    # 切换模块
+    public function setModule()
     {
-        $system_id = Dever::input('system_id');
-        $this->checkSystem($this->user['select']['system_id']);
-        $relation_id = Dever::input('relation_id');
-        if ($this->user['system_relation'] && !strstr($this->user['system_relation'], $relation_id)) {
-            Dever::error('无系统权限');
+        $module_id = Dever::input('module_id');
+        $this->checkModule($this->user['select']['module_id']);
+        $data_id = Dever::input('data_id');
+        if ($this->user['module_data'] && !strstr($this->user['module_data'], $module_id . '-' . $data_id)) {
+            Dever::error('无模块权限');
         }
-        $result = Dever::load('common')->token($this->user['id'], $this->user['mobile'], $system_id, $relation_id);
+        $result = Dever::load('common')->token($this->user['id'], $this->user['mobile'], $this->user['select']['partition'], $this->user['select']['system_id'], $this->user['select']['info_id'], $module_id, $data_id);
         return $result;
     }
 
@@ -119,7 +120,7 @@ class Admin extends Auth
         }
         $state = false;
         if ($data) {
-            $state = Dever::db($this->system['relation_user_table'])->update($this->uid, $data);
+            $state = Dever::db($this->system['user_table'])->update($this->uid, $data);
         }
         if (!$state) {
             Dever::error('修改失败');

+ 52 - 12
api/Login.php

@@ -20,22 +20,21 @@ class Login
     public function act()
     {
         //$this->checkCode();
-        $system = Dever::input('system', 'is_string', '系统', 'platform');
-        $system = Dever::db('system', 'manage')->find(array('key' => $system));
-        if (!$system) {
-            Dever::error('登录失败,当前系统不存在');
-        }
+        $system = $this->getSystem();
         $number = Dever::input('number', '', $system['name'] . '号', 'default');
-        $info = Dever::db($system['relation_table'])->find(array('number' => $number));
+        $info = Dever::db($system['info_table'])->find(array('number' => $number));
         if (!$info) {
-            Dever::error('登录失败,当前系统设置错误');
+            Dever::error('登录失败,当前' . $system['name'] . '号错误');
         }
         if ($system['partition'] == 'no') {
             # 不分库
-            $db = Dever::db($system['relation_user_table']);
+            $db = Dever::db($system['user_table']);
         } else {
             # 分库
-            $db = Dever::db($system['relation_user_table'], '', 'default', array($system['partition'] => $info['id']));
+            $info['info_id'] = $info['id'];
+            $info['partition'] = $system['partition'];
+            $info['system_id'] = $system['id'];
+            $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($info));
         }
         $where['mobile'] = Dever::input('mobile', Dever::rule('mobile'), '手机号');
         $password = Dever::input('password', 'is_string', '密码');
@@ -57,12 +56,53 @@ class Login
             Dever::error('登录失败,管理员信息无效');
         }
         if ($admin['status'] == 2) {
-            Dever::error('登录失败,管理员已被封禁');
+            Dever::error('登录失败,账户已被封禁');
         }
         if (Dever::load('common')->hash($password, $admin['salt']) != $admin['password']) {
-            Dever::error('登录失败,账号密码无效');
+            Dever::error('登录失败,账户密码无效');
+        }
+        # 根据角色获取module_id
+        $system_user = Dever::db('system_user', 'manage')->find(array('uid' => $admin['id'], 'system_id' => $system['id'], 'info_id' => $info['id']));
+        $module_id = $data_id = 0;
+        if ($system_user) {
+            $module_id = $system_user['module_id'];
+            $data_id = $system_user['data_id'];
+        } elseif ($admin['role']) {
+            $module = '';
+            $role = Dever::db($system['role_table'])->select(array('id' => array('in', $admin['role'])));
+            foreach ($role as $k => $v) {
+                if ($v['module']) {
+                    $module .= $v['module'] . ',';
+                }
+            }
+            if ($module) {
+                $where['id'] = array('in', $module);
+            } else {
+                $where['system'] = $system['key'];
+            }
+            $module = Dever::db('system_module', 'manage')->select($where);
+            if ($module) {
+                $module_id = $module[0]['id'];
+                $child = Dever::db($module[0]['data_table'])->select([]);
+                if ($child) {
+                    if ($admin['module_data']) {
+                        foreach ($child as $k => $v) {
+                            $key = $module_id . '-' . $v['id'];
+                            if (strstr($admin['module_data'], $key)) {
+                                $data_id = $v['id'];
+                                break;
+                            }
+                        }
+                    } else {
+                        $data_id = $child[0]['id'];
+                    }
+                }
+            }
+        }
+        if (!$module_id || !$data_id) {
+            Dever::error('登录失败,账户无效');
         }
-        return Dever::load('common')->token($admin['id'], $admin['mobile'], $system['id'], $info['id']);
+        return Dever::load('common')->token($admin['id'], $admin['mobile'], $system['partition'], $system['id'], $info['id'], $module_id, $data_id);
     }
     private function checkCode()
     {

+ 2 - 2
api/Menu.php

@@ -7,7 +7,7 @@ class Menu extends Auth
     {
         # 如果后续增加Root,就要这里置为false
         $this->top = true;
-        $top = Dever::db('menu', 'manage')->select(array('parent_id' => '0', 'system_id' => $this->user['select']['system_id']));
+        $top = Dever::db('menu', 'manage')->select(array('parent_id' => '0', 'module_id' => $this->user['select']['module_id']));
         $result = $menu = array();
         $result[] = array
         (
@@ -75,7 +75,7 @@ class Menu extends Auth
             }
             $info['component'] = 'Layout';
         }
-        $where = array('parent_id' => $v['id'], 'system_id' => $this->user['select']['system_id']);
+        $where = array('parent_id' => $v['id'], 'module_id' => $this->user['select']['module_id']);
         $child = Dever::db('menu', 'manage')->select($where);
         if ($child) {
             foreach ($child as $v1) {

+ 1 - 1
api/Page/Data.php

@@ -131,7 +131,7 @@ class Data extends Page
     private function export()
     {
         $result = false;
-        if (isset($this->config['export'])) {
+        if (isset($this->config['export']) && $this->config['export']) {
             $result = array();
             foreach ($this->config['export'] as $k => $v) {
                 $func = $this->getFunc($k, $v, 300);

+ 14 - 5
api/Page/Update.php

@@ -11,7 +11,7 @@ class Update extends Page
     public function get(&$value = array(), &$option = array())
     {
         $func = $this->checkFunc();
-        $remote = $show = $spec = $source = array();
+        $remote = $show = $spec = $source = $default = array();
         $data['update'] = $data['field'] = $data['option'] = array();
         $this->setting('field', $data['update'], true, 'text');
         foreach ($data['update'] as $k => $v) {
@@ -33,6 +33,9 @@ class Update extends Page
             if (isset($v['show']) && is_string($v['show'])) {
                 $show[$v['key']] = array($k, $v['show']);
             }
+            if (isset($v['default']) && is_string($v['default']) && strstr($v['default'], '{')) {
+                $default[$v['key']] = array($k, $v['default'], $v['key']);
+            }
             $data['field'][$v['key']] = $v['value'];
             if ($v['type'] == 'sku') {
                 $data['field'][$v['key'] . '_spec'] = [];
@@ -63,7 +66,7 @@ class Update extends Page
         }
         if ($this->info) {
             $info = $this->info;
-            $this->setInfo($info, $data, $remote, $show, $source);
+            $this->setInfo($info, $data, $remote, $show, $source, $default);
             if ($spec) {
                 foreach ($spec as $k => $v) {
                     $data['update'][$spec[$k][0]]['remote'] = Dever::url($spec[$k][1]);
@@ -75,7 +78,7 @@ class Update extends Page
             }
         } elseif ($value) {
             foreach ($value as $k => &$v) {
-                $this->setInfo($v, $data, $remote, $show, $source, 2);
+                $this->setInfo($v, $data, $remote, $show, $source, $default, 2);
                 $option[$k] = $data['option'];
             }
         } else {
@@ -83,7 +86,7 @@ class Update extends Page
                 $info = array();
                 foreach ($remote as $k => $v) {
                     $data['update'][$v[0]]['remote'] = Dever::url($v[1]);
-                    if (isset($v[2]) && isset($data['option'][$v[2]]) && $data['option'][$v[2]] & $m = Dever::isset($data['option'][$v[2]][0], 'id')) {
+                    if (isset($v[2]) && isset($data['option'][$v[2]]) && $data['option'][$v[2]] && $m = Dever::isset($data['option'][$v[2]][0], 'id')) {
                         $result = Dever::call($v[1], array($m), 'api');
                         if ($result) {
                             $this->setUpdate($info, $data, $result);
@@ -109,7 +112,7 @@ class Update extends Page
         return $data;
     }
 
-    private function setInfo(&$info, &$data, $remote, $show, $source, $type = 1)
+    private function setInfo(&$info, &$data, $remote, $show, $source, $default, $type = 1)
     {
         if ($source) {
             foreach ($source as $k => $v) {
@@ -151,6 +154,12 @@ class Update extends Page
                 }
             }
         }
+        if ($default) {
+            foreach ($default as $k => $v) {
+                $data['update'][$v[0]]['value'] = $this->getShow($v[1], $info);
+                $data['field'][$v[2]] = $this->getShow($v[1], $info);
+            }
+        }
     }
 
     private function setUpdate(&$info, &$data, $result)

+ 18 - 14
lib/Auth.php

@@ -6,42 +6,45 @@ class Auth
     protected $uid;
     protected $user;
     protected $system;
-    protected $relation;
+    protected $info;
     public $data = array();
     public function __construct()
     {
         $info = Dever::load('common', 'manage')->auth();
         if (!$info && $this->login) {
             $info['uid'] = 1;
+            $info['extend']['system_id'] = 'no';
             $info['extend']['system_id'] = 1;
-            $info['extend']['relation_id'] = 1;
+            $info['extend']['info_id'] = 1;
+            $info['extend']['module_id'] = 1;
+            $info['extend']['data_id'] = 1;
             //Dever::error('请先登录');
         }
         $this->system = Dever::db('system', 'manage')->find($info['extend']['system_id']);
         if (!$this->system) {
             Dever::error('当前系统不存在');
         }
-        $this->relation = Dever::db($this->system['relation_table'])->find($info['extend']['relation_id']);
+        $this->system_info = Dever::db($this->system['info_table'])->find($info['extend']['info_id']);
         if (!$this->system) {
             Dever::error('当前系统设置错误');
         }
 
         $this->uid = $info['uid'];
-        $this->user = Dever::db($this->system['relation_user_table'])->find($this->uid);
+        $this->user = Dever::db($this->system['user_table'])->find($this->uid);
         if (!$this->user) {
             Dever::error('请先登录');
         }
-        $this->user['auth'] = array('system' => '', 'menu' => '', 'func' => '');
+        $this->user['auth'] = array('module' => '', 'menu' => '', 'func' => '');
         if ($this->user['role']) {
-            $role = Dever::db($this->system['relation_role_table'])->select(array('id' => array('in', $this->user['role'])));
+            $role = Dever::db($this->system['role_table'])->select(array('id' => array('in', $this->user['role'])));
             foreach ($role as $k => $v) {
-                $this->user['auth']['system'] .= $v['system'] . ',';
+                $this->user['auth']['module'] .= $v['module'] . ',';
                 $this->user['auth']['menu'] .= $v['menu'] . ',';
                 $this->user['auth']['func'] .= $v['auth'] . ',';
             }
         }
-        if ($this->user['auth']['system']) {
-            $this->user['auth']['system'] = rtrim($this->user['auth']['system'], ',');
+        if ($this->user['auth']['module']) {
+            $this->user['auth']['module'] = rtrim($this->user['auth']['module'], ',');
         }
         if ($this->user['auth']['menu']) {
             $this->user['auth']['menu'] = rtrim($this->user['auth']['menu'], ',');
@@ -51,9 +54,10 @@ class Auth
         }
         $this->user['select'] = $info['extend'] ?? false;
         if (!$this->user['select']) {
-            $this->user['select'] = array('system_id' => 1, 'relation_id' => 1);
+            # 分别为系统id,系统基本信息id,模块id,模块数据id
+            $this->user['select'] = array('partition' => 'no', 'system_id' => 1, 'info_id' => 1, 'module_id' => 1, 'data_id' => 1);
         }
-        $this->checkSystem($this->user['select']['system_id']);
+        $this->checkModule($this->user['select']['module_id']);
     }
 
     # 设置功能权限
@@ -99,13 +103,13 @@ class Auth
         return false;
     }
 
-    # 检测系统权限
-    protected function checkSystem($system_id)
+    # 检测系统模块权限
+    protected function checkModule($module_id)
     {
         if ($this->user['id'] == 1) {
             return;
         }
-        if ($this->user['auth']['system'] && !Dever::check($this->user['auth']['system'], $system_id)) {
+        if ($this->user['auth']['module'] && !Dever::check($this->user['auth']['module'], $module_id)) {
             Dever::error('无系统权限');
         }
     }

+ 20 - 17
lib/Common.php

@@ -10,7 +10,7 @@ class Common
     {
         $auth = Env::header('authorization');
         if ($auth) {
-            $auth = ltrim($auth, 'Bearer ');
+            $auth = str_replace('Bearer ', '', $auth);
             Dever::session('auth', $auth);
             $info = Secure::checkLogin($auth);
             return $info;
@@ -36,34 +36,37 @@ class Common
     }
 
     # 获取当前使用的系统 一般为数据库隔离使用
-    public function system($key = '')
+    public function system($info = array())
     {
-        $info = $this->extend();
-        if ($info && isset($info['extend']['relation_id'])) {
+        if (!$info) {
+            $info = $this->extend();
+        }
+        if ($info && isset($info['info_id']) && isset($info['partition'])) {
             # 这里后续增加从数据库中获取
-            $value = $info['extend']['system_id'] . '_' . $info['extend']['relation_id'];
-            if ($key) {
-                return array($key => $value);
-            }
-            return $value;
+            $value = $info['system_id'] . '_' . $info['info_id'];
+            return array($info['partition'] => $value);
         }
         return false;
     }
 
     # 生成token
-    public function token($uid, $mobile, $system_id, $relation_id)
+    public function token($uid, $mobile, $partition, $system_id, $info_id, $module_id, $data_id)
     {
+        $extand['partition'] = $partition;
         $extand['system_id'] = $system_id;
-        $extand['relation_id'] = $relation_id;
-        /* 暂时不做到库中
-        $select['mobile'] = $mobile;
-        $info = Dever::db('mobile_system')->find($select);
+        $extand['info_id'] = $info_id;
+        $extand['module_id'] = $module_id;
+        $extand['data_id'] = $data_id;
+        $select['uid'] = $uid;
+        $select['system_id'] = $system_id;
+        $select['info_id'] = $info_id;
+        $info = Dever::db('system_user', 'manage')->find($select);
         $select += $extand;
         if (!$info) {
-            Dever::db('mobile_system')->insert($select);
+            Dever::db('system_user', 'manage')->insert($select);
         } else {
-            Dever::db('mobile_system')->update($info['id'], $select);
-        }*/
+            Dever::db('system_user', 'manage')->update($info['id'], $select);
+        }
         return array('token' => Secure::login($uid, $extand));
     }
 

+ 37 - 2
lib/Group.php

@@ -19,8 +19,11 @@ class Group extends Auth
     public function update($data)
     {
         if ($data['mobile']) {
-            $database = '"2_' . $data['id'] . '"';
-            $db = Dever::db('group_user', '', 'default', array('database' => $database));
+            $system = Dever::db('system', 'manage')->find(2);
+            $data['system_id'] = $system['id'];
+            $data['info_id'] = $data['id'];
+            $data['partition'] = $system['partition'];
+            $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($data));
             $info = $db->find(1);
             if (!$info) {
                 $password = '123456';
@@ -32,4 +35,36 @@ class Group extends Auth
             }
         }
     }
+
+    # 创建账户
+    public function createUser($module, $data_id, $name, $mobile, $password)
+    {
+        if ($mobile && $password) {
+            $system = Dever::db('system', 'manage')->find(2);
+            $data['system_id'] = $system['id'];
+            $data['info_id'] = 1;
+            $data['partition'] = $system['partition'];
+            $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($data));
+
+            $info = $db->find(array('mobile' => $mobile));
+
+            $module = Dever::db('system_module', 'manage')->find(array('key' => $module, 'system' => 'group'));
+            $insert['name'] = $name;
+            $insert['mobile'] = $mobile;
+            $insert['role'] = 2;
+            $insert['module_data'] = $module['id'] . '-' . $data_id;
+            if (!$info) {
+                $insert += Dever::load('common')->createPwd($password);
+                $db->insert($insert);
+            } else {
+                $insert += Dever::load('common')->createPwd($password);
+                $module_data = $insert['module_data'];
+                unset($insert['module_data']);
+                if (!strstr($info['module_data'], $module_data)) {
+                    $insert['module_data'] = $module_data . ',' . $info['module_data'];
+                }
+                $db->update($info['id'], $insert);
+            }
+        }
+    }
 }

+ 21 - 9
lib/Menu.php

@@ -31,13 +31,25 @@ class Menu
                 $data = $where;
                 $data['name'] = $v['name'];
                 $data['sort'] = $v['sort'];
-                $data['partition'] = $v['partition'] ?? 'database';
-                $data['relation_table'] = $v['relation_table'];
-                $data['relation_field'] = $v['relation_field'];
-                $data['relation_user_table'] = $v['relation_user_table'];
+                $data['partition'] = $v['partition'] ?? 'no';
+                $data['info_table'] = $v['info_table'];
+                $data['user_table'] = $v['user_table'];
+                $data['role_table'] = $v['role_table'];
                 Dever::db('system', 'manage')->up($where, $data);
             }
         }
+        if (isset($core['module'])) {
+            foreach ($core['module'] as $k => $v) {
+                $where = array();
+                $where['key'] = $k;
+                $data = $where;
+                $data['name'] = $v['name'];
+                $data['sort'] = $v['sort'];
+                $data['system'] = $v['system'];
+                $data['data_table'] = $v['data_table'];
+                Dever::db('system_module', 'manage')->up($where, $data);
+            }
+        }
         if (isset($core['menu'])) {
             foreach ($core['menu'] as $k => $v) {
                 $where = array();
@@ -50,7 +62,7 @@ class Menu
                     $parent = Dever::db('menu', 'manage')->find(array('key' => $v['parent']));
                     if ($parent) {
                         $where['parent_id'] = $parent['id'];
-                        $where['system_id'] = $parent['system_id'];
+                        $where['module_id'] = $parent['module_id'];
                         $where['level'] = 2;
                         if ($parent['parent_id']) {
                             $where['level'] = 3;
@@ -59,10 +71,10 @@ class Menu
                 } else {
                     $where['level'] = 1;
                 }
-                if (isset($v['system'])) {
-                    $system = Dever::db('system', 'manage')->find(array('key' => $v['system']));
-                    if ($system) {
-                        $where['system_id'] = $system['id'];
+                if (isset($v['module'])) {
+                    $module = Dever::db('system_module', 'manage')->find(array('key' => $v['module']));
+                    if ($module) {
+                        $where['module_id'] = $module['id'];
                     }
                 }
                 $data = $where;

+ 18 - 0
lib/Module.php

@@ -0,0 +1,18 @@
+<?php namespace Manage\Lib;
+use Dever;
+use Dever\Project;
+class Module extends Auth
+{
+    public function getTree()
+    {
+        $data = Dever::db('system_module', 'manage')->select([]);
+        $result = array();
+        $result[] = array
+        (
+            'id' => 'root',
+            'name' => '系统模块',
+            'children' => $data,
+        );
+        return $result;
+    }
+}

+ 3 - 3
lib/Page.php

@@ -21,7 +21,7 @@ class Page extends Auth
             $load = Dever::input('load');
         }
         list($this->db, $this->menu) = Dever::load('common', 'manage')->db($load);
-        if ($this->menu) {
+        if ($this->menu && $this->menu['show'] == 1) {
             $this->checkMenu($this->menu['id'], false);
         }
         $this->config = $this->db->config['manage'][$key] ?? array();
@@ -310,7 +310,7 @@ class Page extends Auth
         if (empty($value['name']) && isset($this->db->config['struct'][$value['key']])) {
             $value['name'] = $this->db->config['struct'][$value['key']]['name'];
         }
-        if (empty($value['placeholder'])) {
+        if (empty($value['placeholder']) && isset($value['name'])) {
             $value['placeholder'] = $value['name'];
         }
     }
@@ -328,7 +328,7 @@ class Page extends Auth
         }
         if (isset($value['upload']) && Dever::project('upload')) {
             $value['url'] = Dever::url('upload/save.act', array('id' => $value['upload']));
-            $value['config'] = Dever::load('upload/save')->get($value['upload']);
+            $value['config'] = Dever::load('save', 'upload')->get($value['upload']);
             if (isset($value['multiple']) && $value['multiple']) {
                 $value['limit'] = 10;
             } else {

+ 17 - 10
lib/Role.php

@@ -7,7 +7,7 @@ class Role extends Auth
         if ($data['auth']) {
             $auth = explode(',', $data['auth']);
             $data['auth'] = array();
-            $system = $menu = $func = array();
+            $module = $menu = $func = array();
             foreach ($auth as $k => $v) {
                 if (!strstr($v, '-')) {
                     if (strstr($v, 'v')) {
@@ -23,14 +23,14 @@ class Role extends Auth
                 foreach ($funcData as $k => $v) {
                     $menu[] = $v['menu_id'];
                 }
-                $menuData = Dever::db('menu', 'manage')->select(array('id' => array('in', $menu)), array('group' => 'system_id'));
+                $menuData = Dever::db('menu', 'manage')->select(array('id' => array('in', $menu)), array('group' => 'module_id'));
                 foreach ($menuData as $k => $v) {
-                    $system[] = $v['system_id'];
+                    $module[] = $v['module_id'];
                 }
             }
             $data['auth'] = implode(',', $data['auth']);
             $data['menu'] = implode(',', $menu);
-            $data['system'] = implode(',', $system);
+            $data['module'] = implode(',', $module);
         }
         return $data;
     }
@@ -39,17 +39,19 @@ class Role extends Auth
     {
         $result = array();
         $extend = Dever::load('common', 'manage')->extend();
-        $where = array();
         if ($extend && $extend['system_id']) {
-            $where['id'] = $extend['system_id'];
+            $system_id = $extend['system_id'];
         } else {
-            $where['id'] = 1;
+            $system_id = 1;
         }
-        $system = Dever::db('system', 'manage')->select($where);
-        foreach ($system as $k => $v) {
+        $info = Dever::db('system', 'manage')->find($system_id);
+        $where = array();
+        $where['system'] = $info['key'];
+        $module = Dever::db('system_module', 'manage')->select($where);
+        foreach ($module as $k => $v) {
             $result[$k]['value'] = 's-' . $v['id'];
             $result[$k]['label'] = $v['name'];
-            $result[$k]['children'] = Dever::db('menu', 'manage')->tree(array('system_id' => $v['id'], 'show' => array('<', '3')), array('parent_id', '0', 'id'), array($this, 'getAuthInfo'), array('col' => 'id,name as label,parent_id,`key`,func'));
+            $result[$k]['children'] = Dever::db('menu', 'manage')->tree(array('module_id' => $v['id'], 'show' => array('<', '3')), array('parent_id', '0', 'id'), array($this, 'getAuthInfo'), array('col' => 'id,name as label,parent_id,`key`,func'));
         }
         return $result;
     }
@@ -71,6 +73,11 @@ class Role extends Auth
     {
         return Dever::db('system', 'manage')->show(array('id' => array('in', $data)));
     }
+    # 展示系统模块
+    public function showModule($data)
+    {
+        return Dever::db('system_module', 'manage')->show(array('id' => array('in', $data)));
+    }
     # 展示菜单
     public function showMenu($data)
     {

+ 3 - 3
table/admin.php

@@ -32,13 +32,13 @@ return array
             'value'    => 'role',
             /*
             'value'    => 'manage/role',//跟role一样,但可以调取别的app的方法
-            'value'    => 'Dever::load("manage/role.get")',//调用某个类的方法
+            'value'    => 'Dever::call("manage/role.get")',//调用某个类的方法
             'value'    => array(1 => 'a', 2 => 'b'),//直接设置可选项
             */
         ),
-        'system_relation' => array
+        'module_data' => array
         (
-            'name'      => '关联子系统',
+            'name'      => '系统模块',
             'type'      => 'varchar(2000)',
         ),
         'avatar' => array

+ 1 - 1
table/cron.php

@@ -14,7 +14,7 @@ return array
         (
             'type'      => 'varchar(30)',
             'name'      => '项目',
-            'value'     => 'Dever::load("manage/common.project")',
+            'value'     => 'Dever::call("manage/common.project")',
         ),
         
         'interface'     => array

+ 1 - 4
table/group_org.php

@@ -2,10 +2,7 @@
 return array
 (
     'name' => '集团组织',
-    'partition' => array
-    (
-        'database' => 'Dever::call("manage/common.system")',
-    ),
+    'partition' => 'Dever::call("manage/common.system")',
     'order' => 'sort asc',
     'struct' => array
     (

+ 1 - 4
table/group_org_job.php

@@ -2,10 +2,7 @@
 return array
 (
     'name' => '组织职位',
-    'partition' => array
-    (
-        'database' => 'Dever::call("manage/common.system")',
-    ),
+    'partition' => 'Dever::call("manage/common.system")',
     'order' => 'sort asc',
     'struct' => array
     (

+ 6 - 9
table/group_role.php

@@ -2,10 +2,7 @@
 return array
 (
     'name' => '集团角色',
-    'partition' => array
-    (
-        'database' => 'Dever::call("manage/common.system")',
-    ),
+    'partition' => 'Dever::call("manage/common.system")',
     'struct' => array
     (
         'name' => array
@@ -13,21 +10,21 @@ return array
             'name'      => '名称',
             'type'      => 'varchar(32)',
         ),
-        'system' => array
+        'module' => array
         (
-            'name'      => '系统',
-            'type'      => 'varchar(1000)',
+            'name'      => '系统模块',
+            'type'      => 'varchar(2000)',
         ),
         'menu' => array
         (
             'name'      => '菜单',
-            'type'      => 'varchar(2000)',
+            'type'      => 'text',
         ),
         'auth' => array
         (
             'name'      => '权限',
             'type'      => 'text',
-            'value'    => 'Dever::load("role.getAuthData")',
+            'value'    => 'Dever::call("role.getAuthData")',
         ),
     ),
     'default' => array

+ 3 - 6
table/group_user.php

@@ -3,10 +3,7 @@ return array
 (
     'name' => '集团账户',
     # 定义数据分离
-    'partition' => array
-    (
-        'database' => 'Dever::call("manage/common.system")',
-    ),
+    'partition' => 'Dever::call("manage/common.system")',
     'struct' => array
     (
         'name' => array
@@ -35,9 +32,9 @@ return array
             'type'      => 'varchar(100)',
             'value'    => 'group_role',
         ),
-        'system_relation' => array
+        'module_data' => array
         (
-            'name'      => '关联子系统',
+            'name'      => '模块数据',
             'type'      => 'varchar(2000)',
         ),
         'avatar' => array

+ 4 - 4
table/manage/admin.php

@@ -156,7 +156,7 @@ return array
             //'链接跳转' => array('link', 'https://www.baidu.com/'),
             # 第三个参数可以自定义图标:https://element-plus.org/zh-CN/component/icon.html#icon-collection
             //'路由跳转' => array('route', 'manage/menu?test=1', 'ChatLineSquare'),
-            //'管理账户列表' => array('route', array('path' => 'set_group/group_user', 'param' => array('set' => array('system_id' => 2, 'relation_id' => 'id')))),
+            //'管理账户列表' => array('route', array('path' => 'set_group/group_user', 'param' => array('set' => array('module_id' => 2, 'relation_id' => 'id')))),
         ),
         # 列表页导入
         'import' => array
@@ -445,12 +445,12 @@ return array
                 # 是否开启控制功能,需要配置control
                 //'control' => true,
                 # 开启远程获取数据功能,这里设置接口即可,访问到api下
-                'remote' => 'manage/admin.getSystem',
+                'remote' => 'manage/admin.getModuleData',
             ),
-            'system_relation' => array
+            'module_data' => array
             (
                 'type' => 'tree',
-                //'value'    => 'Dever::load("role.getSystemData")',
+                'desc' => '',
             ),
             # 定义另外一个表或者方法里的字段,带有"."就是方法,调用manage/role里的upload配置,这里也可以自行配置
             //'manage/role' => 'upload',

+ 26 - 11
table/manage/core.php

@@ -11,14 +11,29 @@ return array
         (
             'name' => '测试系统',
             'sort' => '-100',
-            # 这个是系统的数据隔离类型,database是分库隔离,table是分表隔离,field是分区隔离,where是字段隔离
-            'partition' => 'database',
-            # 关联表名
-            'relation_table' => 'manage/platform',
-            # 关联字段名
-            'relation_field' => 'platform_id',
-            # 关联用户表表名
-            'relation_user_table' => 'manage/admin',
+            # 这个是系统的数据隔离类型,no无需隔离,database是分库隔离,table是分表隔离,field是分区隔离,where是字段隔离
+            'partition' => 'no',
+            # 基本信息表名
+            'info_table' => 'manage/platform',
+            # 用户表名
+            'user_table' => 'manage/admin',
+            # 角色表名
+            'role_table' => 'manage/role',
+        ),
+    ),*/
+
+    # 系统模块定义 默认将建立platform和group模块
+    /*
+    'module' => array
+    (
+        'main' => array
+        (
+            # 系统key
+            'system' => 'platform',
+            'name' => '测试系统',
+            'sort' => '-100',
+            # 模块下数据表名
+            'data_table' => 'manage/platform',
         ),
     ),*/
 
@@ -34,8 +49,8 @@ return array
             'icon' => 'settings-line',
             # 菜单排序 正序
             'sort' => '100',
-            # 所属系统 系统key,一般只需主菜单填写system
-            'system' => 'platform',
+            # 所属系统模块 模块key,一般只需主菜单填写module
+            'module' => 'platform',
         ),
         # 定义二级菜单
         'platform' => array
@@ -133,7 +148,7 @@ return array
             'name' => '配置',
             'icon' => 'settings-line',
             'sort' => '100',
-            'system' => 'group',
+            'module' => 'group',
         ),
 
         'group' => array

+ 9 - 14
table/manage/menu.php

@@ -1,15 +1,15 @@
 <?php
-$system = Dever::input('search')['system_id'] ?? 1;
+$module = Dever::input('search')['module_id'] ?? 1;
 return array
 (
     'list' => array
     (
-        'where' => array('system_id' => $system, 'show' => array('<', '3')),
+        'where' => array('module_id' => $module, 'show' => array('<', '3')),
         # 展示左侧分栏
         'column' => array
         (
             # 分栏数据来源
-            'load' => 'manage/system',
+            'load' => 'manage/system_module',
             # 分栏新增按钮
             //'add' => '新增',
             # 分栏编辑按钮,这里直接用图标
@@ -20,11 +20,11 @@ return array
             # 关键字段,一般为id或者key
             'key' => 'id',
             # 获取数据
-            'data' => 'system.getTree',
+            'data' => 'module.getTree',
             # 默认展开
             'active' => 1,
             # 对应的where条件的key
-            'where' => 'system_id',
+            'where' => 'module_id',
         ),
         # 展示的字段
         'field'      => array
@@ -34,11 +34,6 @@ return array
                 'width' => '400',
             ),
             'key',
-            /*
-            'system_id' => array
-            (
-                'show' => 'Dever::db("system", "manage")->find(array("key" => "{system_id}"))["name"] ?? ""',
-            ),*/
             //'path',
             'icon' => 'icon',
             'sort' => 'input',
@@ -58,19 +53,19 @@ return array
 
         'search'    => array
         (
-            'system_id' => 'hidden',
+            'module_id' => 'hidden',
             'name',
         ),
 
         'button' => array
         (
-            '新增主菜单' => array('fastadd', array('parent_id' => '0', 'system_id' => $system, 'path' => '')),
+            '新增主菜单' => array('fastadd', array('parent_id' => '0', 'module_id' => $module, 'path' => '')),
         ),
 
         'data_button' => array
         (
             '编辑' => array('fastedit', 'name,key,icon,path,link,sort,show'),
-            '新增子菜单' => array('fastadd', array('parent_id' => 'id', 'system_id' => $system)),
+            '新增子菜单' => array('fastadd', array('parent_id' => 'id', 'module_id' => $module)),
             //'删除' => 'recycle',
         ),
 
@@ -82,7 +77,7 @@ return array
             'name',
             'key',
             'parent_id',
-            'system_id',
+            'module_id',
             'path' => array
             (
                 'type' => 'select',

+ 2 - 2
table/manage/role.php

@@ -7,9 +7,9 @@ return array
         (
             'id',
             'name',
-            'system' => array
+            'module' => array
             (
-                'show' => 'Dever::load("role")->showSystem("{system}")',
+                'show' => 'Dever::load("role")->showModule("{module}")',
             ),
             'menu' => array
             (

+ 21 - 0
table/manage/system_module.php

@@ -0,0 +1,21 @@
+<?php
+return array
+(
+    'list' => array
+    (
+        'field'      => array
+        (
+            'name',
+            'sort',
+        ),
+    ),
+    'update' => array
+    (
+        'field'    => array
+        (
+            'name',
+            'sort',
+        ),
+        'check' => 'key',
+    ),
+);

+ 2 - 2
table/menu.php

@@ -27,9 +27,9 @@ return array
             'type'      => 'int(11)',
             'default'   => '0',
         ),
-        'system_id' => array
+        'module_id' => array
         (
-            'name'      => '系统',
+            'name'      => '系统模块',
             'type'      => 'varchar(80)',
         ),
         'path' => array

+ 0 - 23
table/mobile_system.php

@@ -1,23 +0,0 @@
-<?php
-return array
-(
-    'name' => '当前用户选择的系统',
-    'struct' => array
-    (
-        'mobile' => array
-        (
-            'name'      => '手机号',
-            'type'      => 'varchar(11)',
-        ),
-        'system_id' => array
-        (
-            'name'      => '系统id',
-            'type'      => 'int(11)',
-        ),
-        'relation_id' => array
-        (
-            'name'      => '系统关联表id',
-            'type'      => 'int(11)',
-        ),
-    ),
-);

+ 6 - 6
table/role.php

@@ -9,26 +9,26 @@ return array
             'name'      => '名称',
             'type'      => 'varchar(32)',
         ),
-        'system' => array
+        'module' => array
         (
-            'name'      => '系统',
-            'type'      => 'varchar(1000)',
+            'name'      => '系统模块',
+            'type'      => 'varchar(2000)',
         ),
         'menu' => array
         (
             'name'      => '菜单',
-            'type'      => 'varchar(2000)',
+            'type'      => 'text',
         ),
         'auth' => array
         (
             'name'      => '权限',
             'type'      => 'text',
-            'value'    => 'Dever::load("role.getAuthData")',
+            'value'    => 'Dever::call("role.getAuthData")',
         ),
     ),
     'default' => array
     (
-        'field' => 'name,system,cdate',
+        'field' => 'name,module,cdate',
         'value' => array
         (
             '"默认角色",1,' . DEVER_TIME,

+ 10 - 15
table/system.php

@@ -19,7 +19,7 @@ return array
         (
             'name'      => '数据隔离类型',
             'type'      => 'varchar(20)',
-            'default'   => 'database',
+            'default'   => 'no',
             'value'     => array
             (
                 'no'    => '不做数据隔离',
@@ -29,24 +29,19 @@ return array
                 'where' => '分条件隔离',
             ),
         ),
-        'relation_table' => array
+        'info_table' => array
         (
-            'name'      => '关联表表名',
+            'name'      => '基本信息表名',
             'type'      => 'varchar(200)',
         ),
-        'relation_field' => array
+        'user_table' => array
         (
-            'name'      => '关联表字段名',
+            'name'      => '用户表表名',
             'type'      => 'varchar(200)',
         ),
-        'relation_user_table' => array
+        'role_table' => array
         (
-            'name'      => '关联用户表表名',
-            'type'      => 'varchar(200)',
-        ),
-        'relation_role_table' => array
-        (
-            'name'      => '关联角色表表名',
+            'name'      => '角色表表名',
             'type'      => 'varchar(200)',
         ),
         'sort' => array
@@ -58,11 +53,11 @@ return array
 
     'default' => array
     (
-        'field' => 'id,name,`key`,`partition`,relation_table,relation_field,relation_user_table,relation_role_table,sort',
+        'field' => 'id,name,`key`,`partition`,info_table,user_table,role_table,sort',
         'value' => array
         (
-            '1,"平台","platform","database","manage/platform","platform_id","manage/admin","manage/role",-1000',
-            '2,"集团","group","database","manage/group","group_id","manage/group_user","manage/group_role",-900',
+            '1,"平台系统","platform","no","manage/platform","manage/admin","manage/role",-1000',
+            '2,"集团系统","group","database","manage/group","manage/group_user","manage/group_role",-900',
         ),
         'num' => 1,
     ),

+ 45 - 0
table/system_module.php

@@ -0,0 +1,45 @@
+<?php
+return array
+(
+    'name' => '系统模块',
+    'order' => 'sort asc',
+    'struct' => array
+    (
+        'name' => array
+        (
+            'name'      => '模块名称',
+            'type'      => 'varchar(32)',
+        ),
+        'key' => array
+        (
+            'name'      => '模块标识',
+            'type'      => 'varchar(60)',
+        ),
+        'system' => array
+        (
+            'name'      => '系统标识',
+            'type'      => 'varchar(200)',
+        ),
+        'data_table' => array
+        (
+            'name'      => '模块下数据表名',
+            'type'      => 'varchar(200)',
+        ),
+        'sort' => array
+        (
+            'name'      => '排序',
+            'type'      => 'int(11)',
+        ),
+    ),
+
+    'default' => array
+    (
+        'field' => 'id,name,`key`,system,data_table,sort',
+        'value' => array
+        (
+            '1,"平台","platform","platform","manage/platform",-1000',
+            '2,"集团","group","group","manage/group",-900',
+        ),
+        'num' => 1,
+    ),
+);

+ 33 - 0
table/system_user.php

@@ -0,0 +1,33 @@
+<?php
+return array
+(
+    'name' => '账户模块记录表',
+    'struct' => array
+    (
+        'uid' => array
+        (
+            'name'      => '账户id',
+            'type'      => 'int(11)',
+        ),
+        'system_id' => array
+        (
+            'name'      => '系统id',
+            'type'      => 'int(11)',
+        ),
+        'info_id' => array
+        (
+            'name'      => '系统信息表id',
+            'type'      => 'int(11)',
+        ),
+        'module_id' => array
+        (
+            'name'      => '模块id',
+            'type'      => 'int(11)',
+        ),
+        'data_id' => array
+        (
+            'name'      => '模块数据id',
+            'type'      => 'int(11)',
+        ),
+    ),
+);