feat: 追溯码新增分组管理与批量分组/启停接口

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nixevol
2026-06-28 18:28:01 +08:00
co-authored by Cursor
parent a20220ccbc
commit 6578007c9e
6 changed files with 226 additions and 4 deletions
@@ -0,0 +1,18 @@
-- AlterTable
ALTER TABLE `trace_code` ADD COLUMN `group_id` INTEGER NULL;
-- CreateTable
CREATE TABLE `trace_code_group` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL,
`remark` VARCHAR(191) NULL,
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateIndex
CREATE INDEX `trace_code_group_id_idx` ON `trace_code`(`group_id`);
-- AddForeignKey
ALTER TABLE `trace_code` ADD CONSTRAINT `trace_code_group_id_fkey` FOREIGN KEY (`group_id`) REFERENCES `trace_code_group`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+14
View File
@@ -202,6 +202,17 @@ model Certificate {
@@map("certificate")
}
model TraceCodeGroup {
id Int @id @default(autoincrement())
name String
remark String?
createdAt DateTime @default(now()) @map("created_at")
traceCodes TraceCode[]
@@map("trace_code_group")
}
model Batch {
id Int @id @default(autoincrement())
batchNo String @unique @map("batch_no")
@@ -222,6 +233,7 @@ model TraceCode {
shortCode String @unique @map("short_code")
artworkId Int? @unique @map("artwork_id")
batchId Int? @map("batch_id")
groupId Int? @map("group_id")
sku String?
archiveNo String? @map("archive_no")
outTime DateTime? @map("out_time")
@@ -236,10 +248,12 @@ model TraceCode {
artwork Artwork? @relation(fields: [artworkId], references: [id])
batch Batch? @relation(fields: [batchId], references: [id])
group TraceCodeGroup? @relation(fields: [groupId], references: [id])
proofs BlockchainProof[]
queryLogs QueryLog[]
@@index([batchId])
@@index([groupId])
@@index([status])
@@map("trace_code")
}