Files
web_template/internal/database/seed_food.go

232 lines
23 KiB
Go
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.
package database
import (
"log"
"gotest/internal/model"
"gorm.io/gorm"
)
// seedFoodData 初始化外卖数据(3 套外卖网站共用)
func seedFoodData(db *gorm.DB) error {
var count int64
db.Model(&model.Restaurant{}).Count(&count)
if count > 0 {
log.Println("检测到已有外卖数据,跳过初始化")
return nil
}
// 餐厅分类
categories := []model.RestaurantCategory{
{Name: "Chinese Cuisine", Icon: "chinese", Sort: 1},
{Name: "Japanese & Korean", Icon: "japanese", Sort: 2},
{Name: "Western Fast Food", Icon: "western", Sort: 3},
{Name: "Hot Pot & BBQ", Icon: "hotpot", Sort: 4},
{Name: "Bubble Tea & Desserts", Icon: "dessert", Sort: 5},
{Name: "Healthy Light Bites", Icon: "healthy", Sort: 6},
}
for i := range categories {
if err := db.Create(&categories[i]).Error; err != nil {
return err
}
}
// 餐厅数据
restaurants := []model.Restaurant{
{Name: "Shuxiangyuan · Classic Sichuan", Description: "Authentic Sichuan flavors with bold, numbing, and spicy taste. Our chef hails from Chengdu, sourcing authentic Sichuan peppercorns and chilies to deliver the ultimate flavor experience. Signature dishes like Boiled Fish and Mapo Tofu are fan favorites.", CategoryID: 1, CategoryName: "Chinese Cuisine", Rating: 4.8, Sales: 5600, DeliveryFee: 3, MinOrder: 20, DeliveryTime: 35, Distance: "1.2km", Tags: `["Spicy","Sichuan","Rice Pairing"]`, Notice: "Contactless delivery available. Utensils are strictly sterilized.", Status: 1, Sort: 1},
{Name: "Old Beijing Roast Duck", Description: "A century-old hung-oven roasting tradition, slow-roasted over fruitwood charcoal for crispy skin and tender meat. Served with thin pancakes, scallion strips, and sweet bean sauce — one bite and you'll never forget. A variety of classic Beijing side dishes also available.", CategoryID: 1, CategoryName: "Chinese Cuisine", Rating: 4.9, Sales: 8900, DeliveryFee: 5, MinOrder: 30, DeliveryTime: 40, Distance: "2.5km", Tags: `["Signature","Beijing Style","Gathering"]`, Notice: "Roast duck is prepared fresh to order, so delivery may take a bit longer. Thank you for your patience.", Status: 1, Sort: 2},
{Name: "Cantonese Cha Chaan Teng · Hong Kong Style", Description: "Authentic Hong Kong-style tea restaurant. Silky milk tea, pineapple bun with butter, and wok-fried beef chow fun are all specialties. Dim sum served all day — shrimp dumplings and siu mai steamed to order.", CategoryID: 1, CategoryName: "Chinese Cuisine", Rating: 4.6, Sales: 4200, DeliveryFee: 2, MinOrder: 15, DeliveryTime: 30, Distance: "0.8km", Tags: `["Cantonese","Tea Restaurant","Dim Sum"]`, Notice: "Weekday lunch set meals at 20% off.", Status: 1, Sort: 3},
{Name: "Sakura Japanese · Sushi & Sashimi", Description: "Air-flown ingredients delivered fresh daily. Thick-cut salmon sashimi, plump tuna nigiri — each piece crafted with 15 years of sushi-making expertise.", CategoryID: 2, CategoryName: "Japanese & Korean", Rating: 4.7, Sales: 3200, DeliveryFee: 5, MinOrder: 25, DeliveryTime: 35, Distance: "1.8km", Tags: `["Japanese","Sashimi","Refined"]`, Notice: "Sashimi is best enjoyed within 30 minutes of arrival.", Status: 1, Sort: 1},
{Name: "Korean Palace · BBQ & Bibimbap", Description: "Authentic Korean BBQ with freshly grilled and sliced pork belly and beef short ribs. Sizzling stone pot bibimbap served with kimchi and side dishes for a full Korean experience.", CategoryID: 2, CategoryName: "Japanese & Korean", Rating: 4.5, Sales: 3800, DeliveryFee: 3, MinOrder: 20, DeliveryTime: 30, Distance: "1.5km", Tags: `["Korean","BBQ","Bibimbap"]`, Notice: "Bibimbap can be customized with extra spice or no spice.", Status: 1, Sort: 2},
{Name: "Burger House · American Burgers", Description: "100% Angus beef patties, freshly grilled and juicy. Topped with cheddar cheese, bacon, and house-made secret sauce. Thick-cut fries on the side — crispy outside, fluffy inside.", CategoryID: 3, CategoryName: "Western Fast Food", Rating: 4.6, Sales: 6500, DeliveryFee: 4, MinOrder: 18, DeliveryTime: 25, Distance: "1.0km", Tags: `["Burgers","Fast Food","American"]`, Notice: "Buy one get one half off promotion now on.", Status: 1, Sort: 1},
{Name: "Pizza Hot · Handmade Pizza", Description: "Italian-style handmade crust — thin, crispy, and chewy. Choose from Margherita, Hawaiian, or Meat Lover's. Extra-long cheese pull for maximum satisfaction.", CategoryID: 3, CategoryName: "Western Fast Food", Rating: 4.5, Sales: 2800, DeliveryFee: 5, MinOrder: 35, DeliveryTime: 35, Distance: "2.0km", Tags: `["Pizza","Italian","Cheese"]`, Notice: "Buy one get one free on 9-inch pizzas (weekdays only).", Status: 1, Sort: 2},
{Name: "Chongqing Old Hot Pot", Description: "Nine-grid hot pot with a rich and mellow beef tallow broth. Fresh tripe, duck intestines, and beef aorta for that authentic crunchy texture. DIY dipping sauce station to recreate the flavors of the mountain city.", CategoryID: 4, CategoryName: "Hot Pot & BBQ", Rating: 4.7, Sales: 7200, DeliveryFee: 6, MinOrder: 50, DeliveryTime: 45, Distance: "3.0km", Tags: `["Hot Pot","Spicy","Gathering"]`, Notice: "Broth and ingredients are delivered separately so you can enjoy hot pot fresh at home.", Status: 1, Sort: 1},
{Name: "Northeast Skewer King · BBQ", Description: "Charcoal-grilled to order — lamb kidneys, lamb skewers, and chicken wings all available. Generously seasoned with cumin and chili powder. The ultimate late-night snack.", CategoryID: 4, CategoryName: "Hot Pot & BBQ", Rating: 4.6, Sales: 9500, DeliveryFee: 3, MinOrder: 25, DeliveryTime: 30, Distance: "1.3km", Tags: `["BBQ","Late Night","Skewers"]`, Notice: "Buy one get one half off on skewers after 10 PM every night.", Status: 1, Sort: 2},
{Name: "Chayan Yuese · Handmade Milk Tea", Description: "Fresh milk brewed with tea leaves — no non-dairy creamer. Signature Youlan Latte and Shengsheng Oolong with smooth tea and creamy milk. Limited handmade batches daily for consistent quality.", CategoryID: 5, CategoryName: "Bubble Tea & Desserts", Rating: 4.8, Sales: 12000, DeliveryFee: 2, MinOrder: 12, DeliveryTime: 20, Distance: "0.5km", Tags: `["Milk Tea","Fresh Milk","Popular"]`, Notice: "Summer limited-edition iced drinks now available.", Status: 1, Sort: 1},
{Name: "Sweet Times · French Desserts", Description: "Curated by a French pastry chef — tiramisu, molten lava cake, and macarons beautifully presented. Every bite is a moment of sweet bliss.", CategoryID: 5, CategoryName: "Bubble Tea & Desserts", Rating: 4.7, Sales: 1800, DeliveryFee: 4, MinOrder: 20, DeliveryTime: 30, Distance: "2.2km", Tags: `["Desserts","French","Refined"]`, Notice: "Birthday cakes must be ordered at least 4 hours in advance.", Status: 1, Sort: 2},
{Name: "Green Fields Light Bites · Salad Bowls", Description: "Organic greens paired with premium proteins — quinoa, chicken breast, and avocado in a scientifically balanced ratio. Low-calorie, high-protein, ideal for fitness enthusiasts.", CategoryID: 6, CategoryName: "Healthy Light Bites", Rating: 4.6, Sales: 3400, DeliveryFee: 3, MinOrder: 18, DeliveryTime: 25, Distance: "1.1km", Tags: `["Light Bites","Healthy","Low Calorie"]`, Notice: "Salad dressing can be customized — try our low-fat vinaigrette.", Status: 1, Sort: 1},
}
for i := range restaurants {
if err := db.Create(&restaurants[i]).Error; err != nil {
return err
}
}
// 为每个餐厅创建菜品分类和菜品
type catSeed struct {
name string
items []model.MenuItem
}
restaurantMenus := map[uint][]catSeed{
// 蜀香苑 川菜
1: {
{"Signature Picks", []model.MenuItem{
{Name: "Boiled Fish Fillets", Description: "Fresh grass carp fillets in a spicy red oil broth infused with fragrant Sichuan peppercorns. Tender, flavorful, and numbingly spicy.", Price: 48, OriginalPrice: 58, Rating: 4.9, Sales: 3200, Tags: `["Signature","Spicy"]`, Sort: 1, Status: 1, RestaurantID: 1},
{Name: "Mapo Tofu", Description: "Silky tofu with minced beef in a doubanjiang-based sauce. Numbing, spicy, aromatic, and irresistible with rice.", Price: 22, Rating: 4.7, Sales: 2800, Tags: `["Classic","Rice Pairing"]`, Sort: 2, Status: 1, RestaurantID: 1},
{Name: "Twice-Cooked Pork", Description: "Pork belly with garlic sprouts and green peppers, stir-fried in Pixian doubanjiang. Rich flavor, never greasy.", Price: 32, Rating: 4.6, Sales: 2100, Tags: `["Classic"]`, Sort: 3, Status: 1, RestaurantID: 1},
}},
{"Hot Dishes", []model.MenuItem{
{Name: "Kung Pao Chicken", Description: "Diced chicken breast with peanuts in a sweet and slightly spicy sauce. A timeless Sichuan classic loved by all ages.", Price: 28, Rating: 4.5, Sales: 1900, Tags: `["Sweet & Sour"]`, Sort: 1, Status: 1, RestaurantID: 1},
{Name: "Yu Xiang Shredded Pork", Description: "Shredded pork tenderloin with wood ear mushrooms and bamboo shoots in a fish-fragrant sauce. A perfect balance of salty, sweet, sour, and spicy.", Price: 26, Rating: 4.4, Sales: 1600, Tags: `["Classic"]`, Sort: 2, Status: 1, RestaurantID: 1},
{Name: "Dry-Fried Green Beans", Description: "Green beans with minced pork, dry-fried until the skin wrinkles. Crispy and full of flavor.", Price: 20, Rating: 4.5, Sales: 1200, Tags: `["Vegetable"]`, Sort: 3, Status: 1, RestaurantID: 1},
}},
{"Staples & Soups", []model.MenuItem{
{Name: "Dan Dan Noodles", Description: "Thin noodles topped with minced meat and chili oil with crushed peanuts. Numbing and fragrant.", Price: 18, Rating: 4.6, Sales: 1500, Tags: `["Staple"]`, Sort: 1, Status: 1, RestaurantID: 1},
{Name: "Hot & Sour Soup", Description: "Shredded tofu, wood ear mushrooms, and ham in a tangy, spicy broth. Appetizing and warming.", Price: 12, Rating: 4.3, Sales: 800, Tags: `["Soup"]`, Sort: 2, Status: 1, RestaurantID: 1},
}},
},
// 老北京烤鸭
2: {
{"Signature Roast Duck", []model.MenuItem{
{Name: "Classic Roast Duck (Whole)", Description: "Slow-roasted over fruitwood charcoal for crispy skin and tender meat. Served with thin pancakes, scallion strips, and sweet bean sauce. Serves 4-6.", Price: 168, OriginalPrice: 198, Rating: 4.9, Sales: 1800, Tags: `["Signature","Whole"]`, Sort: 1, Status: 1, RestaurantID: 2},
{Name: "Roast Duck (Half)", Description: "Half a roast duck with pancakes and sauce. Serves 2-3.", Price: 88, Rating: 4.8, Sales: 1200, Tags: `["Signature"]`, Sort: 2, Status: 1, RestaurantID: 2},
}},
{"Beijing Side Dishes", []model.MenuItem{
{Name: "Mustard Napa Cabbage", Description: "Napa cabbage with mustard, refreshing and appetizing. A traditional Beijing cold dish.", Price: 18, Rating: 4.3, Sales: 500, Tags: `["Cold Dish"]`, Sort: 1, Status: 1, RestaurantID: 2},
{Name: "Zhajiang Noodles", Description: "Hand-pulled noodles with minced meat sauce, shredded cucumber, and bean sprouts. Authentic Beijing flavor.", Price: 22, Rating: 4.6, Sales: 900, Tags: `["Staple"]`, Sort: 2, Status: 1, RestaurantID: 2},
}},
},
// 粤式茶餐厅
3: {
{"Hong Kong-Style Drinks", []model.MenuItem{
{Name: "Silk-Stocking Milk Tea", Description: "Ceylon black tea blended with evaporated milk for a silky, rich flavor. A Hong Kong classic.", Price: 15, Rating: 4.7, Sales: 2800, Tags: `["Signature","Drink"]`, Sort: 1, Status: 1, RestaurantID: 3},
{Name: "Iced Lemon Tea", Description: "Black tea with fresh lemon, chilled and refreshing.", Price: 13, Rating: 4.5, Sales: 1900, Tags: `["Drink"]`, Sort: 2, Status: 1, RestaurantID: 3},
}},
{"Dim Sum & Staples", []model.MenuItem{
{Name: "Crystal Shrimp Dumplings", Description: "Translucent wrappers encasing whole fresh shrimp, bouncy and delicious. 4 pieces per basket.", Price: 25, Rating: 4.8, Sales: 1600, Tags: `["Dim Sum","Signature"]`, Sort: 1, Status: 1, RestaurantID: 3},
{Name: "Wok-Fried Beef Chow Fun", Description: "Rice noodles with beef and bean sprouts, wok-tossed over high heat. Full of wok hei.", Price: 28, Rating: 4.6, Sales: 1400, Tags: `["Staple"]`, Sort: 2, Status: 1, RestaurantID: 3},
{Name: "Pineapple Bun with Butter", Description: "Freshly baked pineapple bun with a slab of chilled butter. Crispy outside, soft inside.", Price: 12, Rating: 4.5, Sales: 1100, Tags: `["Baked"]`, Sort: 3, Status: 1, RestaurantID: 3},
}},
},
// 樱花日料
4: {
{"Sashimi", []model.MenuItem{
{Name: "Salmon Sashimi (6 slices)", Description: "Norwegian salmon, thick-cut. Vibrant orange-red flesh with a buttery, melt-in-your-mouth texture.", Price: 58, Rating: 4.8, Sales: 900, Tags: `["Signature","Sashimi"]`, Sort: 1, Status: 1, RestaurantID: 4},
{Name: "Tuna Sashimi (6 slices)", Description: "Bluefin tuna belly, rich in marbling. Dissolves on the tongue.", Price: 68, Rating: 4.7, Sales: 600, Tags: `["Sashimi"]`, Sort: 2, Status: 1, RestaurantID: 4},
}},
{"Sushi & Hand Rolls", []model.MenuItem{
{Name: "Salmon Nigiri (2 pieces)", Description: "Vinegared rice with thick-cut salmon — simple and pure.", Price: 22, Rating: 4.6, Sales: 800, Tags: `["Sushi"]`, Sort: 1, Status: 1, RestaurantID: 4},
{Name: "Eel Sushi (2 pieces)", Description: "Kabayaki-glazed eel over vinegared rice, rich in savory sauce.", Price: 28, Rating: 4.7, Sales: 700, Tags: `["Sushi"]`, Sort: 2, Status: 1, RestaurantID: 4},
{Name: "California Roll (8 pieces)", Description: "Crab, avocado, and cucumber rolled and coated with flying fish roe.", Price: 32, Rating: 4.5, Sales: 1000, Tags: `["Roll"]`, Sort: 3, Status: 1, RestaurantID: 4},
}},
},
// 韩宫
5: {
{"BBQ", []model.MenuItem{
{Name: "Pork Belly Set", Description: "Thick-cut pork belly served with lettuce, garlic, and rice. Serves 2-3.", Price: 68, Rating: 4.6, Sales: 1200, Tags: `["Signature","BBQ"]`, Sort: 1, Status: 1, RestaurantID: 5},
{Name: "Beef Short Ribs", Description: "Marinated beef short ribs, tender and juicy. Served with side dishes.", Price: 88, Rating: 4.7, Sales: 800, Tags: `["BBQ"]`, Sort: 2, Status: 1, RestaurantID: 5},
}},
{"Staples & Side Dishes", []model.MenuItem{
{Name: "Stone Pot Bibimbap", Description: "Rice topped with vegetables, beef, and egg in a sizzling stone pot.", Price: 28, Rating: 4.5, Sales: 1500, Tags: `["Staple","Signature"]`, Sort: 1, Status: 1, RestaurantID: 5},
{Name: "Kimchi Stew", Description: "Tangy and spicy kimchi stew with tofu and pork. Warming and appetizing.", Price: 25, Rating: 4.4, Sales: 700, Tags: `["Soup"]`, Sort: 2, Status: 1, RestaurantID: 5},
}},
},
// Burger House
6: {
{"Burgers", []model.MenuItem{
{Name: "Classic Double Cheeseburger", Description: "Double Angus beef patties with double cheddar cheese. Maximum satisfaction.", Price: 38, Rating: 4.7, Sales: 2800, Tags: `["Signature","Double"]`, Sort: 1, Status: 1, RestaurantID: 6},
{Name: "Bacon Beef Burger", Description: "Beef patty with crispy bacon, lettuce, tomato, and secret sauce.", Price: 32, Rating: 4.6, Sales: 2100, Tags: `["Best Seller"]`, Sort: 2, Status: 1, RestaurantID: 6},
{Name: "Crispy Chicken Burger", Description: "Crispy fried chicken patty with mayo and lettuce. Crunchy outside, juicy inside.", Price: 26, Rating: 4.5, Sales: 1800, Tags: `["Chicken"]`, Sort: 3, Status: 1, RestaurantID: 6},
}},
{"Sides & Drinks", []model.MenuItem{
{Name: "Thick-Cut Fries", Description: "Chunky fries, crispy on the outside, fluffy inside. Served with ketchup.", Price: 12, Rating: 4.5, Sales: 2200, Tags: `["Side"]`, Sort: 1, Status: 1, RestaurantID: 6},
{Name: "Cola", Description: "Ice-cold Coca-Cola 330ml.", Price: 6, Rating: 4.2, Sales: 1500, Tags: `["Drink"]`, Sort: 2, Status: 1, RestaurantID: 6},
}},
},
// Pizza Hot
7: {
{"Pizza", []model.MenuItem{
{Name: "Margherita Pizza (9 inch)", Description: "Tomato base sauce with fresh mozzarella and basil. A timeless Italian classic.", Price: 48, Rating: 4.6, Sales: 800, Tags: `["Classic"]`, Sort: 1, Status: 1, RestaurantID: 7},
{Name: "Meat Lover's (9 inch)", Description: "Bacon, ham, and beef crumbles — triple meat indulgence with stretchy cheese.", Price: 58, Rating: 4.7, Sales: 700, Tags: `["Signature","Meat Lovers"]`, Sort: 2, Status: 1, RestaurantID: 7},
{Name: "Hawaiian (9 inch)", Description: "Ham paired with pineapple for a sweet and savory combination.", Price: 45, Rating: 4.3, Sales: 500, Tags: `["Sweet & Savory"]`, Sort: 3, Status: 1, RestaurantID: 7},
}},
{"Sides", []model.MenuItem{
{Name: "Mozzarella Sticks (5 pcs)", Description: "Mozzarella cheese sticks fried golden. Served with ketchup.", Price: 18, Rating: 4.5, Sales: 600, Tags: `["Side"]`, Sort: 1, Status: 1, RestaurantID: 7},
{Name: "Chicken Wings (6 pcs)", Description: "Roasted chicken wings with honey mustard sauce.", Price: 22, Rating: 4.4, Sales: 500, Tags: `["Side"]`, Sort: 2, Status: 1, RestaurantID: 7},
}},
},
// 重庆老火锅
8: {
{"Hot Pot Broth", []model.MenuItem{
{Name: "Nine-Grid Beef Tallow Broth", Description: "Authentic Chongqing beef tallow broth — numbing, spicy, rich, and deeply flavorful.", Price: 48, Rating: 4.8, Sales: 1500, Tags: `["Signature","Spicy"]`, Sort: 1, Status: 1, RestaurantID: 8},
{Name: "Tomato Broth", Description: "Simmered from fresh tomatoes, tangy and appetizing. A non-spicy option.", Price: 28, Rating: 4.5, Sales: 600, Tags: `["Non-Spicy"]`, Sort: 2, Status: 1, RestaurantID: 8},
}},
{"Hot Pot Ingredients", []model.MenuItem{
{Name: "Fresh Beef Tripe", Description: "Fresh tripe, quick-dipped for the perfect crunch. Tender and crisp.", Price: 38, Rating: 4.7, Sales: 1200, Tags: `["Signature"]`, Sort: 1, Status: 1, RestaurantID: 8},
{Name: "Duck Intestines", Description: "Fresh duck intestines, ready in just 10 seconds. Ultra-crispy.", Price: 32, Rating: 4.6, Sales: 900, Tags: `["Classic"]`, Sort: 2, Status: 1, RestaurantID: 8},
{Name: "Tender Beef Slices", Description: "Marinated beef tenderloin, silky and juicy.", Price: 42, Rating: 4.5, Sales: 1100, Tags: `["Meat"]`, Sort: 3, Status: 1, RestaurantID: 8},
{Name: "Fresh Duck Blood Curd", Description: "Silky duck blood curd that stays tender no matter how long it's cooked.", Price: 15, Rating: 4.4, Sales: 700, Tags: `["Classic"]`, Sort: 4, Status: 1, RestaurantID: 8},
}},
},
// 东北串王
9: {
{"Grilled Skewers", []model.MenuItem{
{Name: "Lamb Skewers (10 skewers)", Description: "Charcoal-grilled to order with cumin and chili powder. Crispy outside, juicy inside.", Price: 35, Rating: 4.7, Sales: 3200, Tags: `["Signature","Must Order"]`, Sort: 1, Status: 1, RestaurantID: 9},
{Name: "Grilled Lamb Kidneys (3 skewers)", Description: "Fresh lamb kidneys, seared over high heat. Crispy and completely odor-free.", Price: 28, Rating: 4.5, Sales: 1800, Tags: `["Specialty"]`, Sort: 2, Status: 1, RestaurantID: 9},
{Name: "Grilled Chicken Wings (4 pcs)", Description: "Honey-glazed wings with crispy skin. Juicy and full of flavor.", Price: 24, Rating: 4.6, Sales: 2100, Tags: `["Best Seller"]`, Sort: 3, Status: 1, RestaurantID: 9},
}},
{"Grilled Sides & Staples", []model.MenuItem{
{Name: "Grilled Leeks", Description: "Fresh leeks brushed with oil and seasoned. Aromatic and irresistible.", Price: 12, Rating: 4.3, Sales: 900, Tags: `["Vegetable"]`, Sort: 1, Status: 1, RestaurantID: 9},
{Name: "Grilled Bun Slices", Description: "Sliced steamed buns brushed with sauce, crispy outside and soft inside.", Price: 8, Rating: 4.4, Sales: 800, Tags: `["Staple"]`, Sort: 2, Status: 1, RestaurantID: 9},
{Name: "Chilled Beer", Description: "Ice-cold Tsingtao Beer 500ml.", Price: 8, Rating: 4.5, Sales: 2500, Tags: `["Drink"]`, Sort: 3, Status: 1, RestaurantID: 9},
}},
},
// 茶颜悦色
10: {
{"Signature Milk Teas", []model.MenuItem{
{Name: "Youlan Latte", Description: "Sri Lankan black tea with fresh milk, topped with crushed pecans. Aromatic tea with creamy smoothness.", Price: 18, Rating: 4.9, Sales: 5800, Tags: `["Signature","Popular"]`, Sort: 1, Status: 1, RestaurantID: 10},
{Name: "Shengsheng Oolong", Description: "High-mountain oolong tea with fresh milk for a lingering tea flavor.", Price: 16, Rating: 4.7, Sales: 3200, Tags: `["Best Seller"]`, Sort: 2, Status: 1, RestaurantID: 10},
{Name: "Osmanthus Oolong", Description: "Osmanthus oolong fresh milk tea with a delicate floral aroma.", Price: 17, Rating: 4.6, Sales: 2400, Tags: `["Floral"]`, Sort: 3, Status: 1, RestaurantID: 10},
}},
{"Fruit Tea & Iced Drinks", []model.MenuItem{
{Name: "Strawberry Shake Smoothie", Description: "Fresh strawberries blended with milk and ice — sweet, tangy, and refreshing.", Price: 20, Rating: 4.6, Sales: 2800, Tags: `["Summer Limited"]`, Sort: 1, Status: 1, RestaurantID: 10},
{Name: "Mango Coconut Delight", Description: "Mango puree with coconut milk — tropical vibes in every sip.", Price: 19, Rating: 4.5, Sales: 2200, Tags: `["New"]`, Sort: 2, Status: 1, RestaurantID: 10},
}},
},
// 甜蜜时光
11: {
{"Signature Desserts", []model.MenuItem{
{Name: "Classic Tiramisu", Description: "Mascarpone cheese layered with coffee-soaked ladyfingers. Rich and decadent.", Price: 32, Rating: 4.8, Sales: 600, Tags: `["Signature"]`, Sort: 1, Status: 1, RestaurantID: 11},
{Name: "Chocolate Lava Cake", Description: "Warm cake with a molten chocolate center. Served with vanilla ice cream.", Price: 28, Rating: 4.7, Sales: 500, Tags: `["Best Seller"]`, Sort: 2, Status: 1, RestaurantID: 11},
{Name: "Macarons (6 pcs)", Description: "French macarons in assorted flavors. Crisp shell with a chewy center.", Price: 38, Rating: 4.5, Sales: 300, Tags: `["Refined"]`, Sort: 3, Status: 1, RestaurantID: 11},
}},
},
// 绿野轻食
12: {
{"Salad Bowls", []model.MenuItem{
{Name: "Avocado Chicken Breast Salad", Description: "Organic greens with grilled chicken breast and avocado. Low-calorie, high-protein.", Price: 35, Rating: 4.6, Sales: 1200, Tags: `["Signature","Low Calorie"]`, Sort: 1, Status: 1, RestaurantID: 12},
{Name: "Quinoa Salmon Bowl", Description: "Quinoa base with salmon and fresh vegetables. Nutritionally balanced.", Price: 42, Rating: 4.7, Sales: 800, Tags: `["High Protein"]`, Sort: 2, Status: 1, RestaurantID: 12},
{Name: "Garden Vegan Salad", Description: "All-vegan salad with assorted greens and vinaigrette dressing.", Price: 28, Rating: 4.4, Sales: 600, Tags: `["Vegan"]`, Sort: 3, Status: 1, RestaurantID: 12},
}},
{"Drinks", []model.MenuItem{
{Name: "Fresh-Pressed Juice", Description: "Carrot, apple, and orange — freshly pressed to order.", Price: 18, Rating: 4.5, Sales: 500, Tags: `["Freshly Pressed"]`, Sort: 1, Status: 1, RestaurantID: 12},
{Name: "Yogurt Cup", Description: "Greek yogurt topped with nuts and blueberries.", Price: 15, Rating: 4.4, Sales: 400, Tags: `["Healthy"]`, Sort: 2, Status: 1, RestaurantID: 12},
}},
},
}
for restID, cats := range restaurantMenus {
for _, cs := range cats {
menuCat := model.MenuCategory{RestaurantID: restID, Name: cs.name, Sort: 1}
if err := db.Create(&menuCat).Error; err != nil {
return err
}
for i := range cs.items {
cs.items[i].CategoryID = menuCat.ID
if err := db.Create(&cs.items[i]).Error; err != nil {
return err
}
}
}
}
log.Printf("外卖数据初始化完成(%d 分类 + %d 餐厅 + 菜品)", len(categories), len(restaurants))
return nil
}