Files
hughhuangandClaude Sonnet 4.5 830a17bf46 初始化项目结构和基础模块
完成内容:
- 创建前后端项目目录结构
- 初始化 Node.js + TypeScript 后端项目 (Fastify)
- 初始化 Vue 3 + TypeScript 前端项目 (Vite)
- 配置 Prisma ORM 和 MySQL 数据库
- 创建数据库 Schema 和种子数据
- 实现后端基础模块 (配置、日志、错误处理、验证)
- 创建基础服务类 (BaseService)
- 配置 Git 仓库和忽略文件

技术栈:
- 后端:Fastify + Prisma + MySQL + Winston
- 前端:Vue 3 + TypeScript + Element Plus + Pinia

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 12:11:57 +08:00

90 lines
2.2 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
console.log('开始填充种子数据...');
// 创建默认 LLM 配置
const defaultLlmConfig = await prisma.llmConfig.create({
data: {
name: '默认配置',
baseUrl: 'https://api.openai.com/v1',
model: 'gpt-4o-mini',
apiKey: 'your-api-key-here',
enabled: true,
},
});
console.log('✅ 创建默认 LLM 配置:', defaultLlmConfig.id);
// 创建示例数据源
const sampleSource = await prisma.source.create({
data: {
name: '示例新闻源',
type: 'api',
config: JSON.stringify({
url: 'https://api.example.com/news',
method: 'GET',
headers: {},
}),
cronExpression: '0 */6 * * *',
enabled: false,
},
});
console.log('✅ 创建示例数据源:', sampleSource.id);
// 创建示例推送渠道
const sampleChannel = await prisma.channel.create({
data: {
name: '示例邮箱',
type: 'email',
config: JSON.stringify({
smtpHost: 'smtp.example.com',
smtpPort: 587,
username: 'user@example.com',
password: 'password',
to: 'recipient@example.com',
}),
enabled: false,
},
});
console.log('✅ 创建示例推送渠道:', sampleChannel.id);
// 创建示例主题
const sampleTopic = await prisma.topic.create({
data: {
name: '示例主题',
description: '这是一个示例主题,用于演示功能',
processMode: 'summary',
llmConfigId: defaultLlmConfig.id,
scheduleConfig: JSON.stringify({
cron: '0 9 * * *',
timezone: 'Asia/Shanghai',
}),
enabled: false,
topicSources: {
create: {
sourceId: sampleSource.id,
},
},
topicChannels: {
create: {
channelId: sampleChannel.id,
},
},
},
});
console.log('✅ 创建示例主题:', sampleTopic.id);
console.log('\n✨ 种子数据填充完成!');
}
main()
.catch((e) => {
console.error('❌ 种子数据填充失败:', e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});