testapi
This commit is contained in:
1 parent
2db9525570
commit
5aca82244e
21 files changed
+545
-126
No files matched your search
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "9.0.7",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
using uWine.Core.Infrastructure.Services;
|
||||
|
||||
namespace uWine.Api.Controllers
|
||||
{
|
||||
@@ -8,23 +9,37 @@ namespace uWine.Api.Controllers
|
||||
public class TestController : Controller
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly OwnerService _ownerService;
|
||||
private readonly AuthenticationService _authenticationService;
|
||||
private readonly UserService _userService;
|
||||
|
||||
public TestController(IConfiguration configuration) {
|
||||
_configuration = configuration;
|
||||
public TestController(IConfiguration configuration,
|
||||
OwnerService ownerService,
|
||||
AuthenticationService authenticationService,
|
||||
UserService userService)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_ownerService = ownerService;
|
||||
_authenticationService = authenticationService;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
[HttpGet("cklogin")]
|
||||
public IActionResult test()
|
||||
{
|
||||
try
|
||||
{
|
||||
var TUserId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
var userId = User.FindFirst("userId").Value;
|
||||
var userId = int.Parse(User.FindFirst("userId").Value);
|
||||
var role = User.FindFirst(ClaimTypes.Role)?.Value;
|
||||
return Ok(new { userId, TUserId, role });
|
||||
|
||||
var user = _userService.Process(userId);
|
||||
|
||||
return Ok(new { userId, TUserId, role, user });
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Unauthorized("\"title\": \"Unauthorized\"");
|
||||
return Unauthorized(new { status = 401 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,16 @@ namespace uWine.Api
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddTransient<IAuthenticationRepository, MariaDbAuthenticationRepository>();
|
||||
builder.Services.AddTransient<IOwnerRepository, MariadbOwnerRepository>();
|
||||
builder.Services.AddTransient<IAddressRepository, MariaDbAddressRepository>();
|
||||
builder.Services.AddTransient<IContactRepository, MariaDbContactRepository>();
|
||||
builder.Services.AddTransient<IVineyardRepository, MariaDbVineyardRepository>();
|
||||
builder.Services.AddTransient<IUserRepository, MariaDbUserRepository>();
|
||||
|
||||
|
||||
builder.Services.AddTransient<AuthenticationService>();
|
||||
builder.Services.AddTransient<OwnerService>();
|
||||
builder.Services.AddTransient<UserService>();
|
||||
//builder.Services.AddSingleton<MariaDbServerRepository>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>false</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>\\192.168.0.8\deploy\Api</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
<ProjectGuid>8e5d260e-7395-4875-8a4f-16205f92ad38</ProjectGuid>
|
||||
<SelfContained>false</SelfContained>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<_PublishTargetUrl>\\192.168.0.8\deploy\Api</_PublishTargetUrl>
|
||||
<History>True|2025-07-09T20:17:50.4482481Z||;False|2025-07-09T22:16:08.6429078+02:00||;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -3,5 +3,6 @@
|
||||
<PropertyGroup>
|
||||
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
||||
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
|
||||
<NameOfLastUsedPublishProfile>M:\uv\uWine\uWine.Api\Properties\PublishProfiles\Api01 %28192.168.0.8%29.pubxml</NameOfLastUsedPublishProfile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Reference in new issue
Block a user