refactor: 合并档案与实物码管理入口

This commit is contained in:
Nixevol
2026-07-03 04:05:58 +08:00
parent 96552857f6
commit 8d8bf36d08
12 changed files with 610 additions and 561 deletions
@@ -66,7 +66,7 @@ export class QueryTraceCodeDto extends PaginationDto {
@IsInt()
groupId?: number;
@ApiPropertyOptional({ description: '关键词(短码/追溯码/SKU/档案号)' })
@ApiPropertyOptional({ description: '关键词(短码/追溯码/档案号/作品名称)' })
@IsOptional()
@IsString()
keyword?: string;
@@ -117,6 +117,12 @@ export class BatchStatusDto {
}
export class QueryBatchDto extends PaginationDto {
@ApiPropertyOptional({ description: '作品/款式 ID' })
@IsOptional()
@Type(() => Number)
@IsInt()
artworkId?: number;
@ApiPropertyOptional({ description: '关键词(批次编号)' })
@IsOptional()
@IsString()
@@ -38,7 +38,7 @@ export class TraceCodeService {
}
async generateBatch(dto: GenerateBatchDto, userId: number) {
// 必须指定作品(款):生码即归属该款(一款多码)
// 必须指定作品档案/款式;每条 TraceCode 对应一套实物,仍是一物一码。
const artwork = await this.prisma.artwork.findFirst({
where: { id: dto.artworkId, deletedAt: null },
});
@@ -138,6 +138,7 @@ export class TraceCodeService {
async listBatches(query: QueryBatchDto) {
const where: Prisma.BatchWhereInput = {};
if (query.artworkId) where.artworkId = query.artworkId;
if (query.keyword) where.batchNo = { contains: query.keyword };
const [list, total] = await this.prisma.$transaction([
this.prisma.batch.findMany({