定制项目打包接口完成

This commit is contained in:
aixianling
2022-07-14 10:50:44 +08:00
parent f800b249ca
commit 7a22c233fe
2 changed files with 18 additions and 12 deletions

View File

@@ -3,11 +3,10 @@ module.exports = {
action: "/node/custom/addOrUpdate",
method: "post",
execute: (request, response) => {
let form = request.body
delete form.appList
let {id, name, type, customPath, apps, createTime, dist, version, zipTime, download, error, extra} = request.body
dbUtils.addOrUpdate({
table: 'node_custom_config',
form
form: {id, name, type, customPath, apps, createTime, dist, version, zipTime, download, error, extra}
}).then(data => {
response.send({code: 0, data})
}).catch(err => {

View File

@@ -5,15 +5,22 @@ module.exports = {
execute: (request, response) => {
let {id} = request.query
dbUtils.detail({table: 'node_custom_config', id}).then(data => {
if (data.apps) {
data.apps = JSON.parse(data.apps)
if (data.apps?.length > 0)
dbUtils.query(`select * from node_wechat_apps where id in (${data.apps.map(e=>`'${e}'`)?.toString()})`).then(res => {
data.appList = res
response.send({code: 0, data})
})
else response.send({code: 0, data})
} else response.send({code: 0, data})
data.apps = JSON.parse(data.apps || "[]")
data.extra = JSON.parse(data.extra || null)
Promise.all([
dbUtils.query(`select * from node_wechat_apps where id in (${data.apps?.map(e=>`'${e}'`)?.toString()})`)
.then(res => data.appList = [data.appList, res].flat()),
dbUtils.query(`select * from node_wechat_apps where type='${data.type}' and id like '%project_${data.customPath}%'`)
.then(res => data.appList = [data.appList, res].flat())
]).then(() => {
data.appList = data.appList.filter(Boolean).map(e => {
if (data.type == 'mp') {
e.tabbar = e.id == data.extra?.tabBar.list?.[2].id
}
return e
})
response.send({code: 0, data})
})
}).catch(err => {
response.send({code: 1, err: err?.sqlMessage || err || ""})
})