feat: 完成 PRD 差距与修复,新增审核流与日志清理功能,支持出库信息与动态字段,优化 C 端用户体验

This commit is contained in:
Nixevol
2026-06-29 23:41:39 +08:00
parent d18b7c592d
commit 2fba42c9fd
39 changed files with 1247 additions and 185 deletions
+2
View File
@@ -1,5 +1,6 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ScheduleModule } from '@nestjs/schedule';
import configuration from './config/configuration';
import { PrismaModule } from './prisma/prisma.module';
import { AppController } from './app.controller';
@@ -30,6 +31,7 @@ import { SettingsModule } from './settings/settings.module';
load: [configuration],
envFilePath: ['../../.env', '.env'],
}),
ScheduleModule.forRoot(),
PrismaModule,
RedisModule,
StorageModule,
+12 -1
View File
@@ -2,7 +2,7 @@ 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 { CreateArtworkDto, QueryArtworkDto, UpdateArtworkDto } from './dto/artwork.dto';
import { AuditArtworkDto, CreateArtworkDto, QueryArtworkDto, UpdateArtworkDto } from './dto/artwork.dto';
import { Roles } from '../common/decorators/roles.decorator';
import { CurrentUser, AuthUser } from '../common/decorators/current-user.decorator';
@@ -38,6 +38,17 @@ export class ArtworkController {
return this.artworkService.update(id, dto);
}
@Post(':id/audit')
@Roles(RoleType.AUDITOR)
@ApiOperation({ summary: '审核艺术品(通过/驳回,审核员)' })
audit(
@Param('id', ParseIntPipe) id: number,
@Body() dto: AuditArtworkDto,
@CurrentUser() user: AuthUser,
) {
return this.artworkService.audit(id, dto, user.id);
}
@Delete(':id')
@Roles(RoleType.OPERATOR)
@ApiOperation({ summary: '停用/删除艺术品(软删除)' })
+23 -2
View File
@@ -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() } });
+19 -1
View File
@@ -11,7 +11,8 @@ import {
MaxLength,
ValidateNested,
} from 'class-validator';
import { ArtworkStatus } from '@artveris/shared';
import { IsBoolean } from 'class-validator';
import { ArtworkStatus, AuditStatus } from '@artveris/shared';
import { PaginationDto } from '../../common/dto/pagination.dto';
export class MediaItemDto {
@@ -104,9 +105,26 @@ export class QueryArtworkDto extends PaginationDto {
@IsEnum(ArtworkStatus)
status?: ArtworkStatus;
@ApiPropertyOptional({ description: '审核状态', enum: AuditStatus })
@IsOptional()
@IsEnum(AuditStatus)
auditStatus?: AuditStatus;
@ApiPropertyOptional({ description: '模板 ID' })
@IsOptional()
@Type(() => Number)
@IsInt()
templateId?: number;
}
export class AuditArtworkDto {
@ApiProperty({ description: '是否通过' })
@IsBoolean()
approved!: boolean;
@ApiPropertyOptional({ description: '审核意见(驳回建议填写)' })
@IsOptional()
@IsString()
@MaxLength(255)
remark?: string;
}
+12 -2
View File
@@ -1,11 +1,12 @@
export interface DeviceInfo {
deviceType: string; // Mobile | Tablet | PC
os: string;
browser: string;
}
// 轻量 User-Agent 解析,用于查询日志风控统计。
export function parseUserAgent(ua?: string): DeviceInfo {
if (!ua) return { deviceType: 'Unknown', os: 'Unknown' };
if (!ua) return { deviceType: 'Unknown', os: 'Unknown', browser: 'Unknown' };
const s = ua.toLowerCase();
let deviceType = 'PC';
if (/ipad|tablet/.test(s)) deviceType = 'Tablet';
@@ -18,7 +19,16 @@ export function parseUserAgent(ua?: string): DeviceInfo {
else if (/mac os|macintosh/.test(s)) os = 'macOS';
else if (/linux/.test(s)) os = 'Linux';
return { deviceType, os };
// 浏览器/客户端识别(顺序敏感:微信/Edge 需在通用 Chrome 之前判断)
let browser = 'Unknown';
if (/micromessenger/.test(s)) browser = 'WeChat';
else if (/edg/.test(s)) browser = 'Edge';
else if (/opr|opera/.test(s)) browser = 'Opera';
else if (/firefox|fxios/.test(s)) browser = 'Firefox';
else if (/chrome|crios/.test(s)) browser = 'Chrome';
else if (/safari/.test(s)) browser = 'Safari';
return { deviceType, os, browser };
}
// 从请求中提取真实客户端 IP(兼容反向代理)。
+20 -1
View File
@@ -1,5 +1,6 @@
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsDateString, IsOptional, IsString, MaxLength } from 'class-validator';
import { Type } from 'class-transformer';
import { IsDateString, IsInt, IsOptional, IsString, MaxLength, Min } from 'class-validator';
export class OutboundDto {
@ApiPropertyOptional({ description: 'SKU' })
@@ -24,6 +25,24 @@ export class OutboundDto {
@IsString()
outImageKey?: string;
@ApiPropertyOptional({ description: '上链哈希值(填写则记录上链结果)' })
@IsOptional()
@IsString()
@MaxLength(255)
txHash?: string;
@ApiPropertyOptional({ description: '上链时间' })
@IsOptional()
@IsDateString()
onchainAt?: string;
@ApiPropertyOptional({ description: '区块高度' })
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(0)
blockHeight?: number;
@ApiPropertyOptional({ description: '备注' })
@IsOptional()
@IsString()
+80 -5
View File
@@ -1,12 +1,34 @@
import { Processor, WorkerHost } from '@nestjs/bullmq';
import { Logger } from '@nestjs/common';
import { Job } from 'bullmq';
import { createHash } from 'crypto';
import * as ExcelJS from 'exceljs';
import { JobStatus, OUTBOUND_IMPORT_COLUMNS, QUEUE_NAMES } from '@artveris/shared';
import { JobStatus, OUTBOUND_IMPORT_COLUMNS, ProofStatus, QUEUE_NAMES } from '@artveris/shared';
import { PrismaService } from '../prisma/prisma.service';
import { StorageService } from '../storage/storage.service';
import { JobsService } from '../jobs/jobs.service';
// 将 ExcelJS 单元格值规整为字符串(兼容 Date / 富文本 / 公式结果 / 超链接 / 数字)
function cellToString(v: unknown): string {
if (v === null || v === undefined) return '';
if (v instanceof Date) return v.toISOString();
if (typeof v === 'object') {
const o = v as Record<string, unknown>;
if (typeof o.text === 'string') return o.text.trim();
if (o.result !== undefined && o.result !== null) return String(o.result).trim();
if (Array.isArray(o.richText)) return o.richText.map((r: any) => r.text).join('').trim();
if (o.hyperlink) return String(o.hyperlink).trim();
}
return String(v).trim();
}
// 校验并解析日期,非法返回 null(区分 undefined=未填)
function parseDate(v?: string): Date | undefined | null {
if (!v) return undefined;
const d = new Date(v);
return isNaN(d.getTime()) ? null : d;
}
interface ImportJobData {
jobId: string;
fileKey: string;
@@ -55,8 +77,7 @@ export class ImportProcessor extends WorkerHost {
const values: Record<string, string> = {};
let empty = true;
colToKey.forEach((key, col) => {
const v = row.getCell(col).value;
const text = v === null || v === undefined ? '' : String(v).trim();
const text = cellToString(row.getCell(col).value);
if (text) empty = false;
values[key] = text;
});
@@ -74,22 +95,76 @@ export class ImportProcessor extends WorkerHost {
fail++;
continue;
}
const code = await this.prisma.traceCode.findUnique({ where: { shortCode } });
const code = await this.prisma.traceCode.findUnique({
where: { shortCode },
include: { batch: true },
});
if (!code) {
row.reason = '短码不存在';
fail++;
continue;
}
// 批次编号核对:填写则必须与该码实际批次一致
if (row.values.batchNo && row.values.batchNo !== (code.batch?.batchNo ?? '')) {
row.reason = `批次编号与该码实际批次不符(实际:${code.batch?.batchNo ?? '无'})`;
fail++;
continue;
}
// 字段格式校验
const outTime = parseDate(row.values.outTime);
if (outTime === null) {
row.reason = '出库时间格式不正确(应为 YYYY-MM-DD HH:mm)';
fail++;
continue;
}
const onchainAt = parseDate(row.values.onchainAt);
if (onchainAt === null) {
row.reason = '上链时间格式不正确(应为 YYYY-MM-DD HH:mm)';
fail++;
continue;
}
let blockHeight: bigint | undefined;
if (row.values.blockHeight) {
if (!/^\d+$/.test(row.values.blockHeight)) {
row.reason = '区块高度应为整数';
fail++;
continue;
}
blockHeight = BigInt(row.values.blockHeight);
}
try {
await this.prisma.traceCode.update({
where: { id: code.id },
data: {
sku: row.values.sku || undefined,
archiveNo: row.values.archiveNo || undefined,
outTime: row.values.outTime ? new Date(row.values.outTime) : undefined,
outTime: outTime ?? undefined,
outImage: row.values.outImage || undefined,
remark: row.values.remark || undefined,
},
});
// 录入上链哈希则登记一条已上链存证(同码同哈希去重,避免重复导入污染)
if (row.values.txHash) {
const dup = await this.prisma.blockchainProof.findFirst({
where: { traceCodeId: code.id, txHash: row.values.txHash },
});
if (!dup) {
const dataHash =
'0x' + createHash('sha256').update(`${code.code}:${row.values.txHash}`).digest('hex');
await this.prisma.blockchainProof.create({
data: {
traceCodeId: code.id,
dataHash,
txHash: row.values.txHash,
blockHeight: blockHeight ?? null,
chainName: '手工登记',
onchainAt: onchainAt ?? new Date(),
status: ProofStatus.ONCHAIN,
rawResponse: { source: 'import' },
},
});
}
}
row.ok = true;
success++;
} catch (e) {
+56 -2
View File
@@ -2,14 +2,27 @@ import { Injectable } from '@nestjs/common';
import { InjectQueue } from '@nestjs/bullmq';
import { Queue } from 'bullmq';
import { Response } from 'express';
import { createHash } from 'crypto';
import * as ExcelJS from 'exceljs';
import { ErrorCode, JobType, OUTBOUND_IMPORT_COLUMNS, QUEUE_NAMES } from '@artveris/shared';
import {
ErrorCode,
JobType,
OUTBOUND_IMPORT_COLUMNS,
ProofStatus,
QUEUE_NAMES,
} from '@artveris/shared';
import { PrismaService } from '../prisma/prisma.service';
import { StorageService } from '../storage/storage.service';
import { JobsService } from '../jobs/jobs.service';
import { BusinessException } from '../common/exceptions/business.exception';
import { OutboundDto } from './dto/outbound.dto';
const XLSX_MIME_TYPES = [
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-excel',
'application/octet-stream', // 某些浏览器对 .xlsx 的兜底类型
];
@Injectable()
export class OutboundService {
constructor(
@@ -22,7 +35,7 @@ export class OutboundService {
async updateSingle(traceCodeId: bigint, dto: OutboundDto) {
const code = await this.prisma.traceCode.findUnique({ where: { id: traceCodeId } });
if (!code) throw new BusinessException(ErrorCode.TRACE_CODE_NOT_FOUND, '追溯码不存在', 404);
return this.prisma.traceCode.update({
const updated = await this.prisma.traceCode.update({
where: { id: traceCodeId },
data: {
sku: dto.sku,
@@ -32,6 +45,42 @@ export class OutboundService {
remark: dto.remark,
},
});
// 录入了上链哈希则记录一条已上链存证(手工登记,不触发 Mock 链)
if (dto.txHash) {
await this.recordProof(traceCodeId, code.code, {
txHash: dto.txHash,
onchainAt: dto.onchainAt ? new Date(dto.onchainAt) : new Date(),
blockHeight: dto.blockHeight,
});
}
return updated;
}
// 手工登记上链结果:写入一条 ONCHAIN 存证(数据哈希由 code+txHash 派生)
// 同码同哈希去重:重复保存不会产生多条存证
private async recordProof(
traceCodeId: bigint,
code: string,
p: { txHash: string; onchainAt: Date; blockHeight?: number },
) {
const dup = await this.prisma.blockchainProof.findFirst({
where: { traceCodeId, txHash: p.txHash },
});
if (dup) return;
const dataHash =
'0x' + createHash('sha256').update(`${code}:${p.txHash}`).digest('hex');
await this.prisma.blockchainProof.create({
data: {
traceCodeId,
dataHash,
txHash: p.txHash,
blockHeight: p.blockHeight !== undefined ? BigInt(p.blockHeight) : null,
chainName: '手工登记',
onchainAt: p.onchainAt,
status: ProofStatus.ONCHAIN,
rawResponse: { source: 'manual' },
},
});
}
async generateTemplate(res: Response): Promise<void> {
@@ -65,6 +114,11 @@ export class OutboundService {
async startImport(file: Express.Multer.File, userId: number) {
if (!file) throw new BusinessException(ErrorCode.BAD_REQUEST, '请上传导入文件');
const name = (file.originalname || '').toLowerCase();
const okType = XLSX_MIME_TYPES.includes(file.mimetype) || name.endsWith('.xlsx') || name.endsWith('.xls');
if (!okType) {
throw new BusinessException(ErrorCode.FILE_TYPE_NOT_ALLOWED, '仅支持 Excel(.xlsx/.xls)文件导入');
}
const saved = await this.storage.save(file.buffer, file.originalname || 'import.xlsx', file.mimetype);
const job = await this.jobs.create(JobType.IMPORT_OUTBOUND, 0, userId, { fileKey: saved.key });
await this.queue.add('import', { jobId: job.id, fileKey: saved.key });
@@ -1,12 +1,15 @@
import { Inject, Injectable, Logger } from '@nestjs/common';
import type Redis from 'ioredis';
import { ArtworkStatus, QueryResult, ProofStatus, TraceCodeStatus } from '@artveris/shared';
import { Prisma } from '@prisma/client';
import { ArtworkStatus, AuditStatus, QueryResult, ProofStatus, TraceCodeStatus } from '@artveris/shared';
import { PrismaService } from '../prisma/prisma.service';
import { StorageService } from '../storage/storage.service';
import { GeoService } from '../geo/geo.service';
import { REDIS_CLIENT } from '../redis/redis.module';
import { parseUserAgent } from '../common/utils/ua.util';
type TraceCodeWithBatch = Prisma.TraceCodeGetPayload<{ include: { batch: true } }>;
export interface TraceContext {
ip: string;
userAgent?: string;
@@ -52,17 +55,17 @@ export class PublicTraceService {
return { status: 'INVALID' as const };
}
const code = await this.prisma.traceCode.findUnique({ where: { id } });
const code = await this.prisma.traceCode.findUnique({ where: { id }, include: { batch: true } });
if (!code || !code.artworkId || code.status === TraceCodeStatus.UNBOUND) {
await this.writeLog(id, null, shortCode, QueryResult.INVALID, ctx);
await this.writeLog(id, null, shortCode, QueryResult.INVALID, ctx, code ?? undefined);
return { status: 'INVALID' as const };
}
if (code.status === TraceCodeStatus.DISABLED) {
await this.writeLog(id, code.artworkId, shortCode, QueryResult.DISABLED, ctx);
await this.writeLog(id, code.artworkId, shortCode, QueryResult.DISABLED, ctx, code);
return { status: 'DISABLED' as const };
}
if (code.status === TraceCodeStatus.ABNORMAL) {
await this.writeLog(id, code.artworkId, shortCode, QueryResult.ABNORMAL, ctx);
await this.writeLog(id, code.artworkId, shortCode, QueryResult.ABNORMAL, ctx, code);
return { status: 'ABNORMAL' as const };
}
@@ -74,8 +77,13 @@ export class PublicTraceService {
certificates: { orderBy: { id: 'asc' } },
},
});
if (!artwork || artwork.status === ArtworkStatus.DISABLED) {
await this.writeLog(id, code.artworkId, shortCode, QueryResult.INVALID, ctx);
// 仅展示「未停用」且「审核通过」的作品,否则视为无效,避免未审核数据外泄
if (
!artwork ||
artwork.status === ArtworkStatus.DISABLED ||
artwork.auditStatus !== AuditStatus.APPROVED
) {
await this.writeLog(id, code.artworkId, shortCode, QueryResult.INVALID, ctx, code);
return { status: 'INVALID' as const };
}
@@ -107,10 +115,12 @@ export class PublicTraceService {
});
const result = firstActivate ? QueryResult.FIRST_ACTIVATE : QueryResult.REPEAT;
await this.writeLog(id, artwork.id, shortCode, result, ctx);
await this.writeLog(id, artwork.id, shortCode, result, ctx, { ...code, ...updated });
return {
status: 'OK' as const,
code: code.code,
queriedAt: now,
antiCounterfeit: {
firstQuery: firstActivate,
queryCount: updated.queryCount,
@@ -157,7 +167,19 @@ export class PublicTraceService {
) {
const data = (dynamic as Record<string, unknown>) || {};
return fields
.map((f) => ({ label: f.label, type: f.type, value: data[f.fieldKey] }))
.map((f) => {
let value = data[f.fieldKey];
// 图片/文件字段:若存的是存储 key(非绝对/Data URL),转为可访问 URL,避免 C 端 404
if (
(f.type === 'IMAGE' || f.type === 'FILE') &&
typeof value === 'string' &&
value &&
!/^(https?:|data:|\/)/i.test(value)
) {
value = this.storage.getUrl(value);
}
return { label: f.label, type: f.type, value };
})
.filter((f) => f.value !== undefined && f.value !== null && f.value !== '');
}
@@ -167,6 +189,7 @@ export class PublicTraceService {
shortCode: string,
result: QueryResult,
ctx: TraceContext,
code?: Partial<TraceCodeWithBatch>,
): Promise<void> {
try {
const device = parseUserAgent(ctx.userAgent);
@@ -175,11 +198,19 @@ export class PublicTraceService {
traceCodeId: traceCodeId ?? undefined,
artworkId: artworkId ?? undefined,
shortCode,
code: code?.code ?? undefined,
sku: code?.sku ?? undefined,
archiveNo: code?.archiveNo ?? undefined,
batchNo: code?.batch?.batchNo ?? undefined,
queryCount: code?.queryCount ?? undefined,
firstActivatedAt: code?.firstActivatedAt ?? undefined,
queryResult: result,
ip: ctx.ip,
region: this.geo.resolveRegion(ctx.ip),
userAgent: ctx.userAgent,
deviceType: device.deviceType,
browser: device.browser,
os: device.os,
},
});
} catch (e) {
@@ -0,0 +1,37 @@
import { Injectable, Logger } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';
import { PrismaService } from '../prisma/prisma.service';
import { SettingsService } from '../settings/settings.service';
// 查询日志保留周期清理:每天凌晨执行,删除超过保留天数的日志。
// 保留天数取系统设置 logRetentionDays(后台可配置),<=0 表示长期保留、不清理。
@Injectable()
export class LogRetentionService {
private readonly logger = new Logger(LogRetentionService.name);
constructor(
private readonly prisma: PrismaService,
private readonly settings: SettingsService,
) {}
@Cron(CronExpression.EVERY_DAY_AT_3AM)
async cleanup(): Promise<void> {
const days = await this.resolveRetentionDays();
if (!days || days <= 0) {
this.logger.log('日志保留周期为长期保留,跳过清理');
return;
}
const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000);
const { count } = await this.prisma.queryLog.deleteMany({
where: { queriedAt: { lt: cutoff } },
});
this.logger.log(`查询日志清理完成:删除 ${count} 条(保留 ${days} 天,截止 ${cutoff.toISOString()})`);
}
private async resolveRetentionDays(): Promise<number> {
const raw = await this.settings.get('logRetentionDays');
const n = Number(raw);
if (raw !== null && !Number.isNaN(n)) return n;
return 365;
}
}
+21 -2
View File
@@ -8,11 +8,21 @@ import { buildPage } from '../common/utils/pagination.util';
import { PaginationDto } from '../common/dto/pagination.dto';
class QueryLogQueryDto extends PaginationDto {
@ApiPropertyOptional({ description: '关键词(短码)' })
@ApiPropertyOptional({ description: '关键词(短码 / 追溯码 / SKU / 档案编号)' })
@IsOptional()
@IsString()
keyword?: string;
@ApiPropertyOptional({ description: 'SKU' })
@IsOptional()
@IsString()
sku?: string;
@ApiPropertyOptional({ description: '批次编号' })
@IsOptional()
@IsString()
batchNo?: string;
@ApiPropertyOptional({ description: '查询结果', enum: QueryResult })
@IsOptional()
@IsEnum(QueryResult)
@@ -39,7 +49,16 @@ export class QueryLogController {
@ApiOperation({ summary: '查询日志列表' })
async list(@Query() query: QueryLogQueryDto) {
const where: Prisma.QueryLogWhereInput = {};
if (query.keyword) where.shortCode = { contains: query.keyword };
if (query.keyword) {
where.OR = [
{ shortCode: { contains: query.keyword } },
{ code: { contains: query.keyword } },
{ sku: { contains: query.keyword } },
{ archiveNo: { contains: query.keyword } },
];
}
if (query.sku) where.sku = { contains: query.sku };
if (query.batchNo) where.batchNo = { contains: query.batchNo };
if (query.result) where.queryResult = query.result;
if (query.startTime || query.endTime) {
where.queriedAt = {};
@@ -1,7 +1,9 @@
import { Module } from '@nestjs/common';
import { QueryLogController } from './query-log.controller';
import { LogRetentionService } from './log-retention.service';
@Module({
controllers: [QueryLogController],
providers: [LogRetentionService],
})
export class QueryLogModule {}
@@ -98,6 +98,11 @@ export class BatchStatusDto {
@ApiProperty({ description: 'true 停用,false 启用' })
@IsBoolean()
disabled!: boolean;
@ApiPropertyOptional({ description: 'true 标记为异常(优先级高于 disabled)' })
@IsOptional()
@IsBoolean()
abnormal?: boolean;
}
export class BindArtworkDto {
@@ -101,7 +101,13 @@ export class TraceCodeService {
async batchSetStatus(dto: BatchStatusDto) {
const ids = dto.ids.map((i) => BigInt(i));
if (dto.disabled) {
if (dto.abnormal) {
// 标记异常:用于运营人为标注疑似被复制/盗用的码
await this.prisma.traceCode.updateMany({
where: { id: { in: ids } },
data: { status: TraceCodeStatus.ABNORMAL },
});
} else if (dto.disabled) {
await this.prisma.traceCode.updateMany({
where: { id: { in: ids } },
data: { status: TraceCodeStatus.DISABLED },
+3
View File
@@ -15,9 +15,11 @@ import {
MAX_FILE_SIZE,
MAX_IMAGE_SIZE,
MAX_VIDEO_SIZE,
RoleType,
} from '@artveris/shared';
import { StorageService } from '../storage/storage.service';
import { BusinessException } from '../common/exceptions/business.exception';
import { Roles } from '../common/decorators/roles.decorator';
type UploadType = 'image' | 'video' | 'file';
@@ -34,6 +36,7 @@ export class UploadController {
constructor(private readonly storage: StorageService) {}
@Post()
@Roles(RoleType.OPERATOR)
@ApiOperation({ summary: '上传文件(图片/视频/文档)' })
@ApiConsumes('multipart/form-data')
@ApiQuery({ name: 'type', enum: ['image', 'video', 'file'], required: false })