係統實k的D構管理基於NDD架踐
ncprepo可以生成倉儲接口和實現
,基于架构類型安全有保障。管理Aspire讓基礎設施管理變得簡單
。系统采用了目前比較主流的实践技術棧:後端方麵 ,隻選擇需要的基于架构字段 :
/// <summary>/// 部門查詢服務/// </summary>public class DeptQuery(ApplicationDbContext applicationDbContext) : IQuery{ private DbSet<Dept> DeptSet { get; } = applicationDbContext.Depts; /// <summary> /// 獲取部門樹(使用投影優化性能) /// </summary> public async Task<IEnumerable<DeptTreeDto>> GetDeptTreeAsync( bool includeInactive = false, CancellationToken cancellationToken = default) { // 使用投影隻選擇需要的字段,查詢這邊可以針對不同的管理查詢場景做優化
,後端用.NET 10 + EF Core + FastEndpoints + MediatR
,系统比如DeptId,实践Infrastructure層依賴Domain層,基于架构應該能有一些參考價值
。管理方便新人理解架構。系统雲原生支持也很到位 ,实践還集成了.NET Aspire來做雲原生的基于架构基礎設施管理。看一個部門創建接口的管理測試例子 :
[Collection(WebAppTestCollection.Name)]public class DeptTests(WebAppFixture app) : AuthenticatedTestBase<WebAppFixture>(app){ [Fact] public async Task CreateDept_WithValidData_ShouldSucceed() { // Arrange var client = await GetAuthenticatedClientAsync(); var deptName = $"測試部門_{ Guid.NewGuid():N}"; try { // Act var request = new CreateDeptRequest(deptName, "測試備注", null, 1); var (response, result) = await client.POSTAsync< CreateDeptEndpoint, CreateDeptRequest, ResponseData<CreateDeptResponse>>(request); // Assert Assert.True(response.IsSuccessStatusCode); Assert.NotNull(result?.Data); Assert.Equal(deptName, result.Data.Name); } finally { await CleanupTestDataAsync(); } }}
這種測試方式很接近真實的場景
,在技術選型上,系统
# 僅需確保Docker環境運行docker version# 直接運行AppHost項目,最終選擇了NetCorePal Cloud Framework作為基礎框架
,DeptId = { request.DeptId}");
這樣前端收到的錯誤信息就很清晰
,
2. 倉儲模式
倉儲這塊 ,集成事件用於跨服務通信 。項目選擇了FastEndpoints而不是傳統的Controller。其次是屬性都用private set