Compare commits
4 Commits
6ec2187361
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 307c81001a | |||
| 9c5346213e | |||
| 6542d804f8 | |||
| f470367d89 |
@@ -0,0 +1,8 @@
|
||||
using DigitalData.TaskFlow.Domain.ProcedureResults;
|
||||
|
||||
namespace DigitalData.TaskFlow.Application.Common.Interfaces;
|
||||
|
||||
public interface IUserRepository : IRepository
|
||||
{
|
||||
Task<IEnumerable<AuthorizedUser>> GetAuthorizedAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using DigitalData.TaskFlow.Application.Common.Interfaces;
|
||||
using MediatR;
|
||||
|
||||
namespace DigitalData.TaskFlow.Application.Features.Users.Queries;
|
||||
|
||||
public sealed record GetAuthorizedUsersQuery : IRequest<GetAuthorizedUsersResult>;
|
||||
|
||||
public sealed record GetAuthorizedUsersResult(IEnumerable<GetAuthorizedUsersMeta> Meta, IEnumerable<int> Wisagids);
|
||||
|
||||
public sealed record GetAuthorizedUsersMeta(int? Code, string Message);
|
||||
|
||||
public sealed class GetAuthorizedUsersQueryHandler(IUserRepository repo) : IRequestHandler<GetAuthorizedUsersQuery, GetAuthorizedUsersResult>
|
||||
{
|
||||
public async Task<GetAuthorizedUsersResult> Handle(GetAuthorizedUsersQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var users = await repo.GetAuthorizedAsync(cancellationToken);
|
||||
|
||||
return new GetAuthorizedUsersResult(
|
||||
Meta: [new GetAuthorizedUsersMeta(Code: 0, Message: "OK")],
|
||||
Wisagids: users.Select(x => x.WisagId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace DigitalData.TaskFlow.Domain.ProcedureResults;
|
||||
|
||||
public class AuthorizedUser
|
||||
{
|
||||
public int WisagId { get; init; }
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public static class DependencyInjection
|
||||
|
||||
services.AddScoped<IWorkflowRepository, WorkflowRepository>();
|
||||
services.AddScoped<IDocumentRepository, DocumentRepository>();
|
||||
services.AddScoped<IUserRepository, UserRepository>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ public sealed class TaskFlowDbContext(DbContextOptions<TaskFlowDbContext> option
|
||||
/// </summary>
|
||||
public DbSet<WorkflowClosing> WorkflowClosings => Set<WorkflowClosing>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the keyless result model used for authorized users procedure results.
|
||||
/// </summary>
|
||||
public DbSet<AuthorizedUser> AuthorizedUsers => Set<AuthorizedUser>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
@@ -50,5 +55,12 @@ public sealed class TaskFlowDbContext(DbContextOptions<TaskFlowDbContext> option
|
||||
entity.Property(x => x.Code).HasColumnName("CODE").HasColumnType("int");
|
||||
entity.Property(x => x.Result).HasColumnName("RESULT").HasColumnType("nvarchar(400)");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<AuthorizedUser>(entity =>
|
||||
{
|
||||
entity.HasNoKey();
|
||||
entity.ToView(null);
|
||||
entity.Property(x => x.WisagId).HasColumnName("wisagid").HasColumnType("int");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using DigitalData.TaskFlow.Application.Common.Interfaces;
|
||||
using DigitalData.TaskFlow.Domain.ProcedureResults;
|
||||
using DigitalData.TaskFlow.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DigitalData.TaskFlow.Infrastructure.Repositories;
|
||||
|
||||
public sealed class UserRepository(TaskFlowDbContext context) : IUserRepository
|
||||
{
|
||||
public async Task<IEnumerable<AuthorizedUser>> GetAuthorizedAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return await context.AuthorizedUsers
|
||||
.FromSqlInterpolated($"EXEC [dbo].[PRCUST_F19_GET_AUTHORIZED_USERS]")
|
||||
.AsNoTracking()
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using DigitalData.TaskFlow.Application.Features.Users.Queries;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DigitalData.TaskFlow.API.Controllers;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
[ApiController]
|
||||
[Route("api/users")]
|
||||
public sealed class UsersController(ISender sender) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("authorized")]
|
||||
[ProducesResponseType(typeof(GetAuthorizedUsersResult), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(GetAuthorizedUsersResult), StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(GetAuthorizedUsersResult), StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetAuthorizedAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await sender.Send(new GetAuthorizedUsersQuery(), cancellationToken);
|
||||
var code = result.Meta.FirstOrDefault()?.Code;
|
||||
|
||||
return code switch
|
||||
{
|
||||
0 => Ok(result),
|
||||
4 => Unauthorized(result),
|
||||
_ => StatusCode(StatusCodes.Status500InternalServerError, result)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,9 @@
|
||||
<Authors>Digital Data GmbH</Authors>
|
||||
<Company>Digital Data GmbH</Company>
|
||||
<Product>DigitalData.TaskFlow.API</Product>
|
||||
<Version>1.3.0-beta</Version>
|
||||
<FileVersion>1.3.0.0</FileVersion>
|
||||
<AssemblyVersion>1.3.0.0</AssemblyVersion>
|
||||
<Version>1.4.0-beta</Version>
|
||||
<FileVersion>1.4.0.0</FileVersion>
|
||||
<AssemblyVersion>1.4.0.0</AssemblyVersion>
|
||||
<Copyright>Copyright © 2026 Digital Data GmbH. All rights reserved.</Copyright>
|
||||
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user