/*
?*?author:Jiang
?*?快速添加用戶-后臺(tái)-控制器
?*?UserInfoController.class.php中???
?*?2016-06-07
?*/
public?function?addUserInfoQuick(){
????if(IS_POST){
????????$url?=?'/index.php?m=Admin&c=UserInfo&a=userInfoManage';
????????//控制器主要完成取數(shù)據(jù),調(diào)用biz方法,轉(zhuǎn)發(fā)到下一個(gè)頁面。單元測(cè)試的話,可以使用service接口
????????$d_userInfo?=?array();
????????$d_userInfo['username']?=?I('param.username','','trim,strip_tags');//姓名
????????$d_userInfo['pwd']?=?I('param.pwd','','trim,strip_tags');
????????$d_userInfo['re_pwd']?=?I('param.re_pwd','','trim,strip_tags');
????????$d_userInfo['email']?=?I('param.email','','trim,strip_tags');//郵箱
????????$m_userInfo_service?=?D('Home/UserInfo','Service');
????????$result?=?$m_userInfo_service->addUserInfoQuickService($d_userInfo);//調(diào)用BLL
????????if($result){
????????????json_error_tip(0,'快速添加會(huì)員成功',$url);
????????}else{
????????????json_error_tip(1,'快速添加會(huì)員失敗',$url);
????????}
????}else{
????????$m_config?=?D('Home/Config');
????????$link_expire_list?=?$m_config->getLinkExpires();//鏈接是否有效配置
????????$is_actived_list?=?$m_config->getActiveds();//賬號(hào)是否激活配置
????????$status_list?=?$m_config->getStatus();//賬號(hào)狀態(tài)配置
????????//數(shù)據(jù)
????????$data?=?array();
????????//配置
????????$config_arr?=?array();
????????$config_arr['link_expire_list']?=?$link_expire_list;
????????$config_arr['is_actived_list']?=?$is_actived_list;
????????$config_arr['status_list']?=?$status_list;
????????$data['config_list']?=?$config_arr;
????????//綁定
????????$this->assign('data',$data);
????????$this->display('user_info_add');
????}
}
/**
?*?添加用戶-服務(wù)層
?*?@author?Jiang
?*?@access?public
?*?@param?array?$options?表單數(shù)據(jù)(賬號(hào),密碼,確認(rèn)密碼,驗(yàn)證碼)
?*?@return?mixed
?*?UserInfoService.class.php中
?*?@date?2016-06-07
?*/
public?function?addUserInfoService($options=array()){
????//必填過濾
????if($options['username']?==?''){
????????json_error_tip(1,'請(qǐng)?zhí)顚懹脩裘?);
????}
????if($options['pwd']?==?''){
????????json_error_tip(1,'請(qǐng)?zhí)顚懨艽a');
????}
????if($options['re_pwd']?==?''){
????????json_error_tip(1,'請(qǐng)?zhí)顚懘_認(rèn)密碼');
????}
????if($options['vcode']?==?''){
????????json_error_tip(1,'請(qǐng)?zhí)顚戲?yàn)證碼');
????}
????//格式驗(yàn)證過濾
????if(check_accout($options['username'])?===?false){
????????json_error_tip(1,'用戶名格式不正確');
????}
????if(check_pwd($options['pwd'])?===?false){
????????json_error_tip(1,'密碼格式不正確');
????}
????if(check_pwd($options['repwd'])?===?false){
????????json_error_tip(1,'確認(rèn)密碼格式不正確');
????}
????if($options['pwd']?!=?$options['repwd']){
????????json_error_tip(1,'密碼與確認(rèn)密碼不一致');
????}
????if(check_vcode($options['vcode'],'vcode')?===?false){
????????json_error_tip(1,'驗(yàn)證碼不正確');
????}
????$m_user_info_logic?=?D('Home/UserInfo','Logic');
????$data?=?array();
????$data['username']?=?$options['username'];
????$data['pwd']?=?$options['pwd'];
????return?$m_user_info_logic->addUserInfoLogic($data);
}
/**
?*?快捷添加用戶-邏輯層-后臺(tái)使用
?*?@author?Jiang
?*?@access?public
?*?@param?array?$options?表單數(shù)據(jù)
?*?@return?mixed
?*?UserInfoLogic.class.php中
?*?@date?2016-05-26
?*/
public?function?addUserInfoLogic($options=array()){
???//集中處理核心業(yè)務(wù)邏輯,并返回結(jié)果
???//業(yè)務(wù)邏輯,1用戶名不能重復(fù)
???$m_user_info?=?D('Home/UserInfo');
???$user_info_obj?=?$m_user_info->getUserInfoByUserName($options['username']);
???if(!empty($user_info_obj)){
??????json_error_tip(1,'該賬號(hào)已經(jīng)被使用');
???}
???$options['user_id']?=?get_unique_str($options['username'],'user_');//唯一標(biāo)識(shí)記錄
???$m_userInfo?=?D('Home/UserInfo');
???return?$m_userInfo->addUserInfo($options);//調(diào)用模型添加方法,將數(shù)組作為對(duì)象傳遞給模型層
}
/**
?*?添加用戶-模型層
?*?@param?array?$input?數(shù)據(jù)
?*?UserInfoModel.class.php中
?*?@return?bool|mixed
?*/
public?function?addUserInfo($input=array()){
???if($this->create($input)){
??????$result?=?$this->add();
??????return?$result;
???}else{
??????return?false;
???}
}
1 回答

大寫的王
TA貢獻(xiàn)122條經(jīng)驗(yàn) 獲得超162個(gè)贊
tp? MVC沒有什么嚴(yán)格的區(qū)分,甚至全在控制器中實(shí)現(xiàn)mc的操作都沒什么影響。
- 1 回答
- 0 關(guān)注
- 7537 瀏覽
添加回答
舉報(bào)
0/150
提交
取消