From fcfbddb937ddf5cc727a4ff4de5538ab1e9e8f08 Mon Sep 17 00:00:00 2001 From: xu Date: Thu, 14 Nov 2019 14:56:54 +0800 Subject: [PATCH] app-ht 1. F 上传文件到 OSS拆开来处理 --- app-ht/modules/upgrade/controllers/UpgradeController.php | 3 ++- app-ht/modules/upgrade/views/upgrade/create.php | 2 +- app-ht/modules/upgrade/views/upgrade/edit.php | 10 ++++++---- app-ht/modules/upgrade/views/upgrade/index.php | 9 ++++++--- domain/upgrade/Upgrade.php | 4 ++++ 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app-ht/modules/upgrade/controllers/UpgradeController.php b/app-ht/modules/upgrade/controllers/UpgradeController.php index dd909ab..baa6dd6 100644 --- a/app-ht/modules/upgrade/controllers/UpgradeController.php +++ b/app-ht/modules/upgrade/controllers/UpgradeController.php @@ -593,7 +593,7 @@ class UpgradeController extends BaseController $e->message = "该版本不存在"; return $this->renderJson($e); } - $uploadPath = dirname(dirname(dirname(__DIR__))) . "/" . $upgradeModel->upload_path; + $uploadPath = Yii::getAlias('@app/ht') . "/" . $upgradeModel->upload_path; if (!file_exists($uploadPath)) { $e->message = "该版本ECS文件不存在"; return $this->renderJson($e); @@ -605,6 +605,7 @@ class UpgradeController extends BaseController $upgradeModel->save(); $e->success = true; $e->message = "同步OSS成功"; + return $this->renderJson($e); } catch (\Exception $ex) { $e->message = "同步OSS异常:" . $ex->getMessage(); diff --git a/app-ht/modules/upgrade/views/upgrade/create.php b/app-ht/modules/upgrade/views/upgrade/create.php index 4262a6b..e984389 100644 --- a/app-ht/modules/upgrade/views/upgrade/create.php +++ b/app-ht/modules/upgrade/views/upgrade/create.php @@ -231,7 +231,7 @@ $this->params['breadcrumbs'][] = $this->title; '').appendTo( $li ).find('.progress-bar'); } - $li.find('p.state').text('上传中, 文件会先上传到缓存再传到远程服务器,600M大概是12分钟左右,请耐心等待'); + $li.find('p.state').text('上传中, 请耐心等待'); $percent.css( 'width', percentage * 100 + '%' ); }); diff --git a/app-ht/modules/upgrade/views/upgrade/edit.php b/app-ht/modules/upgrade/views/upgrade/edit.php index f491ed5..8678410 100644 --- a/app-ht/modules/upgrade/views/upgrade/edit.php +++ b/app-ht/modules/upgrade/views/upgrade/edit.php @@ -43,13 +43,13 @@ $this->params['breadcrumbs'][] = $this->title; APP版本号
- " name="version" placeholder="请填写APP版本号" style="margin-top: -6px;" class="form-control""> + " name="version" id="version" placeholder="请填写APP版本号" style="margin-top: -6px;" class="form-control"">
- " name="package_name" placeholder="请填写安装包名称" style="margin-top: -6px;" class="form-control""> + " name="package_name" id="package_name" placeholder="请填写安装包名称" style="margin-top: -6px;" class="form-control"">
@@ -222,7 +222,7 @@ $this->params['breadcrumbs'][] = $this->title; '
').appendTo( $li ).find('.progress-bar'); } - $li.find('p.state').text('上传中, 文件会先上传到缓存再传到远程服务器,600M大概是12分钟左右,请耐心等待'); + $li.find('p.state').text('上传中,请耐心等待'); $percent.css( 'width', percentage * 100 + '%' ); }); @@ -257,7 +257,9 @@ $this->params['breadcrumbs'][] = $this->title; var project = $('#project').val(); var model = $('#model').val(); var type = $('#type').val(); - $.post(checkUpgradeUrl, {manufacture:manufacture, project:project,model:model, id: $('#uid').val(), 'type':type}, function(res){ + var package_name = $('#package_name').val(); + var version = $('#version').val(); + $.post(checkUpgradeUrl, {manufacture:manufacture, project:project,model:model, id: $('#uid').val(), 'type':type, package_name:package_name, version:version}, function(res){ if (res.success) { if (that.hasClass('disabled')) { return false; diff --git a/app-ht/modules/upgrade/views/upgrade/index.php b/app-ht/modules/upgrade/views/upgrade/index.php index 79f7a97..53c4a01 100644 --- a/app-ht/modules/upgrade/views/upgrade/index.php +++ b/app-ht/modules/upgrade/views/upgrade/index.php @@ -194,7 +194,7 @@ $this->params['breadcrumbs'][] = $this->title; }); $(".btn_auth_cancel").bind("click",function () { - if (confirm("确定要取消发布该版本吗?")){ + if (confirm("确定要取消发布该版本吗?")) { var data_id = $.trim($(this).attr("aid")); if (data_id == null || data_id == ""){ alert("丢失参数,暂时无法取消,请刷新后再试"); @@ -220,9 +220,8 @@ $this->params['breadcrumbs'][] = $this->title; }); } }); - $(".btn_upload_oss").bind("click",function () { - if (confirm("确定要同步该版本文件到OSS吗?")){ + if (confirm("确定要同步该版本文件到OSS吗?600M大概需要7分钟左右。")){ var data_id = $.trim($(this).attr("aid")); if (data_id == null || data_id == ""){ alert("丢失参数,暂时无法取消,请刷新后再试"); @@ -230,14 +229,18 @@ $this->params['breadcrumbs'][] = $this->title; } var thiz = $(this); thiz.text("同步中…"); + $('#upload-mark').remove(); + $('body').append('
'); var loding = $.loading(); loding.show(); + $.ajax({ type: "post", url: "", dataType:"json", data: $.csrf({upgrade_id:data_id}), success:function(res){ + $('#upload-mark').remove(); loding.hide(); loding = null; if(!res.success) { diff --git a/domain/upgrade/Upgrade.php b/domain/upgrade/Upgrade.php index a8b1d33..43b9973 100644 --- a/domain/upgrade/Upgrade.php +++ b/domain/upgrade/Upgrade.php @@ -89,6 +89,7 @@ class Upgrade return -1; } } + $oldUploadPath = $upgradeModel->upload_path; if (isset($item['version']) && !empty($item['version'])) { $upgradeModel->version = $item['version']; } @@ -109,6 +110,9 @@ class Upgrade } if (isset($item['upload_path']) && !empty($item['upload_path'])) { $upgradeModel->upload_path = $item['upload_path']; + if ($oldUploadPath != $item['upload_path']) { + $upgradeModel->oss_upload_status = UpgradeStatus::OSS_UPLOAD_WAIT; + } } if (isset($item['focuse']) && !empty($item['focuse'])) { $upgradeModel->focuse = $item['focuse']; -- libgit2 0.21.0