38 lines
997 B
TypeScript
38 lines
997 B
TypeScript
|
|
/**
|
|||
|
|
* 查某门课的封面/主题色/水印(按标题模糊匹配)
|
|||
|
|
* 使用: npx ts-node scripts/check-course-cover.ts [关键词]
|
|||
|
|
* 例: npx ts-node scripts/check-course-cover.ts 产品思维
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
import { PrismaClient } from '@prisma/client';
|
|||
|
|
|
|||
|
|
const prisma = new PrismaClient();
|
|||
|
|
|
|||
|
|
async function main() {
|
|||
|
|
const keyword = process.argv[2] || '产品思维';
|
|||
|
|
const courses = await prisma.course.findMany({
|
|||
|
|
where: {
|
|||
|
|
deletedAt: null,
|
|||
|
|
title: { contains: keyword, mode: 'insensitive' },
|
|||
|
|
},
|
|||
|
|
select: {
|
|||
|
|
id: true,
|
|||
|
|
title: true,
|
|||
|
|
coverImage: true,
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
console.log(`\n课程标题含「${keyword}」的记录数: ${courses.length}\n`);
|
|||
|
|
for (const c of courses) {
|
|||
|
|
console.log('---');
|
|||
|
|
console.log('id:', c.id);
|
|||
|
|
console.log('title:', c.title);
|
|||
|
|
console.log('cover_image:', c.coverImage ?? '(null)');
|
|||
|
|
console.log('');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
main()
|
|||
|
|
.catch((e) => { console.error(e); process.exit(1); })
|
|||
|
|
.finally(() => prisma.$disconnect());
|