refactor: 按甲方确认重构为一款多码(档案编号标识款、批次码、按款统计)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nixevol
2026-06-30 12:02:44 +08:00
co-authored by Cursor
parent 67c5887f8f
commit a16e6f1165
34 changed files with 445 additions and 353 deletions
+13 -11
View File
@@ -68,7 +68,6 @@ enum BatchStatus {
}
enum TraceCodeStatus {
UNBOUND
INACTIVE
ACTIVE
DISABLED
@@ -155,6 +154,7 @@ model Artwork {
templateId Int @map("template_id")
title String
artist String?
archiveNo String? @unique @map("archive_no")
dynamicFields Json? @map("dynamic_fields")
images Json?
status ArtworkStatus @default(DRAFT)
@@ -171,7 +171,8 @@ model Artwork {
creator SysUser? @relation(fields: [createdBy], references: [id])
traceNodes TraceNode[]
certificates Certificate[]
traceCode TraceCode?
batches Batch[]
traceCodes TraceCode[]
@@index([templateId])
@@index([status])
@@ -227,14 +228,17 @@ model TraceCodeGroup {
model Batch {
id Int @id @default(autoincrement())
batchNo String @unique @map("batch_no")
artworkId Int @map("artwork_id")
quantity Int
generatedCount Int @default(0) @map("generated_count")
status BatchStatus @default(PENDING)
createdBy Int? @map("created_by")
createdAt DateTime @default(now()) @map("created_at")
artwork Artwork @relation(fields: [artworkId], references: [id])
traceCodes TraceCode[]
@@index([artworkId])
@@map("batch")
}
@@ -242,27 +246,26 @@ model TraceCode {
id BigInt @id @default(autoincrement())
code String @unique
shortCode String @unique @map("short_code")
artworkId Int? @unique @map("artwork_id")
batchId Int? @map("batch_id")
artworkId Int @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")
outImage String? @map("out_image")
remark String?
status TraceCodeStatus @default(UNBOUND)
status TraceCodeStatus @default(INACTIVE)
queryCount Int @default(0) @map("query_count")
firstActivatedAt DateTime? @map("first_activated_at")
lastQueriedAt DateTime? @map("last_queried_at")
url String?
createdAt DateTime @default(now()) @map("created_at")
artwork Artwork? @relation(fields: [artworkId], references: [id])
batch Batch? @relation(fields: [batchId], references: [id])
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([artworkId])
@@index([batchId])
@@index([groupId])
@@index([status])
@@ -295,7 +298,6 @@ model QueryLog {
artworkId Int? @map("artwork_id")
shortCode String? @map("short_code")
code String?
sku String?
archiveNo String? @map("archive_no")
batchNo String? @map("batch_no")
queryCount Int? @map("query_count")
@@ -313,7 +315,7 @@ model QueryLog {
@@index([traceCodeId])
@@index([queriedAt])
@@index([sku])
@@index([archiveNo])
@@index([batchNo])
@@map("query_log")
}