Files
home-service/backend/seed.ts

121 lines
4.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { NestFactory } from '@nestjs/core';
import { AppModule } from './src/app.module';
import { WishlistCategoriesService } from './src/wishlist/categories.service';
import { WishlistService } from './src/wishlist/wishlist.service';
async function seed() {
const app = await NestFactory.createApplicationContext(AppModule);
const categoriesService = app.get(WishlistCategoriesService);
const wishlistService = app.get(WishlistService);
console.log('🌱 Seeding wishlist categories...');
// Создать категории
const category1 = await categoriesService.create({
name: 'БЮДЖЕТНО',
slug: 'tier-1',
minPrice: 0,
maxPrice: 150000, // 1500 руб
color: '#00ff41',
icon: '🟢',
order: 1,
});
const category2 = await categoriesService.create({
name: 'СРЕДНИЙ',
slug: 'tier-2',
minPrice: 150001,
maxPrice: 500000, // 5000 руб
color: '#00cc33',
icon: '🟡',
order: 2,
});
const category3 = await categoriesService.create({
name: 'ТОП',
slug: 'tier-3',
minPrice: 500001,
maxPrice: null, // без ограничения
color: '#009922',
icon: '🔴',
order: 3,
});
console.log(`✅ Created 3 categories`);
console.log('🌱 Seeding wishlist items...');
// Создать примерные товары
await wishlistService.create({
title: 'Зерновой Кофе (Эфиопия)',
description: 'Люблю светлую обжарку. Желательно Эфиопия или Кения. Нужен именно в зернах.',
price: 85000, // 850 руб
currency: 'RUB',
link: 'https://ozon.ru',
imageUrls: ['https://images.unsplash.com/photo-1497935586351-b67a49e012bf?w=500'],
categoryId: category1.id,
});
await wishlistService.create({
title: 'Молескин в точку',
description: 'Черный, классический. Обязательно в точку, а не в линейку.',
price: 120000, // 1200 руб
currency: 'RUB',
link: 'https://wildberries.ru',
imageUrls: ['https://images.unsplash.com/photo-1531346878377-a513bc957374?w=500'],
categoryId: category1.id,
});
await wishlistService.create({
title: 'Винил: Daft Punk',
description: 'Альбом "Random Access Memories". Мечтаю послушать его на проигрывателе.',
price: 350000, // 3500 руб
currency: 'RUB',
link: 'https://market.yandex.ru',
imageUrls: ['https://images.unsplash.com/photo-1603048588665-791ca8aea617?w=500'],
categoryId: category2.id,
});
await wishlistService.create({
title: 'D&D Стартовый набор',
description: '5-я редакция. Хочу попробовать поиграть с друзьями.',
price: 290000, // 2900 руб
currency: 'RUB',
link: 'https://hobbygames.ru',
imageUrls: ['https://images.unsplash.com/photo-1632501641765-e568d90e09b2?w=500'],
categoryId: category2.id,
});
await wishlistService.create({
title: 'LEGO Speed Champions',
description: 'Любая машинка из этой серии, желательно Porsche или Ferrari.',
price: 250000, // 2500 руб
currency: 'RUB',
link: 'https://detmir.ru',
imageUrls: ['https://images.unsplash.com/photo-1585366119957-e9730b6d0f60?w=500'],
categoryId: category2.id,
});
await wishlistService.create({
title: 'Keychron K2',
description: 'Механическая клавиатура. Свичи Red или Brown. Нужна подсветка.',
price: 900000, // 9000 руб
currency: 'RUB',
link: 'https://geekboards.ru',
imageUrls: ['https://images.unsplash.com/photo-1595225476474-87563907a212?w=500'],
categoryId: category3.id,
});
console.log(`✅ Created 6 wishlist items`);
console.log('✨ Seeding completed!');
await app.close();
process.exit(0);
}
seed().catch((error) => {
console.error('❌ Seeding failed:', error);
process.exit(1);
});