feat: 重构追溯码及上链出库流程
This commit is contained in:
+190
-47
@@ -82,9 +82,11 @@ enum TraceCodeStatus {
|
||||
|
||||
enum ProofStatus {
|
||||
PENDING
|
||||
SUBMITTING
|
||||
CONFIRMING
|
||||
ONCHAIN
|
||||
FAILED
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
enum QueryResult {
|
||||
@@ -99,6 +101,7 @@ enum JobType {
|
||||
GEN_CODE
|
||||
IMPORT_OUTBOUND
|
||||
IMPORT_OUTBOUND_PREVIEW
|
||||
BATCH_OUTBOUND
|
||||
WATERMARK
|
||||
ONCHAIN
|
||||
BACKUP
|
||||
@@ -113,6 +116,25 @@ enum JobStatus {
|
||||
FAILED
|
||||
}
|
||||
|
||||
enum JobItemStatus {
|
||||
PENDING
|
||||
PROCESSING
|
||||
SUCCESS
|
||||
FAILED
|
||||
SKIPPED
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
enum OnchainChunkStatus {
|
||||
PENDING
|
||||
SUBMITTING
|
||||
CONFIRMING
|
||||
SUCCESS
|
||||
PARTIAL
|
||||
FAILED
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
enum OutboundImportSessionStatus {
|
||||
PARSING
|
||||
READY
|
||||
@@ -148,12 +170,15 @@ model SysUser {
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
artworks Artwork[]
|
||||
operationLogs OperationLog[]
|
||||
outboundImportSessions OutboundImportSession[]
|
||||
backupRecords BackupRecord[]
|
||||
submittedArtworkRevisions ArtworkRevision[] @relation("ArtworkRevisionSubmitter")
|
||||
reviewedArtworkRevisions ArtworkRevision[] @relation("ArtworkRevisionReviewer")
|
||||
artworks Artwork[]
|
||||
operationLogs OperationLog[]
|
||||
outboundImportSessions OutboundImportSession[]
|
||||
backupRecords BackupRecord[]
|
||||
submittedArtworkRevisions ArtworkRevision[] @relation("ArtworkRevisionSubmitter")
|
||||
reviewedArtworkRevisions ArtworkRevision[] @relation("ArtworkRevisionReviewer")
|
||||
createdOutboundRecords OutboundRecord[] @relation("OutboundRecordCreator")
|
||||
updatedOutboundRecords OutboundRecord[] @relation("OutboundRecordUpdater")
|
||||
uploadedOutboundImages OutboundImage[] @relation("OutboundImageUploader")
|
||||
|
||||
@@map("sys_user")
|
||||
}
|
||||
@@ -206,13 +231,14 @@ model Artwork {
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
|
||||
template Template @relation(fields: [templateId], references: [id])
|
||||
creator SysUser? @relation(fields: [createdBy], references: [id])
|
||||
traceNodes TraceNode[]
|
||||
certificates Certificate[]
|
||||
batches Batch[]
|
||||
traceCodes TraceCode[]
|
||||
revisions ArtworkRevision[]
|
||||
template Template @relation(fields: [templateId], references: [id])
|
||||
creator SysUser? @relation(fields: [createdBy], references: [id])
|
||||
traceNodes TraceNode[]
|
||||
certificates Certificate[]
|
||||
batches Batch[]
|
||||
traceCodes TraceCode[]
|
||||
revisions ArtworkRevision[]
|
||||
onchainChunks OnchainChunk[]
|
||||
|
||||
@@index([templateId])
|
||||
@@index([status])
|
||||
@@ -228,7 +254,7 @@ model ArtworkRevision {
|
||||
beforeSnapshot Json @map("before_snapshot")
|
||||
afterSnapshot Json @map("after_snapshot")
|
||||
status ArtworkRevisionStatus @default(PENDING)
|
||||
auditRemark String? @db.Text @map("audit_remark")
|
||||
auditRemark String? @map("audit_remark") @db.Text
|
||||
submittedBy Int? @map("submitted_by")
|
||||
submittedAt DateTime @default(now()) @map("submitted_at")
|
||||
reviewedBy Int? @map("reviewed_by")
|
||||
@@ -309,12 +335,10 @@ model Batch {
|
||||
model TraceCode {
|
||||
id BigInt @id @default(autoincrement())
|
||||
shortCode String @unique @map("short_code")
|
||||
serialNo Int @unique @map("serial_no")
|
||||
artworkId Int @map("artwork_id")
|
||||
batchId Int @map("batch_id")
|
||||
groupId Int? @map("group_id")
|
||||
outTime DateTime? @map("out_time")
|
||||
outImages Json? @map("out_images")
|
||||
remark String?
|
||||
status TraceCodeStatus @default(INACTIVE)
|
||||
queryCount Int @default(0) @map("query_count")
|
||||
firstActivatedAt DateTime? @map("first_activated_at")
|
||||
@@ -327,6 +351,8 @@ model TraceCode {
|
||||
group TraceCodeGroup? @relation(fields: [groupId], references: [id])
|
||||
proofs BlockchainProof[]
|
||||
queryLogs QueryLog[]
|
||||
outbound OutboundRecord?
|
||||
jobItems JobItem[]
|
||||
|
||||
@@index([artworkId])
|
||||
@@index([batchId])
|
||||
@@ -335,12 +361,12 @@ model TraceCode {
|
||||
@@map("trace_code")
|
||||
}
|
||||
|
||||
model TraceCodeDailySequence {
|
||||
dateKey String @id @map("date_key") @db.VarChar(6)
|
||||
nextSeq Int @default(0) @map("next_seq")
|
||||
model TraceCodeSequence {
|
||||
id Int @id
|
||||
nextSeq Int @default(1) @map("next_seq")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@map("trace_code_daily_sequence")
|
||||
@@map("trace_code_sequence")
|
||||
}
|
||||
|
||||
model BlockchainProof {
|
||||
@@ -354,14 +380,23 @@ model BlockchainProof {
|
||||
explorerUrl String? @map("explorer_url")
|
||||
tokenId BigInt? @map("token_id")
|
||||
contractAddress String? @map("contract_address")
|
||||
submittedAt DateTime? @map("submitted_at")
|
||||
onchainAt DateTime? @map("onchain_at")
|
||||
status ProofStatus @default(PENDING)
|
||||
onchainChunkId String? @map("onchain_chunk_id")
|
||||
failureReason String? @map("failure_reason") @db.Text
|
||||
lastSyncedAt DateTime? @map("last_synced_at")
|
||||
rawResponse Json? @map("raw_response")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
traceCode TraceCode @relation(fields: [traceCodeId], references: [id], onDelete: Cascade)
|
||||
traceCode TraceCode @relation(fields: [traceCodeId], references: [id], onDelete: Restrict)
|
||||
onchainChunk OnchainChunk? @relation(fields: [onchainChunkId], references: [id], onDelete: SetNull)
|
||||
jobItems JobItem[]
|
||||
|
||||
@@index([traceCodeId])
|
||||
@@unique([traceCodeId])
|
||||
@@index([status])
|
||||
@@index([onchainChunkId])
|
||||
@@map("blockchain_proof")
|
||||
}
|
||||
|
||||
@@ -377,7 +412,7 @@ model QueryLog {
|
||||
queriedAt DateTime @default(now()) @map("queried_at")
|
||||
queryResult QueryResult @map("query_result")
|
||||
ip String?
|
||||
userAgent String? @db.Text @map("user_agent")
|
||||
userAgent String? @map("user_agent") @db.Text
|
||||
deviceType String? @map("device_type")
|
||||
browser String?
|
||||
os String?
|
||||
@@ -405,26 +440,134 @@ model Job {
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
items JobItem[]
|
||||
onchainChunks OnchainChunk[]
|
||||
|
||||
@@index([type])
|
||||
@@index([status])
|
||||
@@map("job")
|
||||
}
|
||||
|
||||
model JobItem {
|
||||
id BigInt @id @default(autoincrement())
|
||||
jobId String @map("job_id")
|
||||
traceCodeId BigInt? @map("trace_code_id")
|
||||
selectionKey String @map("selection_key")
|
||||
proofId Int? @map("proof_id")
|
||||
chunkId String? @map("chunk_id")
|
||||
sequence Int @default(0)
|
||||
shortCode String @map("short_code")
|
||||
status JobItemStatus @default(PENDING)
|
||||
payload Json?
|
||||
result Json?
|
||||
error String? @db.Text
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
|
||||
traceCode TraceCode? @relation(fields: [traceCodeId], references: [id], onDelete: Restrict)
|
||||
proof BlockchainProof? @relation(fields: [proofId], references: [id], onDelete: SetNull)
|
||||
chunk OnchainChunk? @relation(fields: [chunkId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@unique([jobId, selectionKey])
|
||||
@@index([jobId, status])
|
||||
@@index([chunkId, status])
|
||||
@@index([traceCodeId])
|
||||
@@index([proofId])
|
||||
@@map("job_item")
|
||||
}
|
||||
|
||||
model OnchainChunk {
|
||||
id String @id @default(cuid())
|
||||
jobId String @map("job_id")
|
||||
artworkId Int @map("artwork_id")
|
||||
sequenceNo Int @map("sequence_no")
|
||||
status OnchainChunkStatus @default(PENDING)
|
||||
operateId String @unique @map("operate_id") @db.VarChar(20)
|
||||
runToken String? @map("run_token")
|
||||
productIds Json @map("product_ids")
|
||||
metadataSnapshot Json @map("metadata_snapshot")
|
||||
requestPayload Json @map("request_payload")
|
||||
response Json?
|
||||
txHash String? @map("tx_hash")
|
||||
contractAddress String? @map("contract_address")
|
||||
baseTokenId BigInt? @map("base_token_id")
|
||||
failureReason String? @map("failure_reason") @db.Text
|
||||
attemptCount Int @default(0) @map("attempt_count")
|
||||
submittedAt DateTime? @map("submitted_at")
|
||||
unknownAt DateTime? @map("unknown_at")
|
||||
confirmedAt DateTime? @map("confirmed_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
|
||||
artwork Artwork @relation(fields: [artworkId], references: [id], onDelete: Restrict)
|
||||
proofs BlockchainProof[]
|
||||
items JobItem[]
|
||||
|
||||
@@unique([jobId, sequenceNo])
|
||||
@@index([status])
|
||||
@@index([status, updatedAt])
|
||||
@@index([artworkId])
|
||||
@@map("onchain_chunk")
|
||||
}
|
||||
|
||||
model OutboundRecord {
|
||||
id BigInt @id @default(autoincrement())
|
||||
traceCodeId BigInt @unique @map("trace_code_id")
|
||||
outTime DateTime @map("out_time")
|
||||
remark String? @db.Text
|
||||
createdBy Int? @map("created_by")
|
||||
updatedBy Int? @map("updated_by")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
traceCode TraceCode @relation(fields: [traceCodeId], references: [id], onDelete: Restrict)
|
||||
creator SysUser? @relation("OutboundRecordCreator", fields: [createdBy], references: [id], onDelete: SetNull)
|
||||
updater SysUser? @relation("OutboundRecordUpdater", fields: [updatedBy], references: [id], onDelete: SetNull)
|
||||
images OutboundImage[]
|
||||
|
||||
@@index([outTime])
|
||||
@@map("outbound_record")
|
||||
}
|
||||
|
||||
model OutboundImage {
|
||||
id BigInt @id @default(autoincrement())
|
||||
outboundRecordId BigInt @map("outbound_record_id")
|
||||
fileKey String @unique @map("file_key") @db.VarChar(512)
|
||||
fileName String @map("file_name")
|
||||
mimeType String @map("mime_type")
|
||||
size BigInt
|
||||
width Int
|
||||
height Int
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdBy Int? @map("created_by")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
outboundRecord OutboundRecord @relation(fields: [outboundRecordId], references: [id], onDelete: Cascade)
|
||||
uploader SysUser? @relation("OutboundImageUploader", fields: [createdBy], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([outboundRecordId, sortOrder])
|
||||
@@map("outbound_image")
|
||||
}
|
||||
|
||||
model OperationLog {
|
||||
id BigInt @id @default(autoincrement())
|
||||
userId Int? @map("user_id")
|
||||
id BigInt @id @default(autoincrement())
|
||||
userId Int? @map("user_id")
|
||||
username String?
|
||||
role RoleType?
|
||||
module String
|
||||
action String
|
||||
method String
|
||||
path String @db.VarChar(512)
|
||||
targetId String? @map("target_id")
|
||||
path String @db.VarChar(512)
|
||||
targetId String? @map("target_id")
|
||||
status String
|
||||
message String? @db.Text
|
||||
message String? @db.Text
|
||||
ip String?
|
||||
userAgent String? @db.Text @map("user_agent")
|
||||
durationMs Int? @map("duration_ms")
|
||||
requestSummary Json? @map("request_summary")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
userAgent String? @map("user_agent") @db.Text
|
||||
durationMs Int? @map("duration_ms")
|
||||
requestSummary Json? @map("request_summary")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
user SysUser? @relation(fields: [userId], references: [id])
|
||||
|
||||
@@ -455,7 +598,7 @@ model OutboundImportSession {
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
creator SysUser? @relation(fields: [createdBy], references: [id])
|
||||
creator SysUser? @relation(fields: [createdBy], references: [id])
|
||||
rows OutboundImportRow[]
|
||||
|
||||
@@index([status])
|
||||
@@ -465,19 +608,19 @@ model OutboundImportSession {
|
||||
}
|
||||
|
||||
model OutboundImportRow {
|
||||
id BigInt @id @default(autoincrement())
|
||||
sessionId String @map("session_id")
|
||||
rowNo Int @map("row_no")
|
||||
status OutboundImportRowStatus @default(INVALID)
|
||||
shortCode String? @map("short_code")
|
||||
batchNo String? @map("batch_no")
|
||||
outTime DateTime? @map("out_time")
|
||||
outImagePaths Json? @map("out_image_paths")
|
||||
outImageKeys Json? @map("out_image_keys")
|
||||
remark String?
|
||||
reason String? @db.Text
|
||||
preview Json?
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
id BigInt @id @default(autoincrement())
|
||||
sessionId String @map("session_id")
|
||||
rowNo Int @map("row_no")
|
||||
status OutboundImportRowStatus @default(INVALID)
|
||||
shortCode String? @map("short_code")
|
||||
batchNo String? @map("batch_no")
|
||||
outTime DateTime? @map("out_time")
|
||||
outImagePaths Json? @map("out_image_paths")
|
||||
outImageKeys Json? @map("out_image_keys")
|
||||
remark String?
|
||||
reason String? @db.Text
|
||||
preview Json?
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
session OutboundImportSession @relation(fields: [sessionId], references: [id], onDelete: Cascade)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user