347 lines
8.9 KiB
Plaintext
347 lines
8.9 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "mysql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
enum RoleType {
|
|
SUPER_ADMIN
|
|
OPERATOR
|
|
AUDITOR
|
|
VIEWER
|
|
}
|
|
|
|
enum UserStatus {
|
|
ACTIVE
|
|
DISABLED
|
|
}
|
|
|
|
enum TemplateStatus {
|
|
ENABLED
|
|
DISABLED
|
|
}
|
|
|
|
enum FieldType {
|
|
TEXT
|
|
NUMBER
|
|
DATE
|
|
IMAGE
|
|
FILE
|
|
LINK
|
|
TEXTAREA
|
|
}
|
|
|
|
enum ArtworkStatus {
|
|
DRAFT
|
|
ACTIVE
|
|
DISABLED
|
|
}
|
|
|
|
enum AuditStatus {
|
|
PENDING
|
|
APPROVED
|
|
REJECTED
|
|
}
|
|
|
|
enum NodeType {
|
|
CREATE
|
|
PRODUCE
|
|
STORAGE
|
|
OUTBOUND
|
|
OTHER
|
|
}
|
|
|
|
enum CertType {
|
|
PHOTO
|
|
CERT
|
|
APPRAISAL
|
|
}
|
|
|
|
enum BatchStatus {
|
|
PENDING
|
|
GENERATING
|
|
DONE
|
|
FAILED
|
|
}
|
|
|
|
enum TraceCodeStatus {
|
|
INACTIVE
|
|
ACTIVE
|
|
DISABLED
|
|
ABNORMAL
|
|
}
|
|
|
|
enum ProofStatus {
|
|
PENDING
|
|
ONCHAIN
|
|
FAILED
|
|
}
|
|
|
|
enum QueryResult {
|
|
FIRST_ACTIVATE
|
|
REPEAT
|
|
INVALID
|
|
DISABLED
|
|
ABNORMAL
|
|
}
|
|
|
|
enum JobType {
|
|
GEN_CODE
|
|
IMPORT_OUTBOUND
|
|
WATERMARK
|
|
ONCHAIN
|
|
}
|
|
|
|
enum JobStatus {
|
|
PENDING
|
|
PROCESSING
|
|
SUCCESS
|
|
PARTIAL
|
|
FAILED
|
|
}
|
|
|
|
model SysUser {
|
|
id Int @id @default(autoincrement())
|
|
username String @unique
|
|
passwordHash String @map("password_hash")
|
|
realName String? @map("real_name")
|
|
role RoleType @default(VIEWER)
|
|
status UserStatus @default(ACTIVE)
|
|
lastLoginAt DateTime? @map("last_login_at")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
artworks Artwork[]
|
|
|
|
@@map("sys_user")
|
|
}
|
|
|
|
model Template {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
remark String?
|
|
status TemplateStatus @default(ENABLED)
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
deletedAt DateTime? @map("deleted_at")
|
|
|
|
fields TemplateField[]
|
|
artworks Artwork[]
|
|
|
|
@@map("template")
|
|
}
|
|
|
|
model TemplateField {
|
|
id Int @id @default(autoincrement())
|
|
templateId Int @map("template_id")
|
|
fieldKey String @map("field_key")
|
|
label String
|
|
type FieldType @default(TEXT)
|
|
required Boolean @default(false)
|
|
sortOrder Int @default(0) @map("sort_order")
|
|
|
|
template Template @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([templateId])
|
|
@@map("template_field")
|
|
}
|
|
|
|
model Artwork {
|
|
id Int @id @default(autoincrement())
|
|
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)
|
|
auditStatus AuditStatus @default(PENDING) @map("audit_status")
|
|
auditRemark String? @map("audit_remark")
|
|
auditedBy Int? @map("audited_by")
|
|
auditedAt DateTime? @map("audited_at")
|
|
createdBy Int? @map("created_by")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
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[]
|
|
|
|
@@index([templateId])
|
|
@@index([status])
|
|
@@index([auditStatus])
|
|
@@map("artwork")
|
|
}
|
|
|
|
model TraceNode {
|
|
id Int @id @default(autoincrement())
|
|
artworkId Int @map("artwork_id")
|
|
nodeType NodeType @default(OTHER) @map("node_type")
|
|
title String
|
|
occurredAt DateTime? @map("occurred_at")
|
|
location String?
|
|
description String? @db.Text
|
|
mediaFiles Json? @map("media_files")
|
|
sortOrder Int @default(0) @map("sort_order")
|
|
|
|
artwork Artwork @relation(fields: [artworkId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([artworkId])
|
|
@@map("trace_node")
|
|
}
|
|
|
|
model Certificate {
|
|
id Int @id @default(autoincrement())
|
|
artworkId Int @map("artwork_id")
|
|
name String
|
|
issuer String?
|
|
issuedAt DateTime? @map("issued_at")
|
|
type CertType @default(CERT)
|
|
originFileUrl String @map("origin_file_url")
|
|
watermarkFileUrl String? @map("watermark_file_url")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
artwork Artwork @relation(fields: [artworkId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([artworkId])
|
|
@@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")
|
|
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")
|
|
}
|
|
|
|
model TraceCode {
|
|
id BigInt @id @default(autoincrement())
|
|
code String @unique
|
|
shortCode String @unique @map("short_code")
|
|
artworkId Int @map("artwork_id")
|
|
batchId Int @map("batch_id")
|
|
groupId Int? @map("group_id")
|
|
outTime DateTime? @map("out_time")
|
|
outImage String? @map("out_image")
|
|
remark String?
|
|
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])
|
|
group TraceCodeGroup? @relation(fields: [groupId], references: [id])
|
|
proofs BlockchainProof[]
|
|
queryLogs QueryLog[]
|
|
|
|
@@index([artworkId])
|
|
@@index([batchId])
|
|
@@index([groupId])
|
|
@@index([status])
|
|
@@map("trace_code")
|
|
}
|
|
|
|
model BlockchainProof {
|
|
id Int @id @default(autoincrement())
|
|
traceCodeId BigInt @map("trace_code_id")
|
|
dataHash String @map("data_hash")
|
|
txHash String? @map("tx_hash")
|
|
blockHash String? @map("block_hash")
|
|
blockHeight BigInt? @map("block_height")
|
|
chainName String? @map("chain_name")
|
|
explorerUrl String? @map("explorer_url")
|
|
onchainAt DateTime? @map("onchain_at")
|
|
status ProofStatus @default(PENDING)
|
|
rawResponse Json? @map("raw_response")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
traceCode TraceCode @relation(fields: [traceCodeId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([traceCodeId])
|
|
@@map("blockchain_proof")
|
|
}
|
|
|
|
model QueryLog {
|
|
id BigInt @id @default(autoincrement())
|
|
traceCodeId BigInt? @map("trace_code_id")
|
|
artworkId Int? @map("artwork_id")
|
|
shortCode String? @map("short_code")
|
|
code String?
|
|
archiveNo String? @map("archive_no")
|
|
batchNo String? @map("batch_no")
|
|
queryCount Int? @map("query_count")
|
|
firstActivatedAt DateTime? @map("first_activated_at")
|
|
queriedAt DateTime @default(now()) @map("queried_at")
|
|
queryResult QueryResult @map("query_result")
|
|
ip String?
|
|
userAgent String? @db.Text @map("user_agent")
|
|
deviceType String? @map("device_type")
|
|
browser String?
|
|
os String?
|
|
|
|
traceCode TraceCode? @relation(fields: [traceCodeId], references: [id])
|
|
|
|
@@index([traceCodeId])
|
|
@@index([queriedAt])
|
|
@@index([archiveNo])
|
|
@@index([batchNo])
|
|
@@map("query_log")
|
|
}
|
|
|
|
model Job {
|
|
id String @id @default(cuid())
|
|
type JobType
|
|
status JobStatus @default(PENDING)
|
|
total Int @default(0)
|
|
successCount Int @default(0) @map("success_count")
|
|
failCount Int @default(0) @map("fail_count")
|
|
resultFileUrl String? @map("result_file_url")
|
|
payload Json?
|
|
error String? @db.Text
|
|
createdBy Int? @map("created_by")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("job")
|
|
}
|
|
|
|
model SystemSetting {
|
|
id Int @id @default(autoincrement())
|
|
key String @unique
|
|
value String @db.Text
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@map("system_setting")
|
|
}
|