2025-07-07 18:41:36 +08:00
|
|
|
using Arch.EntityFrameworkCore.UnitOfWork;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using WorkStation.Server.Context;
|
|
|
|
using WorkStation.Server.Context.Entity;
|
|
|
|
using WorkStation.Server.Context.Repository;
|
|
|
|
using WorkStation.Server.Services;
|
|
|
|
|
2025-07-05 14:05:59 +08:00
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
|
2025-07-07 18:41:36 +08:00
|
|
|
// Add services to the container.
|
|
|
|
var connectionString = builder.Configuration.GetConnectionString("MySQLConnection");
|
|
|
|
builder.Services.AddDbContext<MyDbContext>(options =>
|
|
|
|
{
|
|
|
|
options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
|
|
|
|
});
|
|
|
|
builder.Services.AddUnitOfWork<MyDbContext>();
|
|
|
|
builder.Services.AddCustomRepository<User, UserRepository>();
|
|
|
|
builder.Services.AddTransient<IUserService, UserService>();
|
2025-07-05 14:05:59 +08:00
|
|
|
builder.Services.AddControllers();
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
2025-07-07 18:41:36 +08:00
|
|
|
|
2025-07-05 14:05:59 +08:00
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
|
|
|
app.Run();
|