gongxiangp2/find-text-materials.js

77 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function findMaterials() {
try {
const materials = await prisma.material.findMany({
where: {
productModel: {
startsWith: 'TEXT'
}
},
select: {
id: true,
productModel: true,
materialType: true,
createdAt: true,
zipFileName: true,
zipFilePath: true,
previewUrl: true,
videoSourceUrl: true,
videoPreview540Url: true,
videoPreviewClipUrl: true,
videoCoverUrl: true,
displayImages: true,
}
});
if (materials.length === 0) {
console.log('没有找到TEXT开头的素材');
return;
}
console.log(`\n找到 ${materials.length} 个TEXT开头的素材:\n`);
console.log('='.repeat(80));
materials.forEach((material, index) => {
console.log(`\n${index + 1}. 素材ID: ${material.id}`);
console.log(` 产品型号: ${material.productModel}`);
console.log(` 素材类型: ${material.materialType}`);
console.log(` 创建时间: ${material.createdAt}`);
console.log(` 文件路径: ${material.zipFilePath || '无'}`);
console.log(` 预览图: ${material.previewUrl || '无'}`);
// 列出所有相关文件
const files = [];
if (material.zipFilePath) files.push(` - 主文件: ${material.zipFilePath}`);
if (material.videoSourceUrl) files.push(` - 视频源: ${material.videoSourceUrl}`);
if (material.previewUrl) files.push(` - 预览图: ${material.previewUrl}`);
if (material.videoPreview540Url) files.push(` - 540p预览: ${material.videoPreview540Url}`);
if (material.videoPreviewClipUrl) files.push(` - 剪辑预览: ${material.videoPreviewClipUrl}`);
if (material.videoCoverUrl) files.push(` - 视频封面: ${material.videoCoverUrl}`);
if (material.displayImages && Array.isArray(material.displayImages) && material.displayImages.length > 0) {
material.displayImages.forEach((img, i) => {
if (img) files.push(` - 展示图${i + 1}: ${img}`);
});
}
if (files.length > 0) {
console.log(` 相关文件 (${files.length}个):`);
files.forEach(f => console.log(f));
}
});
console.log('\n' + '='.repeat(80));
console.log('\n⚠️ 这是一个查询脚本,不会删除任何数据。');
console.log(' 如需删除,请使用 delete-text-materials.js 脚本(需要确认)。\n');
} catch (error) {
console.error('错误:', error);
} finally {
await prisma.$disconnect();
}
}
findMaterials();