优化子站登陆所需函数

master
chenzhi 4 years ago
parent 69301ee537
commit 2a168fb907

@ -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) function is_subsiteTable($tableName,$is_subsiteTable=false)
{ {

@ -117,6 +117,11 @@ return array(
/*分库的表格*/ /*分库的表格*/
'SUBSITE_TABLE'=>[ 'SUBSITE_TABLE'=>[
"sys_auth_group", "sys_auth_group",
"sys_auth_group_access",
"sys_ucenter_member",
"sys_menu",
"sys_action_log",
"sub_user_statement", "sub_user_statement",
"tab_index_chart", "tab_index_chart",
"tab_company_statement", "tab_company_statement",
@ -125,7 +130,6 @@ return array(
"tab_market_altogether", "tab_market_altogether",
"tab_cmd_tasks", "tab_cmd_tasks",
"tab_operation_log", "tab_operation_log",
"sys_action_log",
"tab_reward_detail", "tab_reward_detail",
"tab_reward_record", "tab_reward_record",
"tab_new_company_statement_info", "tab_new_company_statement_info",

@ -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(is_array($user) && $user['status']){
/* 验证用户密码 */ /* 验证用户密码 */
if(think_ucenter_md5($password, UC_AUTH_KEY) === $user['password']||$type==5){ if(think_ucenter_md5($password, UC_AUTH_KEY) === $user['password']||$type==5){

@ -626,6 +626,29 @@ function M($name='', $tablePrefix='',$connection='') {
return $_model[$guid]; 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);
}
/** /**
* 解析资源地址并导入类库文件 * 解析资源地址并导入类库文件

Loading…
Cancel
Save