工具类:
public String getNewModCode(String parentCode,String behindNum) {
String newCode = "";
int x = 0;
List<String> codeList = sysModuleMapper.getAllModCode(parentCode);
if(codeList.size()>0){
x = Integer.valueOf(codeList.get(codeList.size()-1))-Integer.valueOf(codeList.get(0))+1;
if(codeList.get(0).equals(behindNum)){
if(codeList.size()<x){
for(int i=0;i<codeList.size();i++){
if(Integer.valueOf(codeList.get(i))+1==Integer.valueOf(codeList.get(i+1))){
continue;
}else{
behindNum = Integer.valueOf(Integer.valueOf(codeList.get(i))+1).toString();
break;
}
}
}else{
behindNum = Integer.valueOf(Integer.valueOf(codeList.get(codeList.size()-1))+1).toString();
}
}
}
if(parentCode.length()>1){
newCode = parentCode + behindNum;
}else{
newCode = behindNum;
}
return newCode;
}
SQL:
select s.mod_code from sys_module s where s.parent_code=#{parentCode} order by s.mod_code asc使用于小数据量的菜单,机构数据添加,注意:999+1
最后
以上就是背后钥匙最近收集整理的关于根据父级ID生成一个数据库不重复的新ID,(补漏,开头删除,中间删除,的ID都可以按顺序补上)的全部内容,更多相关根据父级ID生成一个数据库不重复内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复