mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 09:38:26 +08:00
test: 更新测试代码。
This commit is contained in:
parent
3361d225aa
commit
a249a67995
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.mybatisflex.test.model;
|
package com.mybatisflex.test.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 王帅
|
* @author 王帅
|
||||||
* @since 2023-06-07
|
* @since 2023-06-07
|
||||||
@ -25,7 +27,8 @@ public class UserVO2 {
|
|||||||
|
|
||||||
private String userId;
|
private String userId;
|
||||||
private String userName;
|
private String userName;
|
||||||
private Role role;
|
private List<String> roles;
|
||||||
|
private List<Integer> roleIds;
|
||||||
|
|
||||||
public String getUserId() {
|
public String getUserId() {
|
||||||
return userId;
|
return userId;
|
||||||
@ -43,12 +46,20 @@ public class UserVO2 {
|
|||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Role getRole() {
|
public List<String> getRoles() {
|
||||||
return role;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRole(Role role) {
|
public void setRoles(List<String> roles) {
|
||||||
this.role = role;
|
this.roles = roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getRoleIds() {
|
||||||
|
return roleIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleIds(List<Integer> roleIds) {
|
||||||
|
this.roleIds = roleIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,7 +67,8 @@ public class UserVO2 {
|
|||||||
return "UserVO2{" +
|
return "UserVO2{" +
|
||||||
"userId='" + userId + '\'' +
|
"userId='" + userId + '\'' +
|
||||||
", userName='" + userName + '\'' +
|
", userName='" + userName + '\'' +
|
||||||
", role=" + role +
|
", roles=" + roles +
|
||||||
|
", roleIds=" + roleIds +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,13 +1,13 @@
|
|||||||
# DataSource Config
|
# DataSource Config
|
||||||
spring:
|
#spring:
|
||||||
# h2:
|
# h2:
|
||||||
# console:
|
# console:
|
||||||
# enabled: true
|
# enabled: true
|
||||||
datasource:
|
# datasource:
|
||||||
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: 12345678
|
# password: 12345678
|
||||||
# sql:
|
# sql:
|
||||||
# init:
|
# init:
|
||||||
# schema-locations: classpath:schema.sql
|
# schema-locations: classpath:schema.sql
|
||||||
@ -15,6 +15,11 @@ spring:
|
|||||||
mybatis-flex:
|
mybatis-flex:
|
||||||
mapper-locations:
|
mapper-locations:
|
||||||
- classpath*:/mapper/*.xml
|
- classpath*:/mapper/*.xml
|
||||||
|
datasource:
|
||||||
|
data-center:
|
||||||
|
url: jdbc:mysql://localhost:3306/flex_test
|
||||||
|
username: root
|
||||||
|
password: 12345678
|
||||||
#mybatis-flex:
|
#mybatis-flex:
|
||||||
# datasource:
|
# datasource:
|
||||||
# ds1:
|
# ds1:
|
||||||
|
|||||||
@ -152,4 +152,21 @@ class UserMapperTest {
|
|||||||
} while (page.hasNext());
|
} while (page.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testListString() {
|
||||||
|
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||||
|
.select(USER.USER_ID,
|
||||||
|
USER.USER_NAME,
|
||||||
|
ROLE.ROLE_NAME.as("roles"),
|
||||||
|
ROLE.ROLE_ID.as("role_ids"))
|
||||||
|
.from(USER.as("u"))
|
||||||
|
.leftJoin(USER_ROLE).as("ur").on(USER_ROLE.USER_ID.eq(USER.USER_ID))
|
||||||
|
.leftJoin(ROLE).as("r").on(USER_ROLE.ROLE_ID.eq(ROLE.ROLE_ID))
|
||||||
|
.where(USER.USER_ID.eq(2));
|
||||||
|
UserVO2 user = userMapper.selectOneByQueryAs(queryWrapper, UserVO2.class);
|
||||||
|
System.err.println(user);
|
||||||
|
user = userMapper.selectOneByQueryAs(queryWrapper, UserVO2.class);
|
||||||
|
System.err.println(user);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user