Files
dvcp-node-service/src/rest/wechat/sync.js
2022-12-23 18:02:51 +08:00

22 lines
831 B
JavaScript

const dbUtils = require("../../utils/dbUitls");
uid = e => [e.appid, e.corpId].join("_")
module.exports = {
action: "/node/wxmp/sync",
method: "post",
execute: (request, response) => {
let records = {}, meta = []
Promise.all([
dbUtils.query("select * from app_dvcp_config").then(res => meta = res),
dbUtils.query("select * from node_wxmp_deploy").then(res => res?.map(e => records[uid(e)] = e))
]).then(() => Promise.all(meta.map(e => {
const {name, miniapp_appid: appid, corp_id: corpId, web_url: webUrl} = e
const id = records[uid({appid, corpId})]?.id
delete e.system_info
return dbUtils.addOrUpdate({
table: 'node_wxmp_deploy',
form: {id, name, appid, corpId, webUrl, dvcpConfig: e}
})
}))).finally(() => response.send({code: 0, data: ""}))
}
}