feat: 完成 PRD 差距与修复,新增审核流与日志清理功能,支持出库信息与动态字段,优化 C 端用户体验
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { ArtworkStatus, ErrorCode } from '@artveris/shared';
|
||||
import { AuditStatus, ErrorCode } 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 { CreateArtworkDto, QueryArtworkDto, UpdateArtworkDto } from './dto/artwork.dto';
|
||||
import { AuditArtworkDto, CreateArtworkDto, QueryArtworkDto, UpdateArtworkDto } from './dto/artwork.dto';
|
||||
|
||||
interface MediaItem {
|
||||
key: string;
|
||||
@@ -54,6 +54,7 @@ export class ArtworkService {
|
||||
];
|
||||
}
|
||||
if (query.status) where.status = query.status;
|
||||
if (query.auditStatus) where.auditStatus = query.auditStatus;
|
||||
if (query.templateId) where.templateId = query.templateId;
|
||||
|
||||
const [rows, total] = await this.prisma.$transaction([
|
||||
@@ -105,6 +106,11 @@ export class ArtworkService {
|
||||
title: dto.title,
|
||||
artist: dto.artist,
|
||||
status: dto.status,
|
||||
// 内容变更需重新审核:编辑后回到待审核
|
||||
auditStatus: AuditStatus.PENDING,
|
||||
auditRemark: null,
|
||||
auditedBy: null,
|
||||
auditedAt: null,
|
||||
};
|
||||
if (dto.dynamicFields !== undefined) {
|
||||
data.dynamicFields = dto.dynamicFields as Prisma.InputJsonValue;
|
||||
@@ -116,6 +122,21 @@ export class ArtworkService {
|
||||
return this.get(id);
|
||||
}
|
||||
|
||||
// 审核:通过 / 驳回(审核员或超管)
|
||||
async audit(id: number, dto: AuditArtworkDto, auditorId: number) {
|
||||
await this.ensureExists(id);
|
||||
await this.prisma.artwork.update({
|
||||
where: { id },
|
||||
data: {
|
||||
auditStatus: dto.approved ? AuditStatus.APPROVED : AuditStatus.REJECTED,
|
||||
auditRemark: dto.remark ?? null,
|
||||
auditedBy: auditorId,
|
||||
auditedAt: new Date(),
|
||||
},
|
||||
});
|
||||
return this.get(id);
|
||||
}
|
||||
|
||||
async remove(id: number) {
|
||||
await this.ensureExists(id);
|
||||
await this.prisma.artwork.update({ where: { id }, data: { deletedAt: new Date() } });
|
||||
|
||||
Reference in New Issue
Block a user