Add project files.

This commit is contained in:
Liam Pietralla 2024-10-19 10:39:31 +11:00
parent eca47c84c6
commit 26c8922752
24 changed files with 414 additions and 0 deletions

54
development/compose.yml Normal file
View File

@ -0,0 +1,54 @@
name: user-manager
services:
db:
image: postgres:16.4
container_name: user-manager-dev-deb
restart: unless-stopped
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: user-manager
volumes:
- user-manager-db-data:/var/lib/postgresql/data
minio:
image: quay.io/minio/minio:RELEASE.2024-09-13T20-26-02Z
container_name: user-manager-dev-minio
restart: unless-stopped
ports:
- "9000:9000"
- "9001:9001"
environment:
MINIO_ROOT_USER: miniodev
MINIO_ROOT_PASSWORD: miniodevpw
volumes:
- user-manager-minio-data:/data
command: minio server /data --console-address ":9001"
make-minio-buckets:
image: minio/mc
restart: no
container_name: user-manager-dev-minio-mc
depends_on:
- minio
entrypoint: sh
command:
- -c
- |
mc alias set minio http://minio:9000 miniodev miniodevpw;
mc mb minio/usermanager-dev;
mc admin user add minio usermanagerdevaccesskey usermanagerdevsecretkey;
mc admin policy create minio usermanager-dev-rw-access /tmp/minio-policy.json;
mc admin policy attach minio usermanager-dev-rw-access --user usermanageraccesskey;
mc admin user info minio usermanagerdevaccesskey;
exit 0;
volumes:
- ./misc/minio-policy.json:/tmp/minio-policy.json
volumes:
user-manager-db-data:
user-manager-minio-data:

View File

@ -0,0 +1,15 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::usermanager-dev/*"
]
}
]
}

View File

@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace UserManager.API.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

View File

@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
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();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:35300",
"sslPort": 44337
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5110",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7151;http://localhost:5110",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,6 @@
@UserManager.API_HostAddress = http://localhost:5110
GET {{UserManager.API_HostAddress}}/weatherforecast/
Accept: application/json
###

View File

@ -0,0 +1,13 @@
namespace UserManager.API
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,10 @@
using UserManager.Application.Features.Users.Requests;
using UserManager.Application.Features.Users.Responses;
namespace UserManager.Application.Features.Users.Interfaces
{
public interface IUserService
{
Task<CreateUserResponseDto> CreateUserAsync(CreateUserRequestDto request);
}
}

View File

@ -0,0 +1,10 @@
namespace UserManager.Application.Features.Users.Requests
{
public class CreateUserRequestDto
{
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public int? FavouriteRestaurantId { get; set; }
public string? FavouriteRestaurantName { get; set; }
}
}

View File

@ -0,0 +1,7 @@
namespace UserManager.Application.Features.Users.Responses
{
public class CreateUserResponseDto
{
public string FirstName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,19 @@
using UserManager.Application.Features.Users.Interfaces;
using UserManager.Application.Features.Users.Requests;
using UserManager.Application.Features.Users.Responses;
using UserManager.Application.Interfaces;
namespace UserManager.Application.Features.Users.Services
{
class UserService(IUserRepository userRepository) : IUserService
{
private readonly IUserRepository _userRepository = userRepository;
public Task<CreateUserResponseDto> CreateUserAsync(CreateUserRequestDto request)
{
// TODO
// First validate this user does not exist
// Then create the user
}
}
}

View File

@ -0,0 +1,7 @@
namespace UserManager.Application.Interfaces
{
public interface IBaseRepository<TEntity> where TEntity : class
{
Task CreateAsync(TEntity entity);
}
}

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UserManager.Domain.Entities;
namespace UserManager.Application.Interfaces
{
public interface IUserRepository : IBaseRepository<User> { }
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Features\Restaurants\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UserManager.Domain\UserManager.Domain.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UserManager.Domain.Entities
{
public class User
{
public int UserId { get; set; }
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,7 @@
namespace UserManager.Infrastructure
{
public class Class1
{
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

60
src/UserManager.sln Normal file
View File

@ -0,0 +1,60 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{74E412ED-9D1B-4597-BBFD-05623C814F98}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{5B673FE8-32DA-4CD3-8394-1BD8E1275270}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserManager.API", "UserManager.API\UserManager.API.csproj", "{A9A6D6F8-424B-4555-95D9-ECE60837B800}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserManager.Domain", "UserManager.Domain\UserManager.Domain.csproj", "{17851242-59E3-4790-9FD8-32B848BBAB3D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserManager.Infrastructure", "UserManager.Infrastructure\UserManager.Infrastructure.csproj", "{A85D13CB-884E-439D-AAE7-C4C4C2511FDE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserManager.Application", "UserManager.Application\UserManager.Application.csproj", "{C7215859-A216-4527-A192-7B8F57E50BB4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserManager.Application.UnitTests", "..\tests\UserManager.Application.Tests\UserManager.Application.UnitTests.csproj", "{B0F63D11-6933-4D87-B0D8-6DD7DFC5A23C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A9A6D6F8-424B-4555-95D9-ECE60837B800}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9A6D6F8-424B-4555-95D9-ECE60837B800}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9A6D6F8-424B-4555-95D9-ECE60837B800}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9A6D6F8-424B-4555-95D9-ECE60837B800}.Release|Any CPU.Build.0 = Release|Any CPU
{17851242-59E3-4790-9FD8-32B848BBAB3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17851242-59E3-4790-9FD8-32B848BBAB3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17851242-59E3-4790-9FD8-32B848BBAB3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17851242-59E3-4790-9FD8-32B848BBAB3D}.Release|Any CPU.Build.0 = Release|Any CPU
{A85D13CB-884E-439D-AAE7-C4C4C2511FDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A85D13CB-884E-439D-AAE7-C4C4C2511FDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A85D13CB-884E-439D-AAE7-C4C4C2511FDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A85D13CB-884E-439D-AAE7-C4C4C2511FDE}.Release|Any CPU.Build.0 = Release|Any CPU
{C7215859-A216-4527-A192-7B8F57E50BB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7215859-A216-4527-A192-7B8F57E50BB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7215859-A216-4527-A192-7B8F57E50BB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7215859-A216-4527-A192-7B8F57E50BB4}.Release|Any CPU.Build.0 = Release|Any CPU
{B0F63D11-6933-4D87-B0D8-6DD7DFC5A23C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0F63D11-6933-4D87-B0D8-6DD7DFC5A23C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0F63D11-6933-4D87-B0D8-6DD7DFC5A23C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0F63D11-6933-4D87-B0D8-6DD7DFC5A23C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{A9A6D6F8-424B-4555-95D9-ECE60837B800} = {74E412ED-9D1B-4597-BBFD-05623C814F98}
{17851242-59E3-4790-9FD8-32B848BBAB3D} = {74E412ED-9D1B-4597-BBFD-05623C814F98}
{A85D13CB-884E-439D-AAE7-C4C4C2511FDE} = {74E412ED-9D1B-4597-BBFD-05623C814F98}
{C7215859-A216-4527-A192-7B8F57E50BB4} = {74E412ED-9D1B-4597-BBFD-05623C814F98}
{B0F63D11-6933-4D87-B0D8-6DD7DFC5A23C} = {5B673FE8-32DA-4CD3-8394-1BD8E1275270}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6E7F90F4-4A09-4CDB-8653-6E094E164853}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,7 @@
namespace UserManager.Application.Tests
{
public class Class1
{
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>