From e546ab15a18ae1bdfa4ab32596c2a069e30d89a3 Mon Sep 17 00:00:00 2001 From: xu Date: Thu, 14 Nov 2019 16:52:25 +0800 Subject: [PATCH] app-ht 1. A 版本管理添加条件筛选 --- .gitignore | 3 +++ app-api/web/.gitignore | 1 + app-ht/modules/upgrade/controllers/UpgradeController.php | 46 +++++++++++++++++++++++++++++++++------------- app-ht/modules/upgrade/views/upgrade/index.php | 24 +++++++++++++++++++----- 4 files changed, 56 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 87deab8..cc84d79 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ runtimes /app-ht/web/upload app-ht/web/upload +/app-api/web/upload +app-api/web/upload + diff --git a/app-api/web/.gitignore b/app-api/web/.gitignore index 25c74e6..68c1a8a 100644 --- a/app-api/web/.gitignore +++ b/app-api/web/.gitignore @@ -1,2 +1,3 @@ /index.php /index-test.php +upload diff --git a/app-ht/modules/upgrade/controllers/UpgradeController.php b/app-ht/modules/upgrade/controllers/UpgradeController.php index baa6dd6..1c6a91a 100644 --- a/app-ht/modules/upgrade/controllers/UpgradeController.php +++ b/app-ht/modules/upgrade/controllers/UpgradeController.php @@ -45,6 +45,9 @@ class UpgradeController extends BaseController $endTime = $request->get('endTime'); $status = $request->get('status'); $version = $request->get('version'); + $manufacture_name = $request->get('manufacture_name'); + $project_name = $request->get('project_name'); + $model_name = $request->get('model_name'); $dataType = !empty($request->get('type')) ? $request->get('type') : UpgradeStatus::TYPE_APP; $gets = [ @@ -53,9 +56,25 @@ class UpgradeController extends BaseController 'status' => $status, 'version' => $version, 'type' => $dataType, + 'manufacture_name' => $manufacture_name, + 'project_name' => $project_name, + 'model_name' => $model_name ]; $where = ['and']; + if ($manufacture_name) { + $where[] = ['or', ['like','mf.name', $manufacture_name], ['like','mf.manufacture_no', $manufacture_name]]; + } + + if ($project_name) { + $where[] = ['or', ['like','pro.name', $project_name], ['like','pro.project_no', $project_name]]; + } + + if ($model_name) { + $where[] = ['or', ['like','mo.name', $model_name], ['like','mo.model_no', $model_name]]; + } + + if ($creatTime) { $creatTime = strtotime($creatTime); $where[] = ['>=', 'u.pushed_at', $creatTime]; @@ -408,7 +427,7 @@ class UpgradeController extends BaseController */ public function actionUploadFile() { - header("Expires: Mon, 26 Jul 2020 05:00:00 GMT"); + header("Expires: Mon, 26 Jul 2030 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Content-type: text/html; charset=utf-8"); header("Cache-Control: no-store, no-cache, must-revalidate"); @@ -432,11 +451,11 @@ class UpgradeController extends BaseController // Uncomment this one to fake upload time usleep(5000); // Settings - $upload = dirname(dirname(dirname(__DIR__))) . "/web/upload"; - $savePath = 'web/upload/packages/package_' . date("Ymd"); + $upload = Yii::getAlias('@app/api') . "/web/upload"; + $savePath = 'web/upload/packages/package_' . date("Ym"); $assetsUrl = Yii::$app->params['assetsUrl']; - $targetDir = $upload . '/packages/file_material_tmp/' . Yii::$app->user->id; //存放分片临时目录 - $uploadDir = $upload . '/packages/package_' . date("Ymd"); + $targetDir = $upload . '/packages/file_material_tmp'; //存放分片临时目录 + $uploadDir = $upload . '/packages/package_' . date("Ym"); $cleanupTargetDir = true; // Remove old files $maxFileAge = 5 * 3600; // Temp file age in seconds @@ -517,8 +536,10 @@ class UpgradeController extends BaseController if ($done) { $pathInfo = pathinfo($fileName); - $hashStr = substr(md5($pathInfo['basename']),8,16); - $hashName = time() . $hashStr . '.' .$pathInfo['extension']; + $hashStr = substr(md5(time().mt_rand(000000, 999999)), 8, 16); + $fName = str_replace(' ', '', $pathInfo['basename']); + $filenameArr = explode('.', $fName); + $hashName = $filenameArr[0] .'_'. $hashStr . '.' .$pathInfo['extension']; $uploadPath = $uploadDir . "/" .$hashName; $saveUploadPath = $savePath . "/" . $hashName; if (!$out = fopen($uploadPath, "wb")) { @@ -540,7 +561,7 @@ class UpgradeController extends BaseController } fclose($out); - $savePath = self::getFilePath(Yii::$app->user->id, $hashName); + $savePath = self::getFilePath($hashName, Yii::$app->user->id); $response = [ 'success' => true, @@ -593,7 +614,7 @@ class UpgradeController extends BaseController $e->message = "该版本不存在"; return $this->renderJson($e); } - $uploadPath = Yii::getAlias('@app/ht') . "/" . $upgradeModel->upload_path; + $uploadPath = Yii::getAlias('@app/api') . "/" . $upgradeModel->upload_path; if (!file_exists($uploadPath)) { $e->message = "该版本ECS文件不存在"; return $this->renderJson($e); @@ -740,14 +761,13 @@ class UpgradeController extends BaseController } /** - * 获取文件存储路径: bind_apply/20170509/[userId]/文件名 - * @param $userId + * 获取文件存储路径: bind_apply/201705//文件名 * @param $suffix 文件后缀 * @return string */ - public static function getFilePath($userId, $filename) + public static function getFilePath( $filename, $userId) { - $basePath = "upgrade_packages/" . date("Ymd") . '/' . $userId; + $basePath = "upgrade_packages/" . date("Ym"); $savePath = $basePath . '/' . $filename; return $savePath; } diff --git a/app-ht/modules/upgrade/views/upgrade/index.php b/app-ht/modules/upgrade/views/upgrade/index.php index 53c4a01..988fc81 100644 --- a/app-ht/modules/upgrade/views/upgrade/index.php +++ b/app-ht/modules/upgrade/views/upgrade/index.php @@ -24,20 +24,34 @@ $this->params['breadcrumbs'][] = $this->title; - + + + - + + + + + + + - - +
APP版本号厂商: - + + 项目: + 发布状态:型号: + +
APP版本号 + + 发布状态: 发布时间: + 发布时间:
- -- libgit2 0.21.0