diff --git a/diboot-core/src/main/java/com/diboot/core/vo/DictionaryVO.java b/diboot-core/src/main/java/com/diboot/core/vo/DictionaryVO.java index f00514b..04c3cac 100644 --- a/diboot-core/src/main/java/com/diboot/core/vo/DictionaryVO.java +++ b/diboot-core/src/main/java/com/diboot/core/vo/DictionaryVO.java @@ -31,7 +31,7 @@ import java.util.List; @Accessors(chain = true) public class DictionaryVO extends Dictionary { - @BindEntityList(entity= Dictionary.class, condition="this.type=type AND parent_id>0") + @BindEntityList(entity= Dictionary.class, condition="this.type=type AND this.id=parent_id") private List children; } diff --git a/diboot-core/src/test/java/diboot/core/test/binder/TestEntityListBinder.java b/diboot-core/src/test/java/diboot/core/test/binder/TestEntityListBinder.java index a1b3d04..fcb029f 100644 --- a/diboot-core/src/test/java/diboot/core/test/binder/TestEntityListBinder.java +++ b/diboot-core/src/test/java/diboot/core/test/binder/TestEntityListBinder.java @@ -112,6 +112,7 @@ public class TestEntityListBinder { // 查询是否创建成功 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Dictionary::getType, "GENDER"); + queryWrapper.eq(Dictionary::getParentId, 0L); Dictionary dictionary = dictionaryService.getSingleEntity(queryWrapper); DictionaryVO vo = Binder.convertAndBindRelations(dictionary, DictionaryVO.class); diff --git a/diboot-core/src/test/java/diboot/core/test/service/BaseServiceTest.java b/diboot-core/src/test/java/diboot/core/test/service/BaseServiceTest.java index a6f3a94..21daa86 100644 --- a/diboot-core/src/test/java/diboot/core/test/service/BaseServiceTest.java +++ b/diboot-core/src/test/java/diboot/core/test/service/BaseServiceTest.java @@ -312,12 +312,30 @@ public class BaseServiceTest { List voList = dictionaryService.getViewObjectList(queryWrapper, pagination, DictionaryVO.class); Assert.assertTrue(voList.size() == 1); Assert.assertTrue(pagination.getTotalPage() >= 2); + Assert.assertTrue(V.isEmpty(voList.get(0).getChildren())); pagination.setPageIndex(2); voList = dictionaryService.getViewObjectList(queryWrapper, pagination, DictionaryVO.class); Assert.assertTrue(voList.size() == 1); } + @Test + public void testDictVo(){ + Dictionary dict = new Dictionary(); + dict.setParentId(0L); + dict.setType("GENDER"); + dict.setEditable(true); + + QueryWrapper queryWrapper = QueryBuilder.toQueryWrapper(dict); + + List voList = dictionaryService.getViewObjectList(queryWrapper, null, DictionaryVO.class); + Assert.assertTrue(voList.size() == 1); + Assert.assertTrue(voList.get(0).getChildren().size() == 2); + + List keyValues = dictionaryService.getKeyValueList("GENDER"); + Assert.assertTrue(keyValues.size() == 2); + } + /** * 测试n-n的批量新建/更新 */