Refactor RecActionController and add new endpoints
- Introduced `FakeProfileId` constant to replace hardcoded values.
- Added `HttpGet` endpoint `api/[controller]/fake` to retrieve data using `FakeProfileId`.
- Added `HttpPost` endpoint `api/[controller]/invoke/{profileId}` for batch actions.
- Updated `CreateAction` and `Delete` methods to use `FakeProfileId`.
- Added `HttpDelete` endpoint `api/[controller]/fake` to delete actions using `FakeProfileId`.
- Improved code maintainability by centralizing the fake profile ID and adding dedicated endpoints.
This commit is contained in:
parent
dd33d74863
commit
6de45e3feb
@ -11,6 +11,8 @@ namespace ReC.API.Controllers;
|
||||
[ApiController]
|
||||
public class RecActionController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
private const long FakeProfileId = 2;
|
||||
|
||||
[HttpPost("invoke/{profileId}")]
|
||||
public async Task<IActionResult> Invoke([FromRoute] int profileId, CancellationToken cancel)
|
||||
{
|
||||
@ -25,6 +27,12 @@ public class RecActionController(IMediator mediator) : ControllerBase
|
||||
ProfileId = profileId
|
||||
}, cancel));
|
||||
|
||||
[HttpGet("fake")]
|
||||
public async Task<IActionResult> Get(CancellationToken cancel) => Ok(await mediator.Send(new ReadRecActionQuery()
|
||||
{
|
||||
ProfileId = FakeProfileId
|
||||
}, cancel));
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> CreateAction([FromBody] CreateRecActionCommand command, CancellationToken cancel)
|
||||
{
|
||||
@ -49,7 +57,7 @@ public class RecActionController(IMediator mediator) : ControllerBase
|
||||
|
||||
await mediator.Send(new CreateRecActionCommand()
|
||||
{
|
||||
ProfileId = 2,
|
||||
ProfileId = FakeProfileId,
|
||||
EndpointUri = endpointUri,
|
||||
Type = type,
|
||||
BodyQuery = $@"SELECT '{bodyJson ?? "NULL"}' AS REQUEST_BODY;",
|
||||
@ -66,7 +74,7 @@ public class RecActionController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
await mediator.Send(new DeleteRecActionsCommand()
|
||||
{
|
||||
ProfileId = profileId
|
||||
ProfileId = FakeProfileId
|
||||
}, cancel);
|
||||
|
||||
return NoContent();
|
||||
@ -77,7 +85,7 @@ public class RecActionController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
await mediator.Send(new DeleteRecActionsCommand()
|
||||
{
|
||||
ProfileId = 2
|
||||
ProfileId = FakeProfileId
|
||||
}, cancel);
|
||||
|
||||
return NoContent();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user