fix: harden admin and CMPP delivery workflows
This commit is contained in:
@@ -97,6 +97,10 @@ export class DictionariesService {
|
||||
return this.prisma.phoneSegment.create({ data });
|
||||
}
|
||||
|
||||
deletePhoneSegment(id: string) {
|
||||
return this.prisma.phoneSegment.delete({ where: { id } });
|
||||
}
|
||||
|
||||
async listPhoneCarrierRules(query: PageQuery = {}) {
|
||||
const page = Math.max(1, Number(query.page ?? 1));
|
||||
const pageSize = Math.min(100, Math.max(1, Number(query.pageSize ?? 25)));
|
||||
@@ -258,8 +262,12 @@ export class DictionariesService {
|
||||
return updated;
|
||||
}
|
||||
|
||||
listDrainageFields() {
|
||||
return this.prisma.drainageField.findMany({ orderBy: { createdAt: 'desc' } });
|
||||
async listDrainageFields() {
|
||||
const fields = await this.prisma.drainageField.findMany({
|
||||
include: { _count: { select: { channelReportFields: true } } },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
return fields.map(({ _count, ...field }) => ({ ...field, usageCount: _count.channelReportFields }));
|
||||
}
|
||||
|
||||
createDrainageField(data: CreateDrainageFieldDto) {
|
||||
@@ -282,6 +290,14 @@ export class DictionariesService {
|
||||
});
|
||||
}
|
||||
|
||||
async deleteDrainageField(id: string) {
|
||||
const usageCount = await this.prisma.channelReportField.count({ where: { drainageFieldId: id } });
|
||||
if (usageCount > 0) {
|
||||
throw new BadRequestException(`该字段已被 ${usageCount} 个通道使用,不能删除`);
|
||||
}
|
||||
return this.prisma.drainageField.delete({ where: { id } });
|
||||
}
|
||||
|
||||
private writeOperationLog(userId: string | undefined, action: string, resource: string, resourceId: string, detail: Record<string, unknown>) {
|
||||
return this.prisma.operationLog.create({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user