mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 17:18:24 +08:00
test: 更新测试代码。
This commit is contained in:
parent
3361d225aa
commit
a249a67995
@ -16,6 +16,8 @@
|
||||
|
||||
package com.mybatisflex.test.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 王帅
|
||||
* @since 2023-06-07
|
||||
@ -25,7 +27,8 @@ public class UserVO2 {
|
||||
|
||||
private String userId;
|
||||
private String userName;
|
||||
private Role role;
|
||||
private List<String> roles;
|
||||
private List<Integer> roleIds;
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
@ -43,12 +46,20 @@ public class UserVO2 {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public Role getRole() {
|
||||
return role;
|
||||
public List<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRole(Role role) {
|
||||
this.role = role;
|
||||
public void setRoles(List<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public List<Integer> getRoleIds() {
|
||||
return roleIds;
|
||||
}
|
||||
|
||||
public void setRoleIds(List<Integer> roleIds) {
|
||||
this.roleIds = roleIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,7 +67,8 @@ public class UserVO2 {
|
||||
return "UserVO2{" +
|
||||
"userId='" + userId + '\'' +
|
||||
", userName='" + userName + '\'' +
|
||||
", role=" + role +
|
||||
", roles=" + roles +
|
||||
", roleIds=" + roleIds +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
# DataSource Config
|
||||
spring:
|
||||
#spring:
|
||||
# h2:
|
||||
# console:
|
||||
# enabled: true
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/flex_test
|
||||
username: root
|
||||
password: 12345678
|
||||
# datasource:
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://localhost:3306/flex_test
|
||||
# username: root
|
||||
# password: 12345678
|
||||
# sql:
|
||||
# init:
|
||||
# schema-locations: classpath:schema.sql
|
||||
@ -15,6 +15,11 @@ spring:
|
||||
mybatis-flex:
|
||||
mapper-locations:
|
||||
- classpath*:/mapper/*.xml
|
||||
datasource:
|
||||
data-center:
|
||||
url: jdbc:mysql://localhost:3306/flex_test
|
||||
username: root
|
||||
password: 12345678
|
||||
#mybatis-flex:
|
||||
# datasource:
|
||||
# ds1:
|
||||
|
||||
@ -152,4 +152,21 @@ class UserMapperTest {
|
||||
} 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