From 43c59ec34e43c39b8377b9792a923ff0df15360d Mon Sep 17 00:00:00 2001 From: aixianling Date: Mon, 4 Jul 2022 14:43:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=B3=E4=BA=8E=E6=A0=87?= =?UTF-8?q?=E5=87=86=E5=BA=93=E7=9A=84=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rest/custom/download.js | 32 ++++++++++++++++++++++++++++++++ src/rest/wechatapps/list.js | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/rest/custom/download.js diff --git a/src/rest/custom/download.js b/src/rest/custom/download.js new file mode 100644 index 0000000..883f8c9 --- /dev/null +++ b/src/rest/custom/download.js @@ -0,0 +1,32 @@ +const dbUtils = require("../../utils/dbUitls"); +const fse = require("fs-extra"); +const execute = require("../../tools/exec"); +module.exports = { + action: "/node/custom/download", + method: "post", + execute: (request, response) => { + let id = request.query?.id + dbUtils.detail({table: 'node_custom_config', id}).then(info => { + if (info?.id) { + let path = `${info.dist}`, zipPath = `/home/deploy/node-service/zips/${info.id}.zip` + fse.removeSync(zipPath) + fse.pathExists(path, (err, exists) => { + console.log(`${path}=========>${exists}`) + if (exists) { + execute(`cd ${path}&&zip -r ${info.id}.zip .`) + .then(() => execute(`cd ${path}&&mv ${info.id}.zip /home/deploy/node-service/zips`)) + .then(() => { + console.log('压缩完成!') + setTimeout(() => { + response.download(zipPath) + }, 1000) + }) + } else response.send({code: 1, err: "没有打包文件!"}) + }) + } else response.send({code: 1, err: "无法找到项目信息"}) + }).catch(err => { + console.log(err) + response.send({code: 1, err: err.sqlMessage}) + }) + } +} diff --git a/src/rest/wechatapps/list.js b/src/rest/wechatapps/list.js index df6f172..1794280 100644 --- a/src/rest/wechatapps/list.js +++ b/src/rest/wechatapps/list.js @@ -3,9 +3,10 @@ module.exports = { action: "/node/wechatapps/list", method: "post", execute: (request, response) => { - let total = 0, records = [], {size, current = 1, name = "", type} = request.query + let total = 0, records = [], {size, current = 1, name = "", type, isMain} = request.query if (type) { let condition = `where type='${type}' and (name like '%${name}%' or label like '%${name}%')` + isMain && (condition += ` and libPath not like '%project%'`) Promise.all([ dbUtils.query(`select 1 from node_wechat_apps ${condition}`).then(res => { return total = res.length