Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有详细设计文档分享吗 现在就1个readme文档 直接看代码有点难理解 #3

Open
ld140319 opened this issue Oct 13, 2023 · 1 comment

Comments

@ld140319
Copy link

No description provided.

@qiankunli
Copy link
Contributor

qiankunli commented Oct 13, 2023

我是dddfirework的开发者之一, dddfirework是一个基于ddd+cqrs理念的框架

  1. 基于ddd+cqrs 分层理念,dddfirework定义了每一层的抽象,并基于上述抽象,engine.runCommand(XXCommand) 即可串联一次command的执行
  2. 除了基本的command的执行,dddfirework 还提供了事务、分布式锁、event发布消费、定时任务等公共能力,这些能力隐藏在command的执行中,比如 engine.runCommand(XXCommand, withTransaction) 即表示command执行过程中涉及到的数据持久化均支持事务。

image

对于一次command的执行,一般分为以下基本步骤

  1. 校验参数等
  2. 构建domain对象
    1. 底层自动根据id查询po,并将po转为do
  3. 调用domain业务方法,会改变domain属性值
    1. 执行业务方法时,可能会对外发事件
  4. 将domain持久化
    1. 底层自动将do转为po,并持久化

上诉过程可能涉及到事务、加锁。

image

使用dddfirework 你需要

  1. 定义domain,domain对象实现IEntity接口
  2. 定义po,且注册domain和po 之间的转换函数
  3. 定义ICommand,依次实现校验、构建domain、domain业务方法执行等逻辑
  4. 在api层,使用engine.RunCommand(xxCommand) 触发command 逻辑执行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants