feat(system): implement dynamic platform configs for customer service, safety notice, and service agreement
这个提交包含在:
@@ -1051,6 +1051,57 @@ app.delete('/api/admin/coupons/:id', async (req: Request, res: Response) => {
|
||||
}
|
||||
});
|
||||
|
||||
// 3. 平台官方客服、履约公告与规范协议配置接口
|
||||
// 移动端:获取全部有效系统通用配置
|
||||
app.get('/api/system/configs', async (_req: Request, res: Response) => {
|
||||
try {
|
||||
const configs = await repo.getPlatformConfigs();
|
||||
res.json({ code: 20000, data: configs });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ code: 50000, message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// 管理后台:获取全部配置项列表
|
||||
app.get('/api/admin/system/configs', async (_req: Request, res: Response) => {
|
||||
try {
|
||||
const list = await repo.getAdminPlatformConfigs();
|
||||
res.json({ code: 20000, data: list });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ code: 50000, message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// 管理后台:更新指定配置项
|
||||
app.put('/api/admin/system/configs/:key', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const configKey = String(req.params.key);
|
||||
const { name, valueJson, description, status } = req.body;
|
||||
|
||||
// 微信内容安全审查(检查文本内容或字符串化后的配置)
|
||||
const textToCheck = `${name || ''} ${description || ''} ${JSON.stringify(valueJson || '')}`;
|
||||
const sec = contentSecurityService.checkText(textToCheck);
|
||||
if (!sec.pass) {
|
||||
return res.status(400).json({ code: sec.code, message: sec.message });
|
||||
}
|
||||
|
||||
const updated = await repo.updatePlatformConfig(configKey, {
|
||||
name,
|
||||
valueJson,
|
||||
description,
|
||||
status: status !== undefined ? Number(status) : undefined
|
||||
});
|
||||
|
||||
if (!updated) {
|
||||
return res.status(404).json({ code: 40400, message: '配置项不存在' });
|
||||
}
|
||||
|
||||
res.json({ code: 20000, data: updated, message: '系统配置更新成功' });
|
||||
} catch (err: any) {
|
||||
res.status(400).json({ code: 40000, message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// 创建新订单 (落盘 MySQL)
|
||||
app.post('/api/orders', async (req: Request, res: Response) => {
|
||||
try {
|
||||
|
||||
在新工单中引用
屏蔽一个用户