关键词:安卓和IOS共用一套代码
一、IOS共用一套代码(二)
前端找老师那一块共改了三个文件,如下:------备份服务器
1)改了表question_record
增加了个字段(sys)如下:
2) /app/web/api/v1/application/controllers/tutorial—tutorial.php
具体修改如下:
a)创建提问时
if($this->tm->checkQuestion($user['id'])){
$ret= array('err_no'=>1002,'err_msg'=>'您已经有问题正在处理中,请稍后再提问!');
break;
}
//创建新提问
$result = $this->tm->creatQuestion($user['id'],$params['grade_id'],$params['subject_id'],$params['teacher_id'],$params['url'],$availableTime,$params['sys']);
$ret =array('err_no'=>0,'err_msg'=>'success','results'=>array('question_id'=>$result['id']));
}while(0);
$this->output($ret);
}
b)创建课堂时
//创建课堂
$createResult=$this->tm->createClassRoom($params['questionId'],$user['id'],$result['asker_id']);
$roomId = $createResult['id'];
$sys_type = $result['sys']?intval($result['sys']):1;
$imgUrl =$result['question_image_url'];
$invalidTime =$result['available_time'];
$token =curlRequest(TOKEN_URL."/obtainToken");
$token = substr($token,1,strlen($token)-2);
Logger::info($token);
$tTurorUrl = TT_URL.'?roomid='.$roomId.'&token='.$token.'&sys='.$sys_type.'&imgUrl='.$imgUrl;
$sTurorUrl = ST_URL .'?t='.$invalidTime.'&token='.$token.'&sys='.$sys_type.'#'.$roomId;
注:上述代码中,默认设的是Android端。
3) /app/web/api/v1/application/models—----tutorial_model.php
创建新提问时,往表中插字段时,要增加sys字段,如下:
//创建新提问
publicfunctioncreatQuestion($askerId,$gradeId,$subjectId,$questionerId,$quesImgUrl,$availableTime,$sys){
if($questionerId == 0){
$questionerId == null;
}
$data = array(
'asker_id' =>$askerId,
'subject_id' =>$subjectId,
'grade_id' =>$gradeId,
'questioner_id'=>$questionerId,
'question_image_url'=> $quesImgUrl,
'available_time'=>$availableTime,
'create_time' => time(),
'sys' => $sys,
'invalid_time' => time()+ TUTOR_INVALID_TIME
);
Common_log::debug($data);
return$this->insert('question_record',$data);
}
相关截图如下:
2017年1月12日星期四