From 2a168fb907e93f4a92649486a99bb9e0e77fa895 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Fri, 26 Mar 2021 14:51:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=90=E7=AB=99=E7=99=BB?= =?UTF-8?q?=E9=99=86=E6=89=80=E9=9C=80=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/function.php | 15 ------------ Application/Admin/Conf/config.php | 6 ++++- .../User/Model/UcenterMemberModel.class.php | 2 +- ThinkPHP/Common/functions.php | 23 +++++++++++++++++++ 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index 94890ef7a..e1a725236 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -1057,21 +1057,6 @@ function showNumPercent($num) } } -//优化子站点实例化方法 -function SM($name='', $tablePrefix='tab_',$is_subsiteTable=false) -{ - if(empty($name)){ - if(IS_SUBSITE){ - return M($name, $tablePrefix,SUBSITE_DB); - } - }else{ - $tableName = strtolower($tablePrefix.unCamelize($name)); - if(is_subsiteTable($tableName) || $is_subsiteTable){ - return M($name, $tablePrefix,SUBSITE_DB); - } - } - return M($name, $tablePrefix); -} //判断是否有子站点表格 function is_subsiteTable($tableName,$is_subsiteTable=false) { diff --git a/Application/Admin/Conf/config.php b/Application/Admin/Conf/config.php index 30a1267bb..f27decb08 100644 --- a/Application/Admin/Conf/config.php +++ b/Application/Admin/Conf/config.php @@ -117,6 +117,11 @@ return array( /*分库的表格*/ 'SUBSITE_TABLE'=>[ "sys_auth_group", + "sys_auth_group_access", + "sys_ucenter_member", + "sys_menu", + "sys_action_log", + "sub_user_statement", "tab_index_chart", "tab_company_statement", @@ -125,7 +130,6 @@ return array( "tab_market_altogether", "tab_cmd_tasks", "tab_operation_log", - "sys_action_log", "tab_reward_detail", "tab_reward_record", "tab_new_company_statement_info", diff --git a/Application/User/Model/UcenterMemberModel.class.php b/Application/User/Model/UcenterMemberModel.class.php index 1c83af443..d86b98453 100644 --- a/Application/User/Model/UcenterMemberModel.class.php +++ b/Application/User/Model/UcenterMemberModel.class.php @@ -168,7 +168,7 @@ class UcenterMemberModel extends Model{ } /* 获取用户数据 */ - $user = M('UcenterMember','sys_')->where($map)->find(); + $user = SM('UcenterMember','sys_')->where($map)->find(); if(is_array($user) && $user['status']){ /* 验证用户密码 */ if(think_ucenter_md5($password, UC_AUTH_KEY) === $user['password']||$type==5){ diff --git a/ThinkPHP/Common/functions.php b/ThinkPHP/Common/functions.php index 2b1bc4342..af258c2ba 100644 --- a/ThinkPHP/Common/functions.php +++ b/ThinkPHP/Common/functions.php @@ -626,6 +626,29 @@ function M($name='', $tablePrefix='',$connection='') { return $_model[$guid]; } +/** + * 实例化模型,判断是否是子站,如果是,自动接入子站 + * + * @param string $name Model名称 支持指定基础模型 例如 MongoModel:User + * @param string $tablePrefix 表前缀 + * @param boolean $is_subsiteTable 是否强制使用子站 + * @return Think\Model + */ +function SM($name='', $tablePrefix='tab_',$is_subsiteTable=false) +{ + if(empty($name)){ + if(IS_SUBSITE){ + return M($name, $tablePrefix,SUBSITE_DB); + } + }else{ + $tableName = strtolower($tablePrefix.unCamelize($name)); + if(is_subsiteTable($tableName) || $is_subsiteTable){ + return M($name, $tablePrefix,SUBSITE_DB); + } + } + return M($name, $tablePrefix); +} + /** * 解析资源地址并导入类库文件