Code Monkey home page Code Monkey logo

christddd's Introduction

一个基于 DDD 领域驱动设计 + CQRS 命令查询职责分离 的 .net core 框架,完全开源,并且有博客教程,地址在下边。 本项目我是借鉴了 https://github.com/EduardoPires/EquinoxProject 来讲解的,请支持原作者!因为他没有文档,所以我就写了这个系列。


给个星星! ⭐️

如果你喜欢这个项目或者它帮助你, 请给 Star~(辛苦星咯)

Tips

连接字符串统一在web层下的appsettings.json,
DefaultConnection_file文件里的内容,就是DefaultConnection字符串。

  /*
    * mysql和sqlserver的迁移操作步骤一致,不过本项目的迁移文件已经迁移好,在Data文件夹下:
    * msql使用MigrationsMySql文件夹下的迁移记录,卸载/删除另一个Migrations文件夹
    * sqlserver使用Migrations文件夹下的迁移记录,卸载/删除另一个MigrationsMySql文件夹
    * 
    * 当然你也可以都删掉,自己重新做迁移。
    * 
    一、迁移项目1(一定要切换到 Christ3D.Infrastruct 项目下,使用 Package Manager Console):
      1、add-migration InitStudentDbMysql -Context StudyContext  -o MigrationsMySql
      2、add-migration InitEventStoreDbMysql -Context EventStoreSQLContext -o MigrationsMySql/EventStore
      3、update-database -Context StudyContext
      4、update-database -Context EventStoreSQLContext
    二、迁移项目2【弃用,因为现在是使用IdentityServer4】(一定要切换到 Christ3D.Infrastruct.Identity 项目下,使用 Package Manager Console):
      1、add-migration InitIdentityDbMysql -Context ApplicationDbContext -o Data/MigrationsMySql/ 
      2、update-database -Context ApplicationDbContext

   */

知识点

1、概念篇

实体对象:具有唯一标识,能单独存在且可变化的对象
值对象:不能单独存在或在逻辑层面单独存在无意义,且不可变化的对象
聚合:多个对象的集合,对外是一个整体
聚合根:聚合中可代表整个业务操作的实体对象,通过它提供对外访问操作,它维护聚合内部的数据一致性,它是聚合中对象的管理者

2、结构篇

(图片来源于网络)

三大平台同步直播

博客园:https://www.cnblogs.com/laozhang-is-phi/p/9806335.html

简 书:https://www.jianshu.com/c/fe7dd7fc5372

码云:https://gitee.com/laozhangIsPhi/ChristDDD


目录:


主要的流程图,在下边的图中可以体现:

流程图1

流程图2

流程图3

系统环境

  windows 10、SQL server 2012、Visual Studio 2017、Windows Server 2008 R2、Linux Ubuntu、

开发环境

  Visual Studio 15.3+、.NET Core SDK 2.0+、

1、知识点(补充中)

    ASP.NET Core 2.1.2  👉基本框架
    ASP.NET MVC Core  👉实现mvc web页面
    ASP.NET WebApi Core  👉实现 api 接口
    ASP.NET Identity Core  👉身份验证
    Entity Framework Core 2.0  👉实现ORM数据持久化
    Dapper (待定)
    .NET Core 原生 DI  👉实现依赖注入
    AOP  👉面向切面
    Autofact(待定)IoC
    AutoMapper  👉实现Dtos
    FluentValidator验证
    Swagger UI  👉实现接口文档展示
    MediatR  👉基于内存级别的消息发布订阅
    Azure  👉云服务发布

2、特性(补充中)

    领域驱动设计(Domain Driven Design (Layers and Domain Model Pattern)
    命令查询职责分离(CQRS:Command Query Responsibility Segregation)
    领域通知 (Domain Notification)
    领域驱动 (Domain Events)
    事件驱动架构 (EDA)
    事件回溯 (Event Sourcing)
    最终一致性 (Eventually Consistent)
    工作单元模式 (Unit of Work )
    泛型仓储 (Repository and Generic Repository)

编者按: 1、本项目我是借鉴了 https://github.com/EduardoPires/EquinoxProject 来讲解的,请支持原作者!因为他没有文档,所以我就写了这个系列。 2、可能你会说我是抄袭,但是我自己写的时候,结构不是这样的,我当时是按照下边写的(如果你和我下边的分层一样,那就证明我不是瞎说的了):

应用层:除了Service和IService、DTO、还有使用 CQRS 方法的查询、接受的命令,事件驱动的通信(集成事件),但是没有业务规则;

领域(模型)层:这里主要放的是领域实体、值对象、聚合和事件模型、Bus等主要都是模型,非贫血;

基础层:就是ORM的持久化相关;

U I 层:显示页面;

不过我写的时候感觉各层之间凌乱,不适合初学者学习,所以就想着要改变一下,找一个清晰明了的,对比了Git上的各种大神结构,偶然发现了EduardoPires的代码,感觉很清晰,就按照他这个来了。 说白了,就是把CQRS读写分离和事件驱动全部放到领域层了,然后又提炼出来一个领域核心Doman.Core层。

christddd's People

Contributors

anjoy8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

christddd's Issues

Security contact?

Hi, how could I report a potential security vulnerability in the project?

Potential Security Vulnerabilities

Summary

ChristDDD is vulnerable to Cross-Site Scripting (XSS) and Cross-Site Request Forgery (CSRF) that may lead to the elevation of privileges and per-user denial of service (DoS).

Details

Issue 1: XSS (CVE-2018-0784)

The application doesn't have the fix for CVE-2018-0784 that was found in ASP.NET Core templates. It is vulnerable to XSS if the logged-in user is tricked into clicking a malicious link like https://localhost:44315/manage/EnableAuthenticator?AuthenticatorUri=%22%3E%3C/div%3E%00%00%00%00%00%00%00%3Cscript%3Ealert(%22XSS%22)%3C/script%3E and enters an invalid verification code. Mode details are available in the blog post.

Impact

This issue may lead to the elevation of privileges.

Remediation

Modify the code according to the instructions from the advisory.

Issue 2: CSRF (CVE-2018-0785)

The application doesn't have the fix for CVE-2018-0785 that was found in ASP.NET Core templates. It is vulnerable to CSRF. A logged-in user with enabled Second Factor Authentication (2FA) may lose their recovery codes if they are tricked into clicking a link like https://localhost:44315/manage/GenerateRecoveryCodes or visit a malicious site that makes the request without the user's consent. As a result the user may be permanently locked out of their account after loosing access to their 2FA device, as the initial recovery codes would no longer be valid.

Impact

This issue may lead to the per-user DoS.

Remediation

Modify the code according to the instructions from the advisory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.