fix: 修复出库追溯码默认加载
This commit is contained in:
@@ -9,6 +9,7 @@ import * as QRCode from 'qrcode';
|
||||
import dayjs from 'dayjs';
|
||||
import { ArtworkStatus, ErrorCode, JobType, QUEUE_NAMES, TraceCodeStatus } from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { BusinessException } from '../common/exceptions/business.exception';
|
||||
import { buildPage } from '../common/utils/pagination.util';
|
||||
import { JobsService } from '../jobs/jobs.service';
|
||||
@@ -28,6 +29,7 @@ export class TraceCodeService {
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly jobs: JobsService,
|
||||
private readonly config: ConfigService,
|
||||
private readonly storage: StorageService,
|
||||
@InjectQueue(QUEUE_NAMES.GEN_CODE) private readonly genQueue: Queue,
|
||||
) {}
|
||||
|
||||
@@ -173,6 +175,11 @@ export class TraceCodeService {
|
||||
artwork: { select: { id: true, title: true, archiveNo: true } },
|
||||
batch: { select: { id: true, batchNo: true } },
|
||||
group: { select: { id: true, name: true } },
|
||||
proofs: {
|
||||
where: { status: 'ONCHAIN' },
|
||||
orderBy: [{ onchainAt: 'desc' }, { id: 'desc' }],
|
||||
take: 1,
|
||||
},
|
||||
},
|
||||
orderBy: { id: 'desc' },
|
||||
skip: query.skip,
|
||||
@@ -180,7 +187,19 @@ export class TraceCodeService {
|
||||
}),
|
||||
this.prisma.traceCode.count({ where }),
|
||||
]);
|
||||
return buildPage(list, total, query.page, query.pageSize);
|
||||
return buildPage(
|
||||
list.map((code) => {
|
||||
const { proofs, ...rest } = code;
|
||||
return {
|
||||
...rest,
|
||||
outImageUrl: code.outImage ? this.storage.getUrl(code.outImage) : null,
|
||||
latestProof: proofs[0] ?? null,
|
||||
};
|
||||
}),
|
||||
total,
|
||||
query.page,
|
||||
query.pageSize,
|
||||
);
|
||||
}
|
||||
|
||||
async getQrPng(id: bigint): Promise<Buffer> {
|
||||
|
||||
Reference in New Issue
Block a user