diff --git a/api/controller_front/user.js b/api/controller_front/user.js index 9b59c6b..5b49f44 100644 --- a/api/controller_front/user.js +++ b/api/controller_front/user.js @@ -374,6 +374,7 @@ module.exports = { const body = ctx.getBody(); const { sn_code, deliver_config } = body; + if (!sn_code) { return ctx.fail('请提供设备SN码'); } @@ -399,9 +400,14 @@ module.exports = { } // 更新 pla_account 表的 deliver_config 和 auto_deliver 字段 + + // 查出来合并原来的字段,如何没传就不覆盖 + const original_deliver_config = user.deliver_config || {}; + const new_deliver_config = { ...original_deliver_config, ...deliver_config }; + await pla_account.update( { - deliver_config: deliver_config, + deliver_config: new_deliver_config, auto_deliver: deliver_config.auto_delivery ? 1 : 0 }, { where: { id: user.id } }