Merge remote-tracking branch 'origin/main'

This commit is contained in:
michael 2024-01-20 20:11:24 +08:00
commit 8c49da7931
4 changed files with 10 additions and 10 deletions

View File

@ -88,12 +88,6 @@ public class SysUser extends BaseEntity {
this.birthday = birthday; this.birthday = birthday;
} }
@Override
@ColumnAlias("user_create_by")
public String getCreateBy() {
return super.getCreateBy();
}
@Override @Override
public String toString() { public String toString() {
return "SysUser{" + return "SysUser{" +

View File

@ -7,7 +7,7 @@ spring:
# driver-class-name: com.mysql.cj.jdbc.Driver # driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/flex_test url: jdbc:mysql://localhost:3306/flex_test
username: root username: root
password: 123456 password: 12345678
# driver-class-name: # driver-class-name:
# datasource: # datasource:
# driver-class-name: org.h2.Driver # driver-class-name: org.h2.Driver

View File

@ -81,9 +81,10 @@ class AlisaTest {
@Test @Test
void test03() { void test03() {
QueryWrapper queryWrapper = QueryWrapper.create() QueryWrapper queryWrapper = QueryWrapper.create()
.select(SYS_USER.ALL_COLUMNS) // 调整 SELECT 顺序
.select(SYS_ROLE.ALL_COLUMNS) .select(SYS_ROLE.DEFAULT_COLUMNS)
.select(SYS_DEPT.ALL_COLUMNS) .select(SYS_DEPT.DEFAULT_COLUMNS)
.select(SYS_USER.DEFAULT_COLUMNS)
.from(SYS_USER.as("u")) .from(SYS_USER.as("u"))
.leftJoin(SYS_ROLE).as("r").on(SYS_USER.ID.eq(SYS_ROLE.ID)) .leftJoin(SYS_ROLE).as("r").on(SYS_USER.ID.eq(SYS_ROLE.ID))
.leftJoin(SYS_DEPT).as("d").on(SYS_USER.ID.eq(SYS_DEPT.ID)); .leftJoin(SYS_DEPT).as("d").on(SYS_USER.ID.eq(SYS_DEPT.ID));
@ -104,6 +105,7 @@ class AlisaTest {
@Test @Test
void test05() { void test05() {
QueryWrapper queryWrapper = QueryWrapper.create() QueryWrapper queryWrapper = QueryWrapper.create()
// 不支持的情况
.select(column("`u`.`create_by`")) .select(column("`u`.`create_by`"))
.select(column("`u`.`update_by`")) .select(column("`u`.`update_by`"))
.select(column("`d`.`create_by`")) .select(column("`d`.`create_by`"))
@ -117,6 +119,8 @@ class AlisaTest {
@Test @Test
void test06() { void test06() {
QueryWrapper queryWrapper = QueryWrapper.create() QueryWrapper queryWrapper = QueryWrapper.create()
// SELECT 里没有重名列 例如id
// 不指定别名会映射到嵌套对象里面去
.select(SYS_USER.ID, SYS_USER.USER_NAME, SYS_USER.AGE, SYS_USER.BIRTHDAY) .select(SYS_USER.ID, SYS_USER.USER_NAME, SYS_USER.AGE, SYS_USER.BIRTHDAY)
.select(SYS_ROLE.CREATE_BY.as("sys_role$create_by")) .select(SYS_ROLE.CREATE_BY.as("sys_role$create_by"))
.from(SYS_USER.as("u")) .from(SYS_USER.as("u"))

View File

@ -35,6 +35,8 @@
<groupId>com.github.vertical-blank</groupId> <groupId>com.github.vertical-blank</groupId>
<artifactId>sql-formatter</artifactId> <artifactId>sql-formatter</artifactId>
<version>2.0.4</version> <version>2.0.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>${commons-io.version}</version> <version>${commons-io.version}</version>