mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
test: modify failed unit test
This commit is contained in:
parent
adb9f6f27c
commit
b429ea6475
@ -17,7 +17,6 @@
|
||||
package com.mybatisflex.test.relation.onetoone;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.RelationManyToMany;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
|
||||
@ -28,7 +27,7 @@ import java.util.Map;
|
||||
@Table(value = "tb_account")
|
||||
public class Account implements Serializable {
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private String userName;
|
||||
|
||||
@ -45,7 +45,8 @@ public class AccountDTO implements Serializable {
|
||||
@RelationManyToMany(
|
||||
joinTable = "tb_role_mapping",
|
||||
joinSelfColumn = "account_id",
|
||||
joinTargetColumn = "role_id"
|
||||
joinTargetColumn = "role_id",
|
||||
selfField = "id"
|
||||
)
|
||||
private List<Role> roles;
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
|
||||
package com.mybatisflex.test.relation.onetoone;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.RelationManyToMany;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
|
||||
@ -25,6 +26,7 @@ import java.util.List;
|
||||
@Table(value = "tb_role")
|
||||
public class Role implements Serializable {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package com.mybatisflex.test;
|
||||
import com.mybatisflex.core.MybatisFlexBootstrap;
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.audit.ConsoleMessageCollector;
|
||||
import com.mybatisflex.core.datasource.DataSourceKey;
|
||||
import com.mybatisflex.mapper.Account6Mapper;
|
||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
@ -28,6 +29,8 @@ public class Account6Test implements WithAssertions {
|
||||
private EmbeddedDatabase dataSource;
|
||||
private Account6Mapper mapper;
|
||||
|
||||
private static final String DATA_SOURCE_KEY = "none_key";
|
||||
|
||||
@BeforeClass
|
||||
public static void enableAudit() {
|
||||
AuditManager.setAuditEnable(true);
|
||||
@ -43,17 +46,20 @@ public class Account6Test implements WithAssertions {
|
||||
.build();
|
||||
|
||||
MybatisFlexBootstrap bootstrap = new MybatisFlexBootstrap()
|
||||
.setDataSource(this.dataSource)
|
||||
.setDataSource(DATA_SOURCE_KEY, this.dataSource)
|
||||
.setLogImpl(StdOutImpl.class)
|
||||
.addMapper(Account6Mapper.class)
|
||||
.start();
|
||||
|
||||
DataSourceKey.use(DATA_SOURCE_KEY);
|
||||
|
||||
mapper = bootstrap.getMapper(Account6Mapper.class);
|
||||
}
|
||||
|
||||
@After
|
||||
public void destroy() {
|
||||
this.dataSource.shutdown();
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -3,6 +3,7 @@ package com.mybatisflex.test;
|
||||
import com.mybatisflex.core.MybatisFlexBootstrap;
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.audit.ConsoleMessageCollector;
|
||||
import com.mybatisflex.core.datasource.DataSourceKey;
|
||||
import com.mybatisflex.core.keygen.KeyGeneratorFactory;
|
||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||
import org.assertj.core.api.WithAssertions;
|
||||
@ -28,6 +29,8 @@ public class Account7Test implements WithAssertions {
|
||||
private EmbeddedDatabase dataSource;
|
||||
private Account7Mapper mapper;
|
||||
|
||||
private static final String DATA_SOURCE_KEY = "generate_key";
|
||||
|
||||
@BeforeClass
|
||||
public static void enableAudit() {
|
||||
AuditManager.setAuditEnable(true);
|
||||
@ -45,17 +48,20 @@ public class Account7Test implements WithAssertions {
|
||||
.build();
|
||||
|
||||
MybatisFlexBootstrap bootstrap = new MybatisFlexBootstrap()
|
||||
.setDataSource(this.dataSource)
|
||||
.setDataSource(DATA_SOURCE_KEY, this.dataSource)
|
||||
.setLogImpl(StdOutImpl.class)
|
||||
.addMapper(Account7Mapper.class)
|
||||
.start();
|
||||
|
||||
DataSourceKey.use(DATA_SOURCE_KEY);
|
||||
|
||||
mapper = bootstrap.getMapper(Account7Mapper.class);
|
||||
}
|
||||
|
||||
@After
|
||||
public void destroy() {
|
||||
this.dataSource.shutdown();
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -18,6 +18,7 @@ package com.mybatisflex.test;
|
||||
import com.mybatisflex.core.MybatisFlexBootstrap;
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.audit.ConsoleMessageCollector;
|
||||
import com.mybatisflex.core.datasource.DataSourceKey;
|
||||
import com.mybatisflex.mapper.Account5Mapper;
|
||||
import org.assertj.core.api.WithAssertions;
|
||||
import org.junit.After;
|
||||
@ -34,6 +35,8 @@ public class AccountInsertWithArrayAttrTest implements WithAssertions {
|
||||
private Account5Mapper accountMapper;
|
||||
private EmbeddedDatabase dataSource;
|
||||
|
||||
private static final String DATA_SOURCE_KEY = "data05";
|
||||
|
||||
@BeforeClass
|
||||
public static void enableAudit() {
|
||||
AuditManager.setAuditEnable(true);
|
||||
@ -49,16 +52,19 @@ public class AccountInsertWithArrayAttrTest implements WithAssertions {
|
||||
.build();
|
||||
|
||||
MybatisFlexBootstrap bootstrap = new MybatisFlexBootstrap()
|
||||
.setDataSource(dataSource)
|
||||
.setDataSource(DATA_SOURCE_KEY, dataSource)
|
||||
.addMapper(Account5Mapper.class)
|
||||
.start();
|
||||
|
||||
DataSourceKey.use(DATA_SOURCE_KEY);
|
||||
|
||||
accountMapper = bootstrap.getMapper(Account5Mapper.class);
|
||||
}
|
||||
|
||||
@After
|
||||
public void destroy() {
|
||||
this.dataSource.shutdown();
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -70,7 +76,7 @@ public class AccountInsertWithArrayAttrTest implements WithAssertions {
|
||||
account.setDataScope(new Long[]{1L, 2L});
|
||||
accountMapper.insertWithPk(account, false);
|
||||
|
||||
// todo 查询有问题,会抛出 argument type mismatch
|
||||
// todo argument type mismatch
|
||||
Account5 result = accountMapper.selectOneById(3L);
|
||||
assertThat(result).isNotNull()
|
||||
.extracting(Account5::getUserName, Account5::getDataScope)
|
||||
|
||||
@ -19,6 +19,7 @@ import com.mybatisflex.core.FlexGlobalConfig;
|
||||
import com.mybatisflex.core.MybatisFlexBootstrap;
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.audit.ConsoleMessageCollector;
|
||||
import com.mybatisflex.core.datasource.DataSourceKey;
|
||||
import com.mybatisflex.core.mybatis.Mappers;
|
||||
import com.mybatisflex.core.query.If;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
@ -52,6 +53,8 @@ public class AccountNativeTest implements WithAssertions {
|
||||
private AccountMapper accountMapper;
|
||||
private ArticleMapper articleMapper;
|
||||
|
||||
private static final String DATA_SOURCE_KEY = "auto_increment";
|
||||
|
||||
@BeforeClass
|
||||
public static void enableAudit() {
|
||||
AuditManager.setAuditEnable(true);
|
||||
@ -68,12 +71,14 @@ public class AccountNativeTest implements WithAssertions {
|
||||
.build();
|
||||
|
||||
MybatisFlexBootstrap bootstrap = new MybatisFlexBootstrap()
|
||||
.setDataSource(this.dataSource)
|
||||
.setDataSource(DATA_SOURCE_KEY, this.dataSource)
|
||||
.setLogImpl(StdOutImpl.class)
|
||||
.addMapper(AccountMapper.class)
|
||||
.addMapper(ArticleMapper.class)
|
||||
.start();
|
||||
|
||||
DataSourceKey.use(DATA_SOURCE_KEY);
|
||||
|
||||
accountMapper = bootstrap.getMapper(AccountMapper.class);
|
||||
articleMapper = bootstrap.getMapper(ArticleMapper.class);
|
||||
}
|
||||
@ -81,6 +86,7 @@ public class AccountNativeTest implements WithAssertions {
|
||||
@After
|
||||
public void destroy() {
|
||||
this.dataSource.shutdown();
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -154,19 +160,21 @@ public class AccountNativeTest implements WithAssertions {
|
||||
* issues https://gitee.com/mybatis-flex/mybatis-flex/issues/I7QD29
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void testGiteeIssue_I7QD29() {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create();
|
||||
queryWrapper.from(ACCOUNT)
|
||||
.leftJoin(ACCOUNT).as("a1").on(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID))
|
||||
.leftJoin(ACCOUNT).as("a2").on(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID))
|
||||
.leftJoin(ARTICLE).as("a1").on(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID))
|
||||
.leftJoin(ARTICLE).as("a2").on(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID))
|
||||
.where(ACCOUNT.ID.ge(1));
|
||||
// todo Column "TB_ARTICLE.ACCOUNT_ID" not found
|
||||
List<Article> accounts = articleMapper.selectListByQuery(queryWrapper);
|
||||
System.out.println(accounts);
|
||||
String expectSql = "SELECT * FROM `tb_account` " +
|
||||
"LEFT JOIN `tb_article` AS `a1` ON `tb_account`.`id` = `a1`.`account_id` AND `a1`.`is_delete` = 0 " +
|
||||
"LEFT JOIN `tb_article` AS `a2` ON `tb_account`.`id` = `a1`.`account_id` AND `a2`.`is_delete` = 0 " +
|
||||
"WHERE `tb_account`.`id` >= 1";
|
||||
assertThat(queryWrapper.toSQL()).isEqualTo(expectSql);
|
||||
assertThat(accounts).hasSize(9);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* issues https://gitee.com/mybatis-flex/mybatis-flex/issues/I7VAG8
|
||||
*/
|
||||
@ -205,7 +213,7 @@ public class AccountNativeTest implements WithAssertions {
|
||||
// 设置 Ignore 字段,会被自动忽略
|
||||
.setRaw(Account::getTitle, "xxxx")
|
||||
.toEntity();
|
||||
// todo Column "TITLE" not found
|
||||
// todo title not found
|
||||
accountMapper.update(account);
|
||||
}
|
||||
|
||||
|
||||
@ -16,13 +16,11 @@
|
||||
|
||||
package com.mybatisflex.test;
|
||||
|
||||
import com.mybatisflex.core.MybatisFlexBootstrap;
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.audit.ConsoleMessageCollector;
|
||||
import com.mybatisflex.core.row.DbChain;
|
||||
import com.mybatisflex.core.row.Row;
|
||||
import com.mybatisflex.core.row.RowKey;
|
||||
import com.mybatisflex.core.row.RowUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import org.assertj.core.api.WithAssertions;
|
||||
import org.junit.After;
|
||||
@ -46,6 +44,7 @@ public class DbChainTest implements WithAssertions {
|
||||
|
||||
private static final String[] PROPERTIES = new String[]{"ID", "USER_NAME", "AGE", "BIRTHDAY"};
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
||||
private static final String ENVIRONMENT_ID = "db_chain";
|
||||
|
||||
private EmbeddedDatabase database;
|
||||
|
||||
@ -63,9 +62,13 @@ public class DbChainTest implements WithAssertions {
|
||||
.addScript("auto_increment_key_data.sql")
|
||||
.build();
|
||||
|
||||
new MybatisFlexBootstrap()
|
||||
.setDataSource(this.database)
|
||||
.start();
|
||||
// Environment environment = new Environment(ENVIRONMENT_ID, new JdbcTransactionFactory(), this.database);
|
||||
// FlexConfiguration configuration = new FlexConfiguration(environment);
|
||||
// configuration.addMapper(RowMapper.class);
|
||||
// FlexGlobalConfig flexGlobalConfig = new FlexGlobalConfig();
|
||||
// flexGlobalConfig.setConfiguration(configuration);
|
||||
// flexGlobalConfig.setSqlSessionFactory(new DefaultSqlSessionFactory(configuration));
|
||||
// FlexGlobalConfig.setConfig(environment.getId(), flexGlobalConfig, false);
|
||||
}
|
||||
|
||||
@After
|
||||
@ -122,7 +125,6 @@ public class DbChainTest implements WithAssertions {
|
||||
assertThat(count).isEqualTo(1L);
|
||||
|
||||
List<Row> tb_account = DbChain.table("tb_account").list();
|
||||
RowUtil.printPretty(tb_account);
|
||||
|
||||
assertThat(tb_account).hasSize(1)
|
||||
.extracting(PROPERTIES)
|
||||
|
||||
@ -18,13 +18,16 @@ package com.mybatisflex.test;
|
||||
|
||||
import com.mybatisflex.core.FlexGlobalConfig;
|
||||
import com.mybatisflex.core.MybatisFlexBootstrap;
|
||||
import com.mybatisflex.core.datasource.DataSourceKey;
|
||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||
import org.assertj.core.api.WithAssertions;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -35,9 +38,14 @@ import java.util.Date;
|
||||
*/
|
||||
public class ListenerTest implements WithAssertions {
|
||||
|
||||
@Test
|
||||
public void onInsertInterface() {
|
||||
DataSource dataSource = new EmbeddedDatabaseBuilder()
|
||||
private static final String DATA_SOURCE_KEY = "listener";
|
||||
|
||||
private AccountMapper accountMapper;
|
||||
private EmbeddedDatabase dataSource;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
dataSource = new EmbeddedDatabaseBuilder()
|
||||
.setType(EmbeddedDatabaseType.H2)
|
||||
.addScript("auto_increment_key_schema.sql")
|
||||
.build();
|
||||
@ -48,11 +56,22 @@ public class ListenerTest implements WithAssertions {
|
||||
|
||||
MybatisFlexBootstrap bootstrap = new MybatisFlexBootstrap()
|
||||
.setLogImpl(StdOutImpl.class)
|
||||
.setDataSource(dataSource)
|
||||
.setDataSource(DATA_SOURCE_KEY, dataSource)
|
||||
.addMapper(AccountMapper.class)
|
||||
.start();
|
||||
|
||||
AccountMapper accountMapper = bootstrap.getMapper(AccountMapper.class);
|
||||
DataSourceKey.use(DATA_SOURCE_KEY);
|
||||
accountMapper = bootstrap.getMapper(AccountMapper.class);
|
||||
}
|
||||
|
||||
@After
|
||||
public void destroy() {
|
||||
this.dataSource.shutdown();
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onInsertInterface() {
|
||||
Account account = new Account();
|
||||
account.setAge(-2);
|
||||
account.setUserName("on insert");
|
||||
|
||||
@ -15,11 +15,11 @@
|
||||
*/
|
||||
package com.mybatisflex.test;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
import com.mybatisflex.core.MybatisFlexBootstrap;
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.audit.ConsoleMessageCollector;
|
||||
import com.mybatisflex.core.audit.MessageCollector;
|
||||
import com.mybatisflex.core.datasource.DataSourceKey;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.relation.RelationManager;
|
||||
@ -30,78 +30,103 @@ import com.mybatisflex.test.relation.onetoone.Account;
|
||||
import com.mybatisflex.test.relation.onetoone.AccountDTO;
|
||||
import com.mybatisflex.test.relation.onetoone.Book;
|
||||
import com.mybatisflex.test.relation.onetoone.Menu;
|
||||
import lombok.SneakyThrows;
|
||||
import net.javacrumbs.jsonunit.assertj.JsonAssertions;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.assertj.core.api.WithAssertions;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mybatisflex.test.relation.onetoone.table.MenuTableDef.MENU;
|
||||
|
||||
|
||||
public class RelationsTester {
|
||||
public class RelationsTest implements WithAssertions {
|
||||
|
||||
static AccountMapper accountMapper;
|
||||
static BookMapper bookMapper;
|
||||
static MenuMapper menuMapper;
|
||||
private AccountMapper accountMapper;
|
||||
private BookMapper bookMapper;
|
||||
private MenuMapper menuMapper;
|
||||
private EmbeddedDatabase dataSource;
|
||||
|
||||
private static final String DATA_SOURCE_KEY = "relation-onetoone";
|
||||
private static final JsonMapper JSON_MAPPER = JsonMapper.builder().build();
|
||||
|
||||
@BeforeClass
|
||||
public static void init() {
|
||||
DataSource dataSource = new EmbeddedDatabaseBuilder()
|
||||
public static void enableAudit() {
|
||||
AuditManager.setAuditEnable(true);
|
||||
AuditManager.setMessageCollector(new ConsoleMessageCollector());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
dataSource = new EmbeddedDatabaseBuilder()
|
||||
.setType(EmbeddedDatabaseType.H2)
|
||||
.addScript("relation/onetoone/schema.sql")
|
||||
.addScript("relation/onetoone/data.sql")
|
||||
.build();
|
||||
|
||||
MybatisFlexBootstrap bootstrap = MybatisFlexBootstrap.getInstance()
|
||||
.setDataSource(dataSource)
|
||||
.setDataSource(DATA_SOURCE_KEY, dataSource)
|
||||
.addMapper(AccountMapper.class)
|
||||
.addMapper(BookMapper.class)
|
||||
.addMapper(MenuMapper.class)
|
||||
.start();
|
||||
|
||||
//开启审计功能
|
||||
AuditManager.setAuditEnable(true);
|
||||
|
||||
//设置 SQL 审计收集器
|
||||
MessageCollector collector = new ConsoleMessageCollector();
|
||||
AuditManager.setMessageCollector(collector);
|
||||
DataSourceKey.use(DATA_SOURCE_KEY);
|
||||
|
||||
accountMapper = bootstrap.getMapper(AccountMapper.class);
|
||||
bookMapper = bootstrap.getMapper(BookMapper.class);
|
||||
menuMapper = bootstrap.getMapper(MenuMapper.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOneToOne() {
|
||||
List<com.mybatisflex.test.relation.onetoone.Account> accounts = accountMapper.selectAllWithRelations();
|
||||
System.out.println(JSON.toJSONString(accounts));
|
||||
@After
|
||||
public void destroy() {
|
||||
this.dataSource.shutdown();
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void testOneToOne() {
|
||||
List<com.mybatisflex.test.relation.onetoone.Account> accounts = accountMapper.selectAllWithRelations();
|
||||
assertThat(accounts).hasSize(5);
|
||||
assertRelationResult(accounts, "relation/result/account-relation-result.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManyToOne() {
|
||||
List<Book> books = bookMapper.selectAll();
|
||||
System.out.println(">>>>>>1: " + books);
|
||||
assertThat(books).hasSize(6)
|
||||
.extracting(Book::getId)
|
||||
.containsExactly(1L, 2L, 3L, 4L, 5L, 6L);
|
||||
|
||||
RelationManager.queryRelations(bookMapper, books);
|
||||
System.out.println(">>>>>>2: " + books);
|
||||
assertRelationResult(books, "relation/result/book-relation-result.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManyToMany1() {
|
||||
List<com.mybatisflex.test.relation.onetoone.Account> accounts = accountMapper.selectAll();
|
||||
System.out.println(">>>>>>1: " + accounts);
|
||||
assertThat(accounts).hasSize(5)
|
||||
.extracting(Account::getId)
|
||||
.containsExactly(1L, 2L, 3L, 4L, 5L);
|
||||
|
||||
RelationManager.queryRelations(accountMapper, accounts);
|
||||
System.out.println(">>>>>>2: " + accounts);
|
||||
assertRelationResult(accounts, "relation/result/account-relation-result.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsDto() {
|
||||
List<com.mybatisflex.test.relation.onetoone.AccountDTO> accounts = accountMapper.selectListWithRelationsByQueryAs(QueryWrapper.create(), AccountDTO.class);
|
||||
System.out.println(">>>>>>1: " + accounts);
|
||||
assertRelationResult(accounts, "relation/result/accountDto-relation-result.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -110,7 +135,7 @@ public class RelationsTester {
|
||||
qw.where(MENU.PARENT_ID.eq(0));
|
||||
|
||||
List<Menu> menus = menuMapper.selectListWithRelationsByQuery(qw);
|
||||
System.out.println(JSON.toJSONString(menus));
|
||||
assertRelationResult(menus, "relation/result/menu-relation-result.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -120,14 +145,29 @@ public class RelationsTester {
|
||||
|
||||
RelationManager.addIgnoreRelations("parent");
|
||||
List<Menu> menus = menuMapper.selectListWithRelationsByQuery(qw);
|
||||
System.out.println(JSON.toJSONString(menus));
|
||||
assertRelationResult(menus, "relation/result/menu-relation-ignore-parent-result.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPaginate() {
|
||||
Page<Account> accountPage = accountMapper.paginateWithRelations(1, 2, QueryWrapper.create());
|
||||
System.out.println(accountPage);
|
||||
assertRelationResult(accountPage.getRecords(), "relation/result/account-page-relation-result.json");
|
||||
}
|
||||
|
||||
private void assertRelationResult(Object object, String classPath) {
|
||||
String resultJson = writeObject2String(object);
|
||||
String expectJson = getFileAsString(classPath);
|
||||
JsonAssertions.assertThatJson(resultJson).isEqualTo(expectJson);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private String writeObject2String(Object object) {
|
||||
return JSON_MAPPER.writeValueAsString(object);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private String getFileAsString(String classPath) {
|
||||
ClassPathResource resource = new ClassPathResource(classPath);
|
||||
return FileUtils.readFileToString(resource.getFile(), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
@ -19,76 +19,104 @@ import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.core.MybatisFlexBootstrap;
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.audit.ConsoleMessageCollector;
|
||||
import com.mybatisflex.core.datasource.DataSourceKey;
|
||||
import com.mybatisflex.core.keygen.KeyGenerators;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.row.Db;
|
||||
import com.mybatisflex.core.row.Row;
|
||||
import com.mybatisflex.core.row.RowKey;
|
||||
import com.mybatisflex.core.row.RowUtil;
|
||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||
import org.assertj.core.api.WithAssertions;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mybatisflex.test.relation.onetoone.table.AccountTableDef.ACCOUNT;
|
||||
|
||||
public class RowTestStarter {
|
||||
public class RowTest implements WithAssertions {
|
||||
|
||||
private static final String DATA_SOURCE_KEY = "row";
|
||||
|
||||
private EmbeddedDatabase dataSource;
|
||||
|
||||
@BeforeClass
|
||||
public static void init() {
|
||||
DataSource dataSource = new EmbeddedDatabaseBuilder()
|
||||
public static void enableAudit() {
|
||||
AuditManager.setAuditEnable(true);
|
||||
AuditManager.setMessageCollector(new ConsoleMessageCollector());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
dataSource = new EmbeddedDatabaseBuilder()
|
||||
.setType(EmbeddedDatabaseType.H2)
|
||||
.addScript("schema_row.sql")
|
||||
.addScript("data_row.sql")
|
||||
.build();
|
||||
|
||||
MybatisFlexBootstrap.getInstance()
|
||||
.setDataSource(dataSource)
|
||||
new MybatisFlexBootstrap().setDataSource(DATA_SOURCE_KEY, dataSource)
|
||||
.setLogImpl(StdOutImpl.class)
|
||||
.start();
|
||||
|
||||
AuditManager.setAuditEnable(true);
|
||||
AuditManager.setMessageCollector(new ConsoleMessageCollector());
|
||||
DataSourceKey.use(DATA_SOURCE_KEY);
|
||||
}
|
||||
|
||||
@After
|
||||
public void destroy() {
|
||||
this.dataSource.shutdown();
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetRaw(){
|
||||
public void testSetRaw() {
|
||||
Row row = new Row();
|
||||
row.set("user_name","michael");
|
||||
row.setRaw("birthday","now()");
|
||||
row.set("user_name", "michael");
|
||||
row.setRaw("birthday", "now()");
|
||||
|
||||
Db.insert("tb_account",row);
|
||||
Db.insert("tb_account", row);
|
||||
List<Row> rowList = Db.selectAll("tb_account");
|
||||
RowUtil.printPretty(rowList);
|
||||
assertThat(rowList).hasSize(3)
|
||||
.extracting("USER_NAME")
|
||||
.containsOnly("张三", "王麻子叔叔", "michael");
|
||||
// 插入的数据没有 id
|
||||
assertThat(row).doesNotContainKey("id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomRowKey(){
|
||||
public void testCustomRowKey() {
|
||||
RowKey rowKey = RowKey.of("id", KeyType.Generator, KeyGenerators.flexId);
|
||||
|
||||
Row row = Row.ofKey(rowKey);
|
||||
row.set("user_name","michael");
|
||||
row.setRaw("birthday","now()");
|
||||
row.set("user_name", "michael");
|
||||
row.setRaw("birthday", "now()");
|
||||
|
||||
Db.insert("tb_account",row);
|
||||
Db.insert("tb_account", row);
|
||||
List<Row> rowList = Db.selectAll("tb_account");
|
||||
RowUtil.printPretty(rowList);
|
||||
assertThat(rowList).hasSize(3)
|
||||
.extracting("USER_NAME")
|
||||
.containsOnly("张三", "王麻子叔叔", "michael");
|
||||
// 指定了主键生成策略,有 ID 值
|
||||
assertThat(row).containsKey("id")
|
||||
.extracting("id")
|
||||
.isInstanceOf(Long.class);
|
||||
}
|
||||
|
||||
|
||||
//https://gitee.com/mybatis-flex/mybatis-flex/issues/I7W7HQ
|
||||
// https://gitee.com/mybatis-flex/mybatis-flex/issues/I7W7HQ
|
||||
@Test
|
||||
public void testRow01(){
|
||||
public void testGiteeIssue_I7W7HQ() {
|
||||
QueryWrapper qw = QueryWrapper.create().select("id, MAX(`tb_account`.`age`)")
|
||||
.groupBy("id")
|
||||
.from(ACCOUNT);
|
||||
List<Row> rowList = Db.selectListByQuery(qw);
|
||||
RowUtil.printPretty(rowList);
|
||||
assertThat(rowList).hasSize(2)
|
||||
.extracting("MAX(TB_ACCOUNT.AGE)")
|
||||
.containsOnly(18, 19);
|
||||
}
|
||||
|
||||
}
|
||||
@ -19,6 +19,7 @@ package com.mybatisflex.test;
|
||||
import com.mybatisflex.core.MybatisFlexBootstrap;
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.audit.ConsoleMessageCollector;
|
||||
import com.mybatisflex.core.datasource.DataSourceKey;
|
||||
import com.mybatisflex.core.query.QueryChain;
|
||||
import com.mybatisflex.core.update.UpdateChain;
|
||||
import lombok.SneakyThrows;
|
||||
@ -44,6 +45,8 @@ public class UpdateChainTest implements WithAssertions {
|
||||
private AccountMapper accountMapper;
|
||||
private EmbeddedDatabase dataSource;
|
||||
|
||||
private static final String DATA_SOURCE_KEY = "ds2";
|
||||
|
||||
@BeforeClass
|
||||
public static void enableAudit() {
|
||||
AuditManager.setAuditEnable(true);
|
||||
@ -59,16 +62,19 @@ public class UpdateChainTest implements WithAssertions {
|
||||
.build();
|
||||
|
||||
MybatisFlexBootstrap bootstrap = new MybatisFlexBootstrap()
|
||||
.setDataSource(this.dataSource)
|
||||
.setDataSource(DATA_SOURCE_KEY, this.dataSource)
|
||||
.setLogImpl(StdOutImpl.class)
|
||||
.addMapper(AccountMapper.class)
|
||||
.start();
|
||||
|
||||
DataSourceKey.use(DATA_SOURCE_KEY);
|
||||
accountMapper = bootstrap.getMapper(AccountMapper.class);
|
||||
}
|
||||
|
||||
@After
|
||||
public void destroy() {
|
||||
this.dataSource.shutdown();
|
||||
DataSourceKey.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS `tb_account`
|
||||
(
|
||||
`id` INTEGER auto_increment,
|
||||
`id` INTEGER,
|
||||
`user_name` VARCHAR(100),
|
||||
`age` Integer
|
||||
`age` Integer,
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tb_idcard`
|
||||
(
|
||||
`account_id` Integer,
|
||||
@ -13,39 +13,38 @@ CREATE TABLE IF NOT EXISTS `tb_idcard`
|
||||
`content` text
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tb_idcard_mapping`
|
||||
(
|
||||
`account_id` Integer,
|
||||
`idcard_id` Integer
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tb_book`
|
||||
(
|
||||
`id` INTEGER auto_increment,
|
||||
`id` INTEGER,
|
||||
`account_id` Integer,
|
||||
`title` VARCHAR(100),
|
||||
`content` text
|
||||
`content` text,
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tb_role`
|
||||
(
|
||||
`id` INTEGER auto_increment,
|
||||
`name` VARCHAR(100)
|
||||
`id` INTEGER,
|
||||
`name` VARCHAR(100),
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tb_role_mapping`
|
||||
(
|
||||
`account_id` INTEGER ,
|
||||
`account_id` INTEGER ,
|
||||
`role_id` INTEGER
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tb_menu`
|
||||
(
|
||||
`id` INTEGER auto_increment,
|
||||
`parent_id` INTEGER,
|
||||
`name` VARCHAR(100)
|
||||
`id` INTEGER,
|
||||
`parent_id` INTEGER,
|
||||
`name` VARCHAR(100),
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
@ -0,0 +1,85 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": {
|
||||
"3": {
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": [
|
||||
{
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": {
|
||||
"2": {
|
||||
"id": 2,
|
||||
"name": "角色2",
|
||||
"accounts": [
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"3": {
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": [
|
||||
{
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,112 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": {
|
||||
"3": {
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": [
|
||||
{
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": {
|
||||
"2": {
|
||||
"id": 2,
|
||||
"name": "角色2",
|
||||
"accounts": [
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"3": {
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": [
|
||||
{
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"userName": "沙和尚",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"userName": "六耳猕猴",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"userName": "王麻子叔叔",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,155 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "角色1",
|
||||
"accounts": [
|
||||
{
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": [
|
||||
{
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "角色1",
|
||||
"accounts": [
|
||||
{
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "角色2",
|
||||
"accounts": [
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": [
|
||||
{
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"userName": "沙和尚",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": null
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"userName": "六耳猕猴",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": null
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"userName": "王麻子叔叔",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": null
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,138 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"accountId": 1,
|
||||
"title": "图书1",
|
||||
"content": "内容1",
|
||||
"account": {
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": {
|
||||
"3": {
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": []
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"accountId": 2,
|
||||
"title": "图书2",
|
||||
"content": "内容2",
|
||||
"account": {
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": {
|
||||
"2": {
|
||||
"id": 2,
|
||||
"name": "角色2",
|
||||
"accounts": []
|
||||
},
|
||||
"3": {
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": []
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"accountId": 1,
|
||||
"title": "图书3",
|
||||
"content": "内容2",
|
||||
"account": {
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": {
|
||||
"3": {
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": []
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"accountId": 1,
|
||||
"title": "图书4",
|
||||
"content": "内容2",
|
||||
"account": {
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": {
|
||||
"3": {
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": []
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"accountId": 1,
|
||||
"title": "图书5",
|
||||
"content": "内容2",
|
||||
"account": {
|
||||
"id": 1,
|
||||
"userName": "孙悟空",
|
||||
"age": 18,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": {
|
||||
"3": {
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": []
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"accountId": 2,
|
||||
"title": "图书6",
|
||||
"content": "内容2",
|
||||
"account": {
|
||||
"id": 2,
|
||||
"userName": "猪八戒",
|
||||
"age": 19,
|
||||
"idCard": null,
|
||||
"books": [],
|
||||
"roles": [],
|
||||
"rolesMap": {
|
||||
"2": {
|
||||
"id": 2,
|
||||
"name": "角色2",
|
||||
"accounts": []
|
||||
},
|
||||
"3": {
|
||||
"id": 3,
|
||||
"name": "角色3",
|
||||
"accounts": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,90 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"parentId": 0,
|
||||
"name": "顶级菜单1",
|
||||
"parent": null,
|
||||
"children": [
|
||||
{
|
||||
"id": 4,
|
||||
"parentId": 1,
|
||||
"name": "子菜单4",
|
||||
"parent": null,
|
||||
"children": [
|
||||
{
|
||||
"id": 9,
|
||||
"parentId": 4,
|
||||
"name": "子菜单9",
|
||||
"parent": null,
|
||||
"children": null
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"parentId": 4,
|
||||
"name": "子菜单10",
|
||||
"parent": null,
|
||||
"children": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"parentId": 1,
|
||||
"name": "子菜单5",
|
||||
"parent": null,
|
||||
"children": [
|
||||
{
|
||||
"id": 11,
|
||||
"parentId": 5,
|
||||
"name": "子菜单11",
|
||||
"parent": null,
|
||||
"children": null
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"parentId": 5,
|
||||
"name": "子菜单12",
|
||||
"parent": null,
|
||||
"children": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"parentId": 0,
|
||||
"name": "顶级菜单2",
|
||||
"parent": null,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"parentId": 0,
|
||||
"name": "顶级菜单3",
|
||||
"parent": null,
|
||||
"children": [
|
||||
{
|
||||
"id": 6,
|
||||
"parentId": 3,
|
||||
"name": "子菜单6",
|
||||
"parent": null,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"parentId": 3,
|
||||
"name": "子菜单7",
|
||||
"parent": null,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"parentId": 3,
|
||||
"name": "子菜单8",
|
||||
"parent": null,
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,120 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"parentId": 0,
|
||||
"name": "顶级菜单1",
|
||||
"parent": null,
|
||||
"children": [
|
||||
{
|
||||
"id": 4,
|
||||
"parentId": 1,
|
||||
"name": "子菜单4",
|
||||
"parent": {
|
||||
"id": 1,
|
||||
"parentId": 0,
|
||||
"name": "顶级菜单1",
|
||||
"parent": null,
|
||||
"children": null
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": 9,
|
||||
"parentId": 4,
|
||||
"name": "子菜单9",
|
||||
"parent": null,
|
||||
"children": null
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"parentId": 4,
|
||||
"name": "子菜单10",
|
||||
"parent": null,
|
||||
"children": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"parentId": 1,
|
||||
"name": "子菜单5",
|
||||
"parent": {
|
||||
"id": 1,
|
||||
"parentId": 0,
|
||||
"name": "顶级菜单1",
|
||||
"parent": null,
|
||||
"children": null
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": 11,
|
||||
"parentId": 5,
|
||||
"name": "子菜单11",
|
||||
"parent": null,
|
||||
"children": null
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"parentId": 5,
|
||||
"name": "子菜单12",
|
||||
"parent": null,
|
||||
"children": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"parentId": 0,
|
||||
"name": "顶级菜单2",
|
||||
"parent": null,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"parentId": 0,
|
||||
"name": "顶级菜单3",
|
||||
"parent": null,
|
||||
"children": [
|
||||
{
|
||||
"id": 6,
|
||||
"parentId": 3,
|
||||
"name": "子菜单6",
|
||||
"parent": {
|
||||
"id": 3,
|
||||
"parentId": 0,
|
||||
"name": "顶级菜单3",
|
||||
"parent": null,
|
||||
"children": null
|
||||
},
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"parentId": 3,
|
||||
"name": "子菜单7",
|
||||
"parent": {
|
||||
"id": 3,
|
||||
"parentId": 0,
|
||||
"name": "顶级菜单3",
|
||||
"parent": null,
|
||||
"children": null
|
||||
},
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"parentId": 3,
|
||||
"name": "子菜单8",
|
||||
"parent": {
|
||||
"id": 3,
|
||||
"parentId": 0,
|
||||
"name": "顶级菜单3",
|
||||
"parent": null,
|
||||
"children": null
|
||||
},
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -24,15 +24,30 @@
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<commons-io.version>2.15.1</commons-io.version>
|
||||
<org.projectlombok.version>1.18.30</org.projectlombok.version>
|
||||
<!-- 高版本基于 JDK17,勿动 -->
|
||||
<json-unit-assertj.version>2.38.0</json-unit-assertj.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${org.projectlombok.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.javacrumbs.json-unit</groupId>
|
||||
<artifactId>json-unit-assertj</artifactId>
|
||||
<version>${json-unit-assertj.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user