WorkCamera/server/Zr.Admin.NET/ZR.Mall/InitMallTable.cs
2025-12-27 12:17:46 +08:00

35 lines
1.1 KiB
C#

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SqlSugar.IOC;
using ZR.Mall.Model;
namespace ZR.Mall
{
/// <summary>
/// 初始化表
/// </summary>
public static class InitMallTable
{
public static void InitDb(this IServiceCollection services, IWebHostEnvironment environment)
{
var db = DbScoped.SugarScope.GetConnection("0");
var options = App.OptionsSetting;
if (!options.InitDb) return;
if (environment.IsDevelopment())
{
db.CodeFirst.InitTables(typeof(Product));
db.CodeFirst.InitTables(typeof(ProductSpec));
db.CodeFirst.InitTables(typeof(Skus));
db.CodeFirst.InitTables(typeof(Category));
db.CodeFirst.InitTables(typeof(Brand));
db.CodeFirst.InitTables(typeof(OMSOrder));
db.CodeFirst.InitTables(typeof(OMSOrderItem));
db.CodeFirst.InitTables(typeof(MMSUserAddress));
}
}
}
}