2024-10-16 11:27:14 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using LFlow.Base.BusinessInterface;
|
|
|
|
|
|
using LFlow.Base.Interfaces;
|
|
|
|
|
|
using LFlow.Base.Utils;
|
|
|
|
|
|
using LFlow.Home.Models.DataModels;
|
|
|
|
|
|
using LFlow.Home.Models.DtoModel;
|
|
|
|
|
|
using LFlow.Home.Services;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LFlow.Home;
|
2024-10-16 15:22:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 首页模块
|
|
|
|
|
|
/// </summary>
|
2024-10-16 11:27:14 +08:00
|
|
|
|
public class HomeModule : IModule
|
|
|
|
|
|
{
|
2024-10-16 15:22:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 配置模块
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="services">启动前的IServiceCollection</param>
|
2024-10-16 11:27:14 +08:00
|
|
|
|
public void ConfigureModule(IServiceCollection services)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 将HomeModel注册到CodeFirst,将会在程序启动后自动创建表
|
|
|
|
|
|
CodeFirst.AddType(typeof(HomeModel));
|
|
|
|
|
|
|
2024-10-16 15:22:58 +08:00
|
|
|
|
// 注册服务、仓储、模型
|
2024-10-16 11:27:14 +08:00
|
|
|
|
var assembly = Assembly.GetAssembly(typeof(HomeService))!;
|
|
|
|
|
|
var types = assembly.GetTypes().ToList();
|
2024-10-16 15:22:58 +08:00
|
|
|
|
|
2024-10-16 11:27:14 +08:00
|
|
|
|
RegisterModule.RegisterAllService(types, services);
|
|
|
|
|
|
RegisterModule.RegisterAllRepo(types, services);
|
2024-10-16 15:22:58 +08:00
|
|
|
|
RegisterModule.RegisterAllModel(types, services);
|
|
|
|
|
|
|
|
|
|
|
|
// 添加控制器
|
2024-10-16 11:27:14 +08:00
|
|
|
|
services.AddControllers().AddApplicationPart(assembly);
|
|
|
|
|
|
Console.WriteLine("HomeModule ConfigureModule");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|