Features: - Backend statistics API (cloud-native Prisma aggregation) - Results page with hybrid solution (AI consensus + human final decision) - Excel export (frontend generation, zero disk write, cloud-native) - PRISMA-style exclusion reason analysis with bar chart - Batch selection and export (3 export methods) - Fixed logic contradiction (inclusion does not show exclusion reason) - Optimized table width (870px, no horizontal scroll) Components: - Backend: screeningController.ts - add getProjectStatistics API - Frontend: ScreeningResults.tsx - complete results page (hybrid solution) - Frontend: excelExport.ts - Excel export utility (40 columns full info) - Frontend: ScreeningWorkbench.tsx - add navigation button - Utils: get-test-projects.mjs - quick test tool Architecture: - Cloud-native: backend aggregation reduces network transfer - Cloud-native: frontend Excel generation (zero file persistence) - Reuse platform: global prisma instance, logger - Performance: statistics API < 500ms, Excel export < 3s (1000 records) Documentation: - Update module status guide (add Week 4 features) - Update task breakdown (mark Week 4 completed) - Update API design spec (add statistics API) - Update database design (add field usage notes) - Create Week 4 development plan - Create Week 4 completion report - Create technical debt list Test: - End-to-end flow test passed - All features verified - Performance test passed - Cloud-native compliance verified Ref: Week 4 Development Plan Scope: ASL Module MVP - Title Abstract Screening Results Cloud-Native: Backend aggregation + Frontend Excel generation
119 lines
2.1 KiB
TypeScript
119 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();
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|