admin page phaze2
This commit is contained in:
@@ -123,4 +123,96 @@ public sealed class AdminController : ControllerBase
|
||||
var result = await _adminService.GetUsageAsync(from, to, userId, cancellationToken);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
// ==================== Alerts ====================
|
||||
|
||||
[HttpGet("alerts")]
|
||||
public async Task<ActionResult<PagedResult<AdminAlertItemDto>>> Alerts(
|
||||
[FromQuery] int? deviceId,
|
||||
[FromQuery] Domain.AlertStatus? status,
|
||||
[FromQuery] DateTime? from,
|
||||
[FromQuery] DateTime? to,
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 20,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var filter = new AdminAlertFilter
|
||||
{
|
||||
DeviceId = deviceId,
|
||||
Status = status,
|
||||
From = from,
|
||||
To = to,
|
||||
Page = Math.Max(1, page),
|
||||
PageSize = Math.Clamp(pageSize, 1, 100)
|
||||
};
|
||||
|
||||
var result = await _adminService.GetAlertsAsync(filter, cancellationToken);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
// ==================== Posts ====================
|
||||
|
||||
[HttpGet("posts")]
|
||||
public async Task<ActionResult<PagedResult<AdminPostItemDto>>> Posts(
|
||||
[FromQuery] int? deviceId,
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 20,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var filter = new AdminPostFilter
|
||||
{
|
||||
DeviceId = deviceId,
|
||||
Page = Math.Max(1, page),
|
||||
PageSize = Math.Clamp(pageSize, 1, 100)
|
||||
};
|
||||
|
||||
var result = await _adminService.GetPostsAsync(filter, cancellationToken);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpDelete("posts/{id:int}")]
|
||||
public async Task<IActionResult> DeletePost(int id, CancellationToken cancellationToken)
|
||||
{
|
||||
var currentAdminId = ((UserDto)HttpContext.Items["AdminUser"]!).Id;
|
||||
var deleted = await _adminService.DeletePostAsync(id, currentAdminId, cancellationToken);
|
||||
return deleted ? Ok(new { success = true }) : NotFound();
|
||||
}
|
||||
|
||||
// ==================== Device Debug ====================
|
||||
|
||||
[HttpPost("devices/{id:int}/test-sms")]
|
||||
public async Task<ActionResult<AdminDeviceTestResultDto>> TestDeviceSms(int id, CancellationToken cancellationToken)
|
||||
{
|
||||
var currentAdminId = ((UserDto)HttpContext.Items["AdminUser"]!).Id;
|
||||
var result = await _adminService.TestDeviceSmsAsync(id, currentAdminId, cancellationToken);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost("devices/{id:int}/test-voice")]
|
||||
public async Task<ActionResult<AdminDeviceTestResultDto>> TestDeviceVoice(int id, CancellationToken cancellationToken)
|
||||
{
|
||||
var currentAdminId = ((UserDto)HttpContext.Items["AdminUser"]!).Id;
|
||||
var result = await _adminService.TestDeviceVoiceAsync(id, currentAdminId, cancellationToken);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
// ==================== Audit Log ====================
|
||||
|
||||
[HttpGet("audit-logs")]
|
||||
public async Task<ActionResult<PagedResult<AdminAuditLogDto>>> AuditLogs(
|
||||
[FromQuery] int? adminId,
|
||||
[FromQuery] int page = 1,
|
||||
[FromQuery] int pageSize = 20,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var filter = new AdminAuditLogFilter
|
||||
{
|
||||
AdminId = adminId,
|
||||
Page = Math.Max(1, page),
|
||||
PageSize = Math.Clamp(pageSize, 1, 100)
|
||||
};
|
||||
|
||||
var result = await _adminService.GetAuditLogsAsync(filter, cancellationToken);
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user