作者 何书鹏
1 个管道 的构建 失败 耗费 6 秒

接口获取资源地址修改

... ... @@ -150,9 +150,9 @@ class Common extends Api
$this->error("上传失败");
}
$qiniu = get_addon_config('qiniu')['cdnurl'];
//$qiniu = get_addon_config('qiniu')['cdnurl'];
$url['yuan'] = '/' . $object;
$url['dai'] = $qiniu.'/' . $object;
$url['dai'] = cdnurl('/' . $object,true);
//上传成功后将存储变更为qiniu
$attachment->storage = 'qiniu';
... ...
... ... @@ -123,7 +123,6 @@ class Exam extends Api
public function question()
{
$user_id = $this->auth->id;
$qiniu = get_addon_config('qiniu')['cdnurl'];
$study_id = $this->request->param('study_id');
if(empty($study_id)){
$this->error('缺少必要参数');
... ... @@ -227,7 +226,7 @@ class Exam extends Api
$v['option'] = json_decode($v['option'],true);
if($v['type'] == 2){
foreach ($v['option'] as &$val){
$val['gender'] = $qiniu.$val['gender'];
$val['gender'] = cdnurl($val['gender'],true);
}
}
}
... ... @@ -252,7 +251,7 @@ class Exam extends Api
$v['option'] = json_decode($v['option'],true);
if($v['type'] == 2){
foreach ($v['option'] as &$val){
$val['gender'] = $qiniu.$val['gender'];
$val['gender'] = cdnurl($val['gender'],true);
}
}
}
... ...
... ... @@ -31,9 +31,8 @@ class Index extends Api
*/
public function index()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('image')->where('id',1)->field('id,image')->find();
$data['image'] = $qiniu.$data['image'];
$data['image'] = cdnurl($data['image'],true);
$this->success('success',$data);
}
... ... @@ -57,14 +56,13 @@ class Index extends Api
*/
public function banner()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('banner')
->field('id,image,title,url')
->order('id desc')
->limit(5)
->select();
foreach ($data as &$v){
$v['image'] = $qiniu.$v['image'];
$v['image'] = cdnurl($v['image'],true);
}
$this->success('success',$data);
}
... ... @@ -87,12 +85,11 @@ class Index extends Api
*/
public function about()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('about')
->where('id',1)
->field('id,image,content')
->find();
$data['image'] = $qiniu.$data['image'];
$data['image'] = cdnurl($data['image'],true);
$this->success('success',$data);
}
... ... @@ -119,13 +116,12 @@ class Index extends Api
*/
public function kefu()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('kefu')
->where('id',1)
->field('createtime',true)
->find();
$data['downloadimage'] = $qiniu.$data['downloadimage'];
$data['image'] = $qiniu.$data['image'];
$data['downloadimage'] = cdnurl($data['downloadimage'],true);
$data['image'] = cdnurl($data['image'],true);
$this->success('success',$data);
}
... ... @@ -156,13 +152,12 @@ class Index extends Api
*/
public function teacher()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('teacher')
->field('updatetime',true)
->order('createtime desc')
->select();
foreach ($data as &$v){
$v['image'] = $qiniu.$v['image'];
$v['image'] = cdnurl($v['image'],true);
$v['age_num'] = $v['age_num'].'年';
$v['order_num'] = $v['order_num'].'单';
$v['createtime'] = datetime('Y-m-d H:i:s',$v['createtime']);
... ... @@ -197,7 +192,6 @@ class Index extends Api
*/
public function teacher_detail()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$teacher_id = $this->request->param('teacher_id');
if(empty($teacher_id)){
$this->error('缺少必要参数');
... ... @@ -205,7 +199,7 @@ class Index extends Api
$data = Db::name('teacher')->field('updatetime',true)->where('id',$teacher_id)->find();
$data['age_num'] = $data['age_num'].'年';
$data['order_num'] = $data['order_num'].'单';
$data['image'] = $qiniu.$data['image'];
$data['image'] = cdnurl($data['image'],true);
$data['createtime'] = date('Y-m-d H:i:s',$data['createtime']);
$this->success('success',$data);
}
... ... @@ -231,13 +225,12 @@ class Index extends Api
*/
public function center()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('center')
->field('updatetime',true)
->order('id desc')
->select();
foreach ($data as &$v){
$v['image'] = $qiniu.$v['image'];
$v['image'] = cdnurl($v['image'],true);
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
$this->success('success',$data);
... ...
... ... @@ -101,7 +101,6 @@ class Lists extends Api
*/
public function sou()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = $this->auth->id;
$page = $this->request->param('page', 1, 'intval');
$pageNum = $this->request->param('pageNum', 10, 'intval');
... ... @@ -146,7 +145,7 @@ class Lists extends Api
$video_avinfo = json_decode(file_get_contents(cdnurl($v['video_file'], true) . '?avinfo'), true); // 获取视频元信息
$duration = ceil($video_avinfo['format']['duration']);
$v['duration'] = gmdate('H:i:s',$duration);
$v['image'] = $qiniu.$v['image'];
$v['image'] = cdnurl($v['image'],true);
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
$this->success('success',$data);
... ... @@ -169,7 +168,7 @@ class Lists extends Api
->order('id desc')
->select();
foreach ($data['info'] as &$v){
$v['video_file'] = $qiniu.$v['video_file'];
$v['video_file'] = cdnurl($v['video_file'],true);
$video_info = json_decode(file_get_contents($v['video_file'] . '?avinfo'), true);
$v['video_image'] = $this->get_video_first_image( $v['video_file'], $video_info);
}
... ... @@ -329,7 +328,6 @@ class Lists extends Api
*/
public function index_info()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
... ... @@ -358,7 +356,7 @@ class Lists extends Api
foreach ($file_list as &$v){
if(!empty($v['file'])){
$base_url = $v['file'];
$qiniu_url = $qiniu.$v['file'];
$qiniu_url = cdnurl($v['file'],true);
$a = file_get_contents($qiniu_url);
$path = './uploads/'.explode('/',$base_url)[2].'/';
if(!file_exists($path)) {
... ... @@ -401,7 +399,6 @@ class Lists extends Api
*/
public function policy_info()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
... ... @@ -430,7 +427,7 @@ class Lists extends Api
foreach ($file_list as &$v){
if(!empty($v['file'])){
$base_url = $v['file'];
$qiniu_url = $qiniu.$v['file'];
$qiniu_url = cdnurl($v['file'],true);
$a = file_get_contents($qiniu_url);
$path = './uploads/'.explode('/',$base_url)[2].'/';
if(!file_exists($path)) {
... ... @@ -476,7 +473,6 @@ class Lists extends Api
*/
public function download_info()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
... ... @@ -492,7 +488,7 @@ class Lists extends Api
foreach ($file_list as &$v){
if(!empty($v['file'])){
$base_url = $v['file'];
$qiniu_url = $qiniu.$v['file'];
$qiniu_url = cdnurl($v['file'],true);
$a = file_get_contents($qiniu_url);
$path = './uploads/'.explode('/',$base_url)[2].'/';
if(!file_exists($path)) {
... ... @@ -539,7 +535,6 @@ class Lists extends Api
{
$page = $this->request->param('page', 1, 'intval');
$pageNum = $this->request->param('pageNum', 10, 'intval');
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data['total_num'] = Db::name('optimization')
->count();
$data['info'] = Db::name('optimization')
... ... @@ -552,7 +547,7 @@ class Lists extends Api
$video_avinfo = json_decode(file_get_contents(cdnurl($v['video_file'], true) . '?avinfo'), true); // 获取视频元信息
$duration = ceil($video_avinfo['format']['duration']);
$v['duration'] = gmdate('H:i:s',$duration);
$v['image'] = $qiniu.$v['image'];
$v['image'] = cdnurl($v['image'],true);
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
$this->success('success',$data);
... ... @@ -587,12 +582,11 @@ class Lists extends Api
if(empty($id)){
$this->error('缺少必要参数');
}
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('optimization')
->where('id',$id)
->find();
$data['image'] = $qiniu.$data['image'];
$data['video_file'] = $qiniu.$data['video_file'];
$data['image'] = cdnurl($data['image'],true);
$data['video_file'] = cdnurl($data['video_file'],true);
// 获取视频时长
$video_avinfo = json_decode(file_get_contents(cdnurl($data['video_file'], true) . '?avinfo'), true); // 获取视频元信息
... ... @@ -643,7 +637,6 @@ class Lists extends Api
}
$page = $this->request->param('page', 1, 'intval');
$pageNum = $this->request->param('pageNum', 10, 'intval');
$qiniu = get_addon_config('qiniu')['cdnurl'];
// $user_id = Session::get('user_id');
$user_id = $this->auth->id;
$where['expirationtime'] = ['>',time()];
... ... @@ -675,7 +668,7 @@ class Lists extends Api
}
}
$v['image'] = $qiniu.$v['image'];
$v['image'] = cdnurl($v['image'],true);
$v['expirationtime'] = date('Y-m-d H:i:s',$v['expirationtime']);
}
$this->success('success',$data);
... ... @@ -726,7 +719,6 @@ class Lists extends Api
}
$page = $this->request->param('page', 1, 'intval');
$pageNum = $this->request->param('pageNum', 12, 'intval');
$qiniu = get_addon_config('qiniu')['cdnurl'];
// $user_id = Session::get('user_id');
$user_id = $this->auth->id;
$where['expirationtime'] = ['>',time()];
... ... @@ -762,7 +754,7 @@ class Lists extends Api
$third_study = Db::name('third_study')->where('third_id',$user_id)->where('study_id',$v['id'])->field('periodtime')->find();
$v['expirationtime'] = !empty($third_study) ? date('Y-m-d H:i:s',$third_study['periodtime']) : date('Y-m-d H:i:s',$v['expirationtime']);
}
$v['image'] = $qiniu.$v['image'];
$v['image'] = cdnurl($v['image'],true);
}
$this->success('success',$data);
}
... ... @@ -824,8 +816,6 @@ class Lists extends Api
public function password_login(){
$type = $this->request->param('type');
$qiniu = get_addon_config('qiniu')['cdnurl'];
$username = $this->request->param('username');
$password = $this->request->param('password');
if(empty($username) || empty($password)){
... ... @@ -843,7 +833,7 @@ class Lists extends Api
// $this->error('抱歉,有效期已过');
// }
if(!empty($user['image'])){
$user['image'] = $qiniu.$user['image'];
$user['image'] = cdnurl($user['image'],true);
}else{
$user['image'] = '';
}
... ... @@ -1094,11 +1084,10 @@ class Lists extends Api
{
$page = $this->request->param('page', 1, 'intval');
$pageNum = $this->request->param('pageNum', 10, 'intval');
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data['total_num'] = Db::name('kelist')->count();
$data['info'] = Db::name('kelist')->order('id desc')->field('updatetime',true)->page($page,$pageNum)->select();
foreach ($data['info'] as &$v){
$v['image'] = $qiniu.$v['image'];
$v['image'] = cdnurl($v['image'],true);
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
$this->success('success',$data);
... ... @@ -1131,13 +1120,12 @@ class Lists extends Api
*/
public function ke_list_detail()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
}
$data = Db::name('kelist')->where('id',$id)->find();
$data['image'] = $qiniu.$data['image'];
$data['image'] = cdnurl($data['image'],true);
$this->success('success',$data);
}
... ...
... ... @@ -59,7 +59,6 @@ class User extends Api
*/
public function index()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = $this->auth->id;
$data = Db::name('user')->where('id',$user_id)->find();
if(empty($data['nickname'])){
... ... @@ -70,7 +69,7 @@ class User extends Api
$data['yuan_image'] = '';
}else{
$data['yuan_image'] = $data['image'];
$data['image'] = $qiniu.$data['image'];
$data['image'] = cdnurl($data['image'],true);
}
if(empty($data['card'])){
$data['card'] = '';
... ... @@ -202,7 +201,6 @@ class User extends Api
$where['is_major'] = 2;
}
$where['study_id'] = $id;
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data['total_num'] = Db::name('classes')
->where($where)
->count();
... ... @@ -213,9 +211,9 @@ class User extends Api
->order('id desc')
->select();
foreach ($data['info'] as &$v){
$v['video_file'] = $qiniu.$v['video_file'];
$v['video_file'] = cdnurl($v['video_file'],true);
// $video_info = json_decode(file_get_contents($v['video_file'] . '?avinfo'), true);
$v['video_image'] = $qiniu.$v['video_image'];
$v['video_image'] = cdnurl($v['video_image'],true);
}
$this->success('success',$data);
}
... ... @@ -690,7 +688,7 @@ class User extends Api
->where('id',$id)
->find();
$data['exam']['image'] = $qiniu.$data['exam']['image'];
$data['exam']['image'] = cdnurl($data['exam']['image'],true);
$finish_hour = Db::name('study_class')
->alias('a')
... ... @@ -772,7 +770,7 @@ class User extends Api
$v['proportion'] = '100%';
}
$v['duration'] = ceil($v['duration']/60);
$v['video_image'] = $qiniu.$v['video_image'];
$v['video_image'] = cdnurl($v['video_image'],true);
}
$data['third'] = $third_exam;
$this->success('success',$data);
... ... @@ -799,7 +797,6 @@ class User extends Api
})
*/
public function certificate(){
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = $this->auth->id;
$id = $this->request->param('id');
if(empty($id)){
... ... @@ -839,7 +836,7 @@ class User extends Api
if (!file_exists($dir_user)){
mkdir($dir_user,0777,true);
}
$qiniu_url = $qiniu.$data['image'];
$qiniu_url = cdnurl($data['image'],true);
$image_name = $user_id.'.png';
$furl = $dir_user . DS .$image_name;
$a = file_get_contents($qiniu_url);
... ... @@ -850,7 +847,7 @@ class User extends Api
if (!file_exists($dir_qrcode)){
mkdir($dir_qrcode,0777,true);
}
$yinimage = $qiniu.$data['yinimage'];
$yinimage = cdnurl($data['yinimage'],true);
$imagename = $data['study_id'].'.png';
$yinfurl = $dir_qrcode . DS .$imagename;
$b = file_get_contents($yinimage);
... ...