mirror of
https://github.com/TomasiDeveloping/PlayerManagement.git
synced 2026-04-16 17:22:21 +00:00
.
This commit is contained in:
parent
ed79851e8b
commit
98f772e5d5
@ -7,11 +7,29 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
|
||||||
|
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="8.0.2" />
|
||||||
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.8" />
|
||||||
|
<PackageReference Include="Serilog" Version="4.0.2" />
|
||||||
|
<PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Controllers\v1\" />
|
<ProjectReference Include="..\Application\Application.csproj" />
|
||||||
|
<ProjectReference Include="..\Database\Database.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Ui\Ui.esproj">
|
||||||
|
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,22 +1,70 @@
|
|||||||
var builder = WebApplication.CreateBuilder(args);
|
// Configure Serilog logger
|
||||||
|
|
||||||
// Add services to the container.
|
using Api.Configurations;
|
||||||
|
using Application;
|
||||||
|
using Database;
|
||||||
|
using HealthChecks.UI.Client;
|
||||||
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
Log.Logger = new LoggerConfiguration()
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
.WriteTo.Console()
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
.CreateBootstrapLogger();
|
||||||
builder.Services.AddSwaggerGen();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
try
|
||||||
|
{
|
||||||
|
Log.Information("Starting API . . . ");
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
builder.Services.AddSerilog(options =>
|
||||||
|
{
|
||||||
|
options.ReadFrom.Configuration(builder.Configuration);
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.Services.AddDatabase(builder.Configuration);
|
||||||
|
builder.Services.AddApplication();
|
||||||
|
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
|
||||||
|
builder.Services.ConfigureAndApiVersioning();
|
||||||
|
builder.Services.ConfigureAndAddSwagger();
|
||||||
|
builder.Services.ConfigureAndAddCors();
|
||||||
|
builder.Services.ConfigureAndAddHealthChecks(builder.Configuration);
|
||||||
|
|
||||||
|
var jwtSection = builder.Configuration.GetRequiredSection("Jwt");
|
||||||
|
builder.Services.ConfigureAndAddAuthentication(jwtSection);
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseCors("AllowAll");
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseSerilogRequestLogging();
|
||||||
|
|
||||||
app.MapControllers();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseAuthentication();
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
app.MapHealthChecks("/health", new HealthCheckOptions()
|
||||||
|
{
|
||||||
|
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||||
|
});
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Fatal(e, e.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Log.CloseAndFlush();
|
||||||
|
}
|
||||||
|
|
||||||
app.Run();
|
|
||||||
|
|||||||
@ -14,8 +14,8 @@ public class PlayerConfiguration : IEntityTypeConfiguration<Player>
|
|||||||
builder.Property(player => player.Level).IsRequired().HasMaxLength(3);
|
builder.Property(player => player.Level).IsRequired().HasMaxLength(3);
|
||||||
|
|
||||||
builder.HasOne(player => player.Rank)
|
builder.HasOne(player => player.Rank)
|
||||||
.WithOne(rank => rank.Player)
|
.WithMany(rank => rank.Players)
|
||||||
.HasForeignKey<Rank>(rank => rank.PlayerId)
|
.HasForeignKey(player => player.RankId)
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
builder.HasMany(player => player.VsDuels)
|
builder.HasMany(player => player.VsDuels)
|
||||||
|
|||||||
@ -16,33 +16,28 @@ public class RankConfiguration : IEntityTypeConfiguration<Rank>
|
|||||||
{
|
{
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = new Guid(""),
|
Id = new Guid("b1c10a1c-5cf3-4e22-9fc1-d9b165b85dd3"),
|
||||||
Name = "R5",
|
Name = "R5"
|
||||||
Player = null!
|
|
||||||
},
|
},
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = new Guid(""),
|
Id = new Guid("0fc2f68a-0a4d-4922-981e-c624e4c39024"),
|
||||||
Name = "R4",
|
Name = "R4"
|
||||||
Player = null!
|
|
||||||
},
|
},
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = new Guid(""),
|
Id = new Guid("4970e1f5-f7f5-43e8-88cc-7f8fc4075418"),
|
||||||
Name = "R3",
|
Name = "R3"
|
||||||
Player = null!
|
|
||||||
},
|
},
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = new Guid(""),
|
Id = new Guid("d8d0c587-f269-45ff-b13e-4631298bf0af"),
|
||||||
Name = "R2",
|
Name = "R2"
|
||||||
Player = null!
|
|
||||||
},
|
},
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = new Guid(""),
|
Id = new Guid("326edef0-5074-43a5-9db9-edc71221a0f7"),
|
||||||
Name = "R1",
|
Name = "R1"
|
||||||
Player = null!
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -13,25 +13,25 @@ public class RoleConfiguration : IEntityTypeConfiguration<IdentityRole<Guid>>
|
|||||||
{
|
{
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = new Guid(""),
|
Id = new Guid("d8b9f882-95f0-4ba0-80ed-9c22c27ac88a"),
|
||||||
NormalizedName = ApplicationRoles.SystemAdministrator.ToUpper(),
|
NormalizedName = ApplicationRoles.SystemAdministrator.ToUpper(),
|
||||||
Name = ApplicationRoles.SystemAdministrator
|
Name = ApplicationRoles.SystemAdministrator
|
||||||
},
|
},
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = new Guid(""),
|
Id = new Guid("47de05ba-ff1e-46b6-9995-269084006c24"),
|
||||||
NormalizedName = ApplicationRoles.Administrator.ToUpper(),
|
NormalizedName = ApplicationRoles.Administrator.ToUpper(),
|
||||||
Name = ApplicationRoles.Administrator
|
Name = ApplicationRoles.Administrator
|
||||||
},
|
},
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = new Guid(""),
|
Id = new Guid("5cc27946-5601-4a25-b9a9-75b8a11c0cf4"),
|
||||||
NormalizedName = ApplicationRoles.User.ToUpper(),
|
NormalizedName = ApplicationRoles.User.ToUpper(),
|
||||||
Name = ApplicationRoles.User
|
Name = ApplicationRoles.User
|
||||||
},
|
},
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Id = new Guid(""),
|
Id = new Guid("207bb0a3-ad50-49bb-bc41-b266fce66529"),
|
||||||
NormalizedName = ApplicationRoles.ReadOnly.ToUpper(),
|
NormalizedName = ApplicationRoles.ReadOnly.ToUpper(),
|
||||||
Name = ApplicationRoles.ReadOnly
|
Name = ApplicationRoles.ReadOnly
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,8 +11,8 @@ public class UserConfiguration : IEntityTypeConfiguration<User>
|
|||||||
builder.Property(user => user.PlayerName).IsRequired().HasMaxLength(200);
|
builder.Property(user => user.PlayerName).IsRequired().HasMaxLength(200);
|
||||||
|
|
||||||
builder.HasOne(user => user.Alliance)
|
builder.HasOne(user => user.Alliance)
|
||||||
.WithOne(alliance => alliance.User)
|
.WithMany(alliance => alliance.Users)
|
||||||
.HasForeignKey<Alliance>(alliance => alliance.UserId)
|
.HasForeignKey(user => user.AllianceId)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.NoAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,10 +7,15 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="8.0.8" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Database.Entities;
|
using System.Reflection;
|
||||||
|
using Database.Entities;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
@ -10,6 +11,8 @@ public static class DatabaseDependencyInjection
|
|||||||
{
|
{
|
||||||
public static IServiceCollection AddDatabase(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddDatabase(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
services.AddDataProtection();
|
||||||
|
|
||||||
services.AddDbContext<ApplicationContext>(options =>
|
services.AddDbContext<ApplicationContext>(options =>
|
||||||
{
|
{
|
||||||
options.UseSqlServer(configuration.GetConnectionString("ApplicationDbConnection"));
|
options.UseSqlServer(configuration.GetConnectionString("ApplicationDbConnection"));
|
||||||
@ -35,7 +38,6 @@ public static class DatabaseDependencyInjection
|
|||||||
options.TokenLifespan = TimeSpan.FromHours(2);
|
options.TokenLifespan = TimeSpan.FromHours(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,9 +8,7 @@ public class Alliance : BaseEntity
|
|||||||
|
|
||||||
public required string Abbreviation { get; set; }
|
public required string Abbreviation { get; set; }
|
||||||
|
|
||||||
public User User { get; set; }
|
public ICollection<Player> Players { get; set; } = [];
|
||||||
|
|
||||||
public Guid UserId { get; set; }
|
public ICollection<User> Users { get; set; } = [];
|
||||||
|
|
||||||
public ICollection<Player> Players { get; set; }
|
|
||||||
}
|
}
|
||||||
@ -6,8 +6,12 @@ public class Player : BaseEntity
|
|||||||
|
|
||||||
public required Rank Rank { get; set; }
|
public required Rank Rank { get; set; }
|
||||||
|
|
||||||
|
public Guid RankId { get; set; }
|
||||||
|
|
||||||
public Alliance Alliance { get; set; }
|
public Alliance Alliance { get; set; }
|
||||||
|
|
||||||
|
public Guid AllianceId { get; set; }
|
||||||
|
|
||||||
public required string Level { get; set; }
|
public required string Level { get; set; }
|
||||||
|
|
||||||
public ICollection<DesertStorm> DesertStorms { get; set; } = [];
|
public ICollection<DesertStorm> DesertStorms { get; set; } = [];
|
||||||
|
|||||||
@ -4,7 +4,5 @@ public class Rank : BaseEntity
|
|||||||
{
|
{
|
||||||
public required string Name { get; set; }
|
public required string Name { get; set; }
|
||||||
|
|
||||||
public Guid PlayerId { get; set; }
|
public ICollection<Player> Players { get; set; } = [];
|
||||||
|
|
||||||
public required Player Player { get; set; }
|
|
||||||
}
|
}
|
||||||
@ -6,5 +6,7 @@ public class User : IdentityUser<Guid>
|
|||||||
{
|
{
|
||||||
public required Alliance Alliance { get; set; }
|
public required Alliance Alliance { get; set; }
|
||||||
|
|
||||||
|
public Guid AllianceId { get; set; }
|
||||||
|
|
||||||
public required string PlayerName { get; set; }
|
public required string PlayerName { get; set; }
|
||||||
}
|
}
|
||||||
@ -3,11 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.10.35122.118
|
VisualStudioVersion = 17.10.35122.118
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Database", "Database\Database.csproj", "{93C305BF-7225-492E-9FBA-D2DD9B0698DF}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Database", "Database\Database.csproj", "{93C305BF-7225-492E-9FBA-D2DD9B0698DF}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utilities", "Utilities\Utilities.csproj", "{FA8FEE7C-58A5-458F-A7D5-509D9364159B}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utilities", "Utilities\Utilities.csproj", "{FA8FEE7C-58A5-458F-A7D5-509D9364159B}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api", "Api\Api.csproj", "{B3CFE8A6-2BA3-4CB2-893F-3F2B0FABB08F}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api", "Api\Api.csproj", "{B3CFE8A6-2BA3-4CB2-893F-3F2B0FABB08F}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application", "Application\Application.csproj", "{BFE66A98-A2BC-4B8C-803E-610705855E7A}"
|
||||||
|
EndProject
|
||||||
|
Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "Ui", "Ui\Ui.esproj", "{77168004-AF1E-4F51-A096-E8E8BF18A37A}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -27,6 +31,16 @@ Global
|
|||||||
{B3CFE8A6-2BA3-4CB2-893F-3F2B0FABB08F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B3CFE8A6-2BA3-4CB2-893F-3F2B0FABB08F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{B3CFE8A6-2BA3-4CB2-893F-3F2B0FABB08F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B3CFE8A6-2BA3-4CB2-893F-3F2B0FABB08F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{B3CFE8A6-2BA3-4CB2-893F-3F2B0FABB08F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B3CFE8A6-2BA3-4CB2-893F-3F2B0FABB08F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BFE66A98-A2BC-4B8C-803E-610705855E7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BFE66A98-A2BC-4B8C-803E-610705855E7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BFE66A98-A2BC-4B8C-803E-610705855E7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BFE66A98-A2BC-4B8C-803E-610705855E7A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{77168004-AF1E-4F51-A096-E8E8BF18A37A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{77168004-AF1E-4F51-A096-E8E8BF18A37A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{77168004-AF1E-4F51-A096-E8E8BF18A37A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
|
{77168004-AF1E-4F51-A096-E8E8BF18A37A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{77168004-AF1E-4F51-A096-E8E8BF18A37A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{77168004-AF1E-4F51-A096-E8E8BF18A37A}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user