From e07aef983292c729a8456ccb6a96355431c68779 Mon Sep 17 00:00:00 2001 From: aixianling Date: Thu, 30 Jun 2022 10:13:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=9B=B8=E5=90=8Cappid?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E7=89=88=E6=9C=AC=E6=95=B0=E6=8D=AE=E6=B7=B7?= =?UTF-8?q?=E6=B7=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rest/wechat/confirmZip.js | 2 +- src/rest/wechat/download.js | 2 +- src/rest/wechat/getZip.js | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/rest/wechat/confirmZip.js b/src/rest/wechat/confirmZip.js index dfc5fcb..1dc2994 100644 --- a/src/rest/wechat/confirmZip.js +++ b/src/rest/wechat/confirmZip.js @@ -3,7 +3,7 @@ module.exports = { action: "/node/wxmp/confirmZip", method: "post", execute: (request, response) => { - let id = request.query?.appid, sql = `select * from node_wxmp_config where appid='${id}'` + let {appid, pid} = request.query, sql = `select * from node_wxmp_config where appid='${appid}' and pid='${pid}'` dbUtils.query(sql).then(res => { let info = res?.[0] if (info?.appid) { diff --git a/src/rest/wechat/download.js b/src/rest/wechat/download.js index a169539..b59ee9c 100644 --- a/src/rest/wechat/download.js +++ b/src/rest/wechat/download.js @@ -4,7 +4,7 @@ module.exports = { action: "/node/wxmp/download", method: "post", execute: (request, response) => { - let appid = request.query?.appid + let {pid, appid: aid} = request.query, appid = [aid, pid].join("_") if (appid) { let path = `/home/deploy/wxmpZips/${appid}/`, zipPath = `/home/deploy/wxmpZips/${appid}.zip` fse.removeSync(zipPath) diff --git a/src/rest/wechat/getZip.js b/src/rest/wechat/getZip.js index a0321f7..9d4597f 100644 --- a/src/rest/wechat/getZip.js +++ b/src/rest/wechat/getZip.js @@ -6,28 +6,28 @@ module.exports = { action: "/node/wxmp/getZip", method: "post", execute: (request, response) => { - let id = request.query?.appid, sql = `select * from node_dvcp_config where miniapp_appid='${id}'` - db.query(sql).then(res => { + let {appid, id} = request.query, uniCon = `appid='${appid}' and pid='${id}'` + db.query(`select * from node_dvcp_config where id='${id}'`).then(res => { let info = res?.[0], sql - if (info?.appid) { - sql = `update node_wxmp_config set error=null where appid='${info.appid}'` + if (info?.appid && info?.pid) { + sql = `update node_wxmp_config set error=null where appid='${info.appid}' and pid='${info.pid}'` } else if (info?.miniapp_appid) { - sql = `insert into node_wxmp_config ('appid') values('${info?.miniapp_appid}')` + sql = `insert into node_wxmp_config ('appid','pid') values('${info?.miniapp_appid}','${info.id}')` } else return response.send({code: 1, err: "无法找到小程序信息"}) db.query(sql).then(() => setTimeout(() => { response.send({code: 0}) }, 2000)) const path = info.projectPath || '/home/deploy/node-service/dvcp_v2_wechat', - dest = `/home/deploy/wxmpZips/${id}/` - execute(`cd ${path}&&npm run apps&&node bin/pages.js ${id}&&npm run build`) + dest = `/home/deploy/wxmpZips/${appid}/` + execute(`cd ${path}&&npm run apps&&node bin/pages.js ${appid}&&npm run build`) .then(() => fse.emptyDir(dest)) .then(() => fse.copy(`${path}/dist/build/mp-weixin/`, dest)) .then(() => fse.emptyDir(`${path}/dist/build`)) .then(() => { - db.query(`update node_wxmp_config set error='打包时间:${dayjs().format("YYYY-MM-DD HH:mm:ss")}' where appid='${info.appid}'`) + db.query(`update node_wxmp_config set error='打包时间:${dayjs().format("YYYY-MM-DD HH:mm:ss")}' where ${uniCon}`) }).catch(err => { console.log(err) - db.query(`update node_wxmp_config set error='${err}' where appid='${info.appid}'`) + db.query(`update node_wxmp_config set error='${err}' where ${uniCon}`) }) }).catch(err => { console.log(err)