feat: 完善档案删除与追溯码筛选
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user