rabin 1 tahun lalu
induk
melakukan
3494bf24d7
13 mengubah file dengan 84 tambahan dan 38 penghapusan
  1. 3 3
      api/Admin.php
  2. 1 1
      api/Icon.php
  3. 5 5
      api/Login.php
  4. 8 4
      api/Menu.php
  5. 21 4
      api/Page/Data.php
  6. 13 3
      lib/Common.php
  7. 1 1
      lib/Config.php
  8. 1 1
      lib/Group.php
  9. 5 5
      lib/Menu.php
  10. 8 1
      lib/Page.php
  11. 16 9
      lib/Role.php
  12. 1 1
      lib/System.php
  13. 1 0
      table/system.php

+ 3 - 3
api/Admin.php

@@ -20,7 +20,7 @@ class Admin extends Auth
             $where['id'] = array('in', $this->user['auth']['system']);
         }
         $result = array();
-        $system = Dever::db('system')->select($where);
+        $system = Dever::db('system', 'manage')->select($where);
         $i = 0;
         foreach ($system as $k => $v) {
             $child = Dever::db($v['relation_table'])->select([]);
@@ -62,12 +62,12 @@ class Admin extends Auth
             return $result;
         }
         $result = array();
-        $role = Dever::db('role')->select(array('id' => array('in', $value)));
+        $role = Dever::db('role', 'manage')->select(array('id' => array('in', $value)));
         if ($role) {
             $info = $system = array();
             foreach ($role as $k => $v) {
                 if ($v['system']) {
-                    $child = Dever::db('system')->select(array('id' => array('in', $v['system'])));
+                    $child = Dever::db('system', 'manage')->select(array('id' => array('in', $v['system'])));
                     if ($child) {
                         foreach ($child as $k1 => $v1) {
                             if (isset($info[$v1['id']])) {

+ 1 - 1
api/Icon.php

@@ -11,7 +11,7 @@ class Icon extends Auth
         if ($key) {
             $where['key'] = array('like', $key);
         }
-        $data['list'] = Dever::db('icon')->select($where, $set);
+        $data['list'] = Dever::db('icon', 'manage')->select($where, $set);
         $data['total'] = Dever::page('total');
         return $data;
     }

+ 5 - 5
api/Login.php

@@ -8,7 +8,7 @@ class Login
     public function getSystem()
     {
         $system = Dever::input('system', 'is_string', '系统', 'platform');
-        $system = Dever::db('system')->find(array('key' => $system));
+        $system = Dever::db('system', 'manage')->find(array('key' => $system));
         if (!$system) {
             Dever::error('当前系统不存在');
         }
@@ -21,7 +21,7 @@ class Login
     {
         //$this->checkCode();
         $system = Dever::input('system', 'is_string', '系统', 'platform');
-        $system = Dever::db('system')->find(array('key' => $system));
+        $system = Dever::db('system', 'manage')->find(array('key' => $system));
         if (!$system) {
             Dever::error('登录失败,当前系统不存在');
         }
@@ -30,11 +30,11 @@ class Login
         if (!$info) {
             Dever::error('登录失败,当前系统设置错误');
         }
-        if ($system['id'] == 1 && $info['id'] == 1) {
-            # 如果是平台,暂时分库
+        if ($system['partition'] == 'no') {
+            # 不分库
             $db = Dever::db($system['relation_user_table']);
         } else {
-            # 其他系统做分库
+            # 分库
             $db = Dever::db($system['relation_user_table'], '', 'default', array($system['partition'] => $info['id']));
         }
         $where['mobile'] = Dever::input('mobile', Dever::rule('mobile'), '手机号');

+ 8 - 4
api/Menu.php

@@ -7,7 +7,7 @@ class Menu extends Auth
     {
         # 如果后续增加Root,就要这里置为false
         $this->top = true;
-        $top = Dever::db('menu')->select(array('parent_id' => '0', 'system_id' => $this->user['select']['system_id']));
+        $top = Dever::db('menu', 'manage')->select(array('parent_id' => '0', 'system_id' => $this->user['select']['system_id']));
         $result = $menu = array();
         $result[] = array
         (
@@ -36,13 +36,14 @@ class Menu extends Auth
                 ),
             )
         );
+        $this->opened = array();
         foreach ($top as $v) {
-            $v = $this->getMenu($v);
+            $v = $this->getMenu($v, '');
             if ($v) {
                 $result[] = $v;
             }
         }
-        return array('list' => $result);
+        return array('list' => $result, 'opened' => $this->opened);
     }
     private function getMenu($v, $parent = '')
     {
@@ -75,12 +76,15 @@ class Menu extends Auth
             $info['component'] = 'Layout';
         }
         $where = array('parent_id' => $v['id'], 'system_id' => $this->user['select']['system_id']);
-        $child = Dever::db('menu')->select($where);
+        $child = Dever::db('menu', 'manage')->select($where);
         if ($child) {
             foreach ($child as $v1) {
                 if (($v1['level'] == 3 || $v1['show'] != 1) && $this->checkMenu($v1['id'])) {
                     continue;
                 }
+                if (!$parent) {
+                    $this->opened[] = '/' . $v['key'] . '/' . $v1['key'];
+                }
                 $children = $this->getMenu($v1, $v['key']);
                 if ($children) {
                     $info['children'][] = $children;

+ 21 - 4
api/Page/Data.php

@@ -18,7 +18,6 @@ class Data extends Page
         }
         $data['title'] = '';
         $data['button'] = $this->button();
-        $data['bodyButton'] = $this->button('data_button');
         $data['recycler'] = $this->recycler;
         $data = array_merge($data, $this->out());
         $data['total'] = Dever::page('total');
@@ -80,14 +79,18 @@ class Data extends Page
         $result = array();
         if ($data) {
             foreach ($data as $k => $v) {
-                $result[$k] = $this->handleData($v);
+                $result[$k] = $this->handleData($k, $v);
             }
         }
         return $result;
     }
 
-    public function handleData($v)
+    public function handleData($k, $v)
     {
+        $button = $this->button('data_button', $v);
+        if ($button) {
+            $result['button'] = $button;
+        }
         # 是否保留html代码,1是保留,2是不保留
         $html = Dever::input('html', '', '', 1);
         if (isset($v['id'])) {
@@ -208,7 +211,7 @@ class Data extends Page
         }
     }
 
-    private function button($key = 'button')
+    private function button($key = 'button', $data = array())
     {
         $result = array();
         if (!isset($this->config[$key])) {
@@ -230,9 +233,23 @@ class Data extends Page
         }
         $sort = 1;
         foreach ($this->config[$key] as $k => $v) {
+            $d = '';
             $p = '';
             $i = '';
             if (is_array($v)) {
+                if (isset($v[3]) && $data) {
+                    $d = $v[3];
+                    parse_str($d, $t);
+                    $state = true;
+                    foreach ($t as $k1 => $v1) {
+                        if (!isset($data[$k1]) || (isset($data[$k1]) && $data[$k1] != $v1)) {
+                            $state = false;
+                        }
+                    }
+                    if (!$state) {
+                        continue;
+                    }
+                }
                 if (isset($v[2])) {
                     $i = $v[2];
                 }

+ 13 - 3
lib/Common.php

@@ -18,8 +18,8 @@ class Common
         return false;
     }
 
-    # 获取当前使用的系统
-    public function system($key = '')
+    # 获取当前的扩展数据
+    public function extend()
     {
         $info = $this->auth();
         if (!$info) {
@@ -29,7 +29,17 @@ class Common
             }
             $info = Secure::checkLogin($auth);
         }
-        if ($info && isset($info['extend']) && isset($info['extend']['relation_id'])) {
+        if ($info && isset($info['extend'])) {
+            return $info['extend'];
+        }
+        return false;
+    }
+
+    # 获取当前使用的系统 一般为数据库隔离使用
+    public function system($key = '')
+    {
+        $info = $this->extend();
+        if ($info && isset($info['extend']['relation_id'])) {
             # 这里后续增加从数据库中获取
             $value = $info['extend']['system_id'] . '_' . $info['extend']['relation_id'];
             if ($key) {

+ 1 - 1
lib/Config.php

@@ -5,7 +5,7 @@ class Config extends Auth
 {
     public function getTree()
     {
-        $data = Dever::db('config')->select([]);
+        $data = Dever::db('config', 'manage')->select([]);
         $result = array();
         $result[] = array
         (

+ 1 - 1
lib/Group.php

@@ -5,7 +5,7 @@ class Group extends Auth
 {
     public function getTree()
     {
-        $data = Dever::db('group')->select([]);
+        $data = Dever::db('group', 'manage')->select([]);
         $result = array();
         $result[] = array
         (

+ 5 - 5
lib/Menu.php

@@ -35,7 +35,7 @@ class Menu
                 $data['relation_table'] = $v['relation_table'];
                 $data['relation_field'] = $v['relation_field'];
                 $data['relation_user_table'] = $v['relation_user_table'];
-                Dever::db('system')->up($where, $data);
+                Dever::db('system', 'manage')->up($where, $data);
             }
         }
         if (isset($core['menu'])) {
@@ -47,7 +47,7 @@ class Menu
                 $where['app'] = $app;
                 $where['key'] = $k;
                 if (isset($v['parent'])) {
-                    $parent = Dever::db('menu')->find(array('key' => $v['parent']));
+                    $parent = Dever::db('menu', 'manage')->find(array('key' => $v['parent']));
                     if ($parent) {
                         $where['parent_id'] = $parent['id'];
                         $where['system_id'] = $parent['system_id'];
@@ -60,7 +60,7 @@ class Menu
                     $where['level'] = 1;
                 }
                 if (isset($v['system'])) {
-                    $system = Dever::db('system')->find(array('key' => $v['system']));
+                    $system = Dever::db('system', 'manage')->find(array('key' => $v['system']));
                     if ($system) {
                         $where['system_id'] = $system['id'];
                     }
@@ -83,13 +83,13 @@ class Menu
                 if (isset($v['link'])) {
                     $data['link'] = $v['link'];
                 }
-                Dever::db('menu')->up($where, $data);
+                Dever::db('menu', 'manage')->up($where, $data);
             }
         }
     }
     public function getAll()
     {
-        $data = Dever::db('menu')->select(array('parent_id' => '0'));
+        $data = Dever::db('menu', 'manage')->select(array('parent_id' => '0'));
         return $data;
     }
 }

+ 8 - 1
lib/Page.php

@@ -211,7 +211,14 @@ class Page extends Auth
             }
             if ($field) {
                 if (is_array($field)) {
-                    if (isset($field['field']) && !Dever::check($field['field'], $k)) {
+                    if (isset($field['param'])) {
+                        if (isset($field['param']['set'])) {
+                            $field = array_merge($field, $field['param']['set']);
+                        }
+                        if (isset($field['param']['search'])) {
+                            $field = array_merge($field, $field['param']['search']);
+                        }
+                    } elseif (isset($field['field']) && !Dever::check($field['field'], $k)) {
                         continue;
                     }
                     if (isset($field[$k])) {

+ 16 - 9
lib/Role.php

@@ -19,11 +19,11 @@ class Role extends Auth
                 }
             }
             if ($func) {
-                $funcData = Dever::db('menu_func')->select(array('id' => array('in', $func)), array('group' => 'menu_id'));
+                $funcData = Dever::db('menu_func', 'manage')->select(array('id' => array('in', $func)), array('group' => 'menu_id'));
                 foreach ($funcData as $k => $v) {
                     $menu[] = $v['menu_id'];
                 }
-                $menuData = Dever::db('menu')->select(array('id' => array('in', $menu)), array('group' => 'system_id'));
+                $menuData = Dever::db('menu', 'manage')->select(array('id' => array('in', $menu)), array('group' => 'system_id'));
                 foreach ($menuData as $k => $v) {
                     $system[] = $v['system_id'];
                 }
@@ -38,19 +38,26 @@ class Role extends Auth
     public function getAuthData()
     {
         $result = array();
-        $system = Dever::db('system')->select([]);
+        $extend = Dever::load('common', 'manage')->extend();
+        $where = array();
+        if ($extend && $extend['system_id']) {
+            $where['id'] = $extend['system_id'];
+        } else {
+            $where['id'] = 1;
+        }
+        $system = Dever::db('system', 'manage')->select($where);
         foreach ($system as $k => $v) {
             $result[$k]['value'] = 's-' . $v['id'];
             $result[$k]['label'] = $v['name'];
-            $result[$k]['children'] = Dever::db('menu')->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('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'));
         }
         return $result;
     }
-    public function getAuthInfo($info)
+    public function getAuthInfo($k, $info)
     {
         if ($info['func'] == 1) {
             $info['value'] = 'm-' . $info['id'];
-            $info['children'] = Dever::db('menu_func')->select(array('menu_id' => $info['id']), array('col' => 'id as value,name as label'));
+            $info['children'] = Dever::db('menu_func', 'manage')->select(array('menu_id' => $info['id']), array('col' => 'id as value,name as label'));
             if (!$info['children']) {
                 return array();
             }
@@ -62,16 +69,16 @@ class Role extends Auth
     # 展示系统
     public function showSystem($data)
     {
-        return Dever::db('system')->show(array('id' => array('in', $data)));
+        return Dever::db('system', 'manage')->show(array('id' => array('in', $data)));
     }
     # 展示菜单
     public function showMenu($data)
     {
-        return Dever::db('menu')->show(array('id' => array('in', $data)));
+        return Dever::db('menu', 'manage')->show(array('id' => array('in', $data)));
     }
     # 展示权限
     public function showFunc($data)
     {
-        return Dever::db('menu_func')->show(array('id' => array('in', $data)));
+        return Dever::db('menu_func', 'manage')->show(array('id' => array('in', $data)));
     }
 }

+ 1 - 1
lib/System.php

@@ -5,7 +5,7 @@ class System extends Auth
 {
     public function getTree()
     {
-        $data = Dever::db('system')->select([]);
+        $data = Dever::db('system', 'manage')->select([]);
         $result = array();
         $result[] = array
         (

+ 1 - 0
table/system.php

@@ -22,6 +22,7 @@ return array
             'default'   => 'database',
             'value'     => array
             (
+                'no'    => '不做数据隔离',
                 'database' => '分库隔离',
                 'table' => '分表隔离',
                 'field' => '分区隔离',