feat: 增强追溯码单码管理

This commit is contained in:
Nixevol
2026-07-04 05:38:58 +08:00
parent 79bd6270c0
commit a1120848e9
10 changed files with 222 additions and 9 deletions
+3 -2
View File
@@ -112,9 +112,10 @@ export class ArtworkService {
});
if (!a) throw new BusinessException(ErrorCode.ARTWORK_NOT_FOUND, '艺术品不存在', 404);
// 码统计:总数、已激活数、查询总次数(按款聚合)
const [total, active, agg] = await this.prisma.$transaction([
const [total, active, batchTotal, agg] = await this.prisma.$transaction([
this.prisma.traceCode.count({ where: { artworkId: id } }),
this.prisma.traceCode.count({ where: { artworkId: id, status: 'ACTIVE' } }),
this.prisma.batch.count({ where: { artworkId: id } }),
this.prisma.traceCode.aggregate({ where: { artworkId: id }, _sum: { queryCount: true } }),
]);
return {
@@ -126,7 +127,7 @@ export class ArtworkService {
originUrl: c.originFileUrl ? this.storage.getUrl(c.originFileUrl) : null,
watermarkUrl: c.watermarkFileUrl ? this.storage.getUrl(c.watermarkFileUrl) : null,
})),
codeStats: { total, active, queryTotal: agg._sum.queryCount ?? 0 },
codeStats: { total, active, batchTotal, queryTotal: agg._sum.queryCount ?? 0 },
};
}