feat(system): implement dynamic platform configs for customer service, safety notice, and service agreement

这个提交包含在:
xcbyy
2026-10-10 09:47:53 +08:00
父节点 d9c8388711
当前提交 dc19189bc6
共有 10 个文件被更改,包括 613 次插入 和 10 次删除

查看文件

@@ -1247,6 +1247,91 @@ export class MysqlRepository {
return res.affectedRows > 0;
}
// 3. 平台通用配置与指引 (Platform Configs)
async getPlatformConfigs(): Promise<{ [key: string]: any }> {
const [rows]: any = await pool.query(`
SELECT config_key as configKey, name, value_json as valueJson, description, status
FROM platform_configs
WHERE status = 1
`);
const result: { [key: string]: any } = {};
for (const r of rows) {
let val = r.valueJson;
if (typeof val === 'string') {
try {
val = JSON.parse(val);
} catch (_) {}
}
result[r.configKey] = val;
}
return result;
}
async getAdminPlatformConfigs(): Promise<any[]> {
const [rows]: any = await pool.query(`
SELECT id, config_key as configKey, name, value_json as valueJson, description, status,
created_at as createdAt, updated_at as updatedAt
FROM platform_configs
ORDER BY id ASC
`);
return rows.map((r: any) => {
let val = r.valueJson;
if (typeof val === 'string') {
try {
val = JSON.parse(val);
} catch (_) {}
}
return {
...r,
valueJson: val
};
});
}
async updatePlatformConfig(configKey: string, data: { name?: string; valueJson?: any; description?: string; status?: number }): Promise<any> {
const fields: string[] = [];
const values: any[] = [];
if (data.name !== undefined) {
fields.push('name = ?');
values.push(data.name);
}
if (data.valueJson !== undefined) {
fields.push('value_json = ?');
values.push(JSON.stringify(data.valueJson));
}
if (data.description !== undefined) {
fields.push('description = ?');
values.push(data.description);
}
if (data.status !== undefined) {
fields.push('status = ?');
values.push(Number(data.status));
}
if (fields.length > 0) {
values.push(configKey);
await pool.query(`UPDATE platform_configs SET ${fields.join(', ')} WHERE config_key = ?`, values);
}
const [rows]: any = await pool.query(`
SELECT id, config_key as configKey, name, value_json as valueJson, description, status,
created_at as createdAt, updated_at as updatedAt
FROM platform_configs
WHERE config_key = ?
`, [configKey]);
if (!rows || rows.length === 0) return null;
const r = rows[0];
let val = r.valueJson;
if (typeof val === 'string') {
try {
val = JSON.parse(val);
} catch (_) {}
}
return { ...r, valueJson: val };
}
async getArbitrations(): Promise<any[]> {