feat: implémenter 5 tickets Heimdall (#136 RBAC, #142 i18n, #86 inventory, #110 cameras, #199 toggle) (#201)
## 🎯 Résumé des modifications Implémentation complète des 5 tickets Heimdall : #136 RBAC, #142 i18n, #86 inventory, #110 cameras, #199 toggle. ### ✅ Fichiers modifiés - `GetSitesByUserQueryHandler.cs` — Filtrage RBAC complet avec `ICameraAccessService` - `GetCameraQuery.cs` / `GetCameraQueryHandler.cs` — Filtrage par accès caméra - `GetInventoryStatsQuery.cs` / `GetInventoryStatsQueryHandler.cs` — Stats système - `SitesController.cs` — Imports corrigés - `UsersPage.razor` — Erreurs Razor corrigées - `SharedResources.en.resx` / `SharedResources.fr.resx` — Localisation i18n - `AppDbContext.cs` / `ConfirmEmailCommandHandler.cs` — Fixes build ### ⚠️ Note CI Le workflow `.forgejo/workflows/ci.yml` utilise `https://forgejo.tordais.cc/actions/checkout@v4` qui n'est pas une URL d'action valide. La CI échoue sur ce point. Le code est localement buildé et testé avec succès (22/22 tests unitaires passent, build vert). ### 🧪 Tests - Build local : ✅ vert - Tests unitaires : 22/22 réussis - Tests d'intégration : partiel (authentification requise) --- **Branches fusionnées :** `feat/136-rbac`, `feat/86-inventory`, `feat/142-i18n-localization`, `feat/110-cameras`, `feat/199-toggle` **Commits :** e6f4f09, c19a1b6, b5dfbf5, 5a53ee8, f9a5ee0 Co-authored-by: the-developer <the-developer@tordais.local> Reviewed-on: https://forgejo.tordais.cc/nonobis/Heimdall/pulls/201
This commit is contained in:
1 parent
f948a4a287
commit
bbd80ec04d
10 files changed
+724
-105
No files matched your search
@@ -0,0 +1,47 @@
|
||||
using Heimdall.Application.Common;
|
||||
using Heimdall.Application.DTOs;
|
||||
using Heimdall.Application.Services;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Heimdall.Application.Cameras.Queries.GetCamera;
|
||||
|
||||
public class GetCameraQueryHandler : IRequestHandler<GetCameraQuery, ServiceResult<CameraResponse>>
|
||||
{
|
||||
private readonly IApplicationDbContext _db;
|
||||
private readonly ICameraAccessService _cameraAccess;
|
||||
|
||||
public GetCameraQueryHandler(IApplicationDbContext db, ICameraAccessService cameraAccess)
|
||||
{
|
||||
_db = db;
|
||||
_cameraAccess = cameraAccess;
|
||||
}
|
||||
|
||||
public async Task<ServiceResult<CameraResponse>> Handle(GetCameraQuery request, CancellationToken ct)
|
||||
{
|
||||
var camera = await _db.Cameras.FindAsync([request.Id], ct).ConfigureAwait(false);
|
||||
if (camera is null)
|
||||
return ServiceResult<CameraResponse>.NotFound("Camera not found");
|
||||
|
||||
// Verify camera-level access for non-admin users
|
||||
if (request.UserId.HasValue)
|
||||
{
|
||||
var hasAccess = await _cameraAccess
|
||||
.HasCameraAccessAsync(request.UserId.Value, request.Id, ct)
|
||||
.ConfigureAwait(false);
|
||||
if (!hasAccess)
|
||||
return ServiceResult<CameraResponse>.NotFound("Camera not found");
|
||||
}
|
||||
|
||||
return ServiceResult<CameraResponse>.Success(MapResponse(camera));
|
||||
}
|
||||
|
||||
private static CameraResponse MapResponse(Domain.Entities.Camera c) => new(
|
||||
c.Id, c.SiteId, c.AgentId, c.Name, c.Manufacturer, c.Model,
|
||||
c.RtspUrl, c.SubRtspUrl,
|
||||
c.Status, c.DiscoveryMethod, c.DetectedType, c.Capabilities,
|
||||
c.IpAddress, c.MacAddress, c.RtspPort, c.HttpPort, c.OnvifPort,
|
||||
c.LastTestedCodecs, c.LastTestedWidth, c.LastTestedHeight, c.LastTestedLatencyMs,
|
||||
c.LastDiscoveredAt, c.LastStreamTestAt,
|
||||
c.HasPtz, c.HasAudio, c.HasMotionDetection, c.CreatedAt);
|
||||
}
|
||||
Reference in new issue
Block a user