feat(safety): add expert skill tags and price range constraints configuration

这个提交包含在:
xcbyy
2026-10-10 13:56:38 +08:00
父节点 2e726e125d
当前提交 d7f5c31762
共有 5 个文件被更改,包括 351 次插入 和 5 次删除

查看文件

@@ -431,11 +431,20 @@ export class MysqlRepository {
hourly_rate as hourlyRate, voice_duration as voiceDuration,
voice_title as voiceTitle, rating, order_count as orderCount,
status, audit_status as auditStatus, id_card_masked as idCardMasked,
apply_time as applyTime
tags, apply_time as applyTime
FROM companions
ORDER BY id ASC
`);
return rows;
return rows.map((r: any) => {
let tagsArr = [];
try {
tagsArr = typeof r.tags === 'string' ? JSON.parse(r.tags) : (r.tags || []);
} catch (_) {}
return {
...r,
tags: tagsArr
};
});
}
async getCompanionById(id: number | string): Promise<any> {
@@ -453,6 +462,17 @@ export class MysqlRepository {
const c = rows[0];
const game = c.track === 'OFFLINE_MEAL' ? '美食陪吃' : (c.track === 'OFFLINE_SING' ? '同城陪唱' : (c.track === 'OFFLINE_DRINK' ? '下午茶陪喝' : (c.track === 'OFFLINE_PLAY' ? '同城陪玩' : (c.game || '同城生活陪伴'))));
const price = Number(c.hourly_rate) || 68;
let parsedTags = ['高颜值', '性格好', '秒回消息', '文明健康'];
if (c.tags) {
try {
const t = typeof c.tags === 'string' ? JSON.parse(c.tags) : c.tags;
if (Array.isArray(t) && t.length > 0) {
parsedTags = t;
}
} catch (_) {}
}
return {
id: String(c.id),
nickname: c.name,
@@ -473,7 +493,7 @@ export class MysqlRepository {
voiceType: 'voice',
voiceTitle: c.voice_title || '语音招呼',
bio: '专业同城生活陪伴,热情礼貌,守时诚信。',
tags: ['高颜值', '性格好', '秒回消息', '文明健康'],
tags: parsedTags,
photos: [
c.avatar || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=400',
'https://images.unsplash.com/photo-1517841905240-472988babdf9?w=400',
@@ -500,6 +520,34 @@ export class MysqlRepository {
};
}
async updateCompanionProfile(id: number | string, data: { hourlyRate?: number; tags?: string[]; rankName?: string; status?: string }): Promise<any> {
const fields: string[] = [];
const values: any[] = [];
if (data.hourlyRate !== undefined) {
fields.push('hourly_rate = ?');
values.push(Number(data.hourlyRate));
}
if (data.tags !== undefined) {
fields.push('tags = ?');
values.push(JSON.stringify(data.tags));
}
if (data.rankName !== undefined) {
fields.push('rank_name = ?');
values.push(data.rankName);
}
if (data.status !== undefined) {
fields.push('status = ?');
values.push(data.status);
}
if (fields.length > 0) {
values.push(id);
await pool.query(`UPDATE companions SET ${fields.join(', ')} WHERE id = ?`, values);
}
return this.getCompanionById(id);
}
async auditCompanion(id: number, action: 'approve' | 'reject', reason?: string): Promise<any> {
const auditStatus = action === 'approve' ? '已通过' : '已驳回';