mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 01:28:24 +08:00
Merge branch 'main' of https://github.com/farukonfly/mybatis-flex
This commit is contained in:
commit
ab5a21a450
@ -7,7 +7,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: 这个 Bug 是否已经存在:
|
label: 这个 Bug 是否已经存在:
|
||||||
options:
|
options:
|
||||||
- label: 我确定已经把 MyBatis-Flex 升级到最新版本 v1.7.6,并已搜索过现有的问题 (https://gitee.com/mybatis-flex/mybatis-flex/issues)
|
- label: 我确定已经把 MyBatis-Flex 升级到最新版本 v1.7.7,并已搜索过现有的问题 (https://gitee.com/mybatis-flex/mybatis-flex/issues)
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
|
|||||||
@ -13,7 +13,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: 这个问题是否已经存在:
|
label: 这个问题是否已经存在:
|
||||||
options:
|
options:
|
||||||
- label: 我确定已经把 MyBatis-Flex 升级到最新版本 v1.7.6,并已搜索过现有的问题 (https://gitee.com/mybatis-flex/mybatis-flex/issues)
|
- label: 我确定已经把 MyBatis-Flex 升级到最新版本 v1.7.7,并已搜索过现有的问题 (https://gitee.com/mybatis-flex/mybatis-flex/issues)
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: question-description
|
id: question-description
|
||||||
|
|||||||
16
changes.md
16
changes.md
@ -2,6 +2,22 @@
|
|||||||
|
|
||||||
查看 [全部代码贡献者](/zh/intro/what-is-mybatisflex.html#贡献者)。
|
查看 [全部代码贡献者](/zh/intro/what-is-mybatisflex.html#贡献者)。
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.7 20240104:
|
||||||
|
- 新增:添加 spring-boot3 新模块,用于 springboot v3 下使用,感谢 @Suomm
|
||||||
|
- 新增:QueryMethods 添加 NOT (column) 函数,感谢 @wittplus
|
||||||
|
- 优化:更新 Solon 下的 @ProxyComponent 为 @Component,感谢 @citysoft
|
||||||
|
- 优化:修改 com.mybatisflex.annotation.SetListener 的注释错误,感谢 @whzzone
|
||||||
|
- 优化:修改 GBase_8s 数据库类型 sql 语句无反义处理
|
||||||
|
- 优化:升级 MyBatis 到 3.5.15 最新版本 #I8PQLC
|
||||||
|
- 修复:IService.getOne 没有添加 limit 1 的问题
|
||||||
|
- 修复:Db.updateEntitiesBatch 更新部分字段时报错的问题,感谢 @617054137
|
||||||
|
- 文档:更新在 Kotlin 下使用的相关文档,感谢 @kamo-sama
|
||||||
|
- 文档:优化示例代码提交语言标识,感谢 @bf109f
|
||||||
|
- 文档:更新存在一个为 is_deleted 的字段中拼写错误,感谢 @shuangtao
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## v1.7.6 20231223:
|
## v1.7.6 20231223:
|
||||||
- 新增:Db.selectFirstAndSecondColumnsAsMap 方法:查询结果的第一列作为 key,第二列作为 value,感谢 @617054137
|
- 新增:Db.selectFirstAndSecondColumnsAsMap 方法:查询结果的第一列作为 key,第二列作为 value,感谢 @617054137
|
||||||
- 新增:方言添加添加权限处理统一入口 prepareAuth,感谢 @bf109f
|
- 新增:方言添加添加权限处理统一入口 prepareAuth,感谢 @bf109f
|
||||||
|
|||||||
@ -78,8 +78,8 @@ const {Layout} = DefaultTheme
|
|||||||
<!--docs: https://vitepress.dev/guide/extending-default-theme#layout-slots-->
|
<!--docs: https://vitepress.dev/guide/extending-default-theme#layout-slots-->
|
||||||
<template #doc-before>
|
<template #doc-before>
|
||||||
<div style="margin-bottom: 30px">
|
<div style="margin-bottom: 30px">
|
||||||
<a href="https://aieditor.dev" target="_blank">
|
<a href="https://mp.weixin.qq.com/s/V34VkARgBCBKdytSlKhosg" target="_blank">
|
||||||
<img src="/assets/images/ad/doc-banner.jpg">
|
<img src="/assets/images/ad/admin-banner.jpg">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -1,12 +1,8 @@
|
|||||||
:root {
|
:root {
|
||||||
--vp-c-brand: #F06C33;
|
--vp-c-brand-1:#F06C33;
|
||||||
--vp-c-brand-light: #FFCC00;
|
--vp-home-hero-name-color:#F06C33;
|
||||||
--vp-c-brand-lighter: #FFCC99;
|
--vp-button-brand-bg:#F06C33;
|
||||||
--vp-c-brand-dark: #FF9933;
|
--vp-button-brand-hover-bg:#ff986b;
|
||||||
--vp-c-brand-darker: #CC6600;
|
|
||||||
|
|
||||||
--vp-custom-block-tip-border: #FFCC99;
|
|
||||||
--vp-custom-block-tip-text: #F06C33;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.vp-doc .custom-block p {
|
.vp-doc .custom-block p {
|
||||||
|
|||||||
BIN
docs/assets/images/ad/admin-banner.jpg
Normal file
BIN
docs/assets/images/ad/admin-banner.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"docs:dev": "vitepress dev",
|
"docs:dev": "vitepress dev",
|
||||||
"docs:build": "vitepress build",
|
"docs:build": "vitepress build",
|
||||||
"docs:preview": "vitepress preview"
|
"docs:preview": "vitepress preview"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vitepress": "^1.0.0-beta.3 "
|
"vitepress": "^1.0.0-rc.32"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,10 +9,10 @@ MyBatis-Flex 展示的机会。
|
|||||||
|
|
||||||
在本站对应的位置放置您的 LOGO 及跳转链接。
|
在本站对应的位置放置您的 LOGO 及跳转链接。
|
||||||
|
|
||||||
| 位置 | 素材 | 宽高 | 赞助费 | 名额 |
|
| 位置 | 素材 | 宽高 | 赞助费 | 名额 |
|
||||||
| ---------------- | ---------------- | ------------- | ---------- |------------ |
|
| ---------------- | ---------------- |----------| ---------- |----|
|
||||||
| 全站右侧边栏 1 | 图片+链接 | 105*50px | ¥200/月 | 8 |
|
| 全站右侧边栏 1 | 图片+链接 | 105*50px | ¥200/月 | 8 |
|
||||||
| 全站右侧边栏 2 | 图片+链接 | 122*50px | ¥400/月 |1 |
|
| 全站右侧边栏 2 | 图片+链接 | 222*50px | ¥400/月 | 1 |
|
||||||
|
|
||||||
您可以联系微信 `fuh99888` 就展示位的详细事宜。
|
您可以联系微信 `fuh99888` 就展示位的详细事宜。
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,22 @@
|
|||||||
|
|
||||||
查看 [全部代码贡献者](/zh/intro/what-is-mybatisflex.html#贡献者)。
|
查看 [全部代码贡献者](/zh/intro/what-is-mybatisflex.html#贡献者)。
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.7 20240104:
|
||||||
|
- 新增:添加 spring-boot3 新模块,用于 springboot v3 下使用,感谢 @Suomm
|
||||||
|
- 新增:QueryMethods 添加 NOT (column) 函数,感谢 @wittplus
|
||||||
|
- 优化:更新 Solon 下的 @ProxyComponent 为 @Component,感谢 @citysoft
|
||||||
|
- 优化:修改 com.mybatisflex.annotation.SetListener 的注释错误,感谢 @whzzone
|
||||||
|
- 优化:修改 GBase_8s 数据库类型 sql 语句无反义处理
|
||||||
|
- 优化:升级 MyBatis 到 3.5.15 最新版本 #I8PQLC
|
||||||
|
- 修复:IService.getOne 没有添加 limit 1 的问题
|
||||||
|
- 修复:Db.updateEntitiesBatch 更新部分字段时报错的问题,感谢 @617054137
|
||||||
|
- 文档:更新在 Kotlin 下使用的相关文档,感谢 @kamo-sama
|
||||||
|
- 文档:优化示例代码提交语言标识,感谢 @bf109f
|
||||||
|
- 文档:更新存在一个为 is_deleted 的字段中拼写错误,感谢 @shuangtao
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## v1.7.6 20231223:
|
## v1.7.6 20231223:
|
||||||
- 新增:Db.selectFirstAndSecondColumnsAsMap 方法:查询结果的第一列作为 key,第二列作为 value,感谢 @617054137
|
- 新增:Db.selectFirstAndSecondColumnsAsMap 方法:查询结果的第一列作为 key,第二列作为 value,感谢 @617054137
|
||||||
- 新增:方言添加添加权限处理统一入口 prepareAuth,感谢 @bf109f
|
- 新增:方言添加添加权限处理统一入口 prepareAuth,感谢 @bf109f
|
||||||
|
|||||||
@ -119,7 +119,7 @@ public class AuthDialectImpl extends CommonsDialectImpl {
|
|||||||
对`QueryWrapper`的表做筛选可参考 **方式1**
|
对`QueryWrapper`的表做筛选可参考 **方式1**
|
||||||
在项目启动时通过 `DialectFactory` 注册 `AuthDialectImpl`,以spring boot项目为例:
|
在项目启动时通过 `DialectFactory` 注册 `AuthDialectImpl`,以spring boot项目为例:
|
||||||
|
|
||||||
```
|
```java
|
||||||
@Configuration
|
@Configuration
|
||||||
public class MybatisFlexConfig implements MyBatisFlexCustomizer {
|
public class MybatisFlexConfig implements MyBatisFlexCustomizer {
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
## MyBatis-Flex 逻辑删除示例
|
## MyBatis-Flex 逻辑删除示例
|
||||||
|
|
||||||
假设在 tb_account 表中,存在一个为 is_deleted 的字段,用来标识该数据的逻辑删除,那么 tb_account 表
|
假设在 tb_account 表中,存在一个为 is_delete 的字段,用来标识该数据的逻辑删除,那么 tb_account 表
|
||||||
对应的 "Account.java" 实体类应该配置如下:
|
对应的 "Account.java" 实体类应该配置如下:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
|||||||
@ -57,12 +57,11 @@ VALUES (1, '张三', 18, '2020-01-11'),
|
|||||||
需要添加的 Maven 主要依赖示例:
|
需要添加的 Maven 主要依赖示例:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>com.mysql</groupId>
|
||||||
@ -82,6 +81,35 @@ VALUES (1, '张三', 18, '2020-01-11'),
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**注意**: 如果您当前使用的是 SpringBoot v3.x 版本,需要把依赖 `mybatis-flex-spring-boot-starter` 修改为:`mybatis-flex-spring-boot3-starter`,
|
||||||
|
如下代码所示:
|
||||||
|
|
||||||
|
```xml 4
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mybatis-flex</groupId>
|
||||||
|
<artifactId>mybatis-flex-spring-boot3-starter</artifactId>
|
||||||
|
<version>1.7.7</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zaxxer</groupId>
|
||||||
|
<artifactId>HikariCP</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- for test only -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
**第 3 步:对 Spring Boot 项目进行配置**
|
**第 3 步:对 Spring Boot 项目进行配置**
|
||||||
|
|
||||||
在 application.yml 中配置数据源:
|
在 application.yml 中配置数据源:
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.mybatis-flex:mybatis-flex-core:1.7.6")
|
implementation("com.mybatis-flex:mybatis-flex-core:1.7.7")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ dependencies {
|
|||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.mybatis-flex:mybatis-flex-core:1.7.6'
|
implementation 'com.mybatis-flex:mybatis-flex-core:1.7.7'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ dependencies {
|
|||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.mybatis-flex:mybatis-flex-spring:1.7.6")
|
implementation("com.mybatis-flex:mybatis-flex-spring:1.7.7")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ dependencies {
|
|||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.mybatis-flex:mybatis-flex-spring:1.7.6'
|
implementation 'com.mybatis-flex:mybatis-flex-spring:1.7.7'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ dependencies {
|
|||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.mybatis-flex:mybatis-flex-spring-boot-starter:1.7.6")
|
implementation("com.mybatis-flex:mybatis-flex-spring-boot-starter:1.7.7")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ dependencies {
|
|||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.mybatis-flex:mybatis-flex-spring-boot-starter:1.7.6'
|
implementation 'com.mybatis-flex:mybatis-flex-spring-boot-starter:1.7.7'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ dependencies {
|
|||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
dependencies {
|
dependencies {
|
||||||
annotationProcessor("com.mybatis-flex:mybatis-flex-processor:1.7.6")
|
annotationProcessor("com.mybatis-flex:mybatis-flex-processor:1.7.7")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -78,6 +78,6 @@ dependencies {
|
|||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
dependencies {
|
dependencies {
|
||||||
annotationProcessor 'com.mybatis-flex:mybatis-flex-processor:1.7.6'
|
annotationProcessor 'com.mybatis-flex:mybatis-flex-processor:1.7.7'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@ -12,12 +12,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-processor</artifactId>
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
@ -28,33 +28,49 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring</artifactId>
|
<artifactId>mybatis-flex-spring</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-processor</artifactId>
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
``````
|
``````
|
||||||
|
|
||||||
3、用到了 Spring Boot 的场景
|
3、用到了 SpringBoot v2.x 的场景
|
||||||
|
|
||||||
```xml
|
```xml 3
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-processor</artifactId>
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
4、配置 annotationProcessor
|
4、用到了 SpringBoot v3.x 的场景
|
||||||
|
|
||||||
|
```xml 3
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mybatis-flex</groupId>
|
||||||
|
<artifactId>mybatis-flex-spring-boot3-starter</artifactId>
|
||||||
|
<version>1.7.7</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mybatis-flex</groupId>
|
||||||
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
|
<version>1.7.7</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
5、配置 annotationProcessor
|
||||||
|
|
||||||
`mybatis-flex-processor`提供APT服务,可以配置到annotationProcessorPaths,配置后,无需在依赖中声明`mybatis-flex-processor`依赖。
|
`mybatis-flex-processor`提供APT服务,可以配置到annotationProcessorPaths,配置后,无需在依赖中声明`mybatis-flex-processor`依赖。
|
||||||
|
|
||||||
@ -72,14 +88,14 @@
|
|||||||
<path>
|
<path>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-processor</artifactId>
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</path>
|
</path>
|
||||||
</annotationProcessorPaths>
|
</annotationProcessorPaths>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
```
|
```
|
||||||
|
|
||||||
5、配置依赖管理
|
6、配置依赖管理
|
||||||
|
|
||||||
MyBatis-Flex 提供了 `mybatis-flex-dependencies` 模块进行依赖管理,只需要在 `<dependencyManagement>` 标签下进行配置就可以了。
|
MyBatis-Flex 提供了 `mybatis-flex-dependencies` 模块进行依赖管理,只需要在 `<dependencyManagement>` 标签下进行配置就可以了。
|
||||||
|
|
||||||
|
|||||||
@ -1,23 +1,28 @@
|
|||||||
| | | | | |
|
| | | | | |
|
||||||
|-----|-----|-----|-----|-----|
|
|-----|-----|-----|-----|-----|
|
||||||
|Michael Yang|王帅|丌冰|卡莫sama|life|
|
|Michael Yang|王帅|卡莫sama|丌冰|life|
|
||||||
|snyk-bot|lhzsdnu|西东|Font_C|pengpeng|
|
|snyk-bot|lhzsdnu|西东|tangxin|Font_C|
|
||||||
|庄佳彬|Ice-samll|guanmengyuan|王超|笨小孩|
|
|pengpeng|庄佳彬|Ice-samll|guanmengyuan|王超|
|
||||||
|chenjh3|CloudPlayer|Jerry|snow|草语|
|
|笨小孩|bf109f|chenjh3|CloudPlayer|Jerry|
|
||||||
|李楠|菜鸟3853|Jerry_Zheng|tangxin|wujl|
|
|snow|草语|farukonfly|李楠|菜鸟3853|
|
||||||
|piggsoft|赤兮丷|黄沐鸿|loong0306|沈君锋|
|
|mofan|Jerry_Zheng|wujl|Martin7-1|piggsoft|
|
||||||
|英雄路|natsufumij|aqnghu|BQ60ziOxlFI0R0|tan90|
|
|赤兮丷|黄沐鸿|loong0306|沈君锋|英雄路|
|
||||||
|张继续|font-C|liibang|cainiao3853|barql|
|
|natsufumij|BQ60ziOxlFI0R0|tan90|aqnghu|张继续|
|
||||||
|yangs|Robot.L|落羽er|qixy|yuanbaolong|
|
|font-C|liibang|cainiao3853|barql|yangs|
|
||||||
|handy|zhijieqing|Saoforest|bygkn|XiaoLin|
|
|lcxw|Robot.L|落羽er|Faputa|qixy|
|
||||||
|zhongyong|锟斤拷|Watcher.Wang|yang_zzu|锁力|
|
|yuanbaolong|zhijieqing|handy|bygkn|Saoforest|
|
||||||
|shaoerkuai|阿志同学|chenjian835|Haru|duxlei|
|
|唐振超|Watcher.Wang|锟斤拷|zhongyong|XiaoLin|
|
||||||
|豌豆粉|matthew|凌尘|luy|gongzhongqiang|
|
|yang_zzu|锁力|shaoerkuai|meichenhui|阿志同学|
|
||||||
|Alex|EafonYoung|Pioneer-Sun|Q_Alex|wlf|
|
|chenjian835|Haru|duxlei|豌豆粉|涛声依旧|
|
||||||
|CrazyAirhead|winnerself|她出去赚钱了|数据小王子|XiaoLin|
|
|matthew|gongzhongqiang|luy|凌尘|Alex|
|
||||||
|Freeman Liu|大周|欢乐码农|2han9wen71an|Shark|
|
|EafonYoung|Pioneer-Sun|Q_Alex|wlf|1332987|
|
||||||
|庄佳彬|hans|HunnyOvO|关梦园|lcxw|
|
|Lionel|winnerself|CrazyAirhead|她出去赚钱了|数据小王子|
|
||||||
|dgmico|Ikko Eltociear Ashimine|wanggaoquan|Aohan-Zhang|老吉丶|
|
|XiaoLin|丿风轻灬云淡|张博|Freeman Liu|大周|
|
||||||
|玩具猫|meng.liu3|yaochen4|zhy_black|ζั͡ ั͡ ั͡ ั͡Wm|
|
|欢乐码农|2han9wen71an|shark771|庄佳彬|_FLOW__|
|
||||||
|陈国正|ZhuHJay|zoufang162|乌鸦笑猪黑|wnp|
|
|weihuazhou|hans|Ikko Eltociear Ashimine|guanmengyuan|dgmico|
|
||||||
|
|HunnyOvO|wanggaoquan|Aohan-Zhang|老吉丶|玩具猫|
|
||||||
|
|meng.liu3|yaochen4|zhy_black|ζั͡ ั͡ ั͡ ั͡Wm|陈国正|
|
||||||
|
|ZhuHJay|zoufang162|乌鸦笑猪黑|wnp|MyronLi|
|
||||||
|
|norkts|拓宇在思考|张春根|witt|xinjump|
|
||||||
|
|疾浪|sppan|时间淡忘一切|
|
||||||
|
|
||||||
|
|||||||
@ -19,68 +19,70 @@
|
|||||||
|
|
||||||
- 快速构建启动:通过DSL➕重载运算符,快速配置 MybatisFlexBootstrap 实例并启动:
|
- 快速构建启动:通过DSL➕重载运算符,快速配置 MybatisFlexBootstrap 实例并启动:
|
||||||
```kotlin
|
```kotlin
|
||||||
buildBootstrap {
|
runFlex {
|
||||||
// 配置数据源 相当于 setDataSource(dataSource)
|
// 配置数据源 相当于 setDataSource(dataSource)
|
||||||
+dataSource
|
+dataSource
|
||||||
// 配置Mapper 相当于 addMapper(AccountMapper::class.java)
|
// 配置Mapper 相当于 addMapper(AccountMapper::class.java)
|
||||||
+AccountMapper::class
|
+AccountMapper::class
|
||||||
// 配置日志输出 相当于 setLogImpl(StdOutImpl::class.java)
|
// 配置日志输出 相当于 setLogImpl(StdOutImpl::class.java)
|
||||||
logImpl = StdOutImpl::class
|
logImpl = StdOutImpl::class
|
||||||
}.start()
|
}
|
||||||
```
|
```
|
||||||
- 快速查询数据:通过DSL➕泛型快速编写查询语句并查询: (快速查询提供三个函数:all, filter 和 query )
|
- 快速查询数据:通过DSL➕泛型快速编写查询语句并查询: (快速查询提供三个函数:all, filter 和 query )
|
||||||
>- `all<实体类>()` 查泛型对应的表的所有数据
|
>- `all<实体类>()` 查泛型对应的表的所有数据
|
||||||
>- `filter<实体类>(vararg KProperty<*>, ()->QueryCondition)` 按条件查泛型对应的表的数据
|
>- `filter<实体类>(vararg KProperty<*>, ()->QueryCondition)` 按条件查泛型对应的表的数据
|
||||||
>- `query<实体类>(QueryScope.()->Unit)` 较复杂查泛型对应的表的数据 (如: 分组,排序等)
|
>- `query<实体类>(QueryScope.()->Unit)` 较复杂查泛型对应的表的数据 (如: 分组,排序等)
|
||||||
|
>- `paginateWith(pageNumber: Number, pageSize: Number, totalRow: Number? = null, queryConditionGet: () -> QueryCondition): Page<实体类>`
|
||||||
|
与 `paginate(pageNumber: Number, pageSize: Number, totalRow: Number? = null, init: QueryScope.() -> Unit): Page<实体类>` 使用分页的条件查询与较复杂查询
|
||||||
- 简明地构建查询:通过中缀表达式➕扩展方法能更加简单明了的构建条件:
|
- 简明地构建查询:通过中缀表达式➕扩展方法能更加简单明了的构建条件:
|
||||||
* **【对比原生】**
|
|
||||||
* **原生**
|
|
||||||
```kotlin
|
|
||||||
val queryWrapper = QueryWrapper.create()
|
|
||||||
.select(Account::id.column(), Account::userName.column())
|
|
||||||
.where(Account::age.column().isNotNull()).and(Account::age.column().ge(17))
|
|
||||||
.orderBy(Account::id.column().desc())
|
|
||||||
mapper<AccountMapper>().selectListByQuery(queryWrapper)
|
|
||||||
```
|
|
||||||
|
|
||||||
* **扩展后**
|
* **【对比原生】**
|
||||||
```kotlin
|
* **原生**
|
||||||
query<Account> {
|
```kotlin
|
||||||
select(Account::id, Account::userName)
|
val queryWrapper = QueryWrapper.create()
|
||||||
where(Account::age.isNotNull) and { Account::age ge 17 } orderBy -Account::id
|
.select(QueryColumn("id"), QueryColumn("user_name"))
|
||||||
}
|
.where(QueryColumn("age").isNotNull()).and(QueryColumn("age").ge(17))
|
||||||
```
|
.orderBy(QueryColumn("id").desc())
|
||||||
执行的SQL:
|
mapper<AccountMapper>().selectListByQuery(queryWrapper)
|
||||||
```sql
|
```
|
||||||
SELECT `id`, `user_name` FROM `tb_account` WHERE `age` IS NOT NULL AND `age` >= 17 ORDER BY `id` DESC
|
|
||||||
```
|
|
||||||
|
|
||||||
* **【条件优化】**
|
* **扩展后**
|
||||||
- 例如: 查询属性是否在一个连续的区间时,会自动将 IN 转为 BETWEEN 调用
|
```kotlin
|
||||||
```kotlin
|
// 无需注册Mapper与APT/KSP即可查询操作
|
||||||
filter<Account> { Account::age `in` (17..19) }
|
val accountList: List<Account> = query {
|
||||||
```
|
select(Account::id, Account::userName)
|
||||||
|
where(Account::age.isNotNull) and { Account::age ge 17 } orderBy -Account::id
|
||||||
|
}
|
||||||
|
```
|
||||||
执行的SQL:
|
执行的SQL:
|
||||||
```sql
|
```sql
|
||||||
SELECT * FROM `tb_account` WHERE `age` BETWEEN 17 AND 19
|
SELECT `id`, `user_name` FROM `tb_account` WHERE `age` IS NOT NULL AND `age` >= 17 ORDER BY `id` DESC
|
||||||
```
|
|
||||||
- 例如: 构建多属性组合 IN (最多支持三个属性)
|
|
||||||
```kotlin
|
|
||||||
filter<Account> {
|
|
||||||
(Account::id to Account::userName to Account::age).inTriple(
|
|
||||||
1 to "张三" to 18,
|
|
||||||
2 to "李四" to 19,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
执行的SQL:
|
|
||||||
```sql
|
|
||||||
SELECT * FROM `tb_account`
|
|
||||||
WHERE (`id` = 1 AND `user_name` = '张三' AND `age` = 18)
|
|
||||||
OR (`id` = 2 AND `user_name` = '李四' AND `age` = 19)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* **【条件优化】**
|
||||||
|
- 例如: 查询属性是否在一个连续的区间时,会自动将 IN 转为 BETWEEN 调用
|
||||||
|
```kotlin
|
||||||
|
filter<Account> { Account::age `in` (17..19) }
|
||||||
|
```
|
||||||
|
执行的SQL:
|
||||||
|
```sql
|
||||||
|
SELECT * FROM `tb_account` WHERE `age` BETWEEN 17 AND 19
|
||||||
|
```
|
||||||
|
- 例如: 构建多属性组合 IN (最多支持三个属性)
|
||||||
|
```kotlin
|
||||||
|
filter<Account> {
|
||||||
|
(Account::id to Account::userName to Account::age).inTriple(
|
||||||
|
1 to "张三" to 18,
|
||||||
|
2 to "李四" to 19,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
执行的SQL:
|
||||||
|
```sql
|
||||||
|
SELECT * FROM `tb_account`
|
||||||
|
WHERE (`id` = 1 AND `user_name` = '张三' AND `age` = 18)
|
||||||
|
OR (`id` = 2 AND `user_name` = '李四' AND `age` = 19)
|
||||||
|
```
|
||||||
- 摆脱APT: 使用扩展方法摆脱对 APT(注解处理器) 的使用,直接使用属性引用让代码更加灵活优雅:
|
- 摆脱APT: 使用扩展方法摆脱对 APT(注解处理器) 的使用,直接使用属性引用让代码更加灵活优雅:
|
||||||
> 使用APT: `ACCOUNT.ID eq 1` ,使用属性引用: `Account::id eq 1`
|
> 使用APT: `ACCOUNT.ID eq 1` ,使用属性引用: `Account::id eq 1`
|
||||||
>
|
>
|
||||||
|
|||||||
@ -220,7 +220,7 @@ pom.xml 添加 `annotationProcessorPaths` 配置,
|
|||||||
```
|
```
|
||||||
dependencies {
|
dependencies {
|
||||||
...
|
...
|
||||||
annotationProcessor 'com.mybatis-flex:mybatis-flex-processor:1.7.6'
|
annotationProcessor 'com.mybatis-flex:mybatis-flex-processor:1.7.7'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-codegen</artifactId>
|
<artifactId>mybatis-flex-codegen</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent</artifactId>
|
<artifactId>parent</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public interface SetListener extends Listener {
|
|||||||
* @param entity 实体类
|
* @param entity 实体类
|
||||||
* @param property 属性名
|
* @param property 属性名
|
||||||
* @param value 属性值
|
* @param value 属性值
|
||||||
* @return 实体类
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
Object onSet(Object entity, String property, Object value);
|
Object onSet(Object entity, String property, Object value);
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent</artifactId>
|
<artifactId>parent</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import com.mybatisflex.solon.service.impl.ServiceImpl;
|
|||||||
import #(packageConfig.entityPackage).#(table.buildEntityClassName());
|
import #(packageConfig.entityPackage).#(table.buildEntityClassName());
|
||||||
import #(packageConfig.mapperPackage).#(table.buildMapperClassName());
|
import #(packageConfig.mapperPackage).#(table.buildMapperClassName());
|
||||||
import #(packageConfig.servicePackage).#(table.buildServiceClassName());
|
import #(packageConfig.servicePackage).#(table.buildServiceClassName());
|
||||||
import org.noear.solon.annotation.ProxyComponent;
|
import org.noear.solon.annotation.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* #(table.getComment()) 服务层实现。
|
* #(table.getComment()) 服务层实现。
|
||||||
@ -12,7 +12,7 @@ import org.noear.solon.annotation.ProxyComponent;
|
|||||||
* @author #(javadocConfig.getAuthor())
|
* @author #(javadocConfig.getAuthor())
|
||||||
* @since #(javadocConfig.getSince())
|
* @since #(javadocConfig.getSince())
|
||||||
*/
|
*/
|
||||||
@ProxyComponent
|
@Component
|
||||||
public class #(table.buildServiceImplClassName()) extends ServiceImpl<#(table.buildMapperClassName()), #(table.buildEntityClassName())> implements #(table.buildServiceClassName()) {
|
public class #(table.buildServiceImplClassName()) extends ServiceImpl<#(table.buildMapperClassName()), #(table.buildEntityClassName())> implements #(table.buildServiceClassName()) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent</artifactId>
|
<artifactId>parent</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -101,7 +101,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-annotation</artifactId>
|
<artifactId>mybatis-flex-annotation</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public class FlexConsts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String NAME = "MyBatis-Flex";
|
public static final String NAME = "MyBatis-Flex";
|
||||||
public static final String VERSION = "1.7.6";
|
public static final String VERSION = "1.7.7";
|
||||||
|
|
||||||
|
|
||||||
public static final String SQL = "$$sql";
|
public static final String SQL = "$$sql";
|
||||||
|
|||||||
@ -127,6 +127,7 @@ public class DialectFactory {
|
|||||||
case DORIS:
|
case DORIS:
|
||||||
return new CommonsDialectImpl(KeywordWrap.BACK_QUOTE, LimitOffsetProcessor.MYSQL);
|
return new CommonsDialectImpl(KeywordWrap.BACK_QUOTE, LimitOffsetProcessor.MYSQL);
|
||||||
case CLICK_HOUSE:
|
case CLICK_HOUSE:
|
||||||
|
case GBASE_8S:
|
||||||
return new CommonsDialectImpl(KeywordWrap.NONE, LimitOffsetProcessor.MYSQL);
|
return new CommonsDialectImpl(KeywordWrap.NONE, LimitOffsetProcessor.MYSQL);
|
||||||
case DM:
|
case DM:
|
||||||
return new DmDialect();
|
return new DmDialect();
|
||||||
|
|||||||
@ -479,7 +479,7 @@ public class FlexDefaultResultSetHandler extends DefaultResultSetHandler {
|
|||||||
|
|
||||||
private boolean applyPropertyMappings(ResultSetWrapper rsw, ResultMap resultMap, MetaObject metaObject,
|
private boolean applyPropertyMappings(ResultSetWrapper rsw, ResultMap resultMap, MetaObject metaObject,
|
||||||
ResultLoaderMap lazyLoader, String columnPrefix) throws SQLException {
|
ResultLoaderMap lazyLoader, String columnPrefix) throws SQLException {
|
||||||
final List<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
|
final Collection<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
|
||||||
boolean foundValues = false;
|
boolean foundValues = false;
|
||||||
final List<ResultMapping> propertyMappings = resultMap.getPropertyResultMappings();
|
final List<ResultMapping> propertyMappings = resultMap.getPropertyResultMappings();
|
||||||
for (ResultMapping propertyMapping : propertyMappings) {
|
for (ResultMapping propertyMapping : propertyMappings) {
|
||||||
@ -1178,7 +1178,7 @@ public class FlexDefaultResultSetHandler extends DefaultResultSetHandler {
|
|||||||
if (resultMapping.isSimple()) {
|
if (resultMapping.isSimple()) {
|
||||||
final String column = prependPrefix(resultMapping.getColumn(), columnPrefix);
|
final String column = prependPrefix(resultMapping.getColumn(), columnPrefix);
|
||||||
final TypeHandler<?> th = resultMapping.getTypeHandler();
|
final TypeHandler<?> th = resultMapping.getTypeHandler();
|
||||||
List<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
|
Collection<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
|
||||||
// Issue #114
|
// Issue #114
|
||||||
if (column != null && mappedColumnNames.contains(column.toUpperCase(Locale.ENGLISH))) {
|
if (column != null && mappedColumnNames.contains(column.toUpperCase(Locale.ENGLISH))) {
|
||||||
final Object value = th.getResult(rsw.getResultSet(), column);
|
final Object value = th.getResult(rsw.getResultSet(), column);
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import org.apache.ibatis.type.TypeHandler;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -84,7 +85,7 @@ public class FlexResultSetHandler extends FlexDefaultResultSetHandler {
|
|||||||
String columnName = prependPrefix(mapping.getColumn(), columnPrefix);
|
String columnName = prependPrefix(mapping.getColumn(), columnPrefix);
|
||||||
TypeHandler<?> typeHandler = mapping.getTypeHandler();
|
TypeHandler<?> typeHandler = mapping.getTypeHandler();
|
||||||
|
|
||||||
List<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
|
Collection<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
|
||||||
if (columnName != null && mappedColumnNames.contains(columnName.toUpperCase(Locale.ENGLISH))) {
|
if (columnName != null && mappedColumnNames.contains(columnName.toUpperCase(Locale.ENGLISH))) {
|
||||||
return typeHandler.getResult(rsw.getResultSet(), columnName);
|
return typeHandler.getResult(rsw.getResultSet(), columnName);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -247,8 +247,8 @@ public class RowSqlProvider {
|
|||||||
FlexAssert.notNull(entity, "entity can not be null");
|
FlexAssert.notNull(entity, "entity can not be null");
|
||||||
|
|
||||||
// 该 Mapper 是通用 Mapper 无法通过 ProviderContext 获取,直接使用 TableInfoFactory
|
// 该 Mapper 是通用 Mapper 无法通过 ProviderContext 获取,直接使用 TableInfoFactory
|
||||||
TableInfo tableInfo = TableInfoFactory.ofEntityClass(ClassUtil.getUsefulClass(entity.getClass()));
|
|
||||||
|
|
||||||
|
TableInfo tableInfo = TableInfoFactory.ofEntityClass(ClassUtil.getUsefulClass(entity.getClass()));
|
||||||
// 执行 onUpdate 监听器
|
// 执行 onUpdate 监听器
|
||||||
tableInfo.invokeOnUpdateListener(entity);
|
tableInfo.invokeOnUpdateListener(entity);
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import com.mybatisflex.core.util.LambdaGetter;
|
|||||||
import com.mybatisflex.core.util.LambdaUtil;
|
import com.mybatisflex.core.util.LambdaUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.mybatisflex.core.constant.FuncName.*;
|
import static com.mybatisflex.core.constant.FuncName.*;
|
||||||
@ -2346,6 +2347,12 @@ public class QueryMethods {
|
|||||||
return new DistinctQueryColumn(columns);
|
return new DistinctQueryColumn(columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SafeVarargs
|
||||||
|
public static <T> DistinctQueryColumn distinct(LambdaGetter<T>... columns) {
|
||||||
|
return new DistinctQueryColumn(Arrays.stream(columns)
|
||||||
|
.map(LambdaUtil::getQueryColumn).toArray(QueryColumn[]::new));
|
||||||
|
}
|
||||||
|
|
||||||
// === CASE THEN ELSE ===
|
// === CASE THEN ELSE ===
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2564,6 +2571,13 @@ public class QueryMethods {
|
|||||||
return new OperatorQueryCondition("NOT ", childCondition);
|
return new OperatorQueryCondition("NOT ", childCondition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code NOT (column)} 或 {@code NOT column}
|
||||||
|
*/
|
||||||
|
public static <N> QueryColumn not(LambdaGetter<N> column) {
|
||||||
|
return new FunctionQueryColumn("NOT", LambdaUtil.getQueryColumn(column));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 空条件。
|
* 空条件。
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -376,7 +376,7 @@ public interface IService<T> {
|
|||||||
* @return 查询结果数据
|
* @return 查询结果数据
|
||||||
*/
|
*/
|
||||||
default T getOne(QueryCondition condition) {
|
default T getOne(QueryCondition condition) {
|
||||||
return getOne(query().where(condition));
|
return getOne(query().where(condition).limit(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -149,7 +149,9 @@ public class ColumnInfo {
|
|||||||
if (configuration == null) {
|
if (configuration == null) {
|
||||||
configuration = FlexGlobalConfig.getDefaultConfig().getConfiguration();
|
configuration = FlexGlobalConfig.getDefaultConfig().getConfiguration();
|
||||||
}
|
}
|
||||||
buildTypeHandler = configuration.getTypeHandlerRegistry().getTypeHandler(propertyType);
|
if (configuration != null) {
|
||||||
|
buildTypeHandler = configuration.getTypeHandlerRegistry().getTypeHandler(propertyType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildTypeHandler;
|
return buildTypeHandler;
|
||||||
|
|||||||
@ -70,14 +70,15 @@ public class ClassUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Class<T> getUsefulClass(Class<T> clazz) {
|
public static <T> Class<T> getUsefulClass(Class<T> clazz) {
|
||||||
|
|
||||||
|
if (ProxyObject.class.isAssignableFrom(clazz)) {
|
||||||
|
return (Class<T>) clazz.getSuperclass();
|
||||||
|
}
|
||||||
|
|
||||||
if (isProxy(clazz)) {
|
if (isProxy(clazz)) {
|
||||||
return getJdkProxySuperClass(clazz);
|
return getJdkProxySuperClass(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (ProxyObject.class.isAssignableFrom(clazz)){
|
|
||||||
// return (Class<T>) clazz.getSuperclass();
|
|
||||||
// }
|
|
||||||
|
|
||||||
//ControllerTest$ServiceTest$$EnhancerByGuice$$40471411#hello -------> Guice
|
//ControllerTest$ServiceTest$$EnhancerByGuice$$40471411#hello -------> Guice
|
||||||
//com.demo.blog.Blog$$EnhancerByCGLIB$$69a17158 ----> CGLIB
|
//com.demo.blog.Blog$$EnhancerByCGLIB$$69a17158 ----> CGLIB
|
||||||
//io.jboot.test.app.TestAppListener_$$_jvstb9f_0 ------> javassist
|
//io.jboot.test.app.TestAppListener_$$_jvstb9f_0 ------> javassist
|
||||||
|
|||||||
@ -58,13 +58,9 @@ public class FieldWrapper {
|
|||||||
|
|
||||||
String setterName = "set" + StringUtil.firstCharToUpperCase(fieldName);
|
String setterName = "set" + StringUtil.firstCharToUpperCase(fieldName);
|
||||||
Method setter = ClassUtil.getFirstMethod(clazz, method ->
|
Method setter = ClassUtil.getFirstMethod(clazz, method ->
|
||||||
method.getParameterCount() == 1
|
method.getParameterCount() == 1
|
||||||
&& Modifier.isPublic(method.getModifiers())
|
&& Modifier.isPublic(method.getModifiers())
|
||||||
&& method.getName().equals(setterName));
|
&& method.getName().equals(setterName));
|
||||||
|
|
||||||
if (setter == null) {
|
|
||||||
throw new IllegalStateException("Can not find method \"set" + StringUtil.firstCharToUpperCase(fieldName) + "\" in class: " + clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldWrapper = new FieldWrapper();
|
fieldWrapper = new FieldWrapper();
|
||||||
fieldWrapper.field = findField;
|
fieldWrapper.field = findField;
|
||||||
@ -80,8 +76,8 @@ public class FieldWrapper {
|
|||||||
|
|
||||||
String[] getterNames = new String[]{"get" + StringUtil.firstCharToUpperCase(fieldName), "is" + StringUtil.firstCharToUpperCase(fieldName)};
|
String[] getterNames = new String[]{"get" + StringUtil.firstCharToUpperCase(fieldName), "is" + StringUtil.firstCharToUpperCase(fieldName)};
|
||||||
fieldWrapper.getterMethod = ClassUtil.getFirstMethod(clazz, method -> method.getParameterCount() == 0
|
fieldWrapper.getterMethod = ClassUtil.getFirstMethod(clazz, method -> method.getParameterCount() == 0
|
||||||
&& Modifier.isPublic(method.getModifiers())
|
&& Modifier.isPublic(method.getModifiers())
|
||||||
&& ArrayUtil.contains(getterNames, method.getName()));
|
&& ArrayUtil.contains(getterNames, method.getName()));
|
||||||
|
|
||||||
wrapperMap.put(fieldName, fieldWrapper);
|
wrapperMap.put(fieldName, fieldWrapper);
|
||||||
}
|
}
|
||||||
@ -120,6 +116,9 @@ public class FieldWrapper {
|
|||||||
|
|
||||||
public void set(Object value, Object to) {
|
public void set(Object value, Object to) {
|
||||||
try {
|
try {
|
||||||
|
if (setterMethod == null) {
|
||||||
|
throw new IllegalStateException("Can not find method \"set" + StringUtil.firstCharToUpperCase(field.getName()) + "\" in class: " + to.getClass());
|
||||||
|
}
|
||||||
setterMethod.invoke(to, value);
|
setterMethod.invoke(to, value);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -128,6 +127,9 @@ public class FieldWrapper {
|
|||||||
|
|
||||||
public Object get(Object target) {
|
public Object get(Object target) {
|
||||||
try {
|
try {
|
||||||
|
if (getterMethod == null) {
|
||||||
|
throw new IllegalStateException("Can not find method \"get" + StringUtil.firstCharToUpperCase(field.getName()) + ", is" + StringUtil.firstCharToUpperCase(field.getName()) + "\" in class: " + target.getClass());
|
||||||
|
}
|
||||||
return getterMethod.invoke(target);
|
return getterMethod.invoke(target);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -153,4 +155,4 @@ public class FieldWrapper {
|
|||||||
public boolean isIgnore() {
|
public boolean isIgnore() {
|
||||||
return isIgnore;
|
return isIgnore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>parent</artifactId>
|
<artifactId>parent</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>mybatis-flex-dependencies</artifactId>
|
<artifactId>mybatis-flex-dependencies</artifactId>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent</artifactId>
|
<artifactId>parent</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-annotation</artifactId>
|
<artifactId>mybatis-flex-annotation</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent</artifactId>
|
<artifactId>parent</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent</artifactId>
|
<artifactId>parent</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring</artifactId>
|
<artifactId>mybatis-flex-spring</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -104,7 +104,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
38
mybatis-flex-spring-boot3-starter/pom.xml
Normal file
38
mybatis-flex-spring-boot3-starter/pom.xml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.mybatis-flex</groupId>
|
||||||
|
<artifactId>parent</artifactId>
|
||||||
|
<version>1.7.7</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>mybatis-flex-spring-boot3-starter</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mybatis-flex</groupId>
|
||||||
|
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||||
|
<version>1.7.7</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
<artifactId>mybatis-spring</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
<artifactId>mybatis-spring</artifactId>
|
||||||
|
<version>3.0.3</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent</artifactId>
|
<artifactId>parent</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mybatis-flex-test</artifactId>
|
<artifactId>mybatis-flex-test</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@ public class ContributorsDocGen {
|
|||||||
List<String> urls = Arrays.asList(
|
List<String> urls = Arrays.asList(
|
||||||
"https://gitee.com/mybatis-flex/mybatis-flex/contributors?ref=main"
|
"https://gitee.com/mybatis-flex/mybatis-flex/contributors?ref=main"
|
||||||
, "https://gitee.com/mybatis-flex/mybatis-flex/contributors?page=2&ref=main"
|
, "https://gitee.com/mybatis-flex/mybatis-flex/contributors?page=2&ref=main"
|
||||||
|
, "https://gitee.com/mybatis-flex/mybatis-flex/contributors?page=3&ref=main"
|
||||||
);
|
);
|
||||||
StringBuilder markdown = new StringBuilder();
|
StringBuilder markdown = new StringBuilder();
|
||||||
markdown.append("| | | | | |\n" +
|
markdown.append("| | | | | |\n" +
|
||||||
@ -73,12 +74,16 @@ public class ContributorsDocGen {
|
|||||||
if (userName.contains("@")) {
|
if (userName.contains("@")) {
|
||||||
userName = userName.substring(0, userName.indexOf("@"));
|
userName = userName.substring(0, userName.indexOf("@"));
|
||||||
}
|
}
|
||||||
if (StringUtil.isBlank(src)) {
|
// if (StringUtil.isBlank(src)) {
|
||||||
src = "https://api.dicebear.com/7.x/initials/svg?seed=" + userName;
|
// src = "https://api.dicebear.com/7.x/initials/svg?seed=" + userName;
|
||||||
}
|
// }
|
||||||
|
|
||||||
markdown.append("|");
|
markdown.append("|");
|
||||||
markdown.append("");
|
|
||||||
|
if (StringUtil.isNotBlank(src)) {
|
||||||
|
markdown.append("");
|
||||||
|
}
|
||||||
|
|
||||||
markdown.append(userName);
|
markdown.append(userName);
|
||||||
|
|
||||||
startIndex++;
|
startIndex++;
|
||||||
|
|||||||
@ -82,19 +82,28 @@ public class DbTest {
|
|||||||
Map map2 = Db.selectFirstAndSecondColumnsAsMap("select * from tb_account");
|
Map map2 = Db.selectFirstAndSecondColumnsAsMap("select * from tb_account");
|
||||||
System.out.println(map);
|
System.out.println(map);
|
||||||
System.out.println(map2);
|
System.out.println(map2);
|
||||||
|
assert map.equals(map2);
|
||||||
|
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void test03() {
|
public void test03() {
|
||||||
Account account = UpdateEntity.of(Account.class,1);
|
try {
|
||||||
account.setAge(1);
|
Account account = UpdateEntity.of(Account.class, 1);
|
||||||
List<Account> accounts = new ArrayList<>();
|
account.setAge(1);
|
||||||
accounts.add(account);
|
List<Account> accounts = new ArrayList<>();
|
||||||
Account account2 = UpdateEntity.of(Account.class,2);
|
accounts.add(account);
|
||||||
account2.setAge(2);
|
Account account2 = UpdateEntity.of(Account.class, 2);
|
||||||
UpdateWrapper updateWrapper = UpdateWrapper.of(account2);
|
account2.setAge(2);
|
||||||
updateWrapper.setRaw("age","age+1");
|
UpdateWrapper updateWrapper = UpdateWrapper.of(account2);
|
||||||
accounts.add(account2);
|
updateWrapper.setRaw("age", "age+1");
|
||||||
Db.updateEntitiesBatch(accounts);
|
accounts.add(account2);
|
||||||
|
Account account3 = new Account();
|
||||||
|
account3.setId(3L);
|
||||||
|
account3.setAge(4);
|
||||||
|
accounts.add(account3);
|
||||||
|
Db.updateEntitiesBatch(accounts);
|
||||||
|
}catch (Exception e){
|
||||||
|
assert false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mybatis-flex-test</artifactId>
|
<artifactId>mybatis-flex-test</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mybatis-flex-test</artifactId>
|
<artifactId>mybatis-flex-test</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -83,6 +83,24 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testcontainers</groupId>
|
||||||
|
<artifactId>testcontainers</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testcontainers</groupId>
|
||||||
|
<artifactId>mysql</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -0,0 +1,33 @@
|
|||||||
|
package com.mybatisflex.test;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.testcontainers.containers.BindMode;
|
||||||
|
import org.testcontainers.containers.GenericContainer;
|
||||||
|
import org.testcontainers.containers.MySQLContainer;
|
||||||
|
import org.testcontainers.containers.wait.strategy.Wait;
|
||||||
|
import org.testcontainers.utility.DockerImageName;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
public class TestInfrastructure {
|
||||||
|
|
||||||
|
static final String FLEX_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("flex_test.sql").getPath();
|
||||||
|
static final String FIELD_MAPPING_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("field_mapping_test.sql").getPath();
|
||||||
|
static final String PATIENT_DATA_SPLIT_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("patient_data_split_test.sql").getPath();
|
||||||
|
static final String DOCKER_INITDB_PATH = "/docker-entrypoint-initdb.d/";
|
||||||
|
static GenericContainer<?> mysql = new MySQLContainer<>(DockerImageName.parse("mysql:8.2.0"))
|
||||||
|
.waitingFor(Wait.forLogMessage(".*ready for connections.*\\n", 1))
|
||||||
|
.withFileSystemBind(FLEX_TEST_DDL, DOCKER_INITDB_PATH + "flex_test.sql", BindMode.READ_ONLY)
|
||||||
|
.withFileSystemBind(FIELD_MAPPING_TEST_DDL, DOCKER_INITDB_PATH + "field_mapping_test.sql", BindMode.READ_ONLY)
|
||||||
|
.withFileSystemBind(PATIENT_DATA_SPLIT_TEST_DDL, DOCKER_INITDB_PATH + "patient_data_split_test.sql", BindMode.READ_ONLY)
|
||||||
|
.withDatabaseName("flex_test")
|
||||||
|
.withReuse(true)
|
||||||
|
.withPassword("123456");
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
public static void start() {
|
||||||
|
mysql.setPortBindings(Collections.singletonList("3306:3306"));
|
||||||
|
mysql.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,6 +19,11 @@ package com.mybatisflex.test.common;
|
|||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONReader;
|
import com.alibaba.fastjson2.JSONReader;
|
||||||
import com.alibaba.fastjson2.JSONWriter;
|
import com.alibaba.fastjson2.JSONWriter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.mybatisflex.core.query.QueryCondition;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
@ -71,4 +76,26 @@ public class SerialUtil {
|
|||||||
return parseObject(toJSONString(obj), tClass);
|
return parseObject(toJSONString(obj), tClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用jackson对QueryWrapper进行序列化反序列化操作,需要注意QueryCondition的protected属性以及prev和next的递归问题。
|
||||||
|
*
|
||||||
|
* @return Jackson序列化映射
|
||||||
|
*/
|
||||||
|
public static ObjectMapper jacksonMapper(){
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
// 为了将QueryWrapper里的protected属性可见
|
||||||
|
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
|
||||||
|
// 避免QueryCondition里的prev和next在序列化时出现递归调用错误
|
||||||
|
mapper.addMixIn(QueryCondition.class,QueryConditionMixIn.class);
|
||||||
|
return mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 因无法修改QueryCondition而添加的映射属性包装
|
||||||
|
*/
|
||||||
|
class QueryConditionMixIn{
|
||||||
|
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||||
|
protected QueryCondition prev;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,18 +19,16 @@ package com.mybatisflex.test.mapper;
|
|||||||
import com.mybatisflex.core.logicdelete.LogicDeleteManager;
|
import com.mybatisflex.core.logicdelete.LogicDeleteManager;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.core.row.Db;
|
import com.mybatisflex.core.row.Db;
|
||||||
import com.mybatisflex.core.row.Row;
|
import com.mybatisflex.test.TestInfrastructure;
|
||||||
import com.mybatisflex.test.model.Account;
|
import com.mybatisflex.test.model.Account;
|
||||||
import com.mybatisflex.test.model.AccountVO;
|
import com.mybatisflex.test.model.AccountVO;
|
||||||
import com.mybatisflex.test.model.AccountVO2;
|
import com.mybatisflex.test.model.AccountVO2;
|
||||||
import lombok.val;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.mybatisflex.core.query.QueryMethods.*;
|
import static com.mybatisflex.core.query.QueryMethods.*;
|
||||||
import static com.mybatisflex.test.model.table.AccountTableDef.ACCOUNT;
|
import static com.mybatisflex.test.model.table.AccountTableDef.ACCOUNT;
|
||||||
@ -44,7 +42,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
|
|||||||
*/
|
*/
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
class AccountMapperTest {
|
class AccountMapperTest extends TestInfrastructure {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AccountMapper accountMapper;
|
private AccountMapper accountMapper;
|
||||||
|
|||||||
@ -18,6 +18,7 @@ package com.mybatisflex.test.mapper;
|
|||||||
|
|
||||||
import com.mybatisflex.core.mybatis.Mappers;
|
import com.mybatisflex.core.mybatis.Mappers;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.test.TestInfrastructure;
|
||||||
import com.mybatisflex.test.model.Good;
|
import com.mybatisflex.test.model.Good;
|
||||||
import com.mybatisflex.test.model.User;
|
import com.mybatisflex.test.model.User;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
@ -34,7 +35,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
|
|||||||
* @since 2023-07-23
|
* @since 2023-07-23
|
||||||
*/
|
*/
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class ActiveRecordTest {
|
class ActiveRecordTest extends TestInfrastructure {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testMapper() {
|
void testMapper() {
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
package com.mybatisflex.test.mapper;
|
package com.mybatisflex.test.mapper;
|
||||||
|
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.test.TestInfrastructure;
|
||||||
import com.mybatisflex.test.model.Account;
|
import com.mybatisflex.test.model.Account;
|
||||||
import com.mybatisflex.test.model.Article;
|
import com.mybatisflex.test.model.Article;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -26,7 +27,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class CombinedMapperTest {
|
public class CombinedMapperTest extends TestInfrastructure {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AccountMapper accountMapper;
|
private AccountMapper accountMapper;
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.mybatisflex.test.mapper;
|
package com.mybatisflex.test.mapper;
|
||||||
|
|
||||||
|
import com.mybatisflex.test.TestInfrastructure;
|
||||||
import com.mybatisflex.test.model.Account;
|
import com.mybatisflex.test.model.Account;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -32,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
* @since 2023/4/24 19:37
|
* @since 2023/4/24 19:37
|
||||||
*/
|
*/
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class MyAccountMapperTest {
|
class MyAccountMapperTest extends TestInfrastructure {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MyAccountMapper mapper;
|
private MyAccountMapper mapper;
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
package com.mybatisflex.test.mapper;
|
package com.mybatisflex.test.mapper;
|
||||||
|
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.test.entity.Inner;
|
import com.mybatisflex.test.TestInfrastructure;
|
||||||
import com.mybatisflex.test.entity.Outer;
|
import com.mybatisflex.test.entity.Outer;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -32,7 +32,7 @@ import static com.mybatisflex.test.entity.table.OuterTableDef.OUTER;
|
|||||||
* @since 2023-07-01
|
* @since 2023-07-01
|
||||||
*/
|
*/
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class OuterMapperTest {
|
class OuterMapperTest extends TestInfrastructure {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OuterMapper outerMapper;
|
private OuterMapper outerMapper;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.mybatisflex.test.mapper;
|
package com.mybatisflex.test.mapper;
|
||||||
|
|
||||||
|
import com.mybatisflex.test.TestInfrastructure;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ import javax.annotation.Resource;
|
|||||||
*/
|
*/
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public class PatientMapperTest {
|
public class PatientMapperTest extends TestInfrastructure {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private PatientMapper patientMapper;
|
private PatientMapper patientMapper;
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import com.mybatisflex.core.field.QueryBuilder;
|
|||||||
import com.mybatisflex.core.query.QueryChain;
|
import com.mybatisflex.core.query.QueryChain;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.core.update.UpdateChain;
|
import com.mybatisflex.core.update.UpdateChain;
|
||||||
|
import com.mybatisflex.test.TestInfrastructure;
|
||||||
import com.mybatisflex.test.model.Gender;
|
import com.mybatisflex.test.model.Gender;
|
||||||
import com.mybatisflex.test.model.User;
|
import com.mybatisflex.test.model.User;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
@ -36,7 +37,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
|
|||||||
* @since 2023-08-08
|
* @since 2023-08-08
|
||||||
*/
|
*/
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class QueryChainTest {
|
class QueryChainTest extends TestInfrastructure {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
UserMapper userMapper;
|
UserMapper userMapper;
|
||||||
|
|||||||
@ -18,6 +18,7 @@ package com.mybatisflex.test.mapper;
|
|||||||
|
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.test.TestInfrastructure;
|
||||||
import com.mybatisflex.test.model.*;
|
import com.mybatisflex.test.model.*;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -42,7 +43,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
|
|||||||
*/
|
*/
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
class UserMapperTest {
|
class UserMapperTest extends TestInfrastructure {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
package com.mybatisflex.test.service;
|
package com.mybatisflex.test.service;
|
||||||
|
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.test.TestInfrastructure;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
@ -28,7 +29,7 @@ import static com.mybatisflex.test.model.table.ArticleTableDef.ARTICLE;
|
|||||||
* @since 2023-07-22
|
* @since 2023-07-22
|
||||||
*/
|
*/
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class ArticleServiceTest {
|
class ArticleServiceTest extends TestInfrastructure {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ArticleService articleService;
|
ArticleService articleService;
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.mybatisflex.test.service;
|
|||||||
|
|
||||||
import com.mybatisflex.test.mapper.FieldMappingInnerMapper;
|
import com.mybatisflex.test.mapper.FieldMappingInnerMapper;
|
||||||
import com.mybatisflex.test.mapper.FieldMappingMapper;
|
import com.mybatisflex.test.mapper.FieldMappingMapper;
|
||||||
|
import com.mybatisflex.test.TestInfrastructure;
|
||||||
import com.mybatisflex.test.model.FieldMapping;
|
import com.mybatisflex.test.model.FieldMapping;
|
||||||
import com.mybatisflex.test.model.FieldMappingInner;
|
import com.mybatisflex.test.model.FieldMappingInner;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -11,11 +12,12 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class FieldMappingTest {
|
class FieldMappingTest extends TestInfrastructure {
|
||||||
@Autowired
|
@Autowired
|
||||||
FieldMappingMapper fieldMappingMapper;
|
FieldMappingMapper fieldMappingMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
FieldMappingInnerMapper fieldMappingInnerMapper;
|
FieldMappingInnerMapper fieldMappingInnerMapper;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFieldMapping() {
|
void testFieldMapping() {
|
||||||
String fieldId = FieldMapping.create().saveOpt().get().getId();
|
String fieldId = FieldMapping.create().saveOpt().get().getId();
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mybatis-flex-test</artifactId>
|
<artifactId>mybatis-flex-test</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mybatis-flex-test</artifactId>
|
<artifactId>mybatis-flex-test</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent</artifactId>
|
<artifactId>parent</artifactId>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
16
pom.xml
16
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>parent</artifactId>
|
<artifactId>parent</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.7.6</version>
|
<version>1.7.7</version>
|
||||||
|
|
||||||
<name>mybatis-flex</name>
|
<name>mybatis-flex</name>
|
||||||
<url>https://mybatis-flex.com</url>
|
<url>https://mybatis-flex.com</url>
|
||||||
@ -45,6 +45,7 @@
|
|||||||
<module>mybatis-flex-core</module>
|
<module>mybatis-flex-core</module>
|
||||||
<module>mybatis-flex-spring</module>
|
<module>mybatis-flex-spring</module>
|
||||||
<module>mybatis-flex-spring-boot-starter</module>
|
<module>mybatis-flex-spring-boot-starter</module>
|
||||||
|
<module>mybatis-flex-spring-boot3-starter</module>
|
||||||
<module>mybatis-flex-solon-plugin</module>
|
<module>mybatis-flex-solon-plugin</module>
|
||||||
<module>mybatis-flex-test</module>
|
<module>mybatis-flex-test</module>
|
||||||
<module>mybatis-flex-processor</module>
|
<module>mybatis-flex-processor</module>
|
||||||
@ -55,9 +56,9 @@
|
|||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
|
||||||
<mybatis-flex.version>1.7.6</mybatis-flex.version>
|
<mybatis-flex.version>1.7.7</mybatis-flex.version>
|
||||||
|
|
||||||
<mybatis.version>3.5.14</mybatis.version>
|
<mybatis.version>3.5.15</mybatis.version>
|
||||||
<mybatis-spring.version>2.1.2</mybatis-spring.version>
|
<mybatis-spring.version>2.1.2</mybatis-spring.version>
|
||||||
<mybatis-freemarker.version>1.2.4</mybatis-freemarker.version>
|
<mybatis-freemarker.version>1.2.4</mybatis-freemarker.version>
|
||||||
<mybatis-velocity.version>2.1.2</mybatis-velocity.version>
|
<mybatis-velocity.version>2.1.2</mybatis-velocity.version>
|
||||||
@ -71,6 +72,7 @@
|
|||||||
<solon.version>2.5.3</solon.version>
|
<solon.version>2.5.3</solon.version>
|
||||||
|
|
||||||
<junit.version>4.13.2</junit.version>
|
<junit.version>4.13.2</junit.version>
|
||||||
|
<testcontainers.version>1.19.3</testcontainers.version>
|
||||||
<maven-flatten.version>1.5.0</maven-flatten.version>
|
<maven-flatten.version>1.5.0</maven-flatten.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -188,6 +190,14 @@
|
|||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testcontainers</groupId>
|
||||||
|
<artifactId>testcontainers-bom</artifactId>
|
||||||
|
<version>${testcontainers.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user