-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
81 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...System.Api/V3/VNext/ApiModels/QtlsInfo.cs → ...em.Api/V3/V20240912/ApiModels/QtlsInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ngRecordSystem/src/TeachingRecordSystem.Api/V3/V20240912/Controllers/PersonsController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Swashbuckle.AspNetCore.Annotations; | ||
using TeachingRecordSystem.Api.Infrastructure.Security; | ||
using TeachingRecordSystem.Api.V3.Core.Operations; | ||
using TeachingRecordSystem.Api.V3.V20240912.ApiModels; | ||
using TeachingRecordSystem.Api.V3.V20240912.Requests; | ||
|
||
namespace TeachingRecordSystem.Api.V3.V20240912.Controllers; | ||
|
||
[Route("persons")] | ||
public class PersonsController(IMapper mapper) : ControllerBase | ||
{ | ||
[HttpPut("{trn}/qtls")] | ||
[SwaggerOperation( | ||
OperationId = "SetQtls", | ||
Summary = "Set QTLS status for a teacher", | ||
Description = "Sets the QTLS status for the teacher with the given TRN.")] | ||
[ProducesResponseType(typeof(QtlsInfo), StatusCodes.Status200OK)] | ||
[ProducesResponseType(typeof(void), StatusCodes.Status202Accepted)] | ||
[MapError(10001, statusCode: StatusCodes.Status404NotFound)] | ||
[Authorize(Policy = AuthorizationPolicies.ApiKey, Roles = ApiRoles.AssignQtls)] | ||
public async Task<IActionResult> PutQtls( | ||
[FromRoute] string trn, | ||
[FromBody] SetQtlsRequest request, | ||
[FromServices] SetQtlsHandler handler) | ||
{ | ||
var command = new SetQtlsCommand(trn, request.QtsDate); | ||
var result = await handler.Handle(command); | ||
return result is { Succeeded: true } ? Ok(result.QtlsInfo!) : Accepted(); | ||
} | ||
|
||
[HttpGet("{trn}/qtls")] | ||
[SwaggerOperation( | ||
OperationId = "GetQtls", | ||
Summary = "Get QTLS status for a teacher", | ||
Description = "Gets the QTLS status for the teacher with the given TRN.")] | ||
[ProducesResponseType(typeof(QtlsInfo), StatusCodes.Status200OK)] | ||
[Authorize(Policy = AuthorizationPolicies.ApiKey, Roles = ApiRoles.AssignQtls)] | ||
public async Task<IActionResult> GetQtls( | ||
[FromRoute] string trn, | ||
[FromServices] GetQtlsHandler handler) | ||
{ | ||
var command = new GetQtlsCommand(trn); | ||
var result = await handler.Handle(command); | ||
var response = mapper.Map<QtlsInfo?>(result); | ||
return response is not null ? Ok(response) : NotFound(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...m.Api/V3/VNext/Requests/SetQtlsRequest.cs → ...i/V3/V20240912/Requests/SetQtlsRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...gRecordSystem/src/TeachingRecordSystem.Api/V3/VNext/Validators/SetQtlsRequestValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...Tests/V3/VNext/GetQtlsDateRequestTests.cs → ...s/V3/V20240912/GetQtlsDateRequestTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...Tests/V3/VNext/SetQtlsDateRequestTests.cs → ...s/V3/V20240912/SetQtlsDateRequestTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/V3/V20240912/TestBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace TeachingRecordSystem.Api.Tests.V3.V20240912; | ||
|
||
public abstract class TestBase : Tests.TestBase | ||
{ | ||
public const string Version = VersionRegistry.V3MinorVersions.V20240912; | ||
|
||
protected TestBase(HostFixture hostFixture) : base(hostFixture) | ||
{ | ||
} | ||
|
||
public HttpClient GetHttpClientWithApiKey() => | ||
GetHttpClientWithApiKey(Version); | ||
|
||
public HttpClient GetHttpClientWithIdentityAccessToken(string trn, string scope = "dqt:read") => | ||
GetHttpClientWithIdentityAccessToken(trn, scope, Version); | ||
} |