fix: implement channel group routing failover
This commit is contained in:
@@ -4,6 +4,7 @@ import { TenantId } from '../common/tenant-id.decorator';
|
||||
import {
|
||||
CreateBlacklistDto,
|
||||
CreateDrainageFieldDto,
|
||||
CreatePhoneCarrierRuleDto,
|
||||
CreatePhoneSegmentDto,
|
||||
CreateSensitiveWordDto,
|
||||
DictionariesService,
|
||||
@@ -25,6 +26,16 @@ export class DictionariesController {
|
||||
return this.dictionaries.createPhoneSegment(body);
|
||||
}
|
||||
|
||||
@Get('phone-carrier-rules')
|
||||
listPhoneCarrierRules() {
|
||||
return this.dictionaries.listPhoneCarrierRules();
|
||||
}
|
||||
|
||||
@Post('phone-carrier-rules')
|
||||
createPhoneCarrierRule(@Body() body: CreatePhoneCarrierRuleDto) {
|
||||
return this.dictionaries.createPhoneCarrierRule(body);
|
||||
}
|
||||
|
||||
@Get('sensitive-words')
|
||||
listSensitiveWords(@Query('keyword') keyword?: string, @Query('status') status?: string) {
|
||||
return this.dictionaries.listSensitiveWords({ keyword, status });
|
||||
|
||||
@@ -9,6 +9,14 @@ export interface CreatePhoneSegmentDto {
|
||||
city?: string;
|
||||
}
|
||||
|
||||
export interface CreatePhoneCarrierRuleDto {
|
||||
carrier: string;
|
||||
pattern: string;
|
||||
priority?: number;
|
||||
status?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface CreateSensitiveWordDto {
|
||||
word: string;
|
||||
level?: string;
|
||||
@@ -56,6 +64,30 @@ export class DictionariesService {
|
||||
return this.prisma.phoneSegment.create({ data });
|
||||
}
|
||||
|
||||
listPhoneCarrierRules() {
|
||||
return this.prisma.phoneCarrierRule.findMany({ orderBy: [{ priority: 'asc' }, { createdAt: 'desc' }], take: 200 });
|
||||
}
|
||||
|
||||
createPhoneCarrierRule(data: CreatePhoneCarrierRuleDto) {
|
||||
if (!data.carrier || !data.pattern) {
|
||||
throw new BadRequestException('carrier and pattern are required');
|
||||
}
|
||||
try {
|
||||
new RegExp(data.pattern);
|
||||
} catch {
|
||||
throw new BadRequestException('pattern must be a valid regular expression');
|
||||
}
|
||||
return this.prisma.phoneCarrierRule.create({
|
||||
data: {
|
||||
carrier: data.carrier,
|
||||
pattern: data.pattern,
|
||||
priority: data.priority ?? 100,
|
||||
status: data.status ?? 'active',
|
||||
remark: data.remark,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
listSensitiveWords(query: DictionaryListQuery = {}) {
|
||||
return this.prisma.sensitiveWord.findMany({
|
||||
where: {
|
||||
|
||||
Reference in New Issue
Block a user