Features: - feat: Excel template generation and download (with examples) - feat: Excel file parsing in memory (cloud-native, no disk write) - feat: Field validation (title + abstract required) - feat: Smart deduplication (DOI priority + Title fallback) - feat: Literature preview table with statistics - feat: Complete submission flow (create project + import literatures) Components: - feat: Create excelUtils.ts with full Excel processing toolkit - feat: Enhance TitleScreeningSettings page with upload/preview/submit - feat: Update API interface signatures and export unified aslApi object Dependencies: - chore: Add xlsx library for Excel file processing Ref: Week 2 Frontend Development - Day 2 Scope: ASL Module MVP - Title Abstract Screening Cloud-Native: Memory parsing, no file persistence
115 lines
2.1 KiB
TypeScript
115 lines
2.1 KiB
TypeScript
/**
|
|
* 数据库种子数据脚本
|
|
* 用于初始化开发环境的测试用户
|
|
*/
|
|
|
|
import { PrismaClient } from '@prisma/client';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
console.log('🌱 开始初始化数据库种子数据...');
|
|
|
|
// 创建测试用户
|
|
const mockUser = await prisma.user.upsert({
|
|
where: { id: 'user-mock-001' },
|
|
update: {},
|
|
create: {
|
|
id: 'user-mock-001',
|
|
email: 'test@example.com',
|
|
password: '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5GyYIkYvKx7ES', // password: "password123"
|
|
name: '测试用户',
|
|
role: 'user',
|
|
status: 'active',
|
|
kbQuota: 3,
|
|
kbUsed: 0,
|
|
isTrial: true,
|
|
trialEndsAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000), // 30天后
|
|
},
|
|
});
|
|
|
|
console.log('✅ 测试用户创建成功:', {
|
|
id: mockUser.id,
|
|
email: mockUser.email,
|
|
name: mockUser.name,
|
|
});
|
|
|
|
// 可选:创建管理员用户
|
|
const adminUser = await prisma.user.upsert({
|
|
where: { email: 'admin@example.com' },
|
|
update: {},
|
|
create: {
|
|
id: 'user-admin-001',
|
|
email: 'admin@example.com',
|
|
password: '$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5GyYIkYvKx7ES', // password: "password123"
|
|
name: '管理员',
|
|
role: 'admin',
|
|
status: 'active',
|
|
kbQuota: 10,
|
|
kbUsed: 0,
|
|
isTrial: false,
|
|
},
|
|
});
|
|
|
|
console.log('✅ 管理员用户创建成功:', {
|
|
id: adminUser.id,
|
|
email: adminUser.email,
|
|
name: adminUser.name,
|
|
});
|
|
|
|
console.log('\n🎉 数据库种子数据初始化完成!\n');
|
|
console.log('📝 测试账号信息:');
|
|
console.log(' 邮箱: test@example.com');
|
|
console.log(' 密码: password123');
|
|
console.log(' 用户ID: user-mock-001\n');
|
|
console.log('📝 管理员账号信息:');
|
|
console.log(' 邮箱: admin@example.com');
|
|
console.log(' 密码: password123');
|
|
console.log(' 用户ID: user-admin-001\n');
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error('❌ 初始化种子数据失败:', e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|