refactor(core): reorganize DTOs into Models and ViewModels folders
Move DTOs from ApiContracts to appropriate locations: - SignalR DTOs → ViewModels (renamed Dto→ViewModel suffix) - Pipeline DTOs → Models/Pipelines - UserInfoDto → Models/Auth - DataUpdateDto → Models/Infrastructure
This commit is contained in:
@@ -2,7 +2,6 @@ using System.Security.Claims;
|
||||
using System.Text.Json;
|
||||
using JdeScoping.Api.Extensions;
|
||||
using JdeScoping.Core.ApiContracts;
|
||||
using JdeScoping.Core.ApiContracts.Auth;
|
||||
using JdeScoping.Core.Interfaces;
|
||||
using JdeScoping.Core.Models;
|
||||
using JdeScoping.Core.Models.Auth;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using JdeScoping.Core.ApiContracts;
|
||||
using JdeScoping.Core.ApiContracts.Pipelines;
|
||||
using JdeScoping.Core.Models.Pipelines;
|
||||
using JdeScoping.Core.Models.Enums;
|
||||
using JdeScoping.DataSync.Configuration;
|
||||
using JdeScoping.DataSync.Contracts;
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using JdeScoping.Core.ApiContracts;
|
||||
using JdeScoping.Core.Models.Infrastructure;
|
||||
using JdeScoping.Core.Interfaces;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace JdeScoping.Api.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoints for data refresh/cache sync status.
|
||||
/// </summary>
|
||||
[Route(ApiRoutes.RefreshStatus.Base)]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class RefreshStatusController : ApiControllerBase
|
||||
{
|
||||
private readonly ILotFinderRepository _repository;
|
||||
|
||||
public RefreshStatusController(ILotFinderRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets aggregated refresh status records within the specified date range.
|
||||
/// </summary>
|
||||
/// <param name="minDT">Start date filter.</param>
|
||||
/// <param name="maxDT">End date filter.</param>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(List<DataUpdateDto>), StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<List<DataUpdateDto>>> GetRefreshStatus(
|
||||
[FromQuery] DateTime minDT,
|
||||
[FromQuery] DateTime maxDT,
|
||||
CancellationToken ct)
|
||||
{
|
||||
// Get raw data updates from repository
|
||||
var updates = await _repository.GetLastDataUpdatesAsync(ct);
|
||||
|
||||
// Filter by date range
|
||||
var filtered = updates
|
||||
.Where(u => u.StartDt >= minDT && u.StartDt <= maxDT.AddDays(1))
|
||||
.ToList();
|
||||
|
||||
// Group by StartDt (rounded to minute) to aggregate multiple table updates into single rows
|
||||
var aggregated = filtered
|
||||
.GroupBy(u => new DateTime(u.StartDt.Year, u.StartDt.Month, u.StartDt.Day, u.StartDt.Hour, u.StartDt.Minute, 0))
|
||||
.Select(g => new DataUpdateDto
|
||||
{
|
||||
StartDt = g.Key,
|
||||
EndDt = g.Max(u => u.EndDt),
|
||||
WasSuccessful = g.All(u => u.WasSuccessful),
|
||||
BranchRecords = (int)(g.FirstOrDefault(u => u.TableName == "Branch")?.NumberRecords ?? 0),
|
||||
ProfitCenterRecords = (int)(g.FirstOrDefault(u => u.TableName == "ProfitCenter")?.NumberRecords ?? 0),
|
||||
WorkCenterRecords = (int)(g.FirstOrDefault(u => u.TableName == "WorkCenter")?.NumberRecords ?? 0),
|
||||
OrgHierarchyRecords = (int)(g.FirstOrDefault(u => u.TableName == "OrgHierarchy")?.NumberRecords ?? 0),
|
||||
StatusCodeRecords = (int)(g.FirstOrDefault(u => u.TableName == "StatusCode")?.NumberRecords ?? 0),
|
||||
UserRecords = (int)(g.FirstOrDefault(u => u.TableName == "JdeUser")?.NumberRecords ?? 0),
|
||||
ItemRecords = (int)(g.FirstOrDefault(u => u.TableName == "Item")?.NumberRecords ?? 0),
|
||||
LotRecords = (int)(g.FirstOrDefault(u => u.TableName == "Lot")?.NumberRecords ?? 0),
|
||||
WorkOrderRecords = (int)(g.FirstOrDefault(u => u.TableName.Contains("WorkOrder_"))?.NumberRecords ?? 0),
|
||||
WorkOrderStepRecords = (int)(g.FirstOrDefault(u => u.TableName.Contains("WorkOrderStep"))?.NumberRecords ?? 0),
|
||||
WorkOrderComponentRecords = (int)(g.FirstOrDefault(u => u.TableName.Contains("WorkOrderComponent"))?.NumberRecords ?? 0)
|
||||
})
|
||||
.OrderByDescending(d => d.StartDt)
|
||||
.ToList();
|
||||
|
||||
return Ok(aggregated);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using JdeScoping.Core.ApiContracts.SignalR;
|
||||
using JdeScoping.Core.ViewModels;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace JdeScoping.Api.Hubs;
|
||||
/// </summary>
|
||||
public class StatusHub : Hub
|
||||
{
|
||||
private static StatusUpdateDto _cachedStatus = new()
|
||||
private static StatusUpdateViewModel _cachedStatus = new()
|
||||
{
|
||||
Message = "Unknown",
|
||||
Timestamp = DateTime.UtcNow
|
||||
@@ -27,7 +27,7 @@ public class StatusHub : Hub
|
||||
/// Caches the update and broadcasts to all clients.
|
||||
/// </summary>
|
||||
/// <param name="statusUpdate">Status update to broadcast</param>
|
||||
public async Task SetStatus(StatusUpdateDto statusUpdate)
|
||||
public async Task SetStatus(StatusUpdateViewModel statusUpdate)
|
||||
{
|
||||
_cachedStatus = statusUpdate;
|
||||
await Clients.All.SendAsync("statusUpdate", statusUpdate);
|
||||
@@ -38,7 +38,7 @@ public class StatusHub : Hub
|
||||
/// Called by clients to get initial cached status on connection.
|
||||
/// </summary>
|
||||
/// <returns>The most recent status update</returns>
|
||||
public StatusUpdateDto GetCachedStatus()
|
||||
public StatusUpdateViewModel GetCachedStatus()
|
||||
{
|
||||
return _cachedStatus;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class StatusHub : Hub
|
||||
/// Called by controllers/services to broadcast search updates.
|
||||
/// </summary>
|
||||
/// <param name="searchUpdate">Search update to broadcast</param>
|
||||
public async Task PublishSearchUpdate(SearchUpdateDto searchUpdate)
|
||||
public async Task PublishSearchUpdate(SearchUpdateViewModel searchUpdate)
|
||||
{
|
||||
await Clients.All.SendAsync("searchUpdate", searchUpdate);
|
||||
_logger.LogDebug("Search update published: ID={Id}, Status={Status}", searchUpdate.Id, searchUpdate.Status);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using JdeScoping.Api.Hubs;
|
||||
using JdeScoping.Core.ApiContracts.SignalR;
|
||||
using JdeScoping.Core.Interfaces;
|
||||
using JdeScoping.Core.Models.Search;
|
||||
using JdeScoping.Core.ViewModels;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SearchNotificationService : ISearchNotificationService
|
||||
{
|
||||
try
|
||||
{
|
||||
var update = SearchUpdateDto.FromSearch(search);
|
||||
var update = SearchUpdateViewModel.FromSearch(search);
|
||||
await _hubContext.Clients.All.SendAsync("searchUpdate", update, ct);
|
||||
_logger.LogDebug(
|
||||
"Search update notification sent: Id={SearchId}, Status={Status}",
|
||||
@@ -56,7 +56,7 @@ public class SearchNotificationService : ISearchNotificationService
|
||||
{
|
||||
try
|
||||
{
|
||||
var update = StatusUpdateDto.Create(status);
|
||||
var update = StatusUpdateViewModel.Create(status);
|
||||
await _hubContext.Clients.All.SendAsync("statusUpdate", update, ct);
|
||||
_logger.LogDebug("Status notification sent: {Status}", status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user