修复字典VO的children注解错误

This commit is contained in:
JerryMa1024 2020-08-18 19:57:31 +08:00
parent f2883e8577
commit c32a441994
3 changed files with 20 additions and 1 deletions

View File

@ -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<Dictionary> children;
}

View File

@ -112,6 +112,7 @@ public class TestEntityListBinder {
// 查询是否创建成功
LambdaQueryWrapper<Dictionary> 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);

View File

@ -312,12 +312,30 @@ public class BaseServiceTest {
List<DictionaryVO> 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<Dictionary> queryWrapper = QueryBuilder.toQueryWrapper(dict);
List<DictionaryVO> voList = dictionaryService.getViewObjectList(queryWrapper, null, DictionaryVO.class);
Assert.assertTrue(voList.size() == 1);
Assert.assertTrue(voList.get(0).getChildren().size() == 2);
List<KeyValue> keyValues = dictionaryService.getKeyValueList("GENDER");
Assert.assertTrue(keyValues.size() == 2);
}
/**
* 测试n-n的批量新建/更新
*/