优化菜单管理、商品分类查询节点的性能
This commit is contained in:
@ -128,6 +128,7 @@ public class YxStoreCategoryServiceImpl implements YxStoreCategoryService {
|
|||||||
|
|
||||||
YxStoreCategoryDTO categoryDTO = new YxStoreCategoryDTO();
|
YxStoreCategoryDTO categoryDTO = new YxStoreCategoryDTO();
|
||||||
Boolean isChild;
|
Boolean isChild;
|
||||||
|
List<YxStoreCategory> categories = yxStoreCategoryRepository.findAll();
|
||||||
for (YxStoreCategoryDTO deptDTO : categoryDTOS) {
|
for (YxStoreCategoryDTO deptDTO : categoryDTOS) {
|
||||||
isChild = false;
|
isChild = false;
|
||||||
if ("0".equals(deptDTO.getPid().toString())) {
|
if ("0".equals(deptDTO.getPid().toString())) {
|
||||||
@ -144,8 +145,11 @@ public class YxStoreCategoryServiceImpl implements YxStoreCategoryService {
|
|||||||
}
|
}
|
||||||
if(isChild)
|
if(isChild)
|
||||||
cates.add(deptDTO);
|
cates.add(deptDTO);
|
||||||
else if(!deptNames.contains(yxStoreCategoryRepository.findNameById(deptDTO.getPid())))
|
for (YxStoreCategory category : categories) {
|
||||||
cates.add(deptDTO);
|
if(category.getId()==deptDTO.getPid()&&!deptNames.contains(category.getCateName())){
|
||||||
|
cates.add(deptDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ public class DeptServiceImpl implements DeptService {
|
|||||||
Set<DeptDTO> depts= new LinkedHashSet<>();
|
Set<DeptDTO> depts= new LinkedHashSet<>();
|
||||||
List<String> deptNames = deptDtos.stream().map(DeptDTO::getName).collect(Collectors.toList());
|
List<String> deptNames = deptDtos.stream().map(DeptDTO::getName).collect(Collectors.toList());
|
||||||
boolean isChild;
|
boolean isChild;
|
||||||
|
List<Dept> deptList = deptRepository.findAll();
|
||||||
for (DeptDTO deptDTO : deptDtos) {
|
for (DeptDTO deptDTO : deptDtos) {
|
||||||
isChild = false;
|
isChild = false;
|
||||||
if ("0".equals(deptDTO.getPid().toString())) {
|
if ("0".equals(deptDTO.getPid().toString())) {
|
||||||
@ -88,8 +89,11 @@ public class DeptServiceImpl implements DeptService {
|
|||||||
}
|
}
|
||||||
if(isChild) {
|
if(isChild) {
|
||||||
depts.add(deptDTO);
|
depts.add(deptDTO);
|
||||||
} else if(!deptNames.contains(deptRepository.findNameById(deptDTO.getPid()))) {
|
for (Dept dept : deptList) {
|
||||||
depts.add(deptDTO);
|
if(dept.getId() == deptDTO.getPid() && !deptNames.contains(dept.getName())){
|
||||||
|
depts.add(deptDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user