diff --git a/api/controller_front/config.js b/api/controller_front/config.js index 3f9d66f..22baef5 100644 --- a/api/controller_front/config.js +++ b/api/controller_front/config.js @@ -55,27 +55,21 @@ module.exports = { return ctx.fail('配置键不能为空'); } - // 临时写死测试数据 - const mockData = { - wx_num: 'test_wechat_123', - wx_img: '/uploads/wechat_qrcode.png' - }; - - // 如果只有一个配置键,返回单个配置值 - if (keys.length === 1) { - const key = keys[0]; - return ctx.success({ - [key]: mockData[key] || '' - }); - } - - // 多个配置键,返回对象 - const result = {}; - keys.forEach(key => { - result[key] = mockData[key] || ''; + const result = await sys_parameter.findAll({ + where: { + key: { + [op.in]: keys + } + } }); - return ctx.success(result); + + const tempData = {}; + result.forEach(item => { + tempData[item.key] = item.value; + }); + + return ctx.success(tempData); } catch (error) { console.error('获取配置失败:', error); return ctx.fail('获取配置失败: ' + error.message);