Commit 52a37824ef73409951f27f3910e12b189fc29c28
1 parent
f656f33b
Exists in
master
1.版本信息添加ECS文件路径,保留原来ECS上传的文件,且支持切换升级包获取路径。
Showing
6 changed files
with
20 additions
and
3 deletions
Show diff stats
app-api/controllers/UpgradeController.php
@@ -177,7 +177,12 @@ class UpgradeController extends BaseController | @@ -177,7 +177,12 @@ class UpgradeController extends BaseController | ||
177 | $e->message = '有升级包'; | 177 | $e->message = '有升级包'; |
178 | $e->update_flag = $upgradeRecord->focuse; | 178 | $e->update_flag = $upgradeRecord->focuse; |
179 | $e->version = $upgradeRecord->version; | 179 | $e->version = $upgradeRecord->version; |
180 | - $e->file_path = $domainURL.$upgradeRecord->path; | 180 | + // 根据配置文件切换读取更新文件的路径 |
181 | + if (isset(Yii::$app->params["UPGRADE_FILE_FROM"]) && "FROM_OSS" == Yii::$app->params["UPGRADE_FILE_FROM"]) { | ||
182 | + $e->file_path = Yii::$app->params["ossOptions"]["url"] . "/" . $upgradeRecord->path; | ||
183 | + } else { | ||
184 | + $e->file_path = $domainURL.$upgradeRecord->upload_path; | ||
185 | + } | ||
181 | $e->file_md5 = $upgradeRecord->file_md5; | 186 | $e->file_md5 = $upgradeRecord->file_md5; |
182 | $e->size = $upgradeRecord->size; | 187 | $e->size = $upgradeRecord->size; |
183 | $e->package_type = $upgradeRecord->package_type; | 188 | $e->package_type = $upgradeRecord->package_type; |
app-ht/modules/upgrade/controllers/UpgradeController.php
@@ -519,7 +519,7 @@ class UpgradeController extends BaseController | @@ -519,7 +519,7 @@ class UpgradeController extends BaseController | ||
519 | $hashStr = substr(md5($pathInfo['basename']),8,16); | 519 | $hashStr = substr(md5($pathInfo['basename']),8,16); |
520 | $hashName = time() . $hashStr . '.' .$pathInfo['extension']; | 520 | $hashName = time() . $hashStr . '.' .$pathInfo['extension']; |
521 | $uploadPath = $uploadDir . "/" .$hashName; | 521 | $uploadPath = $uploadDir . "/" .$hashName; |
522 | - $savePath = $savePath . "/" . $hashName; | 522 | + $saveUploadPath = $savePath . "/" . $hashName; |
523 | if (!$out = fopen($uploadPath, "wb")) { | 523 | if (!$out = fopen($uploadPath, "wb")) { |
524 | die('{"jsonrpc" : "2.0", "error" : {"code": 106, "message": "Failed to open output stream."}, "id" : "id"}'); | 524 | die('{"jsonrpc" : "2.0", "error" : {"code": 106, "message": "Failed to open output stream."}, "id" : "id"}'); |
525 | } | 525 | } |
@@ -545,6 +545,7 @@ class UpgradeController extends BaseController | @@ -545,6 +545,7 @@ class UpgradeController extends BaseController | ||
545 | 'success' => true, | 545 | 'success' => true, |
546 | 'oldName' => $oldName, | 546 | 'oldName' => $oldName, |
547 | 'filePath' => $savePath, | 547 | 'filePath' => $savePath, |
548 | + 'uploadPath' => $saveUploadPath, | ||
548 | 'fileSize' => filesize($uploadPath), | 549 | 'fileSize' => filesize($uploadPath), |
549 | 'fileSuffixes' => $pathInfo['extension'], //文件后缀名 | 550 | 'fileSuffixes' => $pathInfo['extension'], //文件后缀名 |
550 | 'file_md5' => md5_file($uploadPath), | 551 | 'file_md5' => md5_file($uploadPath), |
@@ -554,7 +555,7 @@ class UpgradeController extends BaseController | @@ -554,7 +555,7 @@ class UpgradeController extends BaseController | ||
554 | $fileService = new FileService(); | 555 | $fileService = new FileService(); |
555 | $fileService->add($uploadPath, $savePath); | 556 | $fileService->add($uploadPath, $savePath); |
556 | // 删除服务器传成功的文件 | 557 | // 删除服务器传成功的文件 |
557 | - @unlink($uploadPath); | 558 | + //@unlink($uploadPath); |
558 | 559 | ||
559 | /** | 560 | /** |
560 | * 后台操作日志 | 561 | * 后台操作日志 |
app-ht/modules/upgrade/views/upgrade/create.php
@@ -76,6 +76,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -76,6 +76,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
76 | <label for="package" class="col-sm-4 control-label text-right"><span style="color: #ff0000;">*</span>上传安装包:</label> | 76 | <label for="package" class="col-sm-4 control-label text-right"><span style="color: #ff0000;">*</span>上传安装包:</label> |
77 | <input type="hidden" id="type" name="type" value="<?= (isset($gets["type"]) ? $gets["type"] : UpgradeStatus::TYPE_APP) ?>"/> | 77 | <input type="hidden" id="type" name="type" value="<?= (isset($gets["type"]) ? $gets["type"] : UpgradeStatus::TYPE_APP) ?>"/> |
78 | <input type="hidden" id="path" name="path" value="<?= (isset($gets["path"]) ? $gets["path"] : "") ?>"/> | 78 | <input type="hidden" id="path" name="path" value="<?= (isset($gets["path"]) ? $gets["path"] : "") ?>"/> |
79 | + <input type="hidden" id="upload_path" name="upload_path" value="<?= (isset($gets["upload_path"]) ? $gets["upload_path"] : "") ?>"/> | ||
79 | <input type="hidden" id="size" name="size" value="<?= (isset($gets["size"]) ? $gets["size"] : "") ?>"/> | 80 | <input type="hidden" id="size" name="size" value="<?= (isset($gets["size"]) ? $gets["size"] : "") ?>"/> |
80 | <input type="hidden" id="file_md5" name="file_md5" value="<?= (isset($gets["file_md5"]) ? $gets["file_md5"] : "") ?>"/> | 81 | <input type="hidden" id="file_md5" name="file_md5" value="<?= (isset($gets["file_md5"]) ? $gets["file_md5"] : "") ?>"/> |
81 | <input type="hidden" id="oldName" name="oldName" value="<?= (isset($gets["oldName"]) ? $gets["oldName"] : "") ?>"/> | 82 | <input type="hidden" id="oldName" name="oldName" value="<?= (isset($gets["oldName"]) ? $gets["oldName"] : "") ?>"/> |
@@ -233,6 +234,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -233,6 +234,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
233 | $("#save").removeAttr("disabled"); | 234 | $("#save").removeAttr("disabled"); |
234 | //$list.append('<input type="hidden" name="'+ids+'" value="'+response.filePath+'" />'); | 235 | //$list.append('<input type="hidden" name="'+ids+'" value="'+response.filePath+'" />'); |
235 | $("input[name='path']").val(response.filePath); | 236 | $("input[name='path']").val(response.filePath); |
237 | + $("input[name='upload_path']").val(response.uploadPath); | ||
236 | $("input[name='size']").val(response.fileSize); | 238 | $("input[name='size']").val(response.fileSize); |
237 | $("input[name='file_md5']").val(response.file_md5); | 239 | $("input[name='file_md5']").val(response.file_md5); |
238 | $("input[name='oldName']").val(response.oldName); | 240 | $("input[name='oldName']").val(response.oldName); |
@@ -241,6 +243,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -241,6 +243,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
241 | // 文件上传失败,显示上传出错 | 243 | // 文件上传失败,显示上传出错 |
242 | uploader.on( 'uploadError', function( file ,response) { | 244 | uploader.on( 'uploadError', function( file ,response) { |
243 | $("input[name='path']").val(""); | 245 | $("input[name='path']").val(""); |
246 | + $("input[name='upload_path']").val(""); | ||
244 | $("input[name='size']").val(""); | 247 | $("input[name='size']").val(""); |
245 | $("input[name='file_md5']").val(""); | 248 | $("input[name='file_md5']").val(""); |
246 | $("input[name='oldName']").val(""); | 249 | $("input[name='oldName']").val(""); |
app-ht/modules/upgrade/views/upgrade/edit.php
@@ -76,6 +76,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -76,6 +76,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
76 | <input type="hidden" id="type" name="type" value="<?= (isset($info["type"]) ? $info["type"] : UpgradeStatus::TYPE_APP) ?>"/> | 76 | <input type="hidden" id="type" name="type" value="<?= (isset($info["type"]) ? $info["type"] : UpgradeStatus::TYPE_APP) ?>"/> |
77 | <input type="hidden" id="uid" name="uid" value="<?= (isset($info["id"]) ? $info["id"] : (isset($info["uid"]) ? $info["uid"] : "")) ?>"/> | 77 | <input type="hidden" id="uid" name="uid" value="<?= (isset($info["id"]) ? $info["id"] : (isset($info["uid"]) ? $info["uid"] : "")) ?>"/> |
78 | <input type="hidden" id="path" name="path" value="<?= (isset($info["path"]) ? $info["path"] : "") ?>"/> | 78 | <input type="hidden" id="path" name="path" value="<?= (isset($info["path"]) ? $info["path"] : "") ?>"/> |
79 | + <input type="hidden" id="upload_path" name="upload_path" value="<?= (isset($info["upload_path"]) ? $info["upload_path"] : "") ?>"/> | ||
79 | <input type="hidden" id="size" name="size" value="<?= (isset($info["size"]) ? $info["size"] : "") ?>"/> | 80 | <input type="hidden" id="size" name="size" value="<?= (isset($info["size"]) ? $info["size"] : "") ?>"/> |
80 | <input type="hidden" id="file_md5" name="file_md5" value="<?= (isset($info["file_md5"]) ? $info["file_md5"] : "") ?>"/> | 81 | <input type="hidden" id="file_md5" name="file_md5" value="<?= (isset($info["file_md5"]) ? $info["file_md5"] : "") ?>"/> |
81 | <input type="hidden" id="oldName" name="oldName" value="<?= (isset($info["oldName"]) ? $info["oldName"] : "") ?>"/> | 82 | <input type="hidden" id="oldName" name="oldName" value="<?= (isset($info["oldName"]) ? $info["oldName"] : "") ?>"/> |
@@ -224,6 +225,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -224,6 +225,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
224 | $( '#'+file.id ).find('p.state').text('已上传'); | 225 | $( '#'+file.id ).find('p.state').text('已上传'); |
225 | //$list.append('<input type="hidden" name="'+ids+'" value="'+response.filePath+'" />'); | 226 | //$list.append('<input type="hidden" name="'+ids+'" value="'+response.filePath+'" />'); |
226 | $("input[name='path']").val(response.filePath); | 227 | $("input[name='path']").val(response.filePath); |
228 | + $("input[name='upload_path']").val(response.uploadPath); | ||
227 | $("input[name='size']").val(response.fileSize); | 229 | $("input[name='size']").val(response.fileSize); |
228 | $("input[name='file_md5']").val(response.file_md5); | 230 | $("input[name='file_md5']").val(response.file_md5); |
229 | $("input[name='oldName']").val(response.oldName); | 231 | $("input[name='oldName']").val(response.oldName); |
@@ -233,6 +235,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -233,6 +235,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
233 | uploader.on( 'uploadError', function( file ) { | 235 | uploader.on( 'uploadError', function( file ) { |
234 | $("input[name='path']").val(""); | 236 | $("input[name='path']").val(""); |
235 | $("input[name='size']").val(""); | 237 | $("input[name='size']").val(""); |
238 | + $("input[name='upload_path']").val(""); | ||
236 | $("input[name='file_md5']").val(""); | 239 | $("input[name='file_md5']").val(""); |
237 | $("input[name='oldName']").val(""); | 240 | $("input[name='oldName']").val(""); |
238 | $( '#'+file.id ).find('p.state').text('上传出错'); | 241 | $( '#'+file.id ).find('p.state').text('上传出错'); |
common/config/params.php
@@ -11,4 +11,5 @@ return [ | @@ -11,4 +11,5 @@ return [ | ||
11 | 'url' => 'https://kingboard-prod.oss-cn-shenzhen.aliyuncs.com', | 11 | 'url' => 'https://kingboard-prod.oss-cn-shenzhen.aliyuncs.com', |
12 | 'styleUrl' => 'https://kingboard-prod.oss-cn-shenzhen.aliyuncs.com' | 12 | 'styleUrl' => 'https://kingboard-prod.oss-cn-shenzhen.aliyuncs.com' |
13 | ], | 13 | ], |
14 | + 'UPGRADE_FILE_FROM' => 'FROM_ECS' | ||
14 | ]; | 15 | ]; |
domain/upgrade/Upgrade.php
@@ -41,6 +41,7 @@ class Upgrade | @@ -41,6 +41,7 @@ class Upgrade | ||
41 | $upgradeModel->model_id = $item["model_id"]; // 型号 | 41 | $upgradeModel->model_id = $item["model_id"]; // 型号 |
42 | $upgradeModel->desc = $item["desc"]; // 描述 | 42 | $upgradeModel->desc = $item["desc"]; // 描述 |
43 | $upgradeModel->path = $item["path"]; // 文件路径 | 43 | $upgradeModel->path = $item["path"]; // 文件路径 |
44 | + $upgradeModel->upload_path = $item["upload_path"]; // 服务器文件路径 | ||
44 | $upgradeModel->package_name = $item["package_name"]; // 安装包名称 | 45 | $upgradeModel->package_name = $item["package_name"]; // 安装包名称 |
45 | if (isset($item["device_ids"])) { | 46 | if (isset($item["device_ids"])) { |
46 | $upgradeModel->device_ids = $item["指定deviceID,可以多个,多个用逗号隔开"]; // 版本 | 47 | $upgradeModel->device_ids = $item["指定deviceID,可以多个,多个用逗号隔开"]; // 版本 |
@@ -99,6 +100,9 @@ class Upgrade | @@ -99,6 +100,9 @@ class Upgrade | ||
99 | if (isset($item['path']) && !empty($item['path'])) { | 100 | if (isset($item['path']) && !empty($item['path'])) { |
100 | $upgradeModel->path = $item['path']; | 101 | $upgradeModel->path = $item['path']; |
101 | } | 102 | } |
103 | + if (isset($item['upload_path']) && !empty($item['upload_path'])) { | ||
104 | + $upgradeModel->upload_path = $item['upload_path']; | ||
105 | + } | ||
102 | if (isset($item['focuse']) && !empty($item['focuse'])) { | 106 | if (isset($item['focuse']) && !empty($item['focuse'])) { |
103 | $upgradeModel->focuse = $item['focuse']; | 107 | $upgradeModel->focuse = $item['focuse']; |
104 | } | 108 | } |