1
This commit is contained in:
@@ -21,13 +21,13 @@ module.exports = {
|
|||||||
* required: false
|
* required: false
|
||||||
* schema:
|
* schema:
|
||||||
* type: string
|
* type: string
|
||||||
* description: 配置键(单个,如:wechat_number)
|
* description: 配置键(单个,如:wx_num)
|
||||||
* - in: query
|
* - in: query
|
||||||
* name: configKeys
|
* name: configKeys
|
||||||
* required: false
|
* required: false
|
||||||
* schema:
|
* schema:
|
||||||
* type: string
|
* type: string
|
||||||
* description: 配置键(多个,逗号分隔,如:wechat_number,wechat_qrcode)
|
* description: 配置键(多个,逗号分隔,如:wx_num,wx_img)
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: 获取成功
|
* description: 获取成功
|
||||||
@@ -55,33 +55,24 @@ module.exports = {
|
|||||||
return ctx.fail('配置键不能为空');
|
return ctx.fail('配置键不能为空');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询配置(使用 sys_parameter 表)
|
// 临时写死测试数据
|
||||||
const configs = await sys_parameter.findAll({
|
const mockData = {
|
||||||
where: {
|
wx_num: 'test_wechat_123',
|
||||||
param_key: {
|
wx_img: '/uploads/wechat_qrcode.png'
|
||||||
[op.in]: keys
|
};
|
||||||
},
|
|
||||||
is_delete: 0
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (configs.length === 0) {
|
|
||||||
return ctx.success({});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果只有一个配置键,返回单个配置值
|
// 如果只有一个配置键,返回单个配置值
|
||||||
if (keys.length === 1) {
|
if (keys.length === 1) {
|
||||||
const config = configs[0].toJSON();
|
const key = keys[0];
|
||||||
return ctx.success({
|
return ctx.success({
|
||||||
[config.param_key]: config.param_value
|
[key]: mockData[key] || ''
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 多个配置键,返回对象
|
// 多个配置键,返回对象
|
||||||
const result = {};
|
const result = {};
|
||||||
configs.forEach(config => {
|
keys.forEach(key => {
|
||||||
const configData = config.toJSON();
|
result[key] = mockData[key] || '';
|
||||||
result[configData.param_key] = configData.param_value;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return ctx.success(result);
|
return ctx.success(result);
|
||||||
@@ -89,6 +80,98 @@ module.exports = {
|
|||||||
console.error('获取配置失败:', error);
|
console.error('获取配置失败:', error);
|
||||||
return ctx.fail('获取配置失败: ' + error.message);
|
return ctx.fail('获取配置失败: ' + error.message);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @swagger
|
||||||
|
* /api/config/pricing-plans:
|
||||||
|
* get:
|
||||||
|
* summary: 获取价格套餐列表
|
||||||
|
* description: 获取所有可用的价格套餐
|
||||||
|
* tags: [前端-系统配置]
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: 获取成功
|
||||||
|
*/
|
||||||
|
'GET /config/pricing-plans': async (ctx) => {
|
||||||
|
try {
|
||||||
|
// 写死4条价格套餐数据
|
||||||
|
// 价格计算规则:2小时 = 1天
|
||||||
|
const pricingPlans = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: '体验套餐',
|
||||||
|
duration: '7天',
|
||||||
|
days: 7,
|
||||||
|
price: 28,
|
||||||
|
originalPrice: 28,
|
||||||
|
unit: '元',
|
||||||
|
features: [
|
||||||
|
'7天使用权限',
|
||||||
|
'全功能体验',
|
||||||
|
'技术支持'
|
||||||
|
],
|
||||||
|
featured: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: '月度套餐',
|
||||||
|
duration: '30天',
|
||||||
|
days: 30,
|
||||||
|
price: 99,
|
||||||
|
originalPrice: 120,
|
||||||
|
unit: '元',
|
||||||
|
discount: '约8.3折',
|
||||||
|
features: [
|
||||||
|
'30天使用权限',
|
||||||
|
'全功能使用',
|
||||||
|
'优先技术支持',
|
||||||
|
'性价比最高'
|
||||||
|
],
|
||||||
|
featured: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
name: '季度套餐',
|
||||||
|
duration: '90天',
|
||||||
|
days: 90,
|
||||||
|
price: 269,
|
||||||
|
originalPrice: 360,
|
||||||
|
unit: '元',
|
||||||
|
discount: '7.5折',
|
||||||
|
features: [
|
||||||
|
'90天使用权限',
|
||||||
|
'全功能使用',
|
||||||
|
'优先技术支持',
|
||||||
|
'更优惠价格'
|
||||||
|
],
|
||||||
|
featured: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
name: '终生套餐',
|
||||||
|
duration: '永久',
|
||||||
|
days: -1,
|
||||||
|
price: 888,
|
||||||
|
originalPrice: null,
|
||||||
|
unit: '元',
|
||||||
|
discount: '超值',
|
||||||
|
features: [
|
||||||
|
'永久使用权限',
|
||||||
|
'全功能使用',
|
||||||
|
'终身技术支持',
|
||||||
|
'一次购买,终身使用',
|
||||||
|
'最划算选择'
|
||||||
|
],
|
||||||
|
featured: false
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
return ctx.success(pricingPlans);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取价格套餐失败:', error);
|
||||||
|
return ctx.fail('获取价格套餐失败: ' + error.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user