Commit 8e8caa9b authored by chenzhao's avatar chenzhao

修改动态操作集合可能会造成的安全问题

parent 55879c88
......@@ -10,13 +10,13 @@ import com.yeejoin.amos.boot.module.common.api.mapper.SpecialPositionStaffMapper
import com.yeejoin.amos.boot.module.common.api.service.ISpecialPositionStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* 特岗人员服务实现类
......@@ -70,32 +70,24 @@ public class SpecialPositionStaffServiceImpl extends BaseService<SpecialPosition
List<Long> positionStaffCodeList = this.baseMapper.getPositionStaffCodeList(false,companyId);
// 排除已有数据的,返回
/*bug 3483 陈召 2021-11-18 开始*/
List<MenuFrom> menuListds=new ArrayList<>();
for (int i = 0; i < menuList.size(); i++) {
//排除父岗位是否已有 有就删除
if (positionStaffCodeList.contains(Long.valueOf(menuList.get(i).getKey()))) {
menuList.remove(i);
i--;
}
//排除子岗位是否已有 有就删除
if (null != menuList.get(i).getChildren() && menuList.get(i).getChildren().size() > 0){
List<MenuFrom> children = menuList.get(i).getChildren();
for (int j= 0; j < children.size(); j++) {
if (positionStaffCodeList.contains(Long.valueOf(children.get(j).getKey()))) {
menuList.get(i).getChildren().remove(j);
j--;
}
//当子岗位全部删除时 父岗位也删除
if (children.size() == 0){
menuList.remove(i);
i--;
}
//排除父岗位是否已有 有就删除
List<MenuFrom> dataList = menuList.stream().filter(e -> !positionStaffCodeList.contains(Long.valueOf(e.getKey()))).collect(Collectors.toList());
for (ListIterator<MenuFrom> iterator = dataList.listIterator();iterator.hasNext();){
MenuFrom next = iterator.next();
if (null != next.getChildren() && next.getChildren().size() > 0) {
//排除子岗位是否已有 有就删除
List<MenuFrom> newChildren = next.getChildren().stream().filter(e -> !positionStaffCodeList.contains(Long.valueOf(e.getKey()))).collect(Collectors.toList());
//当子岗位全部删除时 父岗位也删除
if (ValidationUtil.isEmpty(newChildren)){
iterator.remove();
} else {
next.setChildren(newChildren);
}
}
}
/*bug 3483 陈召 2021-11-18 结束*/
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("GWMC", menuList);
objectObjectHashMap.put("GWMC", dataList);
return objectObjectHashMap;
}
}
\ No newline at end of file
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