feat: 完善艺术品审核变更流程
This commit is contained in:
@@ -32,7 +32,10 @@ export const templateApi = {
|
||||
|
||||
export const artworkApi = {
|
||||
list: (params: object) => get<PageResult<any>>('/artworks', params),
|
||||
auditList: (params: object) => get<PageResult<any>>('/artworks/audit-list', params),
|
||||
get: (id: number) => get(`/artworks/${id}`),
|
||||
revisions: (id: number, params: object) => get<PageResult<any>>(`/artworks/${id}/revisions`, params),
|
||||
revision: (id: number, revisionId: string) => get(`/artworks/${id}/revisions/${revisionId}`),
|
||||
create: (data: object) => post('/artworks', data),
|
||||
update: (id: number, data: object) => put(`/artworks/${id}`, data),
|
||||
remove: (id: number) => del(`/artworks/${id}`),
|
||||
@@ -86,8 +89,8 @@ export const outboundApi = {
|
||||
};
|
||||
|
||||
export const auditApi = {
|
||||
list: (params: object) => get<PageResult<any>>('/artworks', params),
|
||||
audit: (id: number, data: { approved: boolean; remark?: string }) => post(`/artworks/${id}/audit`, data),
|
||||
list: (params: object) => get<PageResult<any>>('/artworks/audit-list', params),
|
||||
audit: (id: number, data: { approved: boolean; remark?: string; revisionId?: string }) => post(`/artworks/${id}/audit`, data),
|
||||
};
|
||||
|
||||
export const jobApi = {
|
||||
|
||||
@@ -225,7 +225,8 @@
|
||||
"remarkPlaceholder": "Enter rejection reason or suggestions",
|
||||
"approveConfirm": "Approve \"{title}\"? It will become visible on the consumer page.",
|
||||
"rejectedTip": "This artwork was rejected. Please revise per the notes, save and resubmit for audit.",
|
||||
"pendingTip": "Pending audit; visible on consumer page only after approval. Saving edits re-enters pending."
|
||||
"pendingTip": "Pending audit; visible on consumer page only after approval. Saving edits re-enters pending.",
|
||||
"revisionPreviewTip": "You are previewing a pending revision. It will not replace the version shown to clients until approved."
|
||||
},
|
||||
"artwork": {
|
||||
"title": "Name",
|
||||
@@ -252,6 +253,18 @@
|
||||
"nodes": "Timeline",
|
||||
"certificates": "Certificates",
|
||||
"saveDraft": "Save Draft",
|
||||
"submitReview": "Submit for Audit",
|
||||
"submittedReview": "Submitted for audit. Changes take effect only after approval.",
|
||||
"changeInfo": "Change Notes",
|
||||
"changeTitle": "Change Title",
|
||||
"changeTitlePlaceholder": "e.g. Add certificate, adjust artwork images",
|
||||
"changeReason": "Change Reason",
|
||||
"changeReasonPlaceholder": "Describe why this change is needed for audit and traceability.",
|
||||
"changeRecords": "Change Records",
|
||||
"submitter": "Submitter",
|
||||
"submittedAt": "Submitted At",
|
||||
"reviewer": "Reviewer",
|
||||
"reviewedAt": "Reviewed At",
|
||||
"traceCode": "Trace Code",
|
||||
"status": "Status",
|
||||
"create": "New Artwork",
|
||||
|
||||
@@ -225,7 +225,8 @@
|
||||
"remarkPlaceholder": "请填写驳回原因或修改建议",
|
||||
"approveConfirm": "确认通过《{title}》的审核?通过后将对客户端可见。",
|
||||
"rejectedTip": "该作品审核未通过,请按意见修改后保存再次提交审核",
|
||||
"pendingTip": "该作品待审核,审核通过后方可在客户端展示;保存修改会重新进入待审核"
|
||||
"pendingTip": "该作品待审核,审核通过后方可在客户端展示;保存修改会重新进入待审核",
|
||||
"revisionPreviewTip": "当前正在预览待审核的修改内容,审核通过前不会覆盖客户端正在展示的正式内容。"
|
||||
},
|
||||
"artwork": {
|
||||
"title": "名称",
|
||||
@@ -252,6 +253,18 @@
|
||||
"nodes": "溯源时间轴",
|
||||
"certificates": "认证文件",
|
||||
"saveDraft": "保存草稿",
|
||||
"submitReview": "提交审核",
|
||||
"submittedReview": "已提交审核,审核通过后修改才会生效",
|
||||
"changeInfo": "修改说明",
|
||||
"changeTitle": "修改标题",
|
||||
"changeTitlePlaceholder": "例如:补充认证文件、调整作品图片",
|
||||
"changeReason": "修改理由",
|
||||
"changeReasonPlaceholder": "请说明本次修改的原因,便于审核与追溯",
|
||||
"changeRecords": "修改记录",
|
||||
"submitter": "提交人",
|
||||
"submittedAt": "提交时间",
|
||||
"reviewer": "审核人",
|
||||
"reviewedAt": "审核时间",
|
||||
"traceCode": "追溯码",
|
||||
"status": "状态",
|
||||
"create": "新建作品",
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
<div class="page-title">{{ isNew ? t('pages.artwork.create') : t('pages.artwork.detail') }}</div>
|
||||
<div class="spacer" />
|
||||
<div class="edit-actions">
|
||||
<n-button :loading="saving" :disabled="!auth.canWrite" @click="saveArtwork(true)">
|
||||
<n-button v-if="isNew" :loading="saving" :disabled="!auth.canWrite" @click="saveArtwork(true)">
|
||||
{{ t('pages.artwork.saveDraft') }}
|
||||
</n-button>
|
||||
<n-button type="primary" :loading="saving" :disabled="!auth.canWrite" @click="saveArtwork(false)">
|
||||
{{ t('common.action.save') }}
|
||||
{{ isNew ? t('common.action.save') : t('pages.artwork.submitReview') }}
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -22,26 +22,34 @@
|
||||
<n-grid-item>
|
||||
<n-card :title="t('pages.artwork.basicInfo')" :bordered="false">
|
||||
<template v-if="!isNew" #header-extra>
|
||||
<n-tag :type="auditTagType(artwork?.auditStatus)" size="small">
|
||||
{{ t('pages.audit.status') }}:{{ t(`common.auditStatus.${artwork?.auditStatus || 'PENDING'}`) }}
|
||||
<n-tag :type="auditTagType(artwork?.effectiveAuditStatus || artwork?.auditStatus)" size="small">
|
||||
{{ t('pages.audit.status') }}:{{ t(`common.auditStatus.${artwork?.effectiveAuditStatus || artwork?.auditStatus || 'PENDING'}`) }}
|
||||
</n-tag>
|
||||
</template>
|
||||
<n-alert
|
||||
v-if="!isNew && artwork?.auditStatus === 'REJECTED'"
|
||||
v-if="!isNew && (artwork?.effectiveAuditStatus || artwork?.auditStatus) === 'REJECTED'"
|
||||
type="error"
|
||||
:show-icon="true"
|
||||
style="margin-bottom: 12px"
|
||||
>
|
||||
{{ t('pages.audit.rejectedTip') }}{{ artwork?.auditRemark ? ':' + artwork.auditRemark : '' }}
|
||||
{{ t('pages.audit.rejectedTip') }}{{ artwork?.effectiveAuditRemark || artwork?.auditRemark ? ':' + (artwork?.effectiveAuditRemark || artwork?.auditRemark) : '' }}
|
||||
</n-alert>
|
||||
<n-alert
|
||||
v-else-if="!isNew && artwork?.auditStatus === 'PENDING'"
|
||||
v-else-if="!isNew && (artwork?.effectiveAuditStatus || artwork?.auditStatus) === 'PENDING'"
|
||||
type="info"
|
||||
:show-icon="true"
|
||||
style="margin-bottom: 12px"
|
||||
>
|
||||
{{ t('pages.audit.pendingTip') }}
|
||||
</n-alert>
|
||||
<n-alert
|
||||
v-if="previewRevision"
|
||||
type="warning"
|
||||
:show-icon="true"
|
||||
style="margin-bottom: 12px"
|
||||
>
|
||||
{{ t('pages.audit.revisionPreviewTip') }}
|
||||
</n-alert>
|
||||
<n-form ref="formRef" :model="form" :rules="rules" label-placement="top">
|
||||
<n-grid :cols="2" :x-gap="16" item-responsive responsive="screen">
|
||||
<n-form-item-gi span="2 m:1" path="templateId" :label="t('pages.artwork.template')">
|
||||
@@ -115,6 +123,23 @@
|
||||
|
||||
<n-divider style="margin: 4px 0 16px">{{ t('pages.artwork.images') }}</n-divider>
|
||||
<media-sorter v-model="form.images" :max="12" />
|
||||
|
||||
<template v-if="!isNew && auth.canWrite">
|
||||
<n-divider style="margin: 16px 0">{{ t('pages.artwork.changeInfo') }}</n-divider>
|
||||
<n-grid :cols="2" :x-gap="16" item-responsive responsive="screen">
|
||||
<n-form-item-gi span="2 m:1" :label="t('pages.artwork.changeTitle')">
|
||||
<n-input v-model:value="changeForm.title" :placeholder="t('pages.artwork.changeTitlePlaceholder')" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi span="2 m:1" :label="t('pages.artwork.changeReason')">
|
||||
<n-input
|
||||
v-model:value="changeForm.reason"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
:placeholder="t('pages.artwork.changeReasonPlaceholder')"
|
||||
/>
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
</template>
|
||||
</n-form>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
@@ -188,6 +213,19 @@
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
|
||||
<n-grid-item v-if="!isNew">
|
||||
<n-card :title="t('pages.artwork.changeRecords')" :bordered="false">
|
||||
<n-data-table
|
||||
:columns="revisionColumns"
|
||||
:data="revisions"
|
||||
:loading="revisionLoading"
|
||||
:pagination="false"
|
||||
:scroll-x="980"
|
||||
size="small"
|
||||
/>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
|
||||
</n-grid>
|
||||
|
||||
<!-- 节点弹窗 -->
|
||||
@@ -249,10 +287,10 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { computed, h, onMounted, reactive, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { FormInst, FormRules } from 'naive-ui';
|
||||
import { NTag, type DataTableColumns, type FormInst, type FormRules } from 'naive-ui';
|
||||
import { ArrowBackOutline, AddOutline } from '@vicons/ionicons5';
|
||||
import { ArtworkStatus, CertType, NodeType } from '@artveris/shared';
|
||||
import { artworkApi, templateApi } from '@/api';
|
||||
@@ -272,6 +310,7 @@ const artworkId = computed(() => Number(route.params.id));
|
||||
|
||||
const formRef = ref<FormInst | null>(null);
|
||||
const form = reactive<any>({ templateId: null, title: '', artist: '', status: ArtworkStatus.DRAFT, dynamicFields: {}, images: [] });
|
||||
const changeForm = reactive({ title: '', reason: '' });
|
||||
const rules: FormRules = {
|
||||
templateId: { required: true, type: 'number', message: () => t('pages.artwork.template'), trigger: 'change' },
|
||||
title: { required: true, message: () => t('pages.artwork.title'), trigger: 'blur' },
|
||||
@@ -285,10 +324,30 @@ const nodeTypeOptions = Object.values(NodeType).map((v) => ({ label: t(`common.n
|
||||
const certTypeOptions = Object.values(CertType).map((v) => ({ label: v, value: v }));
|
||||
|
||||
const currentFields = computed(() => templates.value.find((x) => x.id === form.templateId)?.fields ?? []);
|
||||
const revisionColumns: DataTableColumns<any> = [
|
||||
{ title: () => t('pages.artwork.changeTitle'), key: 'title', minWidth: 150, ellipsis: { tooltip: true } },
|
||||
{ title: () => t('pages.artwork.changeReason'), key: 'reason', minWidth: 220, ellipsis: { tooltip: true }, render: (r) => r.reason || '-' },
|
||||
{
|
||||
title: () => t('pages.audit.status'),
|
||||
key: 'status',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
render: (r) =>
|
||||
h(NTag, { size: 'small', type: auditTagType(r.status) }, { default: () => t(`common.auditStatus.${r.status}`) }),
|
||||
},
|
||||
{ title: () => t('pages.artwork.submitter'), key: 'submitter', width: 130, align: 'center', ellipsis: { tooltip: true }, render: (r) => userName(r.submitter) },
|
||||
{ title: () => t('pages.artwork.submittedAt'), key: 'submittedAt', width: 160, align: 'center', render: (r) => fmtDateTime(r.submittedAt) },
|
||||
{ title: () => t('pages.artwork.reviewer'), key: 'reviewer', width: 130, align: 'center', ellipsis: { tooltip: true }, render: (r) => userName(r.reviewer) },
|
||||
{ title: () => t('pages.artwork.reviewedAt'), key: 'reviewedAt', width: 160, align: 'center', render: (r) => fmtDateTime(r.reviewedAt) },
|
||||
{ title: () => t('pages.audit.remark'), key: 'auditRemark', minWidth: 180, ellipsis: { tooltip: true }, render: (r) => r.auditRemark || '-' },
|
||||
];
|
||||
|
||||
const artwork = ref<any>(null);
|
||||
const nodes = ref<any[]>([]);
|
||||
const certs = ref<any[]>([]);
|
||||
const revisions = ref<any[]>([]);
|
||||
const revisionLoading = ref(false);
|
||||
const previewRevision = ref<any>(null);
|
||||
let localIdSeed = 0;
|
||||
|
||||
function nextLocalId(prefix: string) {
|
||||
@@ -316,6 +375,12 @@ function toMedia(url: unknown) {
|
||||
function auditTagType(s?: string) {
|
||||
return s === 'APPROVED' ? 'success' : s === 'REJECTED' ? 'error' : 'warning';
|
||||
}
|
||||
function userName(user?: any) {
|
||||
return user?.realName || user?.username || '-';
|
||||
}
|
||||
function fmtDateTime(value?: string | Date | null) {
|
||||
return value ? fmtDate(value) : '-';
|
||||
}
|
||||
|
||||
async function loadTemplates() {
|
||||
templates.value = await templateApi.options();
|
||||
@@ -324,6 +389,30 @@ async function loadTemplates() {
|
||||
async function loadArtwork() {
|
||||
const a: any = await artworkApi.get(artworkId.value);
|
||||
artwork.value = a;
|
||||
applyArtworkToForm(a);
|
||||
nodes.value = (a.traceNodes || []).map(normalizeNode);
|
||||
certs.value = (a.certificates || []).map(normalizeCert);
|
||||
const revisionId = String(route.query.revisionId || '');
|
||||
if (revisionId) {
|
||||
previewRevision.value = await artworkApi.revision(artworkId.value, revisionId);
|
||||
applySnapshotToForm(previewRevision.value.afterSnapshot);
|
||||
} else {
|
||||
previewRevision.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRevisions() {
|
||||
if (isNew.value) return;
|
||||
revisionLoading.value = true;
|
||||
try {
|
||||
const res: any = await artworkApi.revisions(artworkId.value, { page: 1, pageSize: 20 });
|
||||
revisions.value = res.list || [];
|
||||
} finally {
|
||||
revisionLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function applyArtworkToForm(a: any) {
|
||||
form.templateId = a.templateId;
|
||||
form.title = a.title;
|
||||
form.artist = a.artist;
|
||||
@@ -333,8 +422,30 @@ async function loadArtwork() {
|
||||
...m,
|
||||
type: m.type || (isVideoMedia(m) ? 'video' : 'image'),
|
||||
}));
|
||||
nodes.value = (a.traceNodes || []).map(normalizeNode);
|
||||
certs.value = (a.certificates || []).map(normalizeCert);
|
||||
}
|
||||
|
||||
function applySnapshotToForm(snapshot: any) {
|
||||
if (!snapshot?.artwork) return;
|
||||
applyArtworkToForm({
|
||||
templateId: snapshot.artwork.templateId,
|
||||
title: snapshot.artwork.title,
|
||||
artist: snapshot.artwork.artist,
|
||||
status: snapshot.artwork.status,
|
||||
dynamicFields: snapshot.artwork.dynamicFields,
|
||||
images: snapshot.artwork.images,
|
||||
});
|
||||
nodes.value = (snapshot.traceNodes || []).map((node: any) =>
|
||||
normalizeNode({ ...node, mediaFiles: node.mediaFiles || [] }),
|
||||
);
|
||||
certs.value = (snapshot.certificates || []).map((cert: any) =>
|
||||
normalizeCert({
|
||||
...cert,
|
||||
originFileUrl: cert.originKey,
|
||||
watermarkFileUrl: cert.watermarkKey,
|
||||
originUrl: cert.originUrl,
|
||||
watermarkUrl: cert.watermarkUrl,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeNode(n: any) {
|
||||
@@ -354,6 +465,7 @@ function normalizeCert(c: any) {
|
||||
return {
|
||||
...c,
|
||||
originKey: c.originKey ?? c.originFileUrl,
|
||||
watermarkKey: c.watermarkKey ?? c.watermarkFileUrl,
|
||||
originUrl: c.originUrl,
|
||||
watermarkUrl: c.watermarkUrl,
|
||||
};
|
||||
@@ -381,6 +493,7 @@ function buildCertPayload() {
|
||||
issuer: cert.issuer,
|
||||
type: cert.type,
|
||||
originKey: cert.originKey,
|
||||
watermarkKey: cert.watermarkKey,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -396,27 +509,29 @@ async function saveArtwork(asDraft: boolean) {
|
||||
templateId: form.templateId,
|
||||
title: form.title,
|
||||
artist: form.artist,
|
||||
status: asDraft ? ArtworkStatus.DRAFT : isNew.value ? ArtworkStatus.ACTIVE : form.status,
|
||||
status: asDraft ? ArtworkStatus.DRAFT : isNew.value || form.status === ArtworkStatus.DRAFT ? ArtworkStatus.ACTIVE : form.status,
|
||||
dynamicFields: form.dynamicFields,
|
||||
images: form.images.map((m: any) => ({
|
||||
key: m.key,
|
||||
name: m.name,
|
||||
type: m.type || (isVideoMedia(m) ? 'video' : 'image'),
|
||||
})),
|
||||
revisionTitle: changeForm.title || undefined,
|
||||
revisionReason: changeForm.reason || undefined,
|
||||
traceNodes: buildNodePayload(),
|
||||
certificates: buildCertPayload(),
|
||||
};
|
||||
if (isNew.value) {
|
||||
const created: any = await artworkApi.create({
|
||||
...payload,
|
||||
traceNodes: buildNodePayload(),
|
||||
certificates: buildCertPayload(),
|
||||
});
|
||||
const created: any = await artworkApi.create(payload);
|
||||
message.success(t('common.msg.created'));
|
||||
await router.replace(`/artworks/${created.id}`);
|
||||
await loadArtwork();
|
||||
} else {
|
||||
await artworkApi.update(artworkId.value, payload);
|
||||
message.success(t('common.msg.saved'));
|
||||
message.success(t('pages.artwork.submittedReview'));
|
||||
Object.assign(changeForm, { title: '', reason: '' });
|
||||
await loadArtwork();
|
||||
await loadRevisions();
|
||||
}
|
||||
} finally {
|
||||
saving.value = false;
|
||||
@@ -469,40 +584,33 @@ async function saveNode() {
|
||||
type: m.type || (isVideoMedia(m) ? 'video' : 'image'),
|
||||
})),
|
||||
};
|
||||
if (isNew.value) {
|
||||
const draftNode = normalizeNode({
|
||||
...payload,
|
||||
id: editingNode.value,
|
||||
localId: editingNodeLocalId.value || nextLocalId('node'),
|
||||
media: nodeForm.media,
|
||||
});
|
||||
const index = nodes.value.findIndex((item) => item.localId === draftNode.localId);
|
||||
if (index >= 0) nodes.value.splice(index, 1, draftNode);
|
||||
else nodes.value.push(draftNode);
|
||||
nodes.value = nodes.value.map((node, index) => ({ ...node, sortOrder: index }));
|
||||
} else if (editingNode.value) await artworkApi.updateNode(editingNode.value, payload);
|
||||
else await artworkApi.createNode(artworkId.value, payload);
|
||||
const draftNode = normalizeNode({
|
||||
...payload,
|
||||
id: editingNode.value,
|
||||
localId: editingNodeLocalId.value || nextLocalId('node'),
|
||||
media: nodeForm.media,
|
||||
});
|
||||
const index = nodes.value.findIndex((item) =>
|
||||
editingNode.value ? item.id === editingNode.value : item.localId === draftNode.localId,
|
||||
);
|
||||
if (index >= 0) nodes.value.splice(index, 1, draftNode);
|
||||
else nodes.value.push(draftNode);
|
||||
nodes.value = nodes.value.map((node, index) => ({ ...node, sortOrder: index }));
|
||||
message.success(t('common.msg.saved'));
|
||||
nodeModal.value = false;
|
||||
if (!isNew.value) nodes.value = (await artworkApi.listNodes(artworkId.value)).map(normalizeNode);
|
||||
} finally {
|
||||
nodeSaving.value = false;
|
||||
}
|
||||
}
|
||||
function removeNode(n: any) {
|
||||
if (isNew.value) {
|
||||
nodes.value = nodes.value.filter((item) => item.localId !== n.localId);
|
||||
nodes.value = nodes.value.map((node, index) => ({ ...node, sortOrder: index }));
|
||||
return;
|
||||
}
|
||||
dialog.warning({
|
||||
title: t('common.action.delete'),
|
||||
content: t('common.msg.confirmDelete'),
|
||||
positiveText: t('common.action.confirm'),
|
||||
negativeText: t('common.action.cancel'),
|
||||
onPositiveClick: async () => {
|
||||
await artworkApi.removeNode(n.id);
|
||||
nodes.value = (await artworkApi.listNodes(artworkId.value)).map(normalizeNode);
|
||||
onPositiveClick: () => {
|
||||
nodes.value = nodes.value.filter((item) => (n.id ? item.id !== n.id : item.localId !== n.localId));
|
||||
nodes.value = nodes.value.map((node, index) => ({ ...node, sortOrder: index }));
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -528,45 +636,37 @@ async function saveCert() {
|
||||
type: certForm.type,
|
||||
originKey: certForm.files[0].key,
|
||||
};
|
||||
if (isNew.value) {
|
||||
certs.value.push(
|
||||
normalizeCert({
|
||||
...payload,
|
||||
localId: nextLocalId('cert'),
|
||||
originUrl: certForm.files[0].url,
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
await artworkApi.createCert(artworkId.value, payload);
|
||||
}
|
||||
certs.value.push(
|
||||
normalizeCert({
|
||||
...payload,
|
||||
localId: nextLocalId('cert'),
|
||||
originUrl: certForm.files[0].url,
|
||||
}),
|
||||
);
|
||||
message.success(t('common.msg.created'));
|
||||
certModal.value = false;
|
||||
if (!isNew.value) certs.value = (await artworkApi.listCerts(artworkId.value)).map(normalizeCert);
|
||||
} finally {
|
||||
certSaving.value = false;
|
||||
}
|
||||
}
|
||||
function removeCert(c: any) {
|
||||
if (isNew.value) {
|
||||
certs.value = certs.value.filter((item) => item.localId !== c.localId);
|
||||
return;
|
||||
}
|
||||
dialog.warning({
|
||||
title: t('common.action.delete'),
|
||||
content: t('common.msg.confirmDelete'),
|
||||
positiveText: t('common.action.confirm'),
|
||||
negativeText: t('common.action.cancel'),
|
||||
onPositiveClick: async () => {
|
||||
await artworkApi.removeCert(c.id);
|
||||
certs.value = (await artworkApi.listCerts(artworkId.value)).map(normalizeCert);
|
||||
onPositiveClick: () => {
|
||||
certs.value = certs.value.filter((item) => (c.id ? item.id !== c.id : item.localId !== c.localId));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadTemplates();
|
||||
if (!isNew.value) await loadArtwork();
|
||||
else nodes.value = defaultTraceNodes();
|
||||
if (!isNew.value) {
|
||||
await loadArtwork();
|
||||
await loadRevisions();
|
||||
} else nodes.value = defaultTraceNodes();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -118,8 +118,12 @@ const columns: DataTableColumns<any> = [
|
||||
render: (r) =>
|
||||
h(
|
||||
NTag,
|
||||
{ size: 'small', type: r.auditStatus === 'APPROVED' ? 'success' : r.auditStatus === 'REJECTED' ? 'error' : 'warning' },
|
||||
{ default: () => t(`common.auditStatus.${r.auditStatus || 'PENDING'}`) },
|
||||
{
|
||||
size: 'small',
|
||||
type: (r.effectiveAuditStatus || r.auditStatus) === 'APPROVED' ? 'success' : (r.effectiveAuditStatus || r.auditStatus) === 'REJECTED' ? 'error' : 'warning',
|
||||
title: r.effectiveAuditRemark || r.latestRevision?.auditRemark || '',
|
||||
},
|
||||
{ default: () => t(`common.auditStatus.${r.effectiveAuditStatus || r.auditStatus || 'PENDING'}`) },
|
||||
),
|
||||
},
|
||||
{ title: () => t('common.label.createdAt'), key: 'createdAt', width: 150, align: 'center', ellipsis: { tooltip: true }, render: (r) => fmt(r.createdAt), ...sortProps('createdAt') },
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
class="table-fill"
|
||||
flex-height
|
||||
remote
|
||||
:scroll-x="1350"
|
||||
:scroll-x="1750"
|
||||
:row-key="(r) => r.id"
|
||||
@update:sorter="onSorterChange"
|
||||
/>
|
||||
@@ -125,6 +125,8 @@ const columns: DataTableColumns<any> = [
|
||||
),
|
||||
},
|
||||
{ title: () => t('pages.artwork.artist'), key: 'artist', minWidth: 140, ellipsis: { tooltip: true }, render: (r) => r.artist || '-' },
|
||||
{ title: () => t('pages.artwork.changeTitle'), key: 'revisionTitle', minWidth: 150, ellipsis: { tooltip: true }, render: (r) => r.revisionTitle || '-' },
|
||||
{ title: () => t('pages.artwork.changeReason'), key: 'revisionReason', minWidth: 220, ellipsis: { tooltip: true }, render: (r) => r.revisionReason || '-' },
|
||||
{
|
||||
title: () => renderTableFilterTitle(t('pages.audit.status'), query.auditStatus, auditStatusOptions, (value) => setAuditFilter(value)),
|
||||
key: 'auditStatus',
|
||||
@@ -132,7 +134,9 @@ const columns: DataTableColumns<any> = [
|
||||
align: 'center',
|
||||
render: (r) => h(NTag, { size: 'small', type: auditTagType(r.auditStatus) }, { default: () => t(`common.auditStatus.${r.auditStatus}`) }),
|
||||
},
|
||||
{ title: () => t('pages.audit.remark'), key: 'auditRemark', minWidth: 280, ellipsis: { tooltip: true }, render: (r) => r.auditRemark || '-' },
|
||||
{ title: () => t('pages.artwork.submitter'), key: 'submittedBy', width: 130, align: 'center', ellipsis: { tooltip: true }, render: (r) => r.submittedBy?.realName || r.submittedBy?.username || '-' },
|
||||
{ title: () => t('pages.artwork.submittedAt'), key: 'submittedAt', width: 160, align: 'center', render: (r) => fmt(r.submittedAt) },
|
||||
{ title: () => t('pages.audit.remark'), key: 'auditRemark', minWidth: 200, ellipsis: { tooltip: true }, render: (r) => r.auditRemark || '-' },
|
||||
{ title: () => t('common.label.updatedAt'), key: 'updatedAt', width: 160, align: 'center', render: (r) => fmt(r.updatedAt), ...sortProps('updatedAt') },
|
||||
{
|
||||
title: () => t('common.label.operation'),
|
||||
@@ -154,7 +158,7 @@ async function load() {
|
||||
try {
|
||||
const res: any = await auditApi.list({
|
||||
keyword: query.keyword || undefined,
|
||||
auditStatus: query.auditStatus || undefined,
|
||||
status: query.auditStatus || undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
...sortParams(),
|
||||
@@ -176,7 +180,7 @@ function previewArtworkImages(images: any[]) {
|
||||
);
|
||||
}
|
||||
function goDetail(r: any) {
|
||||
router.push(`/artworks/${r.id}`);
|
||||
router.push(`/artworks/${r.id}${r.revisionId ? `?revisionId=${r.revisionId}` : ''}`);
|
||||
}
|
||||
function setAuditFilter(value: string | number | null) {
|
||||
query.auditStatus = value ? String(value) : null;
|
||||
@@ -189,7 +193,7 @@ function approve(r: any) {
|
||||
positiveText: t('common.action.confirm'),
|
||||
negativeText: t('common.action.cancel'),
|
||||
onPositiveClick: async () => {
|
||||
await auditApi.audit(r.id, { approved: true });
|
||||
await auditApi.audit(r.id, { approved: true, revisionId: r.revisionId });
|
||||
message.success(t('pages.audit.approved'));
|
||||
load();
|
||||
},
|
||||
@@ -204,7 +208,8 @@ async function doReject() {
|
||||
if (rejectId.value === null) return;
|
||||
acting.value = true;
|
||||
try {
|
||||
await auditApi.audit(rejectId.value, { approved: false, remark: rejectRemark.value });
|
||||
const row = rows.value.find((item) => item.id === rejectId.value);
|
||||
await auditApi.audit(rejectId.value, { approved: false, remark: rejectRemark.value, revisionId: row?.revisionId });
|
||||
message.success(t('pages.audit.rejected'));
|
||||
rejectModal.value = false;
|
||||
load();
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
CREATE TABLE `artwork_revision` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`artwork_id` INTEGER NOT NULL,
|
||||
`title` VARCHAR(191) NOT NULL,
|
||||
`reason` TEXT NULL,
|
||||
`before_snapshot` JSON NOT NULL,
|
||||
`after_snapshot` JSON NOT NULL,
|
||||
`status` ENUM('PENDING', 'APPROVED', 'REJECTED') NOT NULL DEFAULT 'PENDING',
|
||||
`audit_remark` TEXT NULL,
|
||||
`submitted_by` INTEGER NULL,
|
||||
`submitted_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`reviewed_by` INTEGER NULL,
|
||||
`reviewed_at` DATETIME(3) NULL,
|
||||
|
||||
INDEX `artwork_revision_artwork_id_idx`(`artwork_id`),
|
||||
INDEX `artwork_revision_status_idx`(`status`),
|
||||
INDEX `artwork_revision_submitted_at_idx`(`submitted_at`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
ALTER TABLE `artwork_revision`
|
||||
ADD CONSTRAINT `artwork_revision_artwork_id_fkey`
|
||||
FOREIGN KEY (`artwork_id`) REFERENCES `artwork`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `artwork_revision`
|
||||
ADD CONSTRAINT `artwork_revision_submitted_by_fkey`
|
||||
FOREIGN KEY (`submitted_by`) REFERENCES `sys_user`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `artwork_revision`
|
||||
ADD CONSTRAINT `artwork_revision_reviewed_by_fkey`
|
||||
FOREIGN KEY (`reviewed_by`) REFERENCES `sys_user`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -46,6 +46,12 @@ enum AuditStatus {
|
||||
REJECTED
|
||||
}
|
||||
|
||||
enum ArtworkRevisionStatus {
|
||||
PENDING
|
||||
APPROVED
|
||||
REJECTED
|
||||
}
|
||||
|
||||
enum NodeType {
|
||||
CREATE
|
||||
PRODUCE
|
||||
@@ -144,6 +150,8 @@ model SysUser {
|
||||
operationLogs OperationLog[]
|
||||
outboundImportSessions OutboundImportSession[]
|
||||
backupRecords BackupRecord[]
|
||||
submittedArtworkRevisions ArtworkRevision[] @relation("ArtworkRevisionSubmitter")
|
||||
reviewedArtworkRevisions ArtworkRevision[] @relation("ArtworkRevisionReviewer")
|
||||
|
||||
@@map("sys_user")
|
||||
}
|
||||
@@ -202,6 +210,7 @@ model Artwork {
|
||||
certificates Certificate[]
|
||||
batches Batch[]
|
||||
traceCodes TraceCode[]
|
||||
revisions ArtworkRevision[]
|
||||
|
||||
@@index([templateId])
|
||||
@@index([status])
|
||||
@@ -209,6 +218,30 @@ model Artwork {
|
||||
@@map("artwork")
|
||||
}
|
||||
|
||||
model ArtworkRevision {
|
||||
id String @id @default(cuid())
|
||||
artworkId Int @map("artwork_id")
|
||||
title String
|
||||
reason String? @db.Text
|
||||
beforeSnapshot Json @map("before_snapshot")
|
||||
afterSnapshot Json @map("after_snapshot")
|
||||
status ArtworkRevisionStatus @default(PENDING)
|
||||
auditRemark String? @db.Text @map("audit_remark")
|
||||
submittedBy Int? @map("submitted_by")
|
||||
submittedAt DateTime @default(now()) @map("submitted_at")
|
||||
reviewedBy Int? @map("reviewed_by")
|
||||
reviewedAt DateTime? @map("reviewed_at")
|
||||
|
||||
artwork Artwork @relation(fields: [artworkId], references: [id], onDelete: Cascade)
|
||||
submitter SysUser? @relation("ArtworkRevisionSubmitter", fields: [submittedBy], references: [id])
|
||||
reviewer SysUser? @relation("ArtworkRevisionReviewer", fields: [reviewedBy], references: [id])
|
||||
|
||||
@@index([artworkId])
|
||||
@@index([status])
|
||||
@@index([submittedAt])
|
||||
@@map("artwork_revision")
|
||||
}
|
||||
|
||||
model TraceNode {
|
||||
id Int @id @default(autoincrement())
|
||||
artworkId Int @map("artwork_id")
|
||||
|
||||
@@ -2,7 +2,13 @@ import { Body, Controller, Delete, Get, Param, ParseIntPipe, Post, Put, Query }
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { RoleType } from '@artveris/shared';
|
||||
import { ArtworkService } from './artwork.service';
|
||||
import { AuditArtworkDto, CreateArtworkDto, QueryArtworkDto, UpdateArtworkDto } from './dto/artwork.dto';
|
||||
import {
|
||||
AuditArtworkDto,
|
||||
CreateArtworkDto,
|
||||
QueryArtworkDto,
|
||||
QueryArtworkRevisionDto,
|
||||
UpdateArtworkDto,
|
||||
} from './dto/artwork.dto';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
import { CurrentUser, AuthUser } from '../common/decorators/current-user.decorator';
|
||||
|
||||
@@ -18,12 +24,30 @@ export class ArtworkController {
|
||||
return this.artworkService.list(query);
|
||||
}
|
||||
|
||||
@Get('audit-list')
|
||||
@ApiOperation({ summary: '内容审核列表' })
|
||||
auditList(@Query() query: QueryArtworkRevisionDto) {
|
||||
return this.artworkService.auditList(query);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: '艺术品详情' })
|
||||
get(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.artworkService.get(id);
|
||||
}
|
||||
|
||||
@Get(':id/revisions')
|
||||
@ApiOperation({ summary: '作品审核变更记录' })
|
||||
revisions(@Param('id', ParseIntPipe) id: number, @Query() query: QueryArtworkRevisionDto) {
|
||||
return this.artworkService.listRevisions(id, query);
|
||||
}
|
||||
|
||||
@Get(':id/revisions/:revisionId')
|
||||
@ApiOperation({ summary: '作品审核变更详情' })
|
||||
revision(@Param('id', ParseIntPipe) id: number, @Param('revisionId') revisionId: string) {
|
||||
return this.artworkService.getRevision(id, revisionId);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@Roles(RoleType.OPERATOR)
|
||||
@ApiOperation({ summary: '创建艺术品档案' })
|
||||
@@ -34,8 +58,8 @@ export class ArtworkController {
|
||||
@Put(':id')
|
||||
@Roles(RoleType.OPERATOR)
|
||||
@ApiOperation({ summary: '更新艺术品档案' })
|
||||
update(@Param('id', ParseIntPipe) id: number, @Body() dto: UpdateArtworkDto) {
|
||||
return this.artworkService.update(id, dto);
|
||||
update(@Param('id', ParseIntPipe) id: number, @Body() dto: UpdateArtworkDto, @CurrentUser() user: AuthUser) {
|
||||
return this.artworkService.update(id, dto, user.id);
|
||||
}
|
||||
|
||||
@Post(':id/audit')
|
||||
|
||||
@@ -2,13 +2,21 @@ import { Injectable } from '@nestjs/common';
|
||||
import { InjectQueue } from '@nestjs/bullmq';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { Queue } from 'bullmq';
|
||||
import { AuditStatus, ErrorCode, QUEUE_NAMES } from '@artveris/shared';
|
||||
import { ArtworkRevisionStatus, ArtworkStatus, AuditStatus, ErrorCode, QUEUE_NAMES } from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { BusinessException } from '../common/exceptions/business.exception';
|
||||
import { buildPage } from '../common/utils/pagination.util';
|
||||
import { buildOrderBy } from '../common/utils/sort.util';
|
||||
import { AuditArtworkDto, CreateArtworkDto, QueryArtworkDto, UpdateArtworkDto } from './dto/artwork.dto';
|
||||
import {
|
||||
AuditArtworkDto,
|
||||
CreateArtworkCertificateDto,
|
||||
CreateArtworkDto,
|
||||
CreateArtworkTraceNodeDto,
|
||||
QueryArtworkDto,
|
||||
QueryArtworkRevisionDto,
|
||||
UpdateArtworkDto,
|
||||
} from './dto/artwork.dto';
|
||||
|
||||
interface MediaItem {
|
||||
key: string;
|
||||
@@ -16,6 +24,38 @@ interface MediaItem {
|
||||
type?: string;
|
||||
}
|
||||
|
||||
interface TraceNodeSnapshot {
|
||||
nodeType: string;
|
||||
title: string;
|
||||
occurredAt?: string | null;
|
||||
location?: string | null;
|
||||
description?: string | null;
|
||||
mediaFiles?: MediaItem[];
|
||||
sortOrder: number;
|
||||
}
|
||||
|
||||
interface CertificateSnapshot {
|
||||
name: string;
|
||||
issuer?: string | null;
|
||||
issuedAt?: string | null;
|
||||
type: string;
|
||||
originKey: string;
|
||||
watermarkKey?: string | null;
|
||||
}
|
||||
|
||||
interface ArtworkSnapshot {
|
||||
artwork: {
|
||||
templateId: number;
|
||||
title: string;
|
||||
artist?: string | null;
|
||||
status: ArtworkStatus;
|
||||
dynamicFields: Record<string, unknown>;
|
||||
images: MediaItem[];
|
||||
};
|
||||
traceNodes: TraceNodeSnapshot[];
|
||||
certificates: CertificateSnapshot[];
|
||||
}
|
||||
|
||||
const DEFAULT_TRACE_NODES: Prisma.TraceNodeCreateWithoutArtworkInput[] = [
|
||||
{ nodeType: 'CREATE', title: '创作 / 选胚', sortOrder: 0 },
|
||||
{ nodeType: 'PRODUCE', title: '制作过程', sortOrder: 1 },
|
||||
@@ -38,7 +78,6 @@ export class ArtworkService {
|
||||
.map((i) => ({ ...i, url: this.storage.getUrl(i.key) }));
|
||||
}
|
||||
|
||||
// 档案编号:款级唯一标识,按作品 id 生成,如 ARTVERIS-000001
|
||||
private buildArchiveNo(id: number): string {
|
||||
return `ARTVERIS-${String(id).padStart(6, '0')}`;
|
||||
}
|
||||
@@ -49,25 +88,10 @@ export class ArtworkService {
|
||||
});
|
||||
if (!tpl) throw new BusinessException(ErrorCode.TEMPLATE_NOT_FOUND, '模板不存在', 404);
|
||||
|
||||
const status = dto.status ?? ArtworkStatus.ACTIVE;
|
||||
const traceNodes =
|
||||
dto.traceNodes === undefined
|
||||
? DEFAULT_TRACE_NODES
|
||||
: dto.traceNodes.map((node, index) => ({
|
||||
nodeType: node.nodeType,
|
||||
title: node.title,
|
||||
occurredAt: node.occurredAt ? new Date(node.occurredAt) : null,
|
||||
location: node.location,
|
||||
description: node.description,
|
||||
mediaFiles: (node.mediaFiles ?? []) as unknown as Prisma.InputJsonValue,
|
||||
sortOrder: node.sortOrder ?? index,
|
||||
}));
|
||||
const certificates = (dto.certificates ?? []).map((cert) => ({
|
||||
name: cert.name,
|
||||
issuer: cert.issuer,
|
||||
issuedAt: cert.issuedAt ? new Date(cert.issuedAt) : null,
|
||||
type: cert.type,
|
||||
originFileUrl: cert.originKey,
|
||||
}));
|
||||
dto.traceNodes === undefined ? DEFAULT_TRACE_NODES : this.normalizeTraceNodeDto(dto.traceNodes);
|
||||
const certificates = this.normalizeCertificateDto(dto.certificates ?? []);
|
||||
|
||||
const artwork = await this.prisma.$transaction(async (tx) => {
|
||||
const created = await tx.artwork.create({
|
||||
@@ -75,27 +99,57 @@ export class ArtworkService {
|
||||
templateId: dto.templateId,
|
||||
title: dto.title,
|
||||
artist: dto.artist,
|
||||
status: dto.status,
|
||||
status,
|
||||
auditStatus: AuditStatus.PENDING,
|
||||
dynamicFields: (dto.dynamicFields ?? {}) as Prisma.InputJsonValue,
|
||||
images: (dto.images ?? []) as unknown as Prisma.InputJsonValue,
|
||||
createdBy: userId,
|
||||
traceNodes: traceNodes.length ? { create: traceNodes } : undefined,
|
||||
certificates: certificates.length ? { create: certificates } : undefined,
|
||||
traceNodes: traceNodes.length
|
||||
? {
|
||||
create: traceNodes.map((node) => ({
|
||||
nodeType: node.nodeType as any,
|
||||
title: node.title,
|
||||
occurredAt: node.occurredAt ? new Date(node.occurredAt) : null,
|
||||
location: node.location,
|
||||
description: node.description,
|
||||
mediaFiles: (node.mediaFiles ?? []) as unknown as Prisma.InputJsonValue,
|
||||
sortOrder: node.sortOrder,
|
||||
})),
|
||||
}
|
||||
: undefined,
|
||||
certificates: certificates.length
|
||||
? {
|
||||
create: certificates.map((cert) => ({
|
||||
name: cert.name,
|
||||
issuer: cert.issuer,
|
||||
issuedAt: cert.issuedAt ? new Date(cert.issuedAt) : null,
|
||||
type: cert.type as any,
|
||||
originFileUrl: cert.originKey,
|
||||
watermarkFileUrl: cert.watermarkKey ?? null,
|
||||
})),
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
include: { certificates: true },
|
||||
include: { traceNodes: true, certificates: true },
|
||||
});
|
||||
await tx.artwork.update({
|
||||
where: { id: created.id },
|
||||
data: { archiveNo: this.buildArchiveNo(created.id) },
|
||||
const archiveNo = this.buildArchiveNo(created.id);
|
||||
await tx.artwork.update({ where: { id: created.id }, data: { archiveNo } });
|
||||
const snapshot = this.snapshotFromRecord(created);
|
||||
await tx.artworkRevision.create({
|
||||
data: {
|
||||
artworkId: created.id,
|
||||
title: status === ArtworkStatus.DRAFT ? '创建草稿' : '提交初次审核',
|
||||
reason: status === ArtworkStatus.DRAFT ? '新建作品保存为草稿' : '新建作品提交审核',
|
||||
beforeSnapshot: {} as Prisma.InputJsonObject,
|
||||
afterSnapshot: snapshot as unknown as Prisma.InputJsonObject,
|
||||
status: status === ArtworkStatus.DRAFT ? ArtworkRevisionStatus.APPROVED : ArtworkRevisionStatus.PENDING,
|
||||
submittedBy: userId,
|
||||
},
|
||||
});
|
||||
return created;
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
artwork.certificates.map((cert) =>
|
||||
this.watermarkQueue.add('generate', { certificateId: cert.id, originKey: cert.originFileUrl }),
|
||||
),
|
||||
);
|
||||
await this.enqueuePendingCertificateWatermarks(artwork.id);
|
||||
return this.get(artwork.id);
|
||||
}
|
||||
|
||||
@@ -126,7 +180,7 @@ export class ArtworkService {
|
||||
}),
|
||||
this.prisma.artwork.count({ where }),
|
||||
]);
|
||||
// 每款查询总次数 = 该款所有码 queryCount 之和(PRD 6.5:按款统计)
|
||||
|
||||
const ids = rows.map((r) => r.id);
|
||||
const sums = ids.length
|
||||
? await this.prisma.traceCode.groupBy({
|
||||
@@ -135,13 +189,33 @@ export class ArtworkService {
|
||||
_sum: { queryCount: true },
|
||||
})
|
||||
: [];
|
||||
const revisions = ids.length
|
||||
? await this.prisma.artworkRevision.findMany({
|
||||
where: { artworkId: { in: ids } },
|
||||
orderBy: { submittedAt: 'desc' },
|
||||
select: { id: true, artworkId: true, title: true, status: true, auditRemark: true, submittedAt: true },
|
||||
})
|
||||
: [];
|
||||
const sumMap = new Map(sums.map((s) => [s.artworkId, s._sum.queryCount ?? 0]));
|
||||
const list = rows.map((a) => ({
|
||||
...a,
|
||||
images: this.mapMedia(a.images),
|
||||
codeCount: a._count.traceCodes,
|
||||
queryTotal: sumMap.get(a.id) ?? 0,
|
||||
}));
|
||||
const revisionMap = new Map<number, (typeof revisions)[number]>();
|
||||
for (const revision of revisions) {
|
||||
const current = revisionMap.get(revision.artworkId);
|
||||
if (!current || revision.status === ArtworkRevisionStatus.PENDING) {
|
||||
revisionMap.set(revision.artworkId, revision);
|
||||
}
|
||||
}
|
||||
const list = rows.map((a) => {
|
||||
const revision = revisionMap.get(a.id) ?? null;
|
||||
return {
|
||||
...a,
|
||||
images: this.mapMedia(a.images),
|
||||
codeCount: a._count.traceCodes,
|
||||
queryTotal: sumMap.get(a.id) ?? 0,
|
||||
latestRevision: revision,
|
||||
effectiveAuditStatus: revision?.status ?? a.auditStatus,
|
||||
effectiveAuditRemark: revision?.auditRemark ?? a.auditRemark,
|
||||
};
|
||||
});
|
||||
return buildPage(list, total, query.page, query.pageSize);
|
||||
}
|
||||
|
||||
@@ -156,12 +230,19 @@ export class ArtworkService {
|
||||
},
|
||||
});
|
||||
if (!a) throw new BusinessException(ErrorCode.ARTWORK_NOT_FOUND, '艺术品不存在', 404);
|
||||
// 码统计:总数、已激活数、查询总次数(按款聚合)
|
||||
const [total, active, batchTotal, agg] = await this.prisma.$transaction([
|
||||
const [total, active, batchTotal, agg, latestRevision] = await this.prisma.$transaction([
|
||||
this.prisma.traceCode.count({ where: { artworkId: id } }),
|
||||
this.prisma.traceCode.count({ where: { artworkId: id, status: 'ACTIVE' } }),
|
||||
this.prisma.batch.count({ where: { artworkId: id } }),
|
||||
this.prisma.traceCode.aggregate({ where: { artworkId: id }, _sum: { queryCount: true } }),
|
||||
this.prisma.artworkRevision.findFirst({
|
||||
where: { artworkId: id },
|
||||
orderBy: { submittedAt: 'desc' },
|
||||
include: {
|
||||
submitter: { select: { id: true, username: true, realName: true } },
|
||||
reviewer: { select: { id: true, username: true, realName: true } },
|
||||
},
|
||||
}),
|
||||
]);
|
||||
return {
|
||||
...a,
|
||||
@@ -172,35 +253,174 @@ export class ArtworkService {
|
||||
originUrl: c.originFileUrl ? this.storage.getUrl(c.originFileUrl) : null,
|
||||
watermarkUrl: c.watermarkFileUrl ? this.storage.getUrl(c.watermarkFileUrl) : null,
|
||||
})),
|
||||
latestRevision,
|
||||
effectiveAuditStatus: latestRevision?.status ?? a.auditStatus,
|
||||
effectiveAuditRemark: latestRevision?.auditRemark ?? a.auditRemark,
|
||||
codeStats: { total, active, batchTotal, queryTotal: agg._sum.queryCount ?? 0 },
|
||||
};
|
||||
}
|
||||
|
||||
async update(id: number, dto: UpdateArtworkDto) {
|
||||
await this.ensureExists(id);
|
||||
const data: Prisma.ArtworkUpdateInput = {
|
||||
title: dto.title,
|
||||
artist: dto.artist,
|
||||
status: dto.status,
|
||||
// 内容变更需重新审核:编辑后回到待审核
|
||||
auditStatus: AuditStatus.PENDING,
|
||||
auditRemark: null,
|
||||
auditedBy: null,
|
||||
auditedAt: null,
|
||||
async update(id: number, dto: UpdateArtworkDto, userId: number) {
|
||||
const current = await this.getSnapshot(id);
|
||||
const nextStatus = dto.status === ArtworkStatus.DRAFT ? ArtworkStatus.ACTIVE : dto.status ?? current.artwork.status;
|
||||
const afterSnapshot: ArtworkSnapshot = {
|
||||
artwork: {
|
||||
templateId: current.artwork.templateId,
|
||||
title: dto.title ?? current.artwork.title,
|
||||
artist: dto.artist ?? current.artwork.artist,
|
||||
status: nextStatus,
|
||||
dynamicFields: dto.dynamicFields ?? current.artwork.dynamicFields,
|
||||
images: (dto.images ?? current.artwork.images) as MediaItem[],
|
||||
},
|
||||
traceNodes: dto.traceNodes ? this.normalizeTraceNodeDto(dto.traceNodes) : current.traceNodes,
|
||||
certificates: dto.certificates ? this.normalizeCertificateDto(dto.certificates) : current.certificates,
|
||||
};
|
||||
if (dto.dynamicFields !== undefined) {
|
||||
data.dynamicFields = dto.dynamicFields as Prisma.InputJsonValue;
|
||||
}
|
||||
if (dto.images !== undefined) {
|
||||
data.images = dto.images as unknown as Prisma.InputJsonValue;
|
||||
}
|
||||
await this.prisma.artwork.update({ where: { id }, data });
|
||||
|
||||
const artwork = await this.ensureExists(id);
|
||||
const shouldApplyDirectly = artwork.status !== ArtworkStatus.ACTIVE || artwork.auditStatus !== AuditStatus.APPROVED;
|
||||
const revisionTitle = dto.revisionTitle || '作品内容修改';
|
||||
const revisionReason = dto.revisionReason || null;
|
||||
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
await this.supersedePendingRevisions(tx, id);
|
||||
const revision = await tx.artworkRevision.create({
|
||||
data: {
|
||||
artworkId: id,
|
||||
title: revisionTitle,
|
||||
reason: revisionReason,
|
||||
beforeSnapshot: current as unknown as Prisma.InputJsonObject,
|
||||
afterSnapshot: afterSnapshot as unknown as Prisma.InputJsonObject,
|
||||
status: ArtworkRevisionStatus.PENDING,
|
||||
submittedBy: userId,
|
||||
},
|
||||
});
|
||||
|
||||
if (shouldApplyDirectly) {
|
||||
await this.applySnapshot(tx, id, afterSnapshot, {
|
||||
auditStatus: AuditStatus.PENDING,
|
||||
auditRemark: null,
|
||||
auditedBy: null,
|
||||
auditedAt: null,
|
||||
});
|
||||
await tx.artworkRevision.update({ where: { id: revision.id }, data: { afterSnapshot: afterSnapshot as unknown as Prisma.InputJsonObject } });
|
||||
}
|
||||
});
|
||||
|
||||
await this.enqueuePendingCertificateWatermarks(id);
|
||||
return this.get(id);
|
||||
}
|
||||
|
||||
// 审核:通过 / 驳回(审核员或超管)
|
||||
async auditList(query: QueryArtworkRevisionDto) {
|
||||
const where: Prisma.ArtworkRevisionWhereInput = {};
|
||||
if (query.status) where.status = query.status;
|
||||
else where.status = ArtworkRevisionStatus.PENDING;
|
||||
if (query.keyword) {
|
||||
where.OR = [
|
||||
{ title: { contains: query.keyword } },
|
||||
{ artwork: { title: { contains: query.keyword } } },
|
||||
{ artwork: { archiveNo: { contains: query.keyword } } },
|
||||
];
|
||||
}
|
||||
const orderBy = buildOrderBy(query.sortField, query.sortOrder, ['submittedAt', 'reviewedAt'] as const, {
|
||||
submittedAt: 'desc',
|
||||
});
|
||||
const [rows, total] = await this.prisma.$transaction([
|
||||
this.prisma.artworkRevision.findMany({
|
||||
where,
|
||||
include: {
|
||||
artwork: {
|
||||
include: {
|
||||
template: { select: { id: true, name: true } },
|
||||
_count: { select: { traceCodes: true } },
|
||||
},
|
||||
},
|
||||
submitter: { select: { id: true, username: true, realName: true } },
|
||||
reviewer: { select: { id: true, username: true, realName: true } },
|
||||
},
|
||||
orderBy,
|
||||
skip: query.skip,
|
||||
take: query.take,
|
||||
}),
|
||||
this.prisma.artworkRevision.count({ where }),
|
||||
]);
|
||||
const list = rows
|
||||
.filter((r) => !r.artwork.deletedAt && r.artwork.status !== ArtworkStatus.DRAFT)
|
||||
.map((r) => {
|
||||
const after = this.snapshotWithUrls(r.afterSnapshot) as ArtworkSnapshot & {
|
||||
artwork?: { images?: Array<MediaItem & { url: string }> };
|
||||
};
|
||||
return {
|
||||
...r.artwork,
|
||||
title: after.artwork?.title ?? r.artwork.title,
|
||||
artist: after.artwork?.artist ?? r.artwork.artist,
|
||||
revisionId: r.id,
|
||||
revisionTitle: r.title,
|
||||
revisionReason: r.reason,
|
||||
submittedAt: r.submittedAt,
|
||||
submittedBy: r.submitter,
|
||||
reviewedAt: r.reviewedAt,
|
||||
reviewedBy: r.reviewer,
|
||||
auditStatus: r.status,
|
||||
auditRemark: r.auditRemark,
|
||||
images: after.artwork?.images ?? this.mapMedia(r.artwork.images),
|
||||
codeCount: r.artwork._count.traceCodes,
|
||||
isRevision: true,
|
||||
};
|
||||
});
|
||||
return buildPage(list, total, query.page, query.pageSize);
|
||||
}
|
||||
|
||||
async listRevisions(id: number, query: QueryArtworkRevisionDto) {
|
||||
await this.ensureExists(id);
|
||||
const where: Prisma.ArtworkRevisionWhereInput = { artworkId: id };
|
||||
if (query.status) where.status = query.status;
|
||||
const [rows, total] = await this.prisma.$transaction([
|
||||
this.prisma.artworkRevision.findMany({
|
||||
where,
|
||||
include: {
|
||||
submitter: { select: { id: true, username: true, realName: true } },
|
||||
reviewer: { select: { id: true, username: true, realName: true } },
|
||||
},
|
||||
orderBy: { submittedAt: 'desc' },
|
||||
skip: query.skip,
|
||||
take: query.take,
|
||||
}),
|
||||
this.prisma.artworkRevision.count({ where }),
|
||||
]);
|
||||
return buildPage(rows, total, query.page, query.pageSize);
|
||||
}
|
||||
|
||||
async getRevision(id: number, revisionId: string) {
|
||||
const revision = await this.prisma.artworkRevision.findFirst({
|
||||
where: { id: revisionId, artworkId: id },
|
||||
include: {
|
||||
artwork: { select: { id: true, title: true, archiveNo: true } },
|
||||
submitter: { select: { id: true, username: true, realName: true } },
|
||||
reviewer: { select: { id: true, username: true, realName: true } },
|
||||
},
|
||||
});
|
||||
if (!revision) throw new BusinessException(ErrorCode.NOT_FOUND, '修改记录不存在', 404);
|
||||
return {
|
||||
...revision,
|
||||
beforeSnapshot: this.snapshotWithUrls(revision.beforeSnapshot),
|
||||
afterSnapshot: this.snapshotWithUrls(revision.afterSnapshot),
|
||||
};
|
||||
}
|
||||
|
||||
async audit(id: number, dto: AuditArtworkDto, auditorId: number) {
|
||||
await this.ensureExists(id);
|
||||
const revision = dto.revisionId
|
||||
? await this.prisma.artworkRevision.findFirst({ where: { id: dto.revisionId, artworkId: id } })
|
||||
: await this.prisma.artworkRevision.findFirst({
|
||||
where: { artworkId: id, status: ArtworkRevisionStatus.PENDING },
|
||||
orderBy: { submittedAt: 'desc' },
|
||||
});
|
||||
|
||||
if (revision) {
|
||||
await this.auditRevision(id, revision.id, dto, auditorId);
|
||||
return this.get(id);
|
||||
}
|
||||
|
||||
await this.prisma.artwork.update({
|
||||
where: { id },
|
||||
data: {
|
||||
@@ -222,7 +442,7 @@ export class ArtworkService {
|
||||
if (traceCodeCount > 0 || queryLogCount > 0) {
|
||||
throw new BusinessException(
|
||||
ErrorCode.ARTWORK_IN_USE,
|
||||
'该档案已生成追溯码或存在查询记录,不能删除;请改为停用或归档',
|
||||
'该档案已生成追溯码或存在查询记录,不能删除;请改为停用或归档。',
|
||||
400,
|
||||
);
|
||||
}
|
||||
@@ -230,6 +450,242 @@ export class ArtworkService {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
private normalizeTraceNodeDto(nodes: CreateArtworkTraceNodeDto[]): TraceNodeSnapshot[] {
|
||||
return nodes.map((node, index) => ({
|
||||
nodeType: node.nodeType,
|
||||
title: node.title,
|
||||
occurredAt: node.occurredAt ?? null,
|
||||
location: node.location ?? null,
|
||||
description: node.description ?? null,
|
||||
mediaFiles: (node.mediaFiles ?? []) as MediaItem[],
|
||||
sortOrder: node.sortOrder ?? index,
|
||||
}));
|
||||
}
|
||||
|
||||
private normalizeCertificateDto(certs: CreateArtworkCertificateDto[]): CertificateSnapshot[] {
|
||||
return certs.map((cert) => ({
|
||||
name: cert.name,
|
||||
issuer: cert.issuer ?? null,
|
||||
issuedAt: cert.issuedAt ?? null,
|
||||
type: cert.type,
|
||||
originKey: cert.originKey,
|
||||
watermarkKey: cert.watermarkKey ?? null,
|
||||
}));
|
||||
}
|
||||
|
||||
private snapshotFromRecord(record: {
|
||||
templateId: number;
|
||||
title: string;
|
||||
artist: string | null;
|
||||
status: string;
|
||||
dynamicFields: Prisma.JsonValue | null;
|
||||
images: Prisma.JsonValue | null;
|
||||
traceNodes: Array<{
|
||||
nodeType: string;
|
||||
title: string;
|
||||
occurredAt: Date | null;
|
||||
location: string | null;
|
||||
description: string | null;
|
||||
mediaFiles: Prisma.JsonValue | null;
|
||||
sortOrder: number;
|
||||
}>;
|
||||
certificates: Array<{
|
||||
name: string;
|
||||
issuer: string | null;
|
||||
issuedAt: Date | null;
|
||||
type: string;
|
||||
originFileUrl: string;
|
||||
watermarkFileUrl: string | null;
|
||||
}>;
|
||||
}): ArtworkSnapshot {
|
||||
return {
|
||||
artwork: {
|
||||
templateId: record.templateId,
|
||||
title: record.title,
|
||||
artist: record.artist,
|
||||
status: record.status as ArtworkStatus,
|
||||
dynamicFields: (record.dynamicFields as Record<string, unknown>) ?? {},
|
||||
images: (Array.isArray(record.images) ? record.images : []) as unknown as MediaItem[],
|
||||
},
|
||||
traceNodes: record.traceNodes
|
||||
.sort((a, b) => a.sortOrder - b.sortOrder)
|
||||
.map((node) => ({
|
||||
nodeType: node.nodeType,
|
||||
title: node.title,
|
||||
occurredAt: node.occurredAt ? node.occurredAt.toISOString() : null,
|
||||
location: node.location,
|
||||
description: node.description,
|
||||
mediaFiles: (Array.isArray(node.mediaFiles) ? node.mediaFiles : []) as unknown as MediaItem[],
|
||||
sortOrder: node.sortOrder,
|
||||
})),
|
||||
certificates: record.certificates.map((cert) => ({
|
||||
name: cert.name,
|
||||
issuer: cert.issuer,
|
||||
issuedAt: cert.issuedAt ? cert.issuedAt.toISOString() : null,
|
||||
type: cert.type,
|
||||
originKey: cert.originFileUrl,
|
||||
watermarkKey: cert.watermarkFileUrl,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
private snapshotWithUrls(input: unknown) {
|
||||
const snapshot = input as ArtworkSnapshot | Record<string, never>;
|
||||
if (!('artwork' in snapshot)) return snapshot;
|
||||
return {
|
||||
...snapshot,
|
||||
artwork: {
|
||||
...snapshot.artwork,
|
||||
images: this.mapMedia(snapshot.artwork.images),
|
||||
},
|
||||
traceNodes: snapshot.traceNodes.map((node) => ({
|
||||
...node,
|
||||
mediaFiles: this.mapMedia(node.mediaFiles),
|
||||
})),
|
||||
certificates: snapshot.certificates.map((cert) => ({
|
||||
...cert,
|
||||
originUrl: cert.originKey ? this.storage.getUrl(cert.originKey) : null,
|
||||
watermarkUrl: cert.watermarkKey ? this.storage.getUrl(cert.watermarkKey) : null,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
private async getSnapshot(id: number): Promise<ArtworkSnapshot> {
|
||||
const artwork = await this.prisma.artwork.findFirst({
|
||||
where: { id, deletedAt: null },
|
||||
include: {
|
||||
traceNodes: { orderBy: { sortOrder: 'asc' } },
|
||||
certificates: { orderBy: { id: 'asc' } },
|
||||
},
|
||||
});
|
||||
if (!artwork) throw new BusinessException(ErrorCode.ARTWORK_NOT_FOUND, '艺术品不存在', 404);
|
||||
return this.snapshotFromRecord(artwork);
|
||||
}
|
||||
|
||||
private async applySnapshot(
|
||||
tx: Prisma.TransactionClient,
|
||||
id: number,
|
||||
snapshot: ArtworkSnapshot,
|
||||
auditData: Pick<Prisma.ArtworkUpdateInput, 'auditStatus' | 'auditRemark' | 'auditedBy' | 'auditedAt'>,
|
||||
) {
|
||||
await tx.artwork.update({
|
||||
where: { id },
|
||||
data: {
|
||||
templateId: snapshot.artwork.templateId,
|
||||
title: snapshot.artwork.title,
|
||||
artist: snapshot.artwork.artist,
|
||||
status: snapshot.artwork.status,
|
||||
dynamicFields: snapshot.artwork.dynamicFields as Prisma.InputJsonObject,
|
||||
images: snapshot.artwork.images as unknown as Prisma.InputJsonValue,
|
||||
...auditData,
|
||||
},
|
||||
});
|
||||
await tx.traceNode.deleteMany({ where: { artworkId: id } });
|
||||
if (snapshot.traceNodes.length) {
|
||||
await tx.traceNode.createMany({
|
||||
data: snapshot.traceNodes.map((node, index) => ({
|
||||
artworkId: id,
|
||||
nodeType: node.nodeType as any,
|
||||
title: node.title,
|
||||
occurredAt: node.occurredAt ? new Date(node.occurredAt) : null,
|
||||
location: node.location,
|
||||
description: node.description,
|
||||
mediaFiles: (node.mediaFiles ?? []) as unknown as Prisma.InputJsonValue,
|
||||
sortOrder: index,
|
||||
})),
|
||||
});
|
||||
}
|
||||
await tx.certificate.deleteMany({ where: { artworkId: id } });
|
||||
if (snapshot.certificates.length) {
|
||||
await tx.certificate.createMany({
|
||||
data: snapshot.certificates.map((cert) => ({
|
||||
artworkId: id,
|
||||
name: cert.name,
|
||||
issuer: cert.issuer,
|
||||
issuedAt: cert.issuedAt ? new Date(cert.issuedAt) : null,
|
||||
type: cert.type as any,
|
||||
originFileUrl: cert.originKey,
|
||||
watermarkFileUrl: cert.watermarkKey ?? null,
|
||||
})),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async supersedePendingRevisions(tx: Prisma.TransactionClient, artworkId: number) {
|
||||
await tx.artworkRevision.updateMany({
|
||||
where: { artworkId, status: ArtworkRevisionStatus.PENDING },
|
||||
data: {
|
||||
status: ArtworkRevisionStatus.REJECTED,
|
||||
auditRemark: '已被新的修改提交替代',
|
||||
reviewedAt: new Date(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private async auditRevision(id: number, revisionId: string, dto: AuditArtworkDto, auditorId: number) {
|
||||
const artwork = await this.ensureExists(id);
|
||||
const revision = await this.prisma.artworkRevision.findFirst({ where: { id: revisionId, artworkId: id } });
|
||||
if (!revision) throw new BusinessException(ErrorCode.NOT_FOUND, '修改记录不存在', 404);
|
||||
if (revision.status !== ArtworkRevisionStatus.PENDING) {
|
||||
throw new BusinessException(ErrorCode.VALIDATION_FAILED, '该修改记录已审核,不能重复操作', 400);
|
||||
}
|
||||
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
if (dto.approved) {
|
||||
await this.applySnapshot(tx, id, revision.afterSnapshot as unknown as ArtworkSnapshot, {
|
||||
auditStatus: AuditStatus.APPROVED,
|
||||
auditRemark: dto.remark ?? null,
|
||||
auditedBy: auditorId,
|
||||
auditedAt: new Date(),
|
||||
});
|
||||
await tx.artworkRevision.update({
|
||||
where: { id: revisionId },
|
||||
data: {
|
||||
status: ArtworkRevisionStatus.APPROVED,
|
||||
auditRemark: dto.remark ?? null,
|
||||
reviewedBy: auditorId,
|
||||
reviewedAt: new Date(),
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await tx.artworkRevision.update({
|
||||
where: { id: revisionId },
|
||||
data: {
|
||||
status: ArtworkRevisionStatus.REJECTED,
|
||||
auditRemark: dto.remark ?? null,
|
||||
reviewedBy: auditorId,
|
||||
reviewedAt: new Date(),
|
||||
},
|
||||
});
|
||||
if (artwork.auditStatus !== AuditStatus.APPROVED) {
|
||||
await tx.artwork.update({
|
||||
where: { id },
|
||||
data: {
|
||||
auditStatus: AuditStatus.REJECTED,
|
||||
auditRemark: dto.remark ?? null,
|
||||
auditedBy: auditorId,
|
||||
auditedAt: new Date(),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (dto.approved) await this.enqueuePendingCertificateWatermarks(id);
|
||||
}
|
||||
|
||||
private async enqueuePendingCertificateWatermarks(artworkId: number) {
|
||||
const certs = await this.prisma.certificate.findMany({
|
||||
where: { artworkId, watermarkFileUrl: null },
|
||||
select: { id: true, originFileUrl: true },
|
||||
});
|
||||
await Promise.all(
|
||||
certs.map((cert) =>
|
||||
this.watermarkQueue.add('generate', { certificateId: cert.id, originKey: cert.originFileUrl }),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
private async ensureExists(id: number) {
|
||||
const a = await this.prisma.artwork.findFirst({ where: { id, deletedAt: null } });
|
||||
if (!a) throw new BusinessException(ErrorCode.ARTWORK_NOT_FOUND, '艺术品不存在', 404);
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { ArtworkStatus, AuditStatus, CertType, NodeType } from '@artveris/shared';
|
||||
import { ArtworkRevisionStatus, ArtworkStatus, AuditStatus, CertType, NodeType } from '@artveris/shared';
|
||||
import { PaginationDto } from '../../common/dto/pagination.dto';
|
||||
|
||||
export class MediaItemDto {
|
||||
@@ -150,6 +150,11 @@ export class CreateArtworkCertificateDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
originKey!: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '已有水印文件 key' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
watermarkKey?: string;
|
||||
}
|
||||
|
||||
export class UpdateArtworkDto {
|
||||
@@ -181,6 +186,32 @@ export class UpdateArtworkDto {
|
||||
@IsOptional()
|
||||
@IsEnum(ArtworkStatus)
|
||||
status?: ArtworkStatus;
|
||||
|
||||
@ApiPropertyOptional({ description: '变更标题' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(120)
|
||||
revisionTitle?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '变更原因 / 修改说明' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(1000)
|
||||
revisionReason?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '保存时一并提交的溯源时间轴', type: () => [CreateArtworkTraceNodeDto] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => CreateArtworkTraceNodeDto)
|
||||
traceNodes?: CreateArtworkTraceNodeDto[];
|
||||
|
||||
@ApiPropertyOptional({ description: '保存时一并提交的认证文件', type: () => [CreateArtworkCertificateDto] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => CreateArtworkCertificateDto)
|
||||
certificates?: CreateArtworkCertificateDto[];
|
||||
}
|
||||
|
||||
export class QueryArtworkDto extends PaginationDto {
|
||||
@@ -216,4 +247,21 @@ export class AuditArtworkDto {
|
||||
@IsString()
|
||||
@MaxLength(255)
|
||||
remark?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '审核变更稿 ID;为空时审核作品当前版本' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
revisionId?: string;
|
||||
}
|
||||
|
||||
export class QueryArtworkRevisionDto extends PaginationDto {
|
||||
@ApiPropertyOptional({ description: '关键词(作品名称 / 档案编号 / 变更标题)' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
keyword?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '审核状态', enum: ArtworkRevisionStatus })
|
||||
@IsOptional()
|
||||
@IsEnum(ArtworkRevisionStatus)
|
||||
status?: ArtworkRevisionStatus;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ const MODELS = [
|
||||
'template',
|
||||
'templateField',
|
||||
'artwork',
|
||||
'artworkRevision',
|
||||
'traceNode',
|
||||
'certificate',
|
||||
'traceCodeGroup',
|
||||
@@ -41,6 +42,7 @@ const PRISMA_MODEL_BY_DELEGATE: Record<(typeof MODELS)[number], string> = {
|
||||
template: 'Template',
|
||||
templateField: 'TemplateField',
|
||||
artwork: 'Artwork',
|
||||
artworkRevision: 'ArtworkRevision',
|
||||
traceNode: 'TraceNode',
|
||||
certificate: 'Certificate',
|
||||
traceCodeGroup: 'TraceCodeGroup',
|
||||
@@ -60,6 +62,8 @@ const DATE_KEYS = new Set([
|
||||
'updatedAt',
|
||||
'deletedAt',
|
||||
'auditedAt',
|
||||
'submittedAt',
|
||||
'reviewedAt',
|
||||
'occurredAt',
|
||||
'issuedAt',
|
||||
'outTime',
|
||||
|
||||
Reference in New Issue
Block a user