分享我的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
 
posted @ 2021-08-13 10:06  阿新  阅读(584)  评论(2编辑  收藏  举报