gongxiangp2/scripts/check-remaining-materials.ts
chenpei 4dba93c4e5 feat: 完成任务-详情素材迁移到新逻辑
- 迁移57个老素材到新逻辑(本地zip + S3预览图)
- 优化文件命名:SPU_作者_店铺_类型.zip
- PSD文件单独存储,不打包进all.zip
- 修复下载接口,优先使用本地zip文件
- 修复预览图重复问题
- 添加迁移脚本和验证脚本
- 更新文档和迁移计划

迁移统计:
- 总素材数:77个
- 成功迁移:57个
- 新逻辑上传:18个
- 空记录:2个
2026-01-21 10:16:28 +08:00

72 lines
1.9 KiB
TypeScript

/**
* 检查剩余需要迁移的素材详情
*/
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
const materials = await prisma.material.findMany({
where: {
materialType: '任务-详情',
deletedAt: null,
productModel: { in: ['CYJ0062', 'GBPM-SN0208-389'] },
},
select: {
id: true,
productModel: true,
taskNo: true,
zipFilePath: true,
zipFileSize: true,
user: {
select: {
realName: true,
username: true,
},
},
assets: {
select: {
assetType: true,
fileUrl: true,
fileName: true,
},
orderBy: { sortOrder: 'asc' },
},
},
orderBy: { createdAt: 'desc' },
});
console.log(`找到 ${materials.length} 个素材\n`);
for (const material of materials) {
const authorName = material.user?.realName || material.user?.username || '未知';
console.log('='.repeat(80));
console.log(`SPU: ${material.productModel}`);
console.log(`作者: ${authorName}`);
console.log(`任务号: ${material.taskNo || '无'}`);
console.log(`zipFilePath: ${material.zipFilePath || '空'}`);
console.log(`zipFileSize: ${material.zipFileSize || 0}`);
console.log('\n资产列表:');
const s3Assets = material.assets.filter(a => a.fileUrl.startsWith('https://'));
const localAssets = material.assets.filter(a => a.fileUrl.startsWith('uploads/'));
console.log(` S3 预览图: ${s3Assets.length} 个`);
s3Assets.forEach(a => {
console.log(` - ${a.assetType}: ${a.fileName}`);
});
console.log(` 本地 zip: ${localAssets.length} 个`);
localAssets.forEach(a => {
console.log(` - ${a.assetType}: ${a.fileName}`);
});
console.log('');
}
await prisma.$disconnect();
}
main();