ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# MVC结构 ## Controller层 D:\wamp\www\xue.test\xuetang\protected\modules\personal\controllers\UserController.php ``` /* * 增加推荐老师 * author huanghq 08/09/2018 */ public function actionAddRecommend(){ $recommendPhone = Yii::app()->request->getParam('recommendPhone'); $status = UserService::factory()->logRecommendPhone($recommendPhone,Yii::app()->user->id); switch ($status){ case '-1': $this->returnResponse(array('status'=>'-1','msg'=>"手机号码不能为空")); break; case '-2': $this->returnResponse(array('status'=>'-2','msg'=>"手机号码格式不正确")); break; case '-3': $this->returnResponse(array('status'=>'-3','msg'=>"找不到该老师账号")); case '-4': $this->returnResponse(array('status'=>'-4','msg'=>"只能关联老师")); break; default: $nickName = V2UserService::factory()->getShowName($status,'ketang'); $msg = "已关联{$nickName}老师(手机号:{$recommendPhone})"; $this->returnResponse(array('status'=>'0','msg'=>$msg)); } } ``` ### 返回JSON格式 D:\wamp\www\xue.test\xuetang\protected\components\ResponseUtils.php ResponseUtils::json(array('data'=>$list)); ### 返回视图 $this->render('index', []); ## Service层 D:\wamp\www\xue.test\xuetang\protected\service\UserService.php D:\wamp\www\xue.test\xuetang\protected\service\XTUserService.php ## Model层 D:\wamp\www\xue.test\xuetang\protected\models\weike\wkeRecommend.php