所有treeData接口增加parentCode参数,获取一级数据。
This commit is contained in:
@@ -219,11 +219,12 @@ public class AreaController extends BaseController {
|
||||
@RequiresPermissions("user")
|
||||
@RequestMapping(value = "treeData")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> treeData(String excludeCode, String isShowCode, String parentCode) {
|
||||
public List<Map<String, Object>> treeData(String excludeCode, String parentCode, String isShowCode) {
|
||||
List<Map<String, Object>> mapList = ListUtils.newArrayList();
|
||||
List<Area> list = null;
|
||||
if (StringUtils.isNotBlank(parentCode)){
|
||||
Area where = new Area();
|
||||
where.setStatus(Area.STATUS_NORMAL);
|
||||
where.setParentCode(parentCode);
|
||||
list = areaService.findList(where);
|
||||
}else{
|
||||
|
||||
@@ -212,6 +212,7 @@ public class CompanyController extends BaseController {
|
||||
/**
|
||||
* 获取公司树结构数据
|
||||
* @param excludeCode 排除的ID
|
||||
* @param parentCode 设置父级编码返回一级
|
||||
* @param isAll 是否显示所有机构(true:不进行权限过滤)
|
||||
* @param isShowCode 是否显示编码(true or 1:显示在左侧;2:显示在右侧;false or null:不显示)
|
||||
* @param isShowFullName 是否显示全公司名称
|
||||
@@ -220,11 +221,14 @@ public class CompanyController extends BaseController {
|
||||
@RequiresPermissions("user")
|
||||
@RequestMapping(value = "treeData")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> treeData(String excludeCode, Boolean isAll, String isShowCode,
|
||||
public List<Map<String, Object>> treeData(String excludeCode, String parentCode, Boolean isAll, String isShowCode,
|
||||
String isShowFullName, String ctrlPermi) {
|
||||
List<Map<String, Object>> mapList = ListUtils.newArrayList();
|
||||
Company where = new Company();
|
||||
where.setStatus(Company.STATUS_NORMAL);
|
||||
if (StringUtils.isNotBlank(parentCode)){
|
||||
where.setParentCode(parentCode);
|
||||
}
|
||||
if (!(isAll != null && isAll) || Global.isStrictMode()){
|
||||
companyService.addDataScopeFilter(where, ctrlPermi);
|
||||
}
|
||||
@@ -254,6 +258,7 @@ public class CompanyController extends BaseController {
|
||||
map.put("code", e.getViewCode());
|
||||
map.put("name", StringUtils.getTreeNodeName(isShowCode, e.getViewCode(), name));
|
||||
map.put("title", e.getFullName());
|
||||
map.put("isParent", !e.getIsTreeLeaf());
|
||||
mapList.add(map);
|
||||
}
|
||||
return mapList;
|
||||
|
||||
@@ -267,8 +267,8 @@ public class OfficeController extends BaseController {
|
||||
|
||||
/**
|
||||
* 获取机构树结构数据
|
||||
* @param excludeCode 排除的ID
|
||||
* @param parentCode 上级Code
|
||||
* @param excludeCode 排除的ID
|
||||
* @param parentCode 设置父级编码返回一级
|
||||
* @param isAll 是否显示所有机构(true:不进行权限过滤)
|
||||
* @param officeTypes 机构类型(1:省级公司;2:市级公司;3:部门)
|
||||
* @param companyCode 仅查询公司下的机构
|
||||
@@ -328,10 +328,8 @@ public class OfficeController extends BaseController {
|
||||
map.put("code", e.getViewCode());
|
||||
map.put("name", StringUtils.getTreeNodeName(isShowCode, e.getViewCode(), name));
|
||||
map.put("title", e.getFullName());
|
||||
// 如果需要加载用户,则处理用户数据
|
||||
if (StringUtils.inString(isLoadUser, "true", "lazy")) {
|
||||
map.put("isParent", true);
|
||||
}
|
||||
// 返回是否是父节点,如果需要加载用户,则全部都是父节点,来加载用户数据
|
||||
map.put("isParent", !e.getIsTreeLeaf() || StringUtils.inString(isLoadUser, "true", "lazy"));
|
||||
mapList.add(map);
|
||||
}
|
||||
// 一次性后台加载用户,若数据量比较大,建议使用懒加载
|
||||
|
||||
@@ -257,15 +257,21 @@ public class ${ClassName}Controller extends BaseController {
|
||||
/**
|
||||
* 获取树结构数据
|
||||
* @param excludeCode 排除的Code
|
||||
* @param parentCode 设置父级编码返回一级
|
||||
* @param isShowCode 是否显示编码(true or 1:显示在左侧;2:显示在右侧;false or null:不显示)
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("${permissionPrefix}:view")
|
||||
@RequestMapping(value = "treeData")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> treeData(String excludeCode, String isShowCode) {
|
||||
public List<Map<String, Object>> treeData(String excludeCode, String parentCode, String isShowCode) {
|
||||
List<Map<String, Object>> mapList = ListUtils.newArrayList();
|
||||
List<${ClassName}> list = ${className}Service.findList(new ${ClassName}());
|
||||
${ClassName} where = new ${ClassName}();
|
||||
where.setStatus(${ClassName}.STATUS_NORMAL);
|
||||
if (StringUtils.isNotBlank(parentCode)){
|
||||
where.setParentCode(parentCode);
|
||||
}
|
||||
List<${ClassName}> list = ${className}Service.findList(where);
|
||||
for (int i=0; i<list.size(); i++){
|
||||
${ClassName} e = list.get(i);
|
||||
<% if (table.statusExists){ %>
|
||||
@@ -287,6 +293,7 @@ public class ${ClassName}Controller extends BaseController {
|
||||
map.put("id", e.getId());
|
||||
map.put("pId", e.getParentCode());
|
||||
map.put("name", StringUtils.getTreeNodeName(isShowCode, e.get${@StringUtils.cap(table.treeViewCodeAttrName)}(), e.get${@StringUtils.cap(table.treeViewNameAttrName)}()));
|
||||
map.put("isParent", !e.getIsTreeLeaf());
|
||||
mapList.add(map);
|
||||
}
|
||||
return mapList;
|
||||
|
||||
@@ -257,15 +257,21 @@ public class ${ClassName}Controller extends BaseController {
|
||||
/**
|
||||
* 获取树结构数据
|
||||
* @param excludeCode 排除的Code
|
||||
* @param parentCode 设置父级编码返回一级
|
||||
* @param isShowCode 是否显示编码(true or 1:显示在左侧;2:显示在右侧;false or null:不显示)
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("${permissionPrefix}:view")
|
||||
@RequestMapping(value = "treeData")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> treeData(String excludeCode, String isShowCode) {
|
||||
public List<Map<String, Object>> treeData(String excludeCode, String parentCode, String isShowCode) {
|
||||
List<Map<String, Object>> mapList = ListUtils.newArrayList();
|
||||
List<${ClassName}> list = ${className}Service.findList(new ${ClassName}());
|
||||
${ClassName} where = new ${ClassName}();
|
||||
where.setStatus(${ClassName}.STATUS_NORMAL);
|
||||
if (StringUtils.isNotBlank(parentCode)){
|
||||
where.setParentCode(parentCode);
|
||||
}
|
||||
List<${ClassName}> list = ${className}Service.findList(where);
|
||||
for (int i=0; i<list.size(); i++){
|
||||
${ClassName} e = list.get(i);
|
||||
<% if (table.statusExists){ %>
|
||||
@@ -287,6 +293,7 @@ public class ${ClassName}Controller extends BaseController {
|
||||
map.put("id", e.getId());
|
||||
map.put("pId", e.getParentCode());
|
||||
map.put("name", StringUtils.getTreeNodeName(isShowCode, e.get${@StringUtils.cap(table.treeViewCodeAttrName)}(), e.get${@StringUtils.cap(table.treeViewNameAttrName)}()));
|
||||
map.put("isParent", !e.getIsTreeLeaf());
|
||||
mapList.add(map);
|
||||
}
|
||||
return mapList;
|
||||
|
||||
@@ -155,15 +155,21 @@ public class ${ClassName}Controller extends BaseController {
|
||||
/**
|
||||
* 获取树结构数据
|
||||
* @param excludeCode 排除的Code
|
||||
* @param parentCode 设置父级编码返回一级
|
||||
* @param isShowCode 是否显示编码(true or 1:显示在左侧;2:显示在右侧;false or null:不显示)
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("${permissionPrefix}:view")
|
||||
@RequestMapping(value = "treeData")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> treeData(String excludeCode, String isShowCode) {
|
||||
public List<Map<String, Object>> treeData(String excludeCode, String parentCode, String isShowCode) {
|
||||
List<Map<String, Object>> mapList = ListUtils.newArrayList();
|
||||
List<${ClassName}> list = ${className}Service.findList(new ${ClassName}());
|
||||
${ClassName} where = new ${ClassName}();
|
||||
where.setStatus(${ClassName}.STATUS_NORMAL);
|
||||
if (StringUtils.isNotBlank(parentCode)){
|
||||
where.setParentCode(parentCode);
|
||||
}
|
||||
List<${ClassName}> list = ${className}Service.findList(where);
|
||||
for (int i=0; i<list.size(); i++){
|
||||
${ClassName} e = list.get(i);
|
||||
<% if (table.statusExists){ %>
|
||||
@@ -185,6 +191,7 @@ public class ${ClassName}Controller extends BaseController {
|
||||
map.put("id", e.getId());
|
||||
map.put("pId", e.getParentCode());
|
||||
map.put("name", StringUtils.getTreeNodeName(isShowCode, e.get${@StringUtils.cap(table.treeViewCodeAttrName)}(), e.get${@StringUtils.cap(table.treeViewNameAttrName)}()));
|
||||
map.put("isParent", !e.getIsTreeLeaf());
|
||||
mapList.add(map);
|
||||
}
|
||||
return mapList;
|
||||
|
||||
Reference in New Issue
Block a user