MyBatis-Plus for Beginners 4 DDD model
Sat, Jul 15, 2023
2-minute read
mybatis in DDD
App中的tech部分的设置属于标配
- app
- main
- tech
- config // 加密,事业相关的configuration
- plug // 加密等拦截器的具体实现
- Application // SringBootApplication 启动
- resource // matis 配置相关的yml,mapper,config等
- tech
- test
- // 调薪
- // 查询
- main
-
domain
-
infrusture
domain部分, 主要是雇员和薪水类, 记得ddd模式特色
+ app
+ main
+ tech
+ config // 加密,事业相关的configuration
+ plug // 加密等拦截器的具体实现
+ Application // SringBootApplication 启动
+ resource // matis 配置相关的yml,mapper,config等
+ test
+ // 调薪
+ // 查询
-
domain
-
employee
- model
- EmployeeInfoEntity
- reposity
- IEmployeeRepository
- insertEmployInfo插入雇员
- queryEmployInfo查询雇员信息
- IEmployeeRepository
- service
- IEmployeeService
- insertEmployInfo插入雇员
- queryEmployInfo查询雇员信息
- EmployeeService // 引入
@Resource IEmployeeRepository employeeRepository
- IEmployeeService
- model
-
salary
- model
- entity
- EmployeeEntity //这里只需要和薪水挂钩的雇员级别和岗位tatle信息就够了
- EmployeeSalaryAdjustEntity //需要和调薪相关的信息
- valobj
- EmployeePostVO // 雇员级别区间,比如T1到T8, code, des等
- aggreate
- AdjustSalaryApplyOrderAggregate // 罗列了雇员编号,调薪单号,雇员实体,雇员调薪实体,融合model中2个类
- entity
- reposity
- adjustSalary(AdjustSalaryApplyOrderAggregate adjustSalaryApplyOrderAggregate) // 调节薪水
- service
- ISalaryAdjustApplyService
- execSalaryAdjust(AdjustSalaryApplyOrderAggregate adjustSalaryApplyOrderAggregate)
- SalaryAdjustApplyService
- ISalaryAdjustApplyService
- model
-
-
infruster
+ app
+ main
+ tech
+ config // 加密,事业相关的configuration
+ plug // 加密等拦截器的具体实现
+ Application // SringBootApplication 启动
+ resource // matis 配置相关的yml,mapper,config等
+ test
+ // 调薪
+ // 查询
- domain
+ employee
+ model
+ EmployeeInfoEntity
+ reposity
+ IEmployeeRepository
+ insertEmployInfo插入雇员
+ queryEmployInfo查询雇员信息
+ service
+ IEmployeeService
+ insertEmployInfo插入雇员
+ queryEmployInfo查询雇员信息
+ EmployeeService // 引入 `@Resource IEmployeeRepository employeeRepository`
+ salary
+ model
+ entity
+ EmployeeEntity //这里只需要和薪水挂钩的雇员级别和岗位tatle信息就够了
+ EmployeeSalaryAdjustEntity //需要和调薪相关的信息
+ valobj
+ EmployeePostVO // 雇员级别区间,比如T1到T8, code, des等
+ aggreate
+ AdjustSalaryApplyOrderAggregate // 罗列了雇员编号,调薪单号,雇员实体,雇员调薪实体,融合model中2个类
+ reposity
+ adjustSalary(AdjustSalaryApplyOrderAggregate adjustSalaryApplyOrderAggregate) // 调节薪水
+ service
+ ISalaryAdjustApplyService
+ execSalaryAdjust(AdjustSalaryApplyOrderAggregate adjustSalaryApplyOrderAggregate)
+ SalaryAdjustApplyService
功能实现在这里, 导入domain模块
-
infrustruture
-
dao
- IEmployeeDAO
- IEmployeesalaryAdustDAO
- IEmployeesalaryDAO
-
repository
- //这里做了对数据库表的操作,事业相关的,比如更新岗位,更新薪酬,写入流水, 查询雇员和薪酬
- EmployeeRespsitory
- SalaryAdustRepository
-
po
- // 这里几个类和数据库表是对应的,一表一类
- EmployeePO //跟domain 里面的 EmployeeEntity相比,多了自增id,去掉了薪水相关
- EmployeeSalaryAdjustPO
- EmployeeSalaryPO
-
上面写完了后想domain里面的类干嘛用,
+ app
+ main
+ tech
+ config // 加密,事业相关的configuration
+ plug // 加密等拦截器的具体实现
+ Application // SringBootApplication 启动
+ resource // matis 配置相关的yml,mapper,config等
- app
- test
- domain
- // 这里是直接ISalaryAdjustApplyService 对 .model下面的类操作,测试薪水调整和查询雇员
- IEmployeeServiceTest
- ISalaryAdjustApplyServiceTest
- infrastructure
- //这里是直接IEmployeeSalaryDAO 对 EmployeeSalaryPO操作,只需要用到infrastructure.dao和po下面的类
- IEmployeeDAOTest
- IEmployeeSalaryAdjustDAOTest
- IEmployeeSalaryDAOTest
- ApiTest
- domain
- test
- domain
+ employee
+ model
+ EmployeeInfoEntity
+ reposity
+ IEmployeeRepository
+ insertEmployInfo插入雇员
+ queryEmployInfo查询雇员信息
+ service
+ IEmployeeService
+ insertEmployInfo插入雇员
+ queryEmployInfo查询雇员信息
+ EmployeeService // 引入 `@Resource IEmployeeRepository employeeRepository`
+ salary
+ model
+ entity
+ EmployeeEntity //这里只需要和薪水挂钩的雇员级别和岗位tatle信息就够了
+ EmployeeSalaryAdjustEntity //需要和调薪相关的信息
+ valobj
+ EmployeePostVO // 雇员级别区间,比如T1到T8, code, des等
+ aggreate
+ AdjustSalaryApplyOrderAggregate // 罗列了雇员编号,调薪单号,雇员实体,雇员调薪实体,融合model中2个类
+ reposity
+ adjustSalary(AdjustSalaryApplyOrderAggregate adjustSalaryApplyOrderAggregate) // 调节薪水
+ service
+ ISalaryAdjustApplyService
+ execSalaryAdjust(AdjustSalaryApplyOrderAggregate adjustSalaryApplyOrderAggregate)
+ SalaryAdjustApplyService
+ infrustruture
+ dao
+ IEmployeeDAO
+ IEmployeesalaryAdustDAO
+ IEmployeesalaryDAO
. + repository + //这里做了对数据库表的操作,事业相关的,比如更新岗位,更新薪酬,写入流水, 查询雇员和薪酬 + EmployeeRespsitory
这里实现了两个方法,就是domain中IEmployeeRepository的插入和查询雇员的两个方法employeeInfoEntity这个enployeePO来源就是domain里面的employeeInfoEntity,就是domain里面的IEmployeeRepository的实现在这里
```java
ry {
EmployeePO employeePO = EmployeePO.builder()
.employeeNumber(employeeInfoEntity.getEmployeeNumber())
.employeeName(employeeInfoEntity.getEmployeeName())
.employeeLevel(employeeInfoEntity.getEmployeeLevel())
.employeeTitle(employeeInfoEntity.getEmployeeTitle())
.build();
employeeDAO.insert(employeePO);
```
+ SalaryAdustRepository
+ po
+ // 这里几个类和数据库表是对应的,一表一类
+ EmployeePO //跟domain 里面的 EmployeeEntity相比,多了自增id,去掉了薪水相关
+ EmployeeSalaryAdjustPO
+ EmployeeSalaryPO