fix: 修复后端竞态/安全/数据处理问题并移除冗余 outImage 列

首次激活改条件更新消除并发竞态;备份恢复补模型全集与版本校验防清库;
审核列表分页总数、操作日志未捕获 Promise、出库导入重复码、加密密钥可编辑、
溯源码盐以 env 为准、证书按 originKey reconcile、env 加载去重等修复;
新增 parseBigId 防非法入参 500、全局安全响应头、去除 SVG 上传、接入 throttler 限流、
入队失败补偿、hashData 稳定序列化、无效码负缓存、看板已激活口径调整;
移除冗余 TraceCode.outImage 列统一 outImages(迁移 drop_trace_code_out_image)。
This commit is contained in:
Nixevol
2026-07-09 13:14:26 +08:00
parent c39974e72d
commit f712b16c1f
29 changed files with 328 additions and 170 deletions
@@ -0,0 +1,7 @@
-- 统一出库实况图为多图 JSON 字段 out_images,移除冗余的单图列 out_image。
-- 先把仍只有 out_image 的历史数据并入 out_images,再删除该列。
UPDATE `trace_code`
SET `out_images` = JSON_ARRAY(JSON_OBJECT('key', `out_image`, 'type', 'image'))
WHERE `out_image` IS NOT NULL AND `out_image` <> '' AND `out_images` IS NULL;
ALTER TABLE `trace_code` DROP COLUMN `out_image`;
-1
View File
@@ -313,7 +313,6 @@ model TraceCode {
batchId Int @map("batch_id")
groupId Int? @map("group_id")
outTime DateTime? @map("out_time")
outImage String? @map("out_image")
outImages Json? @map("out_images")
remark String?
status TraceCodeStatus @default(INACTIVE)
-62
View File
@@ -1,62 +0,0 @@
const { PrismaClient, RoleType, UserStatus } = require('@prisma/client');
const bcrypt = require('bcryptjs');
const prisma = new PrismaClient();
async function ensureAdmin() {
const username = process.env.SEED_ADMIN_USERNAME || 'admin';
const password = process.env.SEED_ADMIN_PASSWORD || 'Admin@12345';
const realName = process.env.SEED_ADMIN_NAME || '超级管理员';
const existing = await prisma.sysUser.findUnique({ where: { username } });
if (existing) return;
await prisma.sysUser.create({
data: {
username,
passwordHash: await bcrypt.hash(password, 10),
realName,
role: RoleType.SUPER_ADMIN,
status: UserStatus.ACTIVE,
},
});
console.log(`[seed-production] 已创建超级管理员:${username}`);
}
async function ensureSettings() {
const defaults = {
appName: process.env.APP_NAME || '艺术品溯源平台',
appIconUrl: '',
logRetentionDays: process.env.LOG_RETENTION_DAYS || '365',
operationLogRetentionDays: process.env.OPERATION_LOG_RETENTION_DAYS || '365',
watermarkText: process.env.WATERMARK_TEXT || '仅供溯源核验使用',
filingInfo: '备案信息待补充',
backupEnabled: 'false',
backupSchedule: 'off',
backupRetentionDays: '30',
backupRetentionCount: '10',
clientCarouselInterval: '5',
};
for (const [key, value] of Object.entries(defaults)) {
await prisma.systemSetting.upsert({
where: { key },
update: {},
create: { key, value },
});
}
}
async function main() {
await ensureAdmin();
await ensureSettings();
}
main()
.catch((error) => {
console.error('[seed-production] 初始化失败', error);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});