优化菜单管理、商品分类查询节点的性能

This commit is contained in:
xwb
2020-04-30 10:32:04 +08:00
parent 8ec7c94516
commit c9ce5fffe0
2 changed files with 14 additions and 6 deletions

View File

@ -128,6 +128,7 @@ public class YxStoreCategoryServiceImpl implements YxStoreCategoryService {
YxStoreCategoryDTO categoryDTO = new YxStoreCategoryDTO();
Boolean isChild;
List<YxStoreCategory> categories = yxStoreCategoryRepository.findAll();
for (YxStoreCategoryDTO deptDTO : categoryDTOS) {
isChild = false;
if ("0".equals(deptDTO.getPid().toString())) {
@ -144,8 +145,11 @@ public class YxStoreCategoryServiceImpl implements YxStoreCategoryService {
}
if(isChild)
cates.add(deptDTO);
else if(!deptNames.contains(yxStoreCategoryRepository.findNameById(deptDTO.getPid())))
cates.add(deptDTO);
for (YxStoreCategory category : categories) {
if(category.getId()==deptDTO.getPid()&&!deptNames.contains(category.getCateName())){
cates.add(deptDTO);
}
}
}
@ -164,4 +168,4 @@ public class YxStoreCategoryServiceImpl implements YxStoreCategoryService {
return map;
//return null;
}
}
}

View File

@ -72,6 +72,7 @@ public class DeptServiceImpl implements DeptService {
Set<DeptDTO> depts= new LinkedHashSet<>();
List<String> deptNames = deptDtos.stream().map(DeptDTO::getName).collect(Collectors.toList());
boolean isChild;
List<Dept> deptList = deptRepository.findAll();
for (DeptDTO deptDTO : deptDtos) {
isChild = false;
if ("0".equals(deptDTO.getPid().toString())) {
@ -88,8 +89,11 @@ public class DeptServiceImpl implements DeptService {
}
if(isChild) {
depts.add(deptDTO);
} else if(!deptNames.contains(deptRepository.findNameById(deptDTO.getPid()))) {
depts.add(deptDTO);
for (Dept dept : deptList) {
if(dept.getId() == deptDTO.getPid() && !deptNames.contains(dept.getName())){
depts.add(deptDTO);
}
}
}
}
@ -158,4 +162,4 @@ public class DeptServiceImpl implements DeptService {
}
return deptDtos;
}
}
}