- 迁移57个老素材到新逻辑(本地zip + S3预览图) - 优化文件命名:SPU_作者_店铺_类型.zip - PSD文件单独存储,不打包进all.zip - 修复下载接口,优先使用本地zip文件 - 修复预览图重复问题 - 添加迁移脚本和验证脚本 - 更新文档和迁移计划 迁移统计: - 总素材数:77个 - 成功迁移:57个 - 新逻辑上传:18个 - 空记录:2个
90 lines
2.5 KiB
TypeScript
90 lines
2.5 KiB
TypeScript
/**
|
|
* 检查所有已迁移的"任务-详情"素材
|
|
*/
|
|
|
|
import { PrismaClient } from '@prisma/client';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
console.log('='.repeat(60));
|
|
console.log('检查所有已迁移的"任务-详情"素材');
|
|
console.log('='.repeat(60));
|
|
|
|
// 查询所有有 zipFilePath 的素材(已迁移)
|
|
const materials = await prisma.material.findMany({
|
|
where: {
|
|
materialType: '任务-详情',
|
|
deletedAt: null,
|
|
zipFilePath: { not: '' },
|
|
},
|
|
select: {
|
|
id: true,
|
|
productModel: true,
|
|
zipFilePath: true,
|
|
},
|
|
orderBy: { createdAt: 'desc' },
|
|
});
|
|
|
|
console.log(`找到 ${materials.length} 个已迁移的素材\n`);
|
|
|
|
for (const material of materials) {
|
|
// 统计各类型资产数量
|
|
const mainPreviewCount = await prisma.materialAsset.count({
|
|
where: { materialId: material.id, assetType: 'main-preview' },
|
|
});
|
|
|
|
const skuPreviewCount = await prisma.materialAsset.count({
|
|
where: { materialId: material.id, assetType: 'sku-preview' },
|
|
});
|
|
|
|
const detailPreviewCount = await prisma.materialAsset.count({
|
|
where: { materialId: material.id, assetType: 'detail-preview' },
|
|
});
|
|
|
|
const mainS3Count = await prisma.materialAsset.count({
|
|
where: {
|
|
materialId: material.id,
|
|
assetType: 'main',
|
|
fileUrl: { startsWith: 'https://' }
|
|
},
|
|
});
|
|
|
|
const skuS3Count = await prisma.materialAsset.count({
|
|
where: {
|
|
materialId: material.id,
|
|
assetType: 'sku',
|
|
fileUrl: { startsWith: 'https://' }
|
|
},
|
|
});
|
|
|
|
const detailS3Count = await prisma.materialAsset.count({
|
|
where: {
|
|
materialId: material.id,
|
|
assetType: 'detail',
|
|
fileUrl: { startsWith: 'https://' }
|
|
},
|
|
});
|
|
|
|
// 检查是否有重复
|
|
const hasDuplicates =
|
|
(mainPreviewCount > 0 && mainS3Count > 0) ||
|
|
(skuPreviewCount > 0 && skuS3Count > 0) ||
|
|
(detailPreviewCount > 0 && detailS3Count > 0);
|
|
|
|
if (hasDuplicates) {
|
|
console.log(`❌ ${material.productModel} (${material.id})`);
|
|
console.log(` 主图: preview=${mainPreviewCount}, S3=${mainS3Count}`);
|
|
console.log(` SKU: preview=${skuPreviewCount}, S3=${skuS3Count}`);
|
|
console.log(` 详情: preview=${detailPreviewCount}, S3=${detailS3Count}`);
|
|
console.log('');
|
|
} else {
|
|
console.log(`✅ ${material.productModel} - 正常`);
|
|
}
|
|
}
|
|
|
|
await prisma.$disconnect();
|
|
}
|
|
|
|
main();
|