分享我的CleanArchitecture for Razor Page項目模板

 

 這個項目是參考和整合了jasontaylordev/CleanArchitecture 和 blazorhero/CleanArchitecture 代碼基礎上,重構出來的新的項目,這兩個項目都是非常優秀和人氣很旺的關於CleanArchitecture的項目模板,我也fork了他們的項目並添加了一些自己的功能模塊,我個人非常喜歡blazorhero/CleanArchitecture這個項目,前端使用的是微軟的Blazor(webassembly)技術,對於.net開發人員可以很快開始工作,幾乎不需要額外的學習,但在項目的進行中發現了一個致命的問題就是在(WASM模式下)性能不行,加載數據一多就容易的卡頓,但相信後面會得到優化,jasontaylordev/CleanArchitecture 項目的前端用的Angular12 由於我對angular/vue/react的技術不是很熟練,學習起來實在是感覺力不從心,在實際開發過程中遇到了很多坑,都需要用google來解決,所以最後我還是選擇了自己最熟悉的開發方式asp.net MVC來對我原來的框架進行重構來實現CleanArchitecture設計模式。

我爲什麼要不斷的升級和重構我個人的開發框架

首先我追求的是開發效率,開發速度一定要快,當然我個人做的項目都是小項目1-2月內完成的頁面不超過50個的那種,所以我必須再1-2周內完成所有的原型開發(能運行增刪改查操作的原型),所以我不考慮用前後端分離的解決方案原因很簡單前後端分離需要來回切換不同的代碼風格同時需要封裝2次代碼,對於一個人的開發工作無疑是增加了很多工作量。

第二考慮的就是編碼的效率和感受,主要是減少拷貝複製的操作,最求極簡的代碼風格(CleanArchitecture就符合這一點,ABP就覺得太複雜了)不需要太多的分層和定義太多的接口,我喜歡編寫那種非常流暢容易理解的代碼,寫代碼追求那種像海上鋼琴師裏那種彈鋼琴的境界

第三就是前端UI必須漂亮符合主流的風格,但我本人對css和UI佈局是真的不行,所以我只能找一個我覺得好看的UI還必須是一整套,所以我選擇了SmartAdmin - Responsive WebApp 如果你們喜歡的話可以通過鏈接購買

下面我介紹一下我的項目

技術棧

  • [ASP.NET Core 5](https://devblogs.microsoft.com/aspnet/announcing-asp-net-core-in-net-5/)
  • [Entity Framework Core 5](https://docs.microsoft.com/en-us/ef/core/)
  • [SmartAdmin - Responsive WebApp](https://wrapbootstrap.com/theme/smartadmin-responsive-webapp-WB0573SK0/)
  • [Razor Pages](https://docs.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-5.0&tabs=visual-studio)
  • [Jquery EasyUI](https://www.jeasyui.com/)
  • [MediatR](https://github.com/jbogard/MediatR)
  • [AutoMapper](https://automapper.org/)
  • [FluentValidation](https://fluentvalidation.net/)
  • [NUnit](https://nunit.org/), [FluentAssertions](https://fluentassertions.com/), [Moq](https://github.com/moq) & [Respawn](https://github.com/jbogard/Respawn)
  • [Docker](https://www.docker.com/)

項目結構

 

 項目結構完全參考jasontaylordev/CleanArchitecture

 Overview

 Domain

This will contain all entities, enums, exceptions, interfaces, types and logic specific to the domain layer.

Application

This layer contains all application logic. It is dependent on the domain layer, but has no dependencies on any other layer or project. This layer defines interfaces that are implemented by outside layers. For example, if the application need to access a notification service, a new interface would be added to application and an implementation would be created within infrastructure.

Infrastructure

This layer contains classes for accessing external resources such as file systems, web services, smtp, and so on. These classes should be based on interfaces defined within the application layer.

[SmartAdmin - Responsive WebApp](https://wrapbootstrap.com/theme/smartadmin-responsive-webapp-WB0573SK0)

– an advanced UI Bootstrap 4 Admin and Dashboard – is built for the next generation. Its’ exceptional design contains vast collection of assorted reusable UI components integrated with latest jQuery plugins optimized to suit every modern web application project worldwide.
 

如何開發

生成數據庫

 

 

 運行項目

 

 初始賬號密碼

 

 模板標準功能

 

 新增/編輯/刪除/查詢/導入/導出

多語言支持

 

 添加新的功能模塊

 

 新增一個實體對象

 

 添加Application CQRS 功能模塊

 

 添加頁面

To-Do List

這個項目還剛剛很多基礎功能還沒有開發完成,後面我會繼續完善,如果喜歡請在Github上給個贊。👍

  • 賬號管理
  • 授權管理
  • 日誌查詢
  • 審批工作流
  • 文檔管理
  • 代碼生成visual studio.net插件 !important
  • ....
keep coding, enjoy coding
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章