mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
commit
c48b6c9ed1
@ -28,13 +28,13 @@ export default defineConfig({
|
|||||||
{text: '帮助文档', link: '/zh/intro/what-is-mybatisflex'},
|
{text: '帮助文档', link: '/zh/intro/what-is-mybatisflex'},
|
||||||
{text: '🔥常见问题', link: '/zh/faq'},
|
{text: '🔥常见问题', link: '/zh/faq'},
|
||||||
{text: '周边', link: '/zh/awesome-things'},
|
{text: '周边', link: '/zh/awesome-things'},
|
||||||
|
{text: 'ChangeLog', link: 'https://gitee.com/mybatis-flex/mybatis-flex/blob/main/changes.md'},
|
||||||
{
|
{
|
||||||
text: '获取源码', items: [
|
text: '获取源码', items: [
|
||||||
{text: 'Gitee', link: 'https://gitee.com/mybatis-flex/mybatis-flex'},
|
{text: 'Gitee', link: 'https://gitee.com/mybatis-flex/mybatis-flex'},
|
||||||
{text: 'Github', link: 'https://github.com/mybatis-flex/mybatis-flex'},
|
{text: 'Github', link: 'https://github.com/mybatis-flex/mybatis-flex'},
|
||||||
{text: '示例代码', link: 'https://gitee.com/mybatis-flex/mybatis-flex-samples'},
|
{text: '示例代码', link: 'https://gitee.com/mybatis-flex/mybatis-flex-samples'},
|
||||||
{text: '性能测试代码', link: 'https://gitee.com/mybatis-flex/mybatis-benchmark'},
|
{text: '性能测试代码', link: 'https://gitee.com/mybatis-flex/mybatis-benchmark'},
|
||||||
{text: 'ChangeLog', link: 'https://gitee.com/mybatis-flex/mybatis-flex/blob/main/changes.md'},
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
- **`deleteById(id)`**: 根据主键删除数据。如果是多个主键的情况下,需要传入数组,例如:`new Integer[]{100,101``。
|
- **`deleteById(id)`**:根据主键删除数据。如果是多个主键的情况下,需要传入数组,例如:`new Integer[]{100,101}`。
|
||||||
- **`deleteBatchByIds(ids)`**: 根据多个主键批量删除数据。
|
- **`deleteBatchByIds(ids)`**:根据多个主键批量删除数据。
|
||||||
- **`deleteBatchByIds(ids, size)`**: 根据多个主键批量删除数据。
|
- **`deleteBatchByIds(ids, size)`**:根据多个主键批量删除数据。
|
||||||
- **`deleteByMap(Map<String, whereConditions)`**: 根据 Map 构建的条件来删除数据。
|
- **`deleteByMap(whereConditions)`**:根据 Map 构建的条件来删除数据。
|
||||||
- **`deleteByCondition(whereConditions)`**: 根据查询条件来删除数据。
|
- **`deleteByCondition(whereConditions)`**:根据查询条件来删除数据。
|
||||||
- **`deleteByQuery(queryWrapper)`**: 根据查询条件来删除数据。
|
- **`deleteByQuery(queryWrapper)`**:根据查询条件来删除数据。
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
- **`insert(entity)`**: 插入实体类数据,不忽略 `null` 值。
|
- **`insert(entity)`**:插入实体类数据,不忽略 `null` 值。
|
||||||
- **`insertSelective(entity)`**: 插入实体类数据,但是忽略 `null` 的数据,只对有值的内容进行插入。这样的好处是数据库已经配置了一些默认值,这些默认值才会生效。
|
- **`insertSelective(entity)`**:插入实体类数据,但是忽略 `null` 的数据,只对有值的内容进行插入。这样的好处是数据库已经配置了一些默认值,这些默认值才会生效。
|
||||||
- **`insert(entity, ignoreNulls)`**: 插入实体类数据。
|
- **`insert(entity, ignoreNulls)`**:插入实体类数据。
|
||||||
- **`insertWithPk(entity)`**: 插入带有主键的实体类,不忽略 `null` 值。
|
- **`insertWithPk(entity)`**:插入带有主键的实体类,不忽略 `null` 值。
|
||||||
- **`insertSelectiveWithPk(entity)`**: 插入带有主键的实体类,忽略 `null` 值。
|
- **`insertSelectiveWithPk(entity)`**:插入带有主键的实体类,忽略 `null` 值。
|
||||||
- **`insertWithPk(entity, ignoreNulls)`**: 带有主键的插入,此时实体类不会经过主键生成器生成主键。
|
- **`insertWithPk(entity, ignoreNulls)`**:带有主键的插入,此时实体类不会经过主键生成器生成主键。
|
||||||
- **`insertBatch(entities)`**: 批量插入实体类数据,只会根据第一条数据来构建插入的字段内容。
|
- **`insertBatch(entities)`**:批量插入实体类数据,只会根据第一条数据来构建插入的字段内容。
|
||||||
- **`insertBatch(entities, size)`**: 批量插入实体类数据,按 size 切分。
|
- **`insertBatch(entities, size)`**:批量插入实体类数据,按 size 切分。
|
||||||
- **`insertOrUpdate(entity)`**: 插入或者更新,若主键有值,则更新,若没有主键值,则插入,插入或者更新都不会忽略 `null` 值。
|
- **`insertOrUpdate(entity)`**:插入或者更新,若主键有值,则更新,若没有主键值,则插入,插入或者更新都不会忽略 `null` 值。
|
||||||
- **`insertOrUpdateSelective(entity)`**: 插入或者更新,若主键有值,则更新,若没有主键值,则插入,插入或者更新都会忽略 `null` 值。
|
- **`insertOrUpdateSelective(entity)`**:插入或者更新,若主键有值,则更新,若没有主键值,则插入,插入或者更新都会忽略 `null`
|
||||||
- **`insertOrUpdate(entity, ignoreNulls)`**: 插入或者更新,若主键有值,则更新,若没有主键值,则插入。
|
值。
|
||||||
|
- **`insertOrUpdate(entity, ignoreNulls)`**:插入或者更新,若主键有值,则更新,若没有主键值,则插入。
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
- **`paginate(pageNumber, pageSize, queryWrapper)`**: 分页查询。
|
- **`paginate(pageNumber, pageSize, queryWrapper)`**:分页查询。
|
||||||
- **`paginateWithRelations(pageNumber, pageSize, queryWrapper)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(pageNumber, pageSize, queryWrapper)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginate(pageNumber, pageSize, whereConditions)`**: 分页查询。
|
- **`paginate(pageNumber, pageSize, whereConditions)`**:分页查询。
|
||||||
- **`paginateWithRelations(pageNumber, pageSize, whereConditions)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(pageNumber, pageSize, whereConditions)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginate(pageNumber, pageSize, totalRow, queryWrapper)`**: 分页查询。
|
- **`paginate(pageNumber, pageSize, totalRow, queryWrapper)`**:分页查询。
|
||||||
- **`paginateWithRelations(pageNumber, pageSize, totalRow, queryWrapper)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(pageNumber, pageSize, totalRow, queryWrapper)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginate(pageNumber, pageSize, totalRow, whereConditions)`**: 分页查询。
|
- **`paginate(pageNumber, pageSize, totalRow, whereConditions)`**:分页查询。
|
||||||
- **`paginateWithRelations(pageNumber, pageSize, totalRow, whereConditions)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(pageNumber, pageSize, totalRow, whereConditions)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginate(page, queryWrapper)`**: 分页查询。
|
- **`paginate(page, queryWrapper)`**:分页查询。
|
||||||
- **`paginate(page, queryWrapper, consumers)`**: 分页查询。
|
- **`paginate(page, queryWrapper, consumers)`**:分页查询。
|
||||||
- **`paginateWithRelations(page, queryWrapper)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(page, queryWrapper)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelations(page, queryWrapper, consumers)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(page, queryWrapper, consumers)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateAs(pageNumber, pageSize, queryWrapper, asType)`**: 分页查询。
|
- **`paginateAs(pageNumber, pageSize, queryWrapper, asType)`**:分页查询。
|
||||||
- **`paginateAs(pageNumber, pageSize, totalRow, queryWrapper, asType)`**: 分页查询。
|
- **`paginateAs(pageNumber, pageSize, totalRow, queryWrapper, asType)`**:分页查询。
|
||||||
- **`paginateAs(page, queryWrapper, asType)`**: 分页查询。
|
- **`paginateAs(page, queryWrapper, asType)`**:分页查询。
|
||||||
- **`paginateAs(page, queryWrapper, asType, consumers)`**: 分页查询。
|
- **`paginateAs(page, queryWrapper, asType, consumers)`**:分页查询。
|
||||||
- **`paginateWithRelationsAs(pageNumber, pageSize, queryWrapper, asType)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelationsAs(pageNumber, pageSize, queryWrapper, asType)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelationsAs(pageNumber, pageSize, totalRow, queryWrapper, asType)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelationsAs(pageNumber, pageSize, totalRow, queryWrapper, asType)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelationsAs(page, queryWrapper, asType)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelationsAs(page, queryWrapper, asType)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelationsAs(page, queryWrapper, asType, consumers)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelationsAs(page, queryWrapper, asType, consumers)`**:分页查询,及其 Relation 字段内容。
|
||||||
|
|||||||
@ -1,28 +1,36 @@
|
|||||||
- **`selectOneById(id)`**: 根据主键查询数据。
|
- **`selectOneById(id)`**:根据主键查询数据。
|
||||||
- **`selectOneByMap(Map<String, whereConditions)`**: 根据 Map 构建的条件来查询数据。
|
- **`selectOneByMap(whereConditions)`**:根据 Map 构建的条件来查询数据。
|
||||||
- **`selectOneByCondition(whereConditions)`**: 根据查询条件查询数据。
|
- **`selectOneByCondition(whereConditions)`**:根据查询条件查询数据。
|
||||||
- **`selectOneByQuery(queryWrapper)`**: 根据查询条件来查询 1 条数据。
|
- **`selectOneByQuery(queryWrapper)`**:根据查询条件来查询 1 条数据。
|
||||||
- **`selectOneByQueryAs(queryWrapper, asType)`**: 根据查询条件来查询 1 条数据。
|
- **`selectOneByQueryAs(queryWrapper, asType)`**:根据查询条件来查询 1 条数据。
|
||||||
- **`selectOneWithRelationsByMap(Map<String, whereConditions)`**: 根据 Map 构建的条件来查询 1 条数据。
|
- **`selectOneWithRelationsByMap(whereConditions)`**:根据 Map 构建的条件来查询 1 条数据。
|
||||||
- **`selectOneWithRelationsByCondition(whereConditions)`**: 根据查询条件查询 1 条数据。
|
- **`selectOneWithRelationsByCondition(whereConditions)`**:根据查询条件查询 1 条数据。
|
||||||
- **`selectOneWithRelationsByQuery(queryWrapper)`**: 根据查询条件来查询 1 条数据。
|
- **`selectOneWithRelationsByQuery(queryWrapper)`**:根据查询条件来查询 1 条数据。
|
||||||
- **`selectOneWithRelationsByQueryAs(queryWrapper, asType)`**: 根据查询条件来查询 1 条数据。
|
- **`selectOneWithRelationsByQueryAs(queryWrapper, asType)`**:根据查询条件来查询 1 条数据。
|
||||||
- **`selectListByIds(ids)`**: 根据多个主键来查询多条数据。
|
- **`selectListByIds(ids)`**:根据多个主键来查询多条数据。
|
||||||
- **`selectListByMap(Map<String, whereConditions)`**: 根据 Map 来构建查询条件,查询多条数据。
|
- **`selectListByMap(whereConditions)`**:根据 Map 来构建查询条件,查询多条数据。
|
||||||
- **`selectListByMap(Map<String, whereConditions, count)`**: 根据 Map 来构建查询条件,查询多条数据。
|
- **`selectListByMap(whereConditions, count)`**:根据 Map 来构建查询条件,查询多条数据。
|
||||||
- **`selectListByCondition(whereConditions)`**: 根据查询条件查询多条数据。
|
- **`selectListByCondition(whereConditions)`**:根据查询条件查询多条数据。
|
||||||
- **`selectListByCondition(whereConditions, count)`**: 根据查询条件查询多条数据。
|
- **`selectListByCondition(whereConditions, count)`**:根据查询条件查询多条数据。
|
||||||
- **`selectListByQuery(queryWrapper)`**: 根据查询条件查询数据列表。
|
- **`selectListByQuery(queryWrapper)`**:根据查询条件查询数据列表。
|
||||||
- **`selectListByQuery(queryWrapper, consumers)`**: 根据查询条件查询数据列表。
|
- **`selectListByQuery(queryWrapper, consumers)`**:根据查询条件查询数据列表。
|
||||||
- **`selectListByQueryAs(queryWrapper, asType)`**: 根据查询条件查询数据列表,要求返回的数据为 asType。这种场景一般用在 left join 时,有多出了实体类本身的字段内容,可以转换为 dto、vo 等场景。
|
- **`selectCursorByQuery(queryWrapper)`**:根据查询条件查询游标数据,该方法必须在事务中才能正常使用,非事务下无法获取数据。
|
||||||
- **`selectListByQueryAs(queryWrapper, asType, consumers)`**: 根据查询条件查询数据列表,要求返回的数据为 asType 类型。
|
- **`selectRowsByQuery(queryWrapper)`**:根据查询条件查询 Row 数据。
|
||||||
- **`selectListWithRelationsByQuery(queryWrapper)`**: 查询实体类及其 Relation 注解字段。
|
- **`selectListByQueryAs(queryWrapper, asType)`**:根据查询条件查询数据列表,要求返回的数据为 asType。这种场景一般用在 left
|
||||||
- **`selectListWithRelationsByQueryAs(queryWrapper, asType)`**: 查询实体类及其 Relation 注解字段。
|
join 时,有多出了实体类本身的字段内容,可以转换为 dto、vo 等场景。
|
||||||
- **`selectListWithRelationsByQueryAs(queryWrapper, asType, consumers)`**: 查询实体类及其 Relation 注解字段。
|
- **`selectListByQueryAs(queryWrapper, asType, consumers)`**:根据查询条件查询数据列表,要求返回的数据为 asType 类型。
|
||||||
- **`selectAll()`**: 查询全部数据。
|
- **`selectListWithRelationsByQuery(queryWrapper)`**:查询实体类及其 Relation 注解字段。
|
||||||
- **`selectAllWithRelations()`**: 查询全部数据,及其 Relation 字段内容。
|
- **`selectListWithRelationsByQueryAs(queryWrapper, asType)`**:查询实体类及其 Relation 注解字段。
|
||||||
- **`selectObjectByQuery(queryWrapper)`**: 查询第一列返回的数据,QueryWrapper 执行的结果应该只有 1 列,例如:<br>`QueryWrapper.create().select(ACCOUNT.id).where(...);`
|
- **`selectListWithRelationsByQueryAs(queryWrapper, asType, consumers)`**:查询实体类及其 Relation 注解字段。
|
||||||
- **`selectObjectByQueryAs(queryWrapper, asType)`**: 查询第一列返回的数据,QueryWrapper 执行的结果应该只有 1 列,例如:<br>`QueryWrapper.create().select(ACCOUNT.id).where(...);`
|
- **`selectAll()`**:查询全部数据。
|
||||||
- **`selectObjectListByQueryAs(queryWrapper, asType)`**: 查询第一列返回的数据集合,QueryWrapper 执行的结果应该只有 1 列,例如:<br>`QueryWrapper.create().select(ACCOUNT.id).where(...);`
|
- **`selectAllWithRelations()`**:查询全部数据,及其 Relation 字段内容。
|
||||||
- **`selectCountByQuery(queryWrapper)`**: 查询数据量。
|
- **`selectObjectByQuery(queryWrapper)`**:查询第一列返回的数据,QueryWrapper 执行的结果应该只有 1
|
||||||
- **`selectCountByCondition(whereConditions)`**: 根据条件查询数据总量。
|
列,例如:`QueryWrapper.create().select(ACCOUNT.id).where(...);`
|
||||||
|
- **`selectObjectByQueryAs(queryWrapper, asType)`**:查询第一列返回的数据,QueryWrapper 执行的结果应该只有 1
|
||||||
|
列,例如:`QueryWrapper.create().select(ACCOUNT.id).where(...);`
|
||||||
|
- **`selectObjectListByQuery(queryWrapper)`**:查询第一列返回的数据集合,QueryWrapper 执行的结果应该只有 1
|
||||||
|
列,例如:`QueryWrapper.create().select(ACCOUNT.id).where(...);`
|
||||||
|
- **`selectObjectListByQueryAs(queryWrapper, asType)`**:查询第一列返回的数据集合,QueryWrapper 执行的结果应该只有 1
|
||||||
|
列,例如:`QueryWrapper.create().select(ACCOUNT.id).where(...);`
|
||||||
|
- **`selectCountByQuery(queryWrapper)`**:查询数据量。
|
||||||
|
- **`selectCountByCondition(whereConditions)`**:根据条件查询数据总量。
|
||||||
|
|||||||
@ -1,18 +1,18 @@
|
|||||||
- **`selectOneWithRelationsByMap(Map<String, whereConditions)`**: 根据 Map 构建的条件来查询 1 条数据。
|
- **`selectOneWithRelationsByMap(whereConditions)`**:根据 Map 构建的条件来查询 1 条数据。
|
||||||
- **`selectOneWithRelationsByCondition(whereConditions)`**: 根据查询条件查询 1 条数据。
|
- **`selectOneWithRelationsByCondition(whereConditions)`**:根据查询条件查询 1 条数据。
|
||||||
- **`selectOneWithRelationsByQuery(queryWrapper)`**: 根据查询条件来查询 1 条数据。
|
- **`selectOneWithRelationsByQuery(queryWrapper)`**:根据查询条件来查询 1 条数据。
|
||||||
- **`selectOneWithRelationsByQueryAs(queryWrapper, asType)`**: 根据查询条件来查询 1 条数据。
|
- **`selectOneWithRelationsByQueryAs(queryWrapper, asType)`**:根据查询条件来查询 1 条数据。
|
||||||
- **`selectListWithRelationsByQuery(queryWrapper)`**: 查询实体类及其 Relation 注解字段。
|
- **`selectListWithRelationsByQuery(queryWrapper)`**:查询实体类及其 Relation 注解字段。
|
||||||
- **`selectListWithRelationsByQueryAs(queryWrapper, asType)`**: 查询实体类及其 Relation 注解字段。
|
- **`selectListWithRelationsByQueryAs(queryWrapper, asType)`**:查询实体类及其 Relation 注解字段。
|
||||||
- **`selectListWithRelationsByQueryAs(queryWrapper, asType, consumers)`**: 查询实体类及其 Relation 注解字段。
|
- **`selectListWithRelationsByQueryAs(queryWrapper, asType, consumers)`**:查询实体类及其 Relation 注解字段。
|
||||||
- **`selectAllWithRelations()`**: 查询全部数据,及其 Relation 字段内容。
|
- **`selectAllWithRelations()`**:查询全部数据,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelations(pageNumber, pageSize, queryWrapper)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(pageNumber, pageSize, queryWrapper)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelations(pageNumber, pageSize, whereConditions)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(pageNumber, pageSize, whereConditions)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelations(pageNumber, pageSize, totalRow, queryWrapper)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(pageNumber, pageSize, totalRow, queryWrapper)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelations(pageNumber, pageSize, totalRow, whereConditions)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(pageNumber, pageSize, totalRow, whereConditions)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelations(page, queryWrapper)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(page, queryWrapper)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelations(page, queryWrapper, consumers)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelations(page, queryWrapper, consumers)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelationsAs(pageNumber, pageSize, queryWrapper, asType)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelationsAs(pageNumber, pageSize, queryWrapper, asType)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelationsAs(pageNumber, pageSize, totalRow, queryWrapper, asType)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelationsAs(pageNumber, pageSize, totalRow, queryWrapper, asType)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelationsAs(page, queryWrapper, asType)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelationsAs(page, queryWrapper, asType)`**:分页查询,及其 Relation 字段内容。
|
||||||
- **`paginateWithRelationsAs(page, queryWrapper, asType, consumers)`**: 分页查询,及其 Relation 字段内容。
|
- **`paginateWithRelationsAs(page, queryWrapper, asType, consumers)`**:分页查询,及其 Relation 字段内容。
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
- **`update(entity)`**: 根据主键来更新数据,若实体类属性数据为 `null`,该属性不会新到数据库。
|
- **`update(entity)`**:根据主键来更新数据,若实体类属性数据为 `null`,该属性不会新到数据库。
|
||||||
- **`update(entity, ignoreNulls)`**: 根据主键来更新数据到数据库。
|
- **`update(entity, ignoreNulls)`**:根据主键来更新数据到数据库。
|
||||||
- **`updateByMap(entity, Map<String, whereConditions)`**: 根据 Map 构建的条件来更新数据。
|
- **`updateByMap(entity, whereConditions)`**:根据 Map 构建的条件来更新数据。
|
||||||
- **`updateByCondition(entity, whereConditions)`**: 根据查询条件来更新数据。
|
- **`updateByMap(entity, ignoreNulls, whereConditions)`**:根据 Map 构建的条件来更新数据。
|
||||||
- **`updateByCondition(entity, ignoreNulls, whereConditions)`**: 根据查询条件来更新数据。
|
- **`updateByCondition(entity, whereConditions)`**:根据查询条件来更新数据。
|
||||||
- **`updateByQuery(entity, queryWrapper)`**: 根据查询条件来更新数据。
|
- **`updateByCondition(entity, ignoreNulls, whereConditions)`**:根据查询条件来更新数据。
|
||||||
- **`updateByQuery(entity, ignoreNulls, queryWrapper)`**: 根据查询条件来更新数据。
|
- **`updateByQuery(entity, queryWrapper)`**:根据查询条件来更新数据。
|
||||||
- **`updateNumberAddByQuery(fieldName, value, queryWrapper)`**: 执行类似 `update table set field = field + 1 where ... ` 的场景。
|
- **`updateByQuery(entity, ignoreNulls, queryWrapper)`**:根据查询条件来更新数据。
|
||||||
- **`updateNumberAddByQuery(column, value, queryWrapper)`**: 执行类似 `update table set field = field + 1 where ... ` 的场景。
|
- **`updateNumberAddByQuery(fieldName, value, queryWrapper)`**:执行类似 `update table set field = field + 1 where ... `
|
||||||
- **`updateNumberAddByQuery(fn, value, queryWrapper)`**: 执行类似 `update table set field = field + 1 where ... ` 的场景。
|
的场景。
|
||||||
|
- **`updateNumberAddByQuery(column, value, queryWrapper)`**:执行类似 `update table set field = field + 1 where ... `
|
||||||
|
的场景。
|
||||||
|
- **`updateNumberAddByQuery(fn, value, queryWrapper)`**:执行类似 `update table set field = field + 1 where ... ` 的场景。
|
||||||
|
|||||||
@ -300,6 +300,19 @@ public interface BaseMapper<T> {
|
|||||||
return updateByQuery(entity, QueryWrapper.create().where(whereConditions));
|
return updateByQuery(entity, QueryWrapper.create().where(whereConditions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 Map 构建的条件来更新数据。
|
||||||
|
*
|
||||||
|
* @param entity 实体类
|
||||||
|
* @param ignoreNulls 是否忽略 {@code null} 数据
|
||||||
|
* @param whereConditions 条件
|
||||||
|
* @return 受影响的行数
|
||||||
|
*/
|
||||||
|
default int updateByMap(T entity, boolean ignoreNulls, Map<String, Object> whereConditions) {
|
||||||
|
FlexAssert.notEmpty(whereConditions, "updateByMap is not allow empty map.");
|
||||||
|
return updateByQuery(entity, ignoreNulls, QueryWrapper.create().where(whereConditions));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据查询条件来更新数据。
|
* 根据查询条件来更新数据。
|
||||||
*
|
*
|
||||||
@ -598,7 +611,7 @@ public interface BaseMapper<T> {
|
|||||||
*/
|
*/
|
||||||
default <R> List<R> selectListByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
|
default <R> List<R> selectListByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
|
||||||
if (Number.class.isAssignableFrom(asType)
|
if (Number.class.isAssignableFrom(asType)
|
||||||
|| String.class == asType) {
|
|| String.class == asType) {
|
||||||
return selectObjectListByQueryAs(queryWrapper, asType);
|
return selectObjectListByQueryAs(queryWrapper, asType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,7 +663,7 @@ public interface BaseMapper<T> {
|
|||||||
*/
|
*/
|
||||||
default <R> List<R> selectListWithRelationsByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
|
default <R> List<R> selectListWithRelationsByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
|
||||||
if (Number.class.isAssignableFrom(asType)
|
if (Number.class.isAssignableFrom(asType)
|
||||||
|| String.class == asType) {
|
|| String.class == asType) {
|
||||||
return selectObjectListByQueryAs(queryWrapper, asType);
|
return selectObjectListByQueryAs(queryWrapper, asType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -774,7 +787,7 @@ public interface BaseMapper<T> {
|
|||||||
} else if (selectColumns.get(0) instanceof FunctionQueryColumn) {
|
} else if (selectColumns.get(0) instanceof FunctionQueryColumn) {
|
||||||
// COUNT 函数必须在第一列
|
// COUNT 函数必须在第一列
|
||||||
if (!FuncName.COUNT.equalsIgnoreCase(
|
if (!FuncName.COUNT.equalsIgnoreCase(
|
||||||
((FunctionQueryColumn) selectColumns.get(0)).getFnName()
|
((FunctionQueryColumn) selectColumns.get(0)).getFnName()
|
||||||
)) {
|
)) {
|
||||||
// 第一个查询列不是 COUNT 函数,使用 COUNT(*) 替换所有的查询列
|
// 第一个查询列不是 COUNT 函数,使用 COUNT(*) 替换所有的查询列
|
||||||
queryWrapper.select(count());
|
queryWrapper.select(count());
|
||||||
|
|||||||
@ -2387,6 +2387,20 @@ public class QueryMethods {
|
|||||||
|
|
||||||
// === 构建 column 列 ===
|
// === 构建 column 列 ===
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 TRUE 常量。
|
||||||
|
*/
|
||||||
|
public static QueryColumn true_() {
|
||||||
|
return new StringQueryColumn("TRUE");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 FALSE 常量。
|
||||||
|
*/
|
||||||
|
public static QueryColumn false_() {
|
||||||
|
return new StringQueryColumn("FALSE");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建 NULL 常量。
|
* 构建 NULL 常量。
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -124,7 +124,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<!-- <scope>test</scope>-->
|
<!-- <scope>test</scope>-->
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.javaparser</groupId>
|
||||||
|
<artifactId>javaparser-symbol-solver-core</artifactId>
|
||||||
|
<version>3.25.4</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,164 +0,0 @@
|
|||||||
package com.mybatisflex.test;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
import com.mybatisflex.core.util.StringUtil;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class BaseMapperDocsGen {
|
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
|
|
||||||
List<MethodInfo> methodInfos = readBaseMapperMethodsInfo();
|
|
||||||
|
|
||||||
StringBuilder insertMethods = new StringBuilder();
|
|
||||||
StringBuilder deleteMethods = new StringBuilder();
|
|
||||||
StringBuilder updateMethods = new StringBuilder();
|
|
||||||
StringBuilder selectMethods = new StringBuilder();
|
|
||||||
StringBuilder relationMethods = new StringBuilder();
|
|
||||||
StringBuilder paginateMethods = new StringBuilder();
|
|
||||||
|
|
||||||
for (MethodInfo methodInfo : methodInfos) {
|
|
||||||
if (methodInfo.name.startsWith("insert")) {
|
|
||||||
insertMethods.append("- **`").append(methodInfo.getName()).append("`**: ").append(methodInfo.desc).append("\n");
|
|
||||||
} else if (methodInfo.name.startsWith("delete")) {
|
|
||||||
deleteMethods.append("- **`").append(methodInfo.getName()).append("`**: ").append(methodInfo.desc).append("\n");
|
|
||||||
} else if (methodInfo.name.startsWith("update")) {
|
|
||||||
updateMethods.append("- **`").append(methodInfo.getName()).append("`**: ").append(methodInfo.desc).append("\n");
|
|
||||||
} else if (methodInfo.name.startsWith("select")) {
|
|
||||||
selectMethods.append("- **`").append(methodInfo.getName()).append("`**: ").append(methodInfo.desc).append("\n");
|
|
||||||
if (methodInfo.name.contains("WithRelation")){
|
|
||||||
relationMethods.append("- **`").append(methodInfo.getName()).append("`**: ").append(methodInfo.desc).append("\n");
|
|
||||||
}
|
|
||||||
}else if (methodInfo.name.startsWith("paginate")) {
|
|
||||||
paginateMethods.append("- **`").append(methodInfo.getName()).append("`**: ").append(methodInfo.desc).append("\n");
|
|
||||||
if (methodInfo.name.contains("WithRelation")){
|
|
||||||
relationMethods.append("- **`").append(methodInfo.getName()).append("`**: ").append(methodInfo.desc).append("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String mdDir = System.getProperty("user.dir") + "/docs/zh/base/parts/";
|
|
||||||
writeString(new File(mdDir, "base-mapper-insert-methods.md"), insertMethods.toString());
|
|
||||||
writeString(new File(mdDir, "base-mapper-delete-methods.md"), deleteMethods.toString());
|
|
||||||
writeString(new File(mdDir, "base-mapper-update-methods.md"), updateMethods.toString());
|
|
||||||
writeString(new File(mdDir, "base-mapper-query-methods.md"), selectMethods.toString());
|
|
||||||
writeString(new File(mdDir, "base-mapper-relation-methods.md"), relationMethods.toString());
|
|
||||||
writeString(new File(mdDir, "base-mapper-paginate-methods.md"), paginateMethods.toString());
|
|
||||||
|
|
||||||
|
|
||||||
///Users/michael/work/git/mybatis-flex/docs/zh/base/parts/base-mapper-insert-methods.md
|
|
||||||
|
|
||||||
System.out.println(JSON.toJSON(methodInfos));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<MethodInfo> readBaseMapperMethodsInfo() throws IOException {
|
|
||||||
List<MethodInfo> methodInfos = new ArrayList<>();
|
|
||||||
String path = System.getProperty("user.dir") + "/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java";
|
|
||||||
BufferedReader br = new BufferedReader(new FileReader(path));
|
|
||||||
String line;
|
|
||||||
MethodInfo methodInfo = null;
|
|
||||||
while ((line = br.readLine()) != null) {
|
|
||||||
line = line.trim();
|
|
||||||
if (line.equals("/**")) {
|
|
||||||
methodInfo = new MethodInfo();
|
|
||||||
} else {
|
|
||||||
if (methodInfo != null && line.length() > 3 && line.startsWith("*") && line.charAt(2) != '@') {
|
|
||||||
methodInfo.addDesc(line.substring(1));
|
|
||||||
} else if (methodInfo != null && !line.contains("=") && (line.startsWith("default")
|
|
||||||
|| line.startsWith("int")
|
|
||||||
|| line.startsWith("T ")
|
|
||||||
|| line.startsWith("List<T> ")
|
|
||||||
)) {
|
|
||||||
String[] tokens = line.split(" ");
|
|
||||||
int methodTokenIndex = 1;
|
|
||||||
if (line.contains("default")) {
|
|
||||||
methodTokenIndex++;
|
|
||||||
}
|
|
||||||
if (line.contains("<R>")) {
|
|
||||||
methodTokenIndex++;
|
|
||||||
}
|
|
||||||
String methodToken = tokens[methodTokenIndex];
|
|
||||||
methodInfo.setName(line.substring(line.indexOf(methodToken)));
|
|
||||||
methodInfos.add(methodInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
br.close();
|
|
||||||
return methodInfos;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void writeString(File file, String content) throws IOException {
|
|
||||||
FileOutputStream fos = null;
|
|
||||||
try {
|
|
||||||
fos = new FileOutputStream(file, false);
|
|
||||||
fos.write(content.getBytes(StandardCharsets.UTF_8));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class MethodInfo {
|
|
||||||
private String name;
|
|
||||||
private String desc;
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
if (name.endsWith("{") || name.endsWith(";")) {
|
|
||||||
name = name.substring(0, name.length() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
name = name.trim();
|
|
||||||
String paramsString = name.substring(name.indexOf("(") + 1, name.lastIndexOf(")"));
|
|
||||||
if (paramsString.length() > 0) {
|
|
||||||
String[] params = paramsString.split(",");
|
|
||||||
for (int i = 0; i < params.length; i++) {
|
|
||||||
String[] paramInfos = params[i].split(" ");
|
|
||||||
params[i] = paramInfos[paramInfos.length - 1];
|
|
||||||
}
|
|
||||||
paramsString = StringUtil.join(", ", params);
|
|
||||||
name = name.substring(0, name.indexOf("(") + 1) + paramsString + ")";
|
|
||||||
this.name = name;
|
|
||||||
} else {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDesc() {
|
|
||||||
return desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDesc(String desc) {
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addDesc(String desc) {
|
|
||||||
if (this.desc == null) {
|
|
||||||
this.desc = desc.trim();
|
|
||||||
} else {
|
|
||||||
this.desc += desc.trim();
|
|
||||||
}
|
|
||||||
if (this.desc.contains("{@code")){
|
|
||||||
this.desc = this.desc.replace("{@code ","`").replace("}","`");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "MethodInfo{" +
|
|
||||||
"name='" + name + '\'' +
|
|
||||||
", desc='" + desc + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* <p>
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.mybatisflex.test;
|
||||||
|
|
||||||
|
import com.github.javaparser.JavaParser;
|
||||||
|
import com.github.javaparser.ParseResult;
|
||||||
|
import com.github.javaparser.ParserConfiguration;
|
||||||
|
import com.github.javaparser.ast.CompilationUnit;
|
||||||
|
import com.github.javaparser.ast.body.MethodDeclaration;
|
||||||
|
import com.github.javaparser.ast.comments.JavadocComment;
|
||||||
|
import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName;
|
||||||
|
import com.github.javaparser.javadoc.Javadoc;
|
||||||
|
import com.github.javaparser.javadoc.description.JavadocDescription;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class BaseMapperDocsGen {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
String mapperPath = System.getProperty("user.dir") + "/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java";
|
||||||
|
|
||||||
|
List<String> methodDescriptions = getMethodDescriptions(mapperPath);
|
||||||
|
|
||||||
|
List<String> insertMethods = new LinkedList<>();
|
||||||
|
List<String> deleteMethods = new LinkedList<>();
|
||||||
|
List<String> updateMethods = new LinkedList<>();
|
||||||
|
List<String> selectMethods = new LinkedList<>();
|
||||||
|
List<String> relationMethods = new LinkedList<>();
|
||||||
|
List<String> paginateMethods = new LinkedList<>();
|
||||||
|
|
||||||
|
methodDescriptions.stream()
|
||||||
|
.map(e -> e.replace("<br>", ""))
|
||||||
|
.map(e -> e.replace("\r\n", ""))
|
||||||
|
.map(e -> e.replaceFirst("\\{@code ", "`"))
|
||||||
|
.map(e -> e.replaceFirst("}", "`"))
|
||||||
|
.map(e -> e.replace("`}", "}`"))
|
||||||
|
.forEach(methodDescription -> {
|
||||||
|
if (methodDescription.contains("insert")) {
|
||||||
|
insertMethods.add(methodDescription);
|
||||||
|
}
|
||||||
|
if (methodDescription.contains("delete")) {
|
||||||
|
deleteMethods.add(methodDescription);
|
||||||
|
}
|
||||||
|
if (methodDescription.contains("update")) {
|
||||||
|
updateMethods.add(methodDescription);
|
||||||
|
}
|
||||||
|
if (methodDescription.contains("select")) {
|
||||||
|
selectMethods.add(methodDescription);
|
||||||
|
}
|
||||||
|
if (methodDescription.contains("Relation")) {
|
||||||
|
relationMethods.add(methodDescription);
|
||||||
|
}
|
||||||
|
if (methodDescription.contains("paginate")) {
|
||||||
|
paginateMethods.add(methodDescription);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
String mdDir = System.getProperty("user.dir") + "/docs/zh/base/parts/";
|
||||||
|
|
||||||
|
writeString(new File(mdDir, "base-mapper-insert-methods.md"), insertMethods);
|
||||||
|
writeString(new File(mdDir, "base-mapper-delete-methods.md"), deleteMethods);
|
||||||
|
writeString(new File(mdDir, "base-mapper-update-methods.md"), updateMethods);
|
||||||
|
writeString(new File(mdDir, "base-mapper-query-methods.md"), selectMethods);
|
||||||
|
writeString(new File(mdDir, "base-mapper-relation-methods.md"), relationMethods);
|
||||||
|
writeString(new File(mdDir, "base-mapper-paginate-methods.md"), paginateMethods);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeString(File file, List<String> contents) throws IOException {
|
||||||
|
try (FileWriter fw = new FileWriter(file, false);
|
||||||
|
BufferedWriter bw = new BufferedWriter(fw)) {
|
||||||
|
for (String content : contents) {
|
||||||
|
bw.write(content);
|
||||||
|
bw.newLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getMethodDescriptions(String mapperPath) throws IOException {
|
||||||
|
ParserConfiguration parserConfiguration = new ParserConfiguration();
|
||||||
|
parserConfiguration.setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_8);
|
||||||
|
JavaParser javaParser = new JavaParser();
|
||||||
|
ParseResult<CompilationUnit> parseResult = javaParser.parse(Paths.get(mapperPath));
|
||||||
|
Optional<CompilationUnit> compilationUnitOpt = parseResult.getResult();
|
||||||
|
List<String> methodDescriptions = new LinkedList<>();
|
||||||
|
if (compilationUnitOpt.isPresent()) {
|
||||||
|
CompilationUnit compilationUnit = compilationUnitOpt.get();
|
||||||
|
List<MethodDeclaration> methodDeclarations = compilationUnit.stream()
|
||||||
|
.filter(e -> e instanceof MethodDeclaration)
|
||||||
|
.map(e -> (MethodDeclaration) e)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
for (MethodDeclaration methodDeclaration : methodDeclarations) {
|
||||||
|
String methodName = methodDeclaration.getNameAsString();
|
||||||
|
String params = methodDeclaration.getParameters()
|
||||||
|
.stream()
|
||||||
|
.map(NodeWithSimpleName::getNameAsString)
|
||||||
|
.collect(Collectors.joining(", ", "(", ")"));
|
||||||
|
String comment = methodDeclaration.getJavadocComment()
|
||||||
|
.map(JavadocComment::parse)
|
||||||
|
.map(Javadoc::getDescription)
|
||||||
|
.map(JavadocDescription::toText)
|
||||||
|
.orElse("");
|
||||||
|
methodDescriptions.add("- **`" + methodName + params + "`**:" + comment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return methodDescriptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user