update 优化 规范化mapper命名
This commit is contained in:
@@ -129,7 +129,8 @@ Vue 3、TypeScript API 文件、生成式列表页、表单状态、字典和日
|
||||
- 包路径和 `@RequestMapping` 与模块保持一致。
|
||||
- 权限标识遵循 `${module}:${business}:${action}`。
|
||||
- Mapper 继承 `BaseMapperPlus<Entity, Vo>`。
|
||||
- Service 使用 `baseMapper`,并按场景返回 `PageResult` 或 `List<Vo>`。
|
||||
- 手写 Service 注入 Mapper 时使用具体业务短名;代码生成器模板按类名首字母小写命名,例如 `SysRoleMapper` 生成 `sysRoleMapper`。
|
||||
- Service 按场景返回 `PageResult` 或 `List<Vo>`。
|
||||
- 查询代码优先使用 `LambdaQueryWrapper`,复杂模块沿用既有 MPJ 联表风格。
|
||||
- BO 使用 `@AutoMapper(target = Entity.class, reverseConvertGenerate = false)`。
|
||||
- VO 使用 `@AutoMapper(target = Entity.class)`。
|
||||
|
||||
@@ -86,13 +86,15 @@
|
||||
## Service 规则
|
||||
|
||||
- 类声明通常是 `@RequiredArgsConstructor`、`@Service`,按需补 `@Slf4j`。
|
||||
- mapper 注入字段命名为 `private final XxxMapper baseMapper;`。
|
||||
- 手写 mapper 注入字段使用具体业务短名;代码生成器模板按类名首字母小写命名。
|
||||
- 命名时去掉清晰的模块/系统前缀后使用 lowerCamel + `Mapper`,例如 `SysRoleMapper` -> `roleMapper`、`SysDictDataMapper` -> `dictDataMapper`。
|
||||
- 如果去掉前缀会产生歧义或命名冲突,保留必要前缀。
|
||||
- 读操作通常返回 `Vo`、`List<Vo>` 或 `PageResult<Vo>`。
|
||||
- BO 转实体用 `MapstructUtils.convert(bo, Entity.class)`。
|
||||
- 查询条件优先用 `LambdaQueryWrapper` 和 `Wrappers.lambdaQuery()`。
|
||||
- 在 wrapper 条件里直接写 `StringUtils.isNotBlank(...)` 和 null 判断。
|
||||
- 分页查询优先采用:
|
||||
`Page<Vo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);`
|
||||
`Page<Vo> result = entityMapper.selectVoPage(pageQuery.build(), lqw);`
|
||||
`return PageResult.build(result.getRecords(), result.getTotal());`
|
||||
- 生成器风格模块保留 `validEntityBeforeSave(...)` 这种扩展点。
|
||||
- 多表写操作使用 `@Transactional(rollbackFor = Exception.class)`。
|
||||
|
||||
Reference in New Issue
Block a user