feat: 作品页支持模块化编排与自定义内容模块
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `template`
|
||||
ADD COLUMN `default_trace_layout` JSON NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `artwork`
|
||||
ADD COLUMN `trace_layout` JSON NULL;
|
||||
@@ -184,13 +184,14 @@ model SysUser {
|
||||
}
|
||||
|
||||
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")
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
remark String?
|
||||
defaultTraceLayout Json? @map("default_trace_layout")
|
||||
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[]
|
||||
@@ -222,6 +223,7 @@ model Artwork {
|
||||
dynamicFields Json? @map("dynamic_fields")
|
||||
images Json?
|
||||
showcaseImages Json? @map("showcase_images")
|
||||
traceLayout Json? @map("trace_layout")
|
||||
showOutboundTimeline Boolean @default(false) @map("show_outbound_timeline")
|
||||
status ArtworkStatus @default(DRAFT)
|
||||
auditStatus AuditStatus @default(PENDING) @map("audit_status")
|
||||
|
||||
@@ -5,6 +5,7 @@ import { dirname, join, resolve } from 'path';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
import { randomBytes, randomInt, createHash } from 'crypto';
|
||||
import sharp from 'sharp';
|
||||
import { createDefaultTraceLayout } from '@artveris/shared';
|
||||
import { addWatermark } from '../src/certificate/watermark.util';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
@@ -24,6 +25,41 @@ const DEFAULT_TEMPLATE_FIELDS = [
|
||||
{ fieldKey: 'dataOwner', label: '数据权属', type: 'TEXT', required: false, sortOrder: 5 },
|
||||
] as const;
|
||||
|
||||
function sampleTraceLayout(
|
||||
index: number,
|
||||
introImage: { key: string; name: string; type: string },
|
||||
galleryItems: Array<{ key: string; name: string; description: string; type: string }>,
|
||||
) {
|
||||
const layout = createDefaultTraceLayout();
|
||||
const authenticity = layout.modules.find((module) => module.type === 'AUTHENTICITY_STATUS');
|
||||
return {
|
||||
...layout,
|
||||
modules: [
|
||||
...layout.modules.filter((module) => module.type !== 'AUTHENTICITY_STATUS'),
|
||||
{
|
||||
id: `seed-image-text-${index + 1}`,
|
||||
type: 'IMAGE_TEXT',
|
||||
visible: true,
|
||||
title: '创作说明',
|
||||
config: {
|
||||
heading: '匠心创作',
|
||||
body: '作品从构思、选材到成型均由艺术家全程把控,保留手工创作的独特痕迹。',
|
||||
imagePosition: index % 2 === 0 ? 'LEFT' : 'RIGHT',
|
||||
image: introImage,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: `seed-gallery-${index + 1}`,
|
||||
type: 'HORIZONTAL_GALLERY',
|
||||
visible: true,
|
||||
title: '多角度鉴赏',
|
||||
config: { items: galleryItems },
|
||||
},
|
||||
...(authenticity ? [authenticity] : []),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function writeStorage(key: string, buf: Buffer): string {
|
||||
const full = join(storageDir, key);
|
||||
mkdirSync(dirname(full), { recursive: true });
|
||||
@@ -107,6 +143,12 @@ async function ensureSampleData(): Promise<void> {
|
||||
const existing = await prisma.template.findFirst({ where: { name: '陶瓷溯源模板' } });
|
||||
if (existing) {
|
||||
await ensureTemplateDefaultFields(existing.id);
|
||||
if (!existing.defaultTraceLayout) {
|
||||
await prisma.template.update({
|
||||
where: { id: existing.id },
|
||||
data: { defaultTraceLayout: createDefaultTraceLayout() as any },
|
||||
});
|
||||
}
|
||||
console.log('示例数据已存在,跳过。');
|
||||
return;
|
||||
}
|
||||
@@ -117,6 +159,7 @@ async function ensureSampleData(): Promise<void> {
|
||||
data: {
|
||||
name: '陶瓷溯源模板',
|
||||
remark: '适用于陶瓷类艺术品',
|
||||
defaultTraceLayout: createDefaultTraceLayout() as any,
|
||||
fields: {
|
||||
create: DEFAULT_TEMPLATE_FIELDS.map((field) => ({ ...field })),
|
||||
},
|
||||
@@ -195,6 +238,11 @@ async function ensureSampleData(): Promise<void> {
|
||||
{ key: img2, name: '细节' },
|
||||
],
|
||||
showcaseImages,
|
||||
traceLayout: sampleTraceLayout(
|
||||
artworkSeq,
|
||||
{ key: img2, name: '创作细节', type: 'image' },
|
||||
showcaseImages,
|
||||
) as any,
|
||||
traceNodes: {
|
||||
create: [
|
||||
{ nodeType: 'CREATE', title: '创作设计', location: '景德镇', description: '设计选胚,确定器型与纹样。', sortOrder: 0, mediaFiles: createMedia },
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { ArtworkRevisionStatus, ArtworkStatus, AuditStatus, RoleType } from '@artveris/shared';
|
||||
import {
|
||||
ArtworkRevisionStatus,
|
||||
ArtworkStatus,
|
||||
AuditStatus,
|
||||
createDefaultTraceLayout,
|
||||
RoleType,
|
||||
} from '@artveris/shared';
|
||||
import type { AuthUser } from '../common/decorators/current-user.decorator';
|
||||
import { CertificateController } from '../certificate/certificate.controller';
|
||||
import { TraceNodeController } from '../trace-node/trace-node.controller';
|
||||
@@ -9,7 +15,7 @@ function user(role: RoleType, id = 9): AuthUser {
|
||||
return { id, username: role.toLowerCase(), role };
|
||||
}
|
||||
|
||||
function createHarness() {
|
||||
function createHarness(template: any = { id: 1 }) {
|
||||
const tx = {
|
||||
artwork: {
|
||||
create: jest.fn().mockImplementation(({ data }) => ({
|
||||
@@ -22,6 +28,7 @@ function createHarness() {
|
||||
dynamicFields: data.dynamicFields,
|
||||
images: data.images,
|
||||
showcaseImages: data.showcaseImages,
|
||||
traceLayout: data.traceLayout,
|
||||
showOutboundTimeline: data.showOutboundTimeline,
|
||||
traceNodes: [],
|
||||
certificates: [],
|
||||
@@ -33,7 +40,7 @@ function createHarness() {
|
||||
},
|
||||
};
|
||||
const prisma = {
|
||||
template: { findFirst: jest.fn().mockResolvedValue({ id: 1 }) },
|
||||
template: { findFirst: jest.fn().mockResolvedValue(template) },
|
||||
$transaction: jest.fn().mockImplementation(async (callback: any) => callback(tx)),
|
||||
};
|
||||
const service = new ArtworkService(prisma as any, {} as any, {} as any);
|
||||
@@ -150,6 +157,51 @@ it('stores showcase images in the artwork and its initial revision snapshot', as
|
||||
).toEqual(showcaseImages);
|
||||
});
|
||||
|
||||
it('deep-copies the template layout into a new artwork and its initial revision', async () => {
|
||||
const defaultTraceLayout = createDefaultTraceLayout();
|
||||
defaultTraceLayout.modules.push({
|
||||
id: 'custom-intro',
|
||||
type: 'IMAGE_TEXT',
|
||||
visible: true,
|
||||
title: '创作说明',
|
||||
config: { imagePosition: 'LEFT' },
|
||||
});
|
||||
const { service, tx } = createHarness({ id: 1, defaultTraceLayout });
|
||||
|
||||
await service.create(
|
||||
{ templateId: 1, title: '使用模板布局的作品', status: ArtworkStatus.ACTIVE } as any,
|
||||
user(RoleType.SUPER_ADMIN),
|
||||
);
|
||||
|
||||
const stored = tx.artwork.create.mock.calls[0][0].data.traceLayout;
|
||||
const snapshotted =
|
||||
tx.artworkRevision.create.mock.calls[0][0].data.afterSnapshot.artwork.traceLayout;
|
||||
expect(stored).toEqual(defaultTraceLayout);
|
||||
expect(stored).not.toBe(defaultTraceLayout);
|
||||
expect(snapshotted).toEqual(defaultTraceLayout);
|
||||
stored.modules[0].visible = false;
|
||||
expect(defaultTraceLayout.modules[0].visible).toBe(true);
|
||||
});
|
||||
|
||||
it('rejects an invalid layout before creating an artwork', async () => {
|
||||
const { service, tx } = createHarness();
|
||||
const invalid = createDefaultTraceLayout();
|
||||
invalid.modules.push({ ...invalid.modules[0] });
|
||||
|
||||
await expect(
|
||||
service.create(
|
||||
{
|
||||
templateId: 1,
|
||||
title: '非法布局',
|
||||
status: ArtworkStatus.ACTIVE,
|
||||
traceLayout: invalid,
|
||||
} as any,
|
||||
user(RoleType.SUPER_ADMIN),
|
||||
),
|
||||
).rejects.toThrow('页面模块配置无效');
|
||||
expect(tx.artwork.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
function updateHarness() {
|
||||
const current = {
|
||||
artwork: {
|
||||
@@ -289,6 +341,32 @@ describe('ArtworkService.update approval policy', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('applies a super-admin module layout change immediately', async () => {
|
||||
const { service, tx, applySnapshot } = updateHarness();
|
||||
const traceLayout = createDefaultTraceLayout();
|
||||
const authenticity = traceLayout.modules.find(
|
||||
(module) => module.type === 'AUTHENTICITY_STATUS',
|
||||
)!;
|
||||
traceLayout.modules = [
|
||||
...traceLayout.modules.filter((module) => module !== authenticity),
|
||||
{ ...authenticity, title: '真伪核验' },
|
||||
];
|
||||
|
||||
await service.update(7, { traceLayout } as any, user(RoleType.SUPER_ADMIN));
|
||||
|
||||
expect(
|
||||
tx.artworkRevision.create.mock.calls[0][0].data.afterSnapshot.artwork.traceLayout,
|
||||
).toEqual(traceLayout);
|
||||
expect(applySnapshot).toHaveBeenCalledWith(
|
||||
tx,
|
||||
7,
|
||||
expect.objectContaining({
|
||||
artwork: expect.objectContaining({ traceLayout }),
|
||||
}),
|
||||
expect.objectContaining({ auditStatus: AuditStatus.APPROVED, auditedBy: 9 }),
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps an operator revision pending and does not overwrite an approved formal version', async () => {
|
||||
const { service, tx, applySnapshot } = updateHarness();
|
||||
|
||||
@@ -327,6 +405,22 @@ describe('ArtworkService.update approval policy', () => {
|
||||
expect(applySnapshot).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('keeps an operator module layout change only in the pending snapshot', async () => {
|
||||
const { service, tx, applySnapshot } = updateHarness();
|
||||
const traceLayout = createDefaultTraceLayout();
|
||||
traceLayout.modules[1] = { ...traceLayout.modules[1], visible: false };
|
||||
|
||||
await service.update(7, { traceLayout } as any, user(RoleType.OPERATOR));
|
||||
|
||||
expect(
|
||||
tx.artworkRevision.create.mock.calls[0][0].data.afterSnapshot.artwork.traceLayout,
|
||||
).toEqual(traceLayout);
|
||||
expect(tx.artworkRevision.create.mock.calls[0][0].data.status).toBe(
|
||||
ArtworkRevisionStatus.PENDING,
|
||||
);
|
||||
expect(applySnapshot).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('treats a legacy snapshot without showcase images as an empty list', async () => {
|
||||
const { service, tx } = updateHarness();
|
||||
|
||||
@@ -456,6 +550,93 @@ describe('ArtworkService.audit approval boundary', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('ArtworkService trace module compatibility and media', () => {
|
||||
it('does not overwrite the current layout when applying a historical snapshot without one', async () => {
|
||||
const tx = {
|
||||
artwork: { update: jest.fn().mockResolvedValue(undefined) },
|
||||
traceNode: { deleteMany: jest.fn().mockResolvedValue({ count: 0 }) },
|
||||
certificate: { findMany: jest.fn().mockResolvedValue([]), deleteMany: jest.fn() },
|
||||
};
|
||||
const service = new ArtworkService({} as any, {} as any, {} as any);
|
||||
|
||||
await (service as any).applySnapshot(
|
||||
tx,
|
||||
7,
|
||||
{
|
||||
artwork: {
|
||||
templateId: 1,
|
||||
title: '历史快照',
|
||||
artist: null,
|
||||
status: ArtworkStatus.ACTIVE,
|
||||
dynamicFields: {},
|
||||
images: [],
|
||||
showcaseImages: [],
|
||||
showOutboundTimeline: false,
|
||||
},
|
||||
traceNodes: [],
|
||||
certificates: [],
|
||||
},
|
||||
{
|
||||
auditStatus: AuditStatus.APPROVED,
|
||||
auditRemark: null,
|
||||
auditedBy: 12,
|
||||
auditedAt: new Date(),
|
||||
},
|
||||
);
|
||||
|
||||
expect(tx.artwork.update.mock.calls[0][0].data.traceLayout).toBeUndefined();
|
||||
});
|
||||
|
||||
it('relocates image-text and horizontal-gallery media into the artwork directory', async () => {
|
||||
let sequence = 0;
|
||||
const storage = {
|
||||
sanitizeSegment: jest.fn((value: string) => value),
|
||||
relocateMedia: jest.fn(async (items: any[], dir: string) => {
|
||||
const mapped = items.map((item) => ({
|
||||
...item,
|
||||
key: `${dir}/module-${++sequence}.jpg`,
|
||||
}));
|
||||
return {
|
||||
items: mapped,
|
||||
changed: mapped.length > 0,
|
||||
keyMap: new Map(items.map((item, index) => [item.key, mapped[index].key])),
|
||||
};
|
||||
}),
|
||||
};
|
||||
const service = new ArtworkService({} as any, storage as any, {} as any);
|
||||
const layout = createDefaultTraceLayout();
|
||||
layout.modules.push(
|
||||
{
|
||||
id: 'custom-image',
|
||||
type: 'IMAGE_TEXT',
|
||||
visible: true,
|
||||
config: { imagePosition: 'TOP', image: { key: 'uploads/intro.jpg', type: 'image' } },
|
||||
},
|
||||
{
|
||||
id: 'custom-gallery',
|
||||
type: 'HORIZONTAL_GALLERY',
|
||||
visible: true,
|
||||
config: { items: [{ key: 'uploads/gallery.jpg', type: 'image' }] },
|
||||
},
|
||||
);
|
||||
|
||||
const result = await (service as any).relocateTraceLayoutMedia(
|
||||
layout,
|
||||
'1/ARTVERIS-000007',
|
||||
);
|
||||
|
||||
expect(result.changed).toBe(true);
|
||||
expect(result.keyMap.get('uploads/intro.jpg')).toMatch(/^1\/ARTVERIS-000007\//);
|
||||
expect(result.keyMap.get('uploads/gallery.jpg')).toMatch(/^1\/ARTVERIS-000007\//);
|
||||
expect(result.layout.modules[7].config.image.key).toMatch(
|
||||
/^1\/ARTVERIS-000007\//,
|
||||
);
|
||||
expect(result.layout.modules[8].config.items[0].key).toMatch(
|
||||
/^1\/ARTVERIS-000007\//,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ArtworkController.create', () => {
|
||||
it('passes the complete authenticated user to the service for role-based approval', () => {
|
||||
const service = { create: jest.fn() };
|
||||
|
||||
@@ -2,7 +2,20 @@ import { Injectable } from '@nestjs/common';
|
||||
import { InjectQueue } from '@nestjs/bullmq';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { Queue } from 'bullmq';
|
||||
import { ArtworkRevisionStatus, ArtworkStatus, AuditStatus, ErrorCode, QUEUE_NAMES, RoleType } from '@artveris/shared';
|
||||
import {
|
||||
ArtworkRevisionStatus,
|
||||
ArtworkStatus,
|
||||
AuditStatus,
|
||||
ErrorCode,
|
||||
parseTraceLayout,
|
||||
QUEUE_NAMES,
|
||||
resolveTraceLayout,
|
||||
RoleType,
|
||||
type TraceHorizontalGalleryConfig,
|
||||
type TraceImageTextConfig,
|
||||
type TraceLayout,
|
||||
type TraceModuleMedia,
|
||||
} from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { BusinessException } from '../common/exceptions/business.exception';
|
||||
@@ -57,6 +70,7 @@ interface ArtworkSnapshot {
|
||||
dynamicFields: Record<string, unknown>;
|
||||
images: MediaItem[];
|
||||
showcaseImages: MediaItem[];
|
||||
traceLayout?: TraceLayout;
|
||||
showOutboundTimeline: boolean;
|
||||
};
|
||||
traceNodes: TraceNodeSnapshot[];
|
||||
@@ -85,6 +99,130 @@ export class ArtworkService {
|
||||
.map((i) => ({ ...i, url: this.storage.getUrl(i.key) }));
|
||||
}
|
||||
|
||||
private parseArtworkTraceLayout(value: unknown): TraceLayout {
|
||||
try {
|
||||
return parseTraceLayout(value);
|
||||
} catch (error) {
|
||||
throw new BusinessException(
|
||||
ErrorCode.VALIDATION_FAILED,
|
||||
`页面模块配置无效:${(error as Error).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private traceLayoutWithUrls(value: unknown) {
|
||||
const layout = resolveTraceLayout(value);
|
||||
return {
|
||||
...layout,
|
||||
modules: layout.modules.map((module) => {
|
||||
if (module.type === 'IMAGE_TEXT') {
|
||||
const config = (module.config ?? {}) as TraceImageTextConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
...(config.image
|
||||
? { image: { ...config.image, url: this.storage.getUrl(config.image.key) } }
|
||||
: {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
if (module.type === 'HORIZONTAL_GALLERY') {
|
||||
const config = (module.config ?? {}) as TraceHorizontalGalleryConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
items: (config.items ?? []).map((item) => ({
|
||||
...item,
|
||||
url: this.storage.getUrl(item.key),
|
||||
})),
|
||||
},
|
||||
};
|
||||
}
|
||||
return module;
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
private remapTraceLayout(layout: TraceLayout, keyMap: Map<string, string>): TraceLayout {
|
||||
if (!keyMap.size) return layout;
|
||||
const remapItem = (item: TraceModuleMedia): TraceModuleMedia => ({
|
||||
...item,
|
||||
key: keyMap.get(item.key) ?? item.key,
|
||||
});
|
||||
return {
|
||||
...layout,
|
||||
modules: layout.modules.map((module) => {
|
||||
if (module.type === 'IMAGE_TEXT') {
|
||||
const config = (module.config ?? {}) as TraceImageTextConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
...(config.image ? { image: remapItem(config.image) } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
if (module.type === 'HORIZONTAL_GALLERY') {
|
||||
const config = (module.config ?? {}) as TraceHorizontalGalleryConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
items: (config.items ?? []).map(remapItem),
|
||||
},
|
||||
};
|
||||
}
|
||||
return module;
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
private async relocateTraceLayoutMedia(
|
||||
layout: TraceLayout,
|
||||
dir: string,
|
||||
): Promise<{ layout: TraceLayout; changed: boolean; keyMap: Map<string, string> }> {
|
||||
let changed = false;
|
||||
const keyMap = new Map<string, string>();
|
||||
const modules: TraceLayout['modules'] = [];
|
||||
for (let index = 0; index < layout.modules.length; index += 1) {
|
||||
const module = layout.modules[index];
|
||||
if (module.type === 'IMAGE_TEXT') {
|
||||
const config = (module.config ?? {}) as TraceImageTextConfig;
|
||||
const relocated = await this.storage.relocateMedia(
|
||||
config.image ? [config.image] : [],
|
||||
dir,
|
||||
`模块图文-${this.storage.sanitizeSegment(module.title || String(index + 1))}`,
|
||||
);
|
||||
relocated.keyMap.forEach((next, previous) => keyMap.set(previous, next));
|
||||
changed ||= relocated.changed;
|
||||
modules.push({
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
...(relocated.items[0] ? { image: relocated.items[0] } : {}),
|
||||
},
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (module.type === 'HORIZONTAL_GALLERY') {
|
||||
const config = (module.config ?? {}) as TraceHorizontalGalleryConfig;
|
||||
const relocated = await this.storage.relocateMedia(
|
||||
config.items ?? [],
|
||||
dir,
|
||||
`模块图库-${this.storage.sanitizeSegment(module.title || String(index + 1))}`,
|
||||
);
|
||||
relocated.keyMap.forEach((next, previous) => keyMap.set(previous, next));
|
||||
changed ||= relocated.changed;
|
||||
modules.push({ ...module, config: { ...config, items: relocated.items } });
|
||||
continue;
|
||||
}
|
||||
modules.push(module);
|
||||
}
|
||||
return { layout: { ...layout, modules }, changed, keyMap };
|
||||
}
|
||||
|
||||
private buildArchiveNo(id: number): string {
|
||||
return `ARTVERIS-${String(id).padStart(6, '0')}`;
|
||||
}
|
||||
@@ -128,6 +266,18 @@ export class ArtworkService {
|
||||
});
|
||||
}
|
||||
|
||||
const currentLayout = resolveTraceLayout(artwork.traceLayout);
|
||||
const remappedLayout = this.remapTraceLayout(currentLayout, keyMap);
|
||||
const layoutRemapped = JSON.stringify(currentLayout) !== JSON.stringify(remappedLayout);
|
||||
const traceLayout = await this.relocateTraceLayoutMedia(remappedLayout, dir);
|
||||
traceLayout.keyMap.forEach((v, k) => keyMap.set(k, v));
|
||||
if (layoutRemapped || traceLayout.changed) {
|
||||
await this.prisma.artwork.update({
|
||||
where: { id: artworkId },
|
||||
data: { traceLayout: traceLayout.layout as unknown as Prisma.InputJsonValue },
|
||||
});
|
||||
}
|
||||
|
||||
for (const node of artwork.traceNodes) {
|
||||
const media = await this.storage.relocateMedia(
|
||||
(node.mediaFiles ?? []) as unknown as MediaItem[],
|
||||
@@ -189,6 +339,10 @@ export class ArtworkService {
|
||||
const traceNodes =
|
||||
dto.traceNodes === undefined ? DEFAULT_TRACE_NODES : this.normalizeTraceNodeDto(dto.traceNodes);
|
||||
const certificates = this.normalizeCertificateDto(dto.certificates ?? []);
|
||||
const traceLayout =
|
||||
dto.traceLayout === undefined
|
||||
? resolveTraceLayout(tpl.defaultTraceLayout)
|
||||
: this.parseArtworkTraceLayout(dto.traceLayout);
|
||||
|
||||
const { created: artwork, revisionId } = await this.prisma.$transaction(async (tx) => {
|
||||
const created = await tx.artwork.create({
|
||||
@@ -204,6 +358,7 @@ export class ArtworkService {
|
||||
dynamicFields: (dto.dynamicFields ?? {}) as Prisma.InputJsonValue,
|
||||
images: (dto.images ?? []) as unknown as Prisma.InputJsonValue,
|
||||
showcaseImages: (dto.showcaseImages ?? []) as unknown as Prisma.InputJsonValue,
|
||||
traceLayout: traceLayout as unknown as Prisma.InputJsonValue,
|
||||
showOutboundTimeline: dto.showOutboundTimeline ?? false,
|
||||
createdBy: userId,
|
||||
traceNodes: traceNodes.length
|
||||
@@ -391,6 +546,7 @@ export class ArtworkService {
|
||||
...a,
|
||||
images: this.mapMedia(a.images),
|
||||
showcaseImages: this.mapMedia(a.showcaseImages),
|
||||
traceLayout: this.traceLayoutWithUrls(a.traceLayout),
|
||||
traceNodes: a.traceNodes.map((n) => ({ ...n, mediaFiles: this.mapMedia(n.mediaFiles) })),
|
||||
certificates: a.certificates.map((c) => ({
|
||||
...c,
|
||||
@@ -407,6 +563,8 @@ export class ArtworkService {
|
||||
async update(id: number, dto: UpdateArtworkDto, user: AuthUser) {
|
||||
const userId = user.id;
|
||||
const artwork = await this.ensureExists(id);
|
||||
let dtoTraceLayout =
|
||||
dto.traceLayout === undefined ? undefined : this.parseArtworkTraceLayout(dto.traceLayout);
|
||||
// 先把既有媒体归位(含历史日期目录的旧文件),拿到 old->new 映射改写 DTO 引用;
|
||||
// 再把 DTO 里新上传的媒体(仍在通用上传目录)归位,保证快照/落库全部使用最终 key
|
||||
const keyMap = await this.relocateArtworkMedia(id);
|
||||
@@ -414,11 +572,15 @@ export class ArtworkService {
|
||||
|
||||
let dtoImages = this.remapMedia(dto.images as MediaItem[] | undefined, keyMap);
|
||||
if (dtoImages && dir) {
|
||||
dtoImages = (await this.storage.relocateMedia(dtoImages, dir, '作品图')).items;
|
||||
const relocated = await this.storage.relocateMedia(dtoImages, dir, '作品图');
|
||||
relocated.keyMap.forEach((next, previous) => keyMap.set(previous, next));
|
||||
dtoImages = relocated.items;
|
||||
}
|
||||
let dtoShowcaseImages = this.remapMedia(dto.showcaseImages as MediaItem[] | undefined, keyMap);
|
||||
if (dtoShowcaseImages && dir) {
|
||||
dtoShowcaseImages = (await this.storage.relocateMedia(dtoShowcaseImages, dir, '作品展示')).items;
|
||||
const relocated = await this.storage.relocateMedia(dtoShowcaseImages, dir, '作品展示');
|
||||
relocated.keyMap.forEach((next, previous) => keyMap.set(previous, next));
|
||||
dtoShowcaseImages = relocated.items;
|
||||
}
|
||||
let dtoNodes = dto.traceNodes ? this.normalizeTraceNodeDto(dto.traceNodes) : undefined;
|
||||
if (dtoNodes && dir) {
|
||||
@@ -448,6 +610,14 @@ export class ArtworkService {
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (dtoTraceLayout) {
|
||||
dtoTraceLayout = this.remapTraceLayout(dtoTraceLayout, keyMap);
|
||||
if (dir) {
|
||||
const relocated = await this.relocateTraceLayoutMedia(dtoTraceLayout, dir);
|
||||
relocated.keyMap.forEach((next, previous) => keyMap.set(previous, next));
|
||||
dtoTraceLayout = relocated.layout;
|
||||
}
|
||||
}
|
||||
|
||||
const current = await this.getSnapshot(id);
|
||||
const nextStatus = dto.status === ArtworkStatus.DRAFT ? ArtworkStatus.ACTIVE : dto.status ?? current.artwork.status;
|
||||
@@ -460,6 +630,7 @@ export class ArtworkService {
|
||||
dynamicFields: dto.dynamicFields ?? current.artwork.dynamicFields,
|
||||
images: (dtoImages ?? current.artwork.images) as MediaItem[],
|
||||
showcaseImages: (dtoShowcaseImages ?? current.artwork.showcaseImages ?? []) as MediaItem[],
|
||||
traceLayout: dtoTraceLayout ?? current.artwork.traceLayout ?? resolveTraceLayout(null),
|
||||
showOutboundTimeline: dto.showOutboundTimeline ?? current.artwork.showOutboundTimeline ?? false,
|
||||
},
|
||||
traceNodes: dtoNodes ?? current.traceNodes,
|
||||
@@ -672,6 +843,7 @@ export class ArtworkService {
|
||||
dynamicFields: Prisma.JsonValue | null;
|
||||
images: Prisma.JsonValue | null;
|
||||
showcaseImages?: Prisma.JsonValue | null;
|
||||
traceLayout?: Prisma.JsonValue | null;
|
||||
showOutboundTimeline?: boolean;
|
||||
traceNodes: Array<{
|
||||
nodeType: string;
|
||||
@@ -700,6 +872,7 @@ export class ArtworkService {
|
||||
dynamicFields: (record.dynamicFields as Record<string, unknown>) ?? {},
|
||||
images: (Array.isArray(record.images) ? record.images : []) as unknown as MediaItem[],
|
||||
showcaseImages: (Array.isArray(record.showcaseImages) ? record.showcaseImages : []) as unknown as MediaItem[],
|
||||
traceLayout: resolveTraceLayout(record.traceLayout),
|
||||
showOutboundTimeline: record.showOutboundTimeline ?? false,
|
||||
},
|
||||
traceNodes: record.traceNodes
|
||||
@@ -744,6 +917,7 @@ export class ArtworkService {
|
||||
dynamicFields: this.normalizeJson(snapshot.artwork.dynamicFields ?? {}),
|
||||
images: this.normalizeMedia(snapshot.artwork.images),
|
||||
showcaseImages: this.normalizeMedia(snapshot.artwork.showcaseImages),
|
||||
traceLayout: resolveTraceLayout(snapshot.artwork.traceLayout),
|
||||
showOutboundTimeline: snapshot.artwork.showOutboundTimeline ?? false,
|
||||
},
|
||||
traceNodes: snapshot.traceNodes.map((node, index) => ({
|
||||
@@ -806,6 +980,7 @@ export class ArtworkService {
|
||||
...snapshot.artwork,
|
||||
images: this.mapMedia(snapshot.artwork.images),
|
||||
showcaseImages: this.mapMedia(snapshot.artwork.showcaseImages),
|
||||
traceLayout: this.traceLayoutWithUrls(snapshot.artwork.traceLayout),
|
||||
},
|
||||
traceNodes: snapshot.traceNodes.map((node) => ({
|
||||
...node,
|
||||
@@ -847,6 +1022,10 @@ export class ArtworkService {
|
||||
dynamicFields: snapshot.artwork.dynamicFields as Prisma.InputJsonObject,
|
||||
images: snapshot.artwork.images as unknown as Prisma.InputJsonValue,
|
||||
showcaseImages: (snapshot.artwork.showcaseImages ?? []) as unknown as Prisma.InputJsonValue,
|
||||
traceLayout:
|
||||
snapshot.artwork.traceLayout === undefined
|
||||
? undefined
|
||||
: (resolveTraceLayout(snapshot.artwork.traceLayout) as unknown as Prisma.InputJsonValue),
|
||||
showOutboundTimeline: snapshot.artwork.showOutboundTimeline ?? false,
|
||||
...auditData,
|
||||
},
|
||||
|
||||
@@ -83,6 +83,11 @@ export class CreateArtworkDto {
|
||||
@Type(() => MediaItemDto)
|
||||
showcaseImages?: MediaItemDto[];
|
||||
|
||||
@ApiPropertyOptional({ description: '客户端页面模块布局' })
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
traceLayout?: Record<string, unknown>;
|
||||
|
||||
@ApiPropertyOptional({ description: '状态', enum: ArtworkStatus })
|
||||
@IsOptional()
|
||||
@IsEnum(ArtworkStatus)
|
||||
@@ -215,6 +220,11 @@ export class UpdateArtworkDto {
|
||||
@Type(() => MediaItemDto)
|
||||
showcaseImages?: MediaItemDto[];
|
||||
|
||||
@ApiPropertyOptional({ description: '客户端页面模块布局' })
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
traceLayout?: Record<string, unknown>;
|
||||
|
||||
@ApiPropertyOptional({ description: '状态', enum: ArtworkStatus })
|
||||
@IsOptional()
|
||||
@IsEnum(ArtworkStatus)
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import { ArtworkStatus, AuditStatus, TraceCodeStatus } from '@artveris/shared';
|
||||
import {
|
||||
ArtworkStatus,
|
||||
AuditStatus,
|
||||
createDefaultTraceLayout,
|
||||
TraceCodeStatus,
|
||||
} from '@artveris/shared';
|
||||
import { PublicTraceService } from './public-trace.service';
|
||||
|
||||
function createHarness(options: {
|
||||
artworkStatus?: ArtworkStatus;
|
||||
showOutboundTimeline?: boolean;
|
||||
withOutbound?: boolean;
|
||||
traceLayout?: any;
|
||||
} = {}) {
|
||||
const outbound = options.withOutbound
|
||||
? {
|
||||
@@ -58,6 +64,7 @@ function createHarness(options: {
|
||||
},
|
||||
],
|
||||
dynamicFields: null,
|
||||
traceLayout: options.traceLayout ?? null,
|
||||
showOutboundTimeline: options.showOutboundTimeline ?? false,
|
||||
template: { fields: [] },
|
||||
traceNodes: [],
|
||||
@@ -69,8 +76,14 @@ function createHarness(options: {
|
||||
if (select && Object.keys(select).length === 1 && select.id) return { id: code.id };
|
||||
return code;
|
||||
}),
|
||||
updateMany: jest.fn(),
|
||||
updateMany: jest.fn().mockResolvedValue({ count: 1 }),
|
||||
update: jest.fn(),
|
||||
findUniqueOrThrow: jest.fn().mockResolvedValue({
|
||||
...code,
|
||||
status: TraceCodeStatus.ACTIVE,
|
||||
queryCount: 1,
|
||||
firstActivatedAt: new Date('2026-07-19T08:00:00.000Z'),
|
||||
}),
|
||||
},
|
||||
artwork: { findFirst: jest.fn().mockResolvedValue(artwork) },
|
||||
queryLog: { create: jest.fn().mockResolvedValue({}) },
|
||||
@@ -155,3 +168,94 @@ describe('PublicTraceService artwork showcase', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PublicTraceService module layout', () => {
|
||||
it('returns the legacy default order for artwork without a saved layout', async () => {
|
||||
const { service } = createHarness({ artworkStatus: ArtworkStatus.ACTIVE });
|
||||
|
||||
const result = await service.preview('482731000001', 'inactive');
|
||||
|
||||
expect((result as any).artwork.traceLayout.modules.map((module: any) => module.type)).toEqual([
|
||||
'HERO_CAROUSEL',
|
||||
'AUTHENTICITY_STATUS',
|
||||
'PRODUCT_INTRO',
|
||||
'SHOWCASE',
|
||||
'CERTIFICATES',
|
||||
'TIMELINE',
|
||||
'BLOCKCHAIN',
|
||||
]);
|
||||
});
|
||||
|
||||
it('filters hidden modules and converts custom module media keys to public URLs', async () => {
|
||||
const traceLayout = createDefaultTraceLayout();
|
||||
traceLayout.modules[1] = { ...traceLayout.modules[1], visible: false };
|
||||
traceLayout.modules.push({
|
||||
id: 'custom-story',
|
||||
type: 'IMAGE_TEXT',
|
||||
visible: true,
|
||||
title: '创作故事',
|
||||
config: {
|
||||
heading: '釉色灵感',
|
||||
body: '源于山水。',
|
||||
imagePosition: 'LEFT',
|
||||
image: {
|
||||
key: 'artwork/10/story.jpg',
|
||||
name: '创作手稿',
|
||||
description: '艺术家手稿',
|
||||
type: 'image',
|
||||
},
|
||||
},
|
||||
});
|
||||
const { service } = createHarness({
|
||||
artworkStatus: ArtworkStatus.ACTIVE,
|
||||
traceLayout,
|
||||
});
|
||||
|
||||
const result = await service.preview('482731000001', 'inactive');
|
||||
const modules = (result as any).artwork.traceLayout.modules;
|
||||
|
||||
expect(modules.some((module: any) => module.type === 'AUTHENTICITY_STATUS')).toBe(false);
|
||||
expect(modules.find((module: any) => module.id === 'custom-story').config.image).toEqual({
|
||||
name: '创作手稿',
|
||||
description: '艺术家手稿',
|
||||
type: 'image',
|
||||
url: '/uploads/artwork/10/story.jpg',
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps first-scan activation and query logging when the authenticity module is hidden', async () => {
|
||||
const traceLayout = createDefaultTraceLayout();
|
||||
traceLayout.modules[1] = { ...traceLayout.modules[1], visible: false };
|
||||
const { service, prisma } = createHarness({
|
||||
artworkStatus: ArtworkStatus.ACTIVE,
|
||||
traceLayout,
|
||||
});
|
||||
|
||||
const result = await service.trace('482731000001', { ip: '127.0.0.1' });
|
||||
|
||||
expect(result.status).toBe('OK');
|
||||
expect((result as any).antiCounterfeit.firstQuery).toBe(true);
|
||||
expect(prisma.traceCode.updateMany).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
where: expect.objectContaining({ status: TraceCodeStatus.INACTIVE }),
|
||||
}),
|
||||
);
|
||||
expect(prisma.queryLog.create).toHaveBeenCalled();
|
||||
expect(
|
||||
(result as any).artwork.traceLayout.modules.some(
|
||||
(module: any) => module.type === 'AUTHENTICITY_STATUS',
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps active preview free of activation, counting and query-log side effects', async () => {
|
||||
const { service, prisma } = createHarness({ artworkStatus: ArtworkStatus.ACTIVE });
|
||||
|
||||
const result = await service.preview('482731000001', 'active');
|
||||
|
||||
expect(result.status).toBe('OK');
|
||||
expect(prisma.traceCode.updateMany).not.toHaveBeenCalled();
|
||||
expect(prisma.traceCode.update).not.toHaveBeenCalled();
|
||||
expect(prisma.queryLog.create).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common';
|
||||
import type Redis from 'ioredis';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { ArtworkStatus, AuditStatus, QueryResult, ProofStatus, TRACE_CODE_PATTERN, TraceCodeStatus } from '@artveris/shared';
|
||||
import {
|
||||
ArtworkStatus,
|
||||
AuditStatus,
|
||||
QueryResult,
|
||||
ProofStatus,
|
||||
resolveTraceLayout,
|
||||
TRACE_CODE_PATTERN,
|
||||
TraceCodeStatus,
|
||||
type TraceHorizontalGalleryConfig,
|
||||
type TraceImageTextConfig,
|
||||
type TraceModuleMedia,
|
||||
} from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { SettingsService } from '../settings/settings.service';
|
||||
@@ -52,6 +63,44 @@ export class PublicTraceService {
|
||||
}));
|
||||
}
|
||||
|
||||
private mapTraceLayout(value: unknown) {
|
||||
const publicMedia = (item: TraceModuleMedia) => ({
|
||||
name: item.name,
|
||||
type: item.type ?? 'image',
|
||||
description: item.description,
|
||||
url: this.storage.getUrl(item.key),
|
||||
});
|
||||
const layout = resolveTraceLayout(value);
|
||||
return {
|
||||
...layout,
|
||||
modules: layout.modules
|
||||
.filter((module) => module.visible)
|
||||
.map((module) => {
|
||||
if (module.type === 'IMAGE_TEXT') {
|
||||
const config = (module.config ?? {}) as TraceImageTextConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
...(config.image ? { image: publicMedia(config.image) } : {}),
|
||||
},
|
||||
};
|
||||
}
|
||||
if (module.type === 'HORIZONTAL_GALLERY') {
|
||||
const config = (module.config ?? {}) as TraceHorizontalGalleryConfig;
|
||||
return {
|
||||
...module,
|
||||
config: {
|
||||
...config,
|
||||
items: (config.items ?? []).map(publicMedia),
|
||||
},
|
||||
};
|
||||
}
|
||||
return module;
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
private buildTimeline(
|
||||
nodes: Array<{
|
||||
nodeType: string;
|
||||
@@ -328,6 +377,7 @@ export class PublicTraceService {
|
||||
archiveNo: artwork.archiveNo,
|
||||
images: this.mapMedia(artwork.images),
|
||||
showcaseImages: this.mapMedia(artwork.showcaseImages),
|
||||
traceLayout: this.mapTraceLayout(artwork.traceLayout),
|
||||
showOutboundTimeline: artwork.showOutboundTimeline,
|
||||
fields: this.buildFields(artwork.template.fields, artwork.dynamicFields),
|
||||
},
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
IsEnum,
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsObject,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
@@ -62,6 +63,11 @@ export class CreateTemplateDto {
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => TemplateFieldDto)
|
||||
fields!: TemplateFieldDto[];
|
||||
|
||||
@ApiPropertyOptional({ description: '客户端默认页面模块布局(建档时复制)' })
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
defaultTraceLayout?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class UpdateTemplateDto {
|
||||
@@ -88,6 +94,11 @@ export class UpdateTemplateDto {
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => TemplateFieldDto)
|
||||
fields?: TemplateFieldDto[];
|
||||
|
||||
@ApiPropertyOptional({ description: '客户端默认页面模块布局(仅影响后续新建作品)' })
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
defaultTraceLayout?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class QueryTemplateDto extends PaginationDto {
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { ErrorCode, TemplateStatus } from '@artveris/shared';
|
||||
import {
|
||||
createDefaultTraceLayout,
|
||||
ErrorCode,
|
||||
parseTraceLayout,
|
||||
templateTraceLayout,
|
||||
TemplateStatus,
|
||||
type TraceLayout,
|
||||
} from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { BusinessException } from '../common/exceptions/business.exception';
|
||||
import { buildPage } from '../common/utils/pagination.util';
|
||||
@@ -11,6 +18,24 @@ import { CreateTemplateDto, QueryTemplateDto, UpdateTemplateDto, TemplateFieldDt
|
||||
export class TemplateService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
private parseDefaultTraceLayout(value: unknown): TraceLayout {
|
||||
try {
|
||||
return parseTraceLayout(value ?? createDefaultTraceLayout(), { template: true });
|
||||
} catch (error) {
|
||||
throw new BusinessException(
|
||||
ErrorCode.VALIDATION_FAILED,
|
||||
`页面模块配置无效:${(error as Error).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private withDefaultTraceLayout<T extends { defaultTraceLayout: Prisma.JsonValue | null }>(template: T) {
|
||||
return {
|
||||
...template,
|
||||
defaultTraceLayout: templateTraceLayout(template.defaultTraceLayout),
|
||||
};
|
||||
}
|
||||
|
||||
private fieldsCreate(fields: TemplateFieldDto[]) {
|
||||
return fields.map((f, i) => ({
|
||||
fieldKey: f.fieldKey,
|
||||
@@ -22,14 +47,16 @@ export class TemplateService {
|
||||
}
|
||||
|
||||
async create(dto: CreateTemplateDto) {
|
||||
return this.prisma.template.create({
|
||||
const template = await this.prisma.template.create({
|
||||
data: {
|
||||
name: dto.name,
|
||||
remark: dto.remark,
|
||||
defaultTraceLayout: this.parseDefaultTraceLayout(dto.defaultTraceLayout) as unknown as Prisma.InputJsonValue,
|
||||
fields: { create: this.fieldsCreate(dto.fields) },
|
||||
},
|
||||
include: { fields: { orderBy: { sortOrder: 'asc' } } },
|
||||
});
|
||||
return this.withDefaultTraceLayout(template);
|
||||
}
|
||||
|
||||
async list(query: QueryTemplateDto) {
|
||||
@@ -47,16 +74,22 @@ export class TemplateService {
|
||||
}),
|
||||
this.prisma.template.count({ where }),
|
||||
]);
|
||||
return buildPage(list, total, query.page, query.pageSize);
|
||||
return buildPage(
|
||||
list.map((template) => this.withDefaultTraceLayout(template)),
|
||||
total,
|
||||
query.page,
|
||||
query.pageSize,
|
||||
);
|
||||
}
|
||||
|
||||
// 供建档表单选择的启用模板(含字段)
|
||||
async options() {
|
||||
return this.prisma.template.findMany({
|
||||
const templates = await this.prisma.template.findMany({
|
||||
where: { deletedAt: null, status: TemplateStatus.ENABLED },
|
||||
include: { fields: { orderBy: { sortOrder: 'asc' } } },
|
||||
orderBy: { id: 'desc' },
|
||||
});
|
||||
return templates.map((template) => this.withDefaultTraceLayout(template));
|
||||
}
|
||||
|
||||
async get(id: number) {
|
||||
@@ -65,7 +98,7 @@ export class TemplateService {
|
||||
include: { fields: { orderBy: { sortOrder: 'asc' } } },
|
||||
});
|
||||
if (!tpl) throw new BusinessException(ErrorCode.TEMPLATE_NOT_FOUND, '模板不存在', 404);
|
||||
return tpl;
|
||||
return this.withDefaultTraceLayout(tpl);
|
||||
}
|
||||
|
||||
async update(id: number, dto: UpdateTemplateDto) {
|
||||
@@ -77,11 +110,20 @@ export class TemplateService {
|
||||
data: this.fieldsCreate(dto.fields).map((f) => ({ ...f, templateId: id })),
|
||||
});
|
||||
}
|
||||
return tx.template.update({
|
||||
const template = await tx.template.update({
|
||||
where: { id },
|
||||
data: { name: dto.name, remark: dto.remark, status: dto.status },
|
||||
data: {
|
||||
name: dto.name,
|
||||
remark: dto.remark,
|
||||
status: dto.status,
|
||||
defaultTraceLayout:
|
||||
dto.defaultTraceLayout === undefined
|
||||
? undefined
|
||||
: (this.parseDefaultTraceLayout(dto.defaultTraceLayout) as unknown as Prisma.InputJsonValue),
|
||||
},
|
||||
include: { fields: { orderBy: { sortOrder: 'asc' } } },
|
||||
});
|
||||
return this.withDefaultTraceLayout(template);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user