feat: complete phase2 baseline cdr quality rbac

This commit is contained in:
hectorzhao
2026-06-24 18:40:21 +08:00
parent 7057fd3c42
commit a86de6545f
63 changed files with 7853 additions and 3678 deletions
+171 -45
View File
@@ -37,6 +37,20 @@ enum MatchMode {
@@map("match_mode")
}
enum CustomerGatewayCallerMatchMode {
ANY
PREFIXES
@@map("customer_gateway_caller_match_mode")
}
enum CustomerGatewayCalleeMatchMode {
ANY
BUSINESS_PREFIXES
@@map("customer_gateway_callee_match_mode")
}
enum RechargeStatus {
SUCCEEDED
FAILED
@@ -162,34 +176,116 @@ model Customer {
}
model CustomerGateway {
id String @id @db.VarChar(32)
customerId String @map("customer_id") @db.VarChar(32)
name String @db.VarChar(120)
authMode GatewayAuthMode @map("auth_mode")
sourceIp String? @map("source_ip") @db.VarChar(45)
sipUsername String? @map("sip_username") @db.VarChar(120)
sipDomain String? @map("sip_domain") @db.VarChar(160)
sipHa1 String? @map("sip_ha1") @db.VarChar(128)
status EntityStatus @default(ENABLED)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
createdBy String? @map("created_by") @db.VarChar(32)
updatedBy String? @map("updated_by") @db.VarChar(32)
version Int @default(1)
deletedAt DateTime? @map("deleted_at") @db.DateTime(3)
id String @id @db.VarChar(32)
customerId String @map("customer_id") @db.VarChar(32)
name String @db.VarChar(120)
authMode GatewayAuthMode @map("auth_mode")
sourceIp String? @map("source_ip") @db.VarChar(45)
sipUsername String? @map("sip_username") @db.VarChar(120)
sipDomain String? @map("sip_domain") @db.VarChar(160)
sipHa1 String? @map("sip_ha1") @db.VarChar(128)
lineGroupId String? @map("line_group_id") @db.VarChar(32)
billingCycleSec Int @default(60) @map("billing_cycle_sec")
cycleRate Decimal @default(0) @map("cycle_rate") @db.Decimal(20, 6)
callerMatchMode CustomerGatewayCallerMatchMode @default(ANY) @map("caller_match_mode")
calleeMatchMode CustomerGatewayCalleeMatchMode @default(ANY) @map("callee_match_mode")
status EntityStatus @default(ENABLED)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
createdBy String? @map("created_by") @db.VarChar(32)
updatedBy String? @map("updated_by") @db.VarChar(32)
version Int @default(1)
deletedAt DateTime? @map("deleted_at") @db.DateTime(3)
customer Customer @relation(fields: [customerId], references: [id], onDelete: Restrict)
policies CustomerGatewayPolicy[]
rawCdrs RawCdr[]
customer Customer @relation(fields: [customerId], references: [id], onDelete: Restrict)
lineGroup LandingLineGroup? @relation(fields: [lineGroupId], references: [id], onDelete: Restrict)
ips CustomerGatewayIp[]
businessPrefixes CustomerGatewayBusinessPrefix[]
callerPrefixes CustomerGatewayCallerPrefix[]
policies CustomerGatewayPolicy[]
rawCdrs RawCdr[]
@@unique([customerId, name])
@@unique([sipUsername, sipDomain])
@@index([customerId, status])
@@index([lineGroupId])
@@index([sourceIp])
@@index([deletedAt])
@@map("customer_gateways")
}
model BusinessPrefix {
id String @id @db.VarChar(32)
prefix String @unique @db.VarChar(32)
name String @db.VarChar(120)
description String? @db.VarChar(500)
priority Int @default(100)
status EntityStatus @default(ENABLED)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
createdBy String? @map("created_by") @db.VarChar(32)
updatedBy String? @map("updated_by") @db.VarChar(32)
version Int @default(1)
deletedAt DateTime? @map("deleted_at") @db.DateTime(3)
customerGateways CustomerGatewayBusinessPrefix[]
rawCdrs RawCdr[]
@@index([status, priority])
@@index([deletedAt])
@@map("business_prefixes")
}
model CustomerGatewayIp {
id String @id @db.VarChar(32)
gatewayId String @map("gateway_id") @db.VarChar(32)
sourceIp String @map("source_ip") @db.VarChar(45)
status EntityStatus @default(ENABLED)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
createdBy String? @map("created_by") @db.VarChar(32)
updatedBy String? @map("updated_by") @db.VarChar(32)
version Int @default(1)
deletedAt DateTime? @map("deleted_at") @db.DateTime(3)
gateway CustomerGateway @relation(fields: [gatewayId], references: [id], onDelete: Cascade)
@@unique([gatewayId, sourceIp])
@@index([sourceIp, status])
@@index([deletedAt])
@@map("customer_gateway_ips")
}
model CustomerGatewayBusinessPrefix {
id String @id @db.VarChar(32)
gatewayId String @map("gateway_id") @db.VarChar(32)
businessPrefixId String @map("business_prefix_id") @db.VarChar(32)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
createdBy String? @map("created_by") @db.VarChar(32)
gateway CustomerGateway @relation(fields: [gatewayId], references: [id], onDelete: Cascade)
businessPrefix BusinessPrefix @relation(fields: [businessPrefixId], references: [id], onDelete: Restrict)
@@unique([gatewayId, businessPrefixId])
@@index([businessPrefixId])
@@map("customer_gateway_business_prefixes")
}
model CustomerGatewayCallerPrefix {
id String @id @db.VarChar(32)
gatewayId String @map("gateway_id") @db.VarChar(32)
prefix String @db.VarChar(64)
priority Int @default(100)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
createdBy String? @map("created_by") @db.VarChar(32)
gateway CustomerGateway @relation(fields: [gatewayId], references: [id], onDelete: Cascade)
@@unique([gatewayId, prefix])
@@index([gatewayId, priority])
@@map("customer_gateway_caller_prefixes")
}
model CustomerGatewayPolicy {
id String @id @db.VarChar(32)
customerId String @map("customer_id") @db.VarChar(32)
@@ -287,34 +383,36 @@ model VendorRecharge {
}
model VendorGateway {
id String @id @db.VarChar(32)
vendorId String @map("vendor_id") @db.VarChar(32)
name String @db.VarChar(120)
authMode GatewayAuthMode @map("auth_mode")
host String @db.VarChar(160)
port Int @default(5060)
transport String @default("udp") @db.VarChar(16)
sipUsername String? @map("sip_username") @db.VarChar(120)
sipHa1 String? @map("sip_ha1") @db.VarChar(128)
cpsLimit Int @default(0) @map("cps_limit")
concurrencyLimit Int @default(0) @map("concurrency_limit")
billingCycleSec Int @default(60) @map("billing_cycle_sec")
cycleRate Decimal @default(0) @map("cycle_rate") @db.Decimal(20, 6)
status EntityStatus @default(ENABLED)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
createdBy String? @map("created_by") @db.VarChar(32)
updatedBy String? @map("updated_by") @db.VarChar(32)
version Int @default(1)
deletedAt DateTime? @map("deleted_at") @db.DateTime(3)
id String @id @db.VarChar(32)
vendorId String @map("vendor_id") @db.VarChar(32)
name String @db.VarChar(120)
authMode GatewayAuthMode @map("auth_mode")
host String @db.VarChar(160)
port Int @default(5060)
transport String @default("udp") @db.VarChar(16)
sipUsername String? @map("sip_username") @db.VarChar(120)
sipHa1 String? @map("sip_ha1") @db.VarChar(128)
cpsLimit Int @default(0) @map("cps_limit")
concurrencyLimit Int @default(0) @map("concurrency_limit")
billingCycleSec Int @default(60) @map("billing_cycle_sec")
cycleRate Decimal @default(0) @map("cycle_rate") @db.Decimal(20, 6)
landingCalleePrefix String? @map("landing_callee_prefix") @db.VarChar(64)
status EntityStatus @default(ENABLED)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
createdBy String? @map("created_by") @db.VarChar(32)
updatedBy String? @map("updated_by") @db.VarChar(32)
version Int @default(1)
deletedAt DateTime? @map("deleted_at") @db.DateTime(3)
vendor Vendor @relation(fields: [vendorId], references: [id], onDelete: Restrict)
forbiddenPeriods VendorGatewayForbiddenPeriod[]
blockedRegions VendorGatewayBlockedRegion[]
codecs VendorGatewayCodec[]
prefixRules VendorGatewayPrefixRule[]
lineGroupItems LandingLineGroupItem[]
rawCdrs RawCdr[]
vendor Vendor @relation(fields: [vendorId], references: [id], onDelete: Restrict)
forbiddenPeriods VendorGatewayForbiddenPeriod[]
blockedRegions VendorGatewayBlockedRegion[]
codecs VendorGatewayCodec[]
prefixRules VendorGatewayPrefixRule[]
callerRewritePool VendorGatewayCallerRewrite[]
lineGroupItems LandingLineGroupItem[]
rawCdrs RawCdr[]
@@unique([vendorId, name])
@@index([vendorId, status])
@@ -498,6 +596,26 @@ model VendorGatewayPrefixRule {
@@map("vendor_gateway_prefix_rules")
}
model VendorGatewayCallerRewrite {
id String @id @db.VarChar(32)
vendorGatewayId String @map("vendor_gateway_id") @db.VarChar(32)
caller String @db.VarChar(64)
weight Int @default(1)
status EntityStatus @default(ENABLED)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
createdBy String? @map("created_by") @db.VarChar(32)
updatedBy String? @map("updated_by") @db.VarChar(32)
version Int @default(1)
deletedAt DateTime? @map("deleted_at") @db.DateTime(3)
vendorGateway VendorGateway @relation(fields: [vendorGatewayId], references: [id], onDelete: Cascade)
@@index([vendorGatewayId, status])
@@index([deletedAt])
@@map("vendor_gateway_caller_rewrite_pool")
}
model LandingLineGroup {
id String @id @db.VarChar(32)
name String @unique @db.VarChar(120)
@@ -511,6 +629,7 @@ model LandingLineGroup {
deletedAt DateTime? @map("deleted_at") @db.DateTime(3)
items LandingLineGroupItem[]
gateways CustomerGateway[]
policies CustomerGatewayPolicy[]
rawCdrs RawCdr[]
rules QualitySamplingRule[]
@@ -553,6 +672,9 @@ model RawCdr {
sourceIp String? @map("source_ip") @db.VarChar(45)
caller String @db.VarChar(64)
callee String @db.VarChar(64)
rawCallee String? @map("raw_callee") @db.VarChar(64)
businessPrefixId String? @map("business_prefix_id") @db.VarChar(32)
businessPrefix String? @map("business_prefix") @db.VarChar(32)
calleeCityCode String? @map("callee_city_code") @db.VarChar(12)
calleeCityName String? @map("callee_city_name") @db.VarChar(80)
calleeProvinceName String? @map("callee_province_name") @db.VarChar(80)
@@ -561,6 +683,8 @@ model RawCdr {
vendorId String? @map("vendor_id") @db.VarChar(32)
vendorGatewayId String? @map("vendor_gateway_id") @db.VarChar(32)
lineGroupId String? @map("line_group_id") @db.VarChar(32)
landingCaller String? @map("landing_caller") @db.VarChar(64)
landingCallee String? @map("landing_callee") @db.VarChar(64)
startedAt DateTime @map("started_at") @db.DateTime(3)
answeredAt DateTime? @map("answered_at") @db.DateTime(3)
endedAt DateTime @map("ended_at") @db.DateTime(3)
@@ -577,6 +701,7 @@ model RawCdr {
customer Customer? @relation(fields: [customerId], references: [id], onDelete: SetNull)
customerGateway CustomerGateway? @relation(fields: [customerGatewayId], references: [id], onDelete: SetNull)
customerGatewayPolicy CustomerGatewayPolicy? @relation(fields: [customerGatewayPolicyId], references: [id], onDelete: SetNull)
businessPrefixRef BusinessPrefix? @relation(fields: [businessPrefixId], references: [id], onDelete: SetNull)
vendor Vendor? @relation(fields: [vendorId], references: [id], onDelete: SetNull)
vendorGateway VendorGateway? @relation(fields: [vendorGatewayId], references: [id], onDelete: SetNull)
lineGroup LandingLineGroup? @relation(fields: [lineGroupId], references: [id], onDelete: SetNull)
@@ -588,6 +713,7 @@ model RawCdr {
@@index([vendorId, startedAt])
@@index([calleeCityCode, startedAt])
@@index([calleeOperator, startedAt])
@@index([businessPrefixId, startedAt])
@@index([sipCode])
@@index([ratingStatus])
@@map("raw_cdrs")