修复相同appid不同版本数据混淆问题

This commit is contained in:
aixianling
2022-06-30 10:13:47 +08:00
parent 569fdcabe7
commit e07aef9832
3 changed files with 11 additions and 11 deletions

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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)