同步产品库内容
This commit is contained in:
@@ -1,22 +1,16 @@
|
||||
const dbUtils = require("../../utils/dbUitls");
|
||||
|
||||
const addOrUpdate = form => {
|
||||
return dbUtils.query(`select 1 from node_wechat_apps where id='${form.id}'`).then(res => {
|
||||
if (res.length > 0) {//编辑
|
||||
let arr = Object.keys(form).filter(e => form[e]).map(e => `${e}='${form[e]}'`)
|
||||
return `update node_wechat_apps set ${arr.join(",")} where id='${form.id}' and type='${form.type}'`
|
||||
} else {//新增
|
||||
let cols = [], arr = []
|
||||
Object.keys(form).map(e => {
|
||||
if (form[e]) {
|
||||
cols.push(e)
|
||||
arr.push(`'${form[e]}'`)
|
||||
}
|
||||
})
|
||||
return `insert into node_wechat_apps (${cols.join(",")}) values(${arr.join(",")})`
|
||||
}
|
||||
return dbUtils.query(`delete from node_wechat_apps where type='${form.type}'`).then(() => {
|
||||
let cols = [], arr = []
|
||||
Object.keys(form).map(e => {
|
||||
if (form[e]) {
|
||||
cols.push(e)
|
||||
arr.push(`'${form[e]}'`)
|
||||
}
|
||||
})
|
||||
return `insert into node_wechat_apps (${cols.join(",")}) values(${arr.join(",")})`
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user