feat: 完善档案删除与追溯码筛选

This commit is contained in:
Nixevol
2026-07-04 07:18:52 +08:00
parent e2b54a8027
commit f51f45bcb1
9 changed files with 190 additions and 54 deletions
+11
View File
@@ -170,6 +170,17 @@ export class ArtworkService {
async remove(id: number) {
await this.ensureExists(id);
const [traceCodeCount, queryLogCount] = await this.prisma.$transaction([
this.prisma.traceCode.count({ where: { artworkId: id } }),
this.prisma.queryLog.count({ where: { artworkId: id } }),
]);
if (traceCodeCount > 0 || queryLogCount > 0) {
throw new BusinessException(
ErrorCode.ARTWORK_IN_USE,
'该档案已生成追溯码或存在查询记录,不能删除;请改为停用或归档',
400,
);
}
await this.prisma.artwork.update({ where: { id }, data: { deletedAt: new Date() } });
return { success: true };
}