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