import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

async function main() {
  console.log('开始初始化 Leaderboard Service 种子数据...');

  // 初始化全局配置
  await prisma.leaderboardConfig.upsert({
    where: { configKey: 'GLOBAL' },
    update: {},
    create: {
      configKey: 'GLOBAL',
      dailyEnabled: true,
      weeklyEnabled: true,
      monthlyEnabled: true,
      virtualRankingEnabled: false,
      virtualAccountCount: 0,
      displayLimit: 30,
      refreshIntervalMinutes: 5,
    },
  });
  console.log('✅ 全局配置初始化完成');

  // 初始化总部社区虚拟账户
  await prisma.virtualAccount.upsert({
    where: { id: 1n },
    update: {},
    create: {
      accountType: 'HEADQUARTERS',
      displayName: '总部',
      isActive: true,
    },
  });
  console.log('✅ 总部社区虚拟账户初始化完成');

  console.log('Seed completed: Leaderboard config and headquarters account initialized');
}

main()
  .catch((e) => {
    console.error(e);
    process.exit(1);
  })
  .finally(async () => {
    await prisma.$disconnect();
  });
