Commit a359c670 by 阳浪

通过父类code查询当前数据字典下的子节点

parent 4892d01e
...@@ -3,6 +3,7 @@ package com.yizhi.system.application.controller.remote; ...@@ -3,6 +3,7 @@ package com.yizhi.system.application.controller.remote;
import java.util.List; import java.util.List;
import com.google.common.collect.Lists;
import com.yizhi.application.orm.util.DomainConverter; import com.yizhi.application.orm.util.DomainConverter;
import com.yizhi.system.application.vo.domain.Dictionary; import com.yizhi.system.application.vo.domain.Dictionary;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -335,6 +336,36 @@ public class DictionaryController { ...@@ -335,6 +336,36 @@ public class DictionaryController {
} }
/**
* 查询当前数据字典下的子节点
*
* @param code 要查找的对象的父节点
* @param includeParent 是否包含父节点(id对应的自身节点),true:包含,false:不包含,默认false
* @param layer 以id对应对象为第0层,查询多少层子节点,默认1层
* @return
*/
@ApiOperation(value = "数据字典", notes = "通过父类code查询当前数据字典下的子节点", response = Response.class)
@GetMapping(value = "/child/listByCode")
public Response<List<Dictionary>> listChildDictionary(
@ApiParam("要查找的对象的父节点") @RequestParam(name = "code", defaultValue = "0") String code,
@ApiParam("是否包含父节点(id对应的自身节点),</br>true:包含,</br>false:不包含,默认false") @RequestParam(name = "includeParent", defaultValue = "false") Boolean includeParent,
@ApiParam("以id对应对象为第0层,查询多少层子节点,默认1层") @RequestParam(name = "layer", defaultValue = "1") Integer layer
) {
try {
com.yizhi.system.application.domain.Dictionary dictionary = dictionaryService.findByCode(code);
if(dictionary==null){
return Response.ok(Lists.newArrayList());
}
List<com.yizhi.system.application.domain.Dictionary> result = dictionaryService.listChildren(dictionary.getId(), includeParent, layer);
List<Dictionary> list = domainConverter.toDOList(result, Dictionary.class);
return Response.ok(list);
} catch (Exception e) {
LOG.error("", e);
return Response.fail(ReturnCode.SERVICE_UNAVAILABLE.getCode(),ReturnCode.SERVICE_UNAVAILABLE.getMsg());
}
}
/** /**
* 检查该字典下是否有子数据 * 检查该字典下是否有子数据
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment