feat: 增强追溯码单码管理
This commit is contained in:
@@ -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 },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user