5.2升级包
This commit is contained in:
parent
aa5bd09acf
commit
8db9504a60
|
@ -1,13 +1,16 @@
|
||||||
package net.mingsoft.cms.upgrade;
|
package net.mingsoft.cms.upgrade;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
import net.mingsoft.basic.util.BasicUtil;
|
import net.mingsoft.basic.util.BasicUtil;
|
||||||
import net.mingsoft.basic.util.SpringUtil;
|
import net.mingsoft.basic.util.SpringUtil;
|
||||||
import net.mingsoft.cms.biz.ICategoryBiz;
|
import net.mingsoft.cms.biz.ICategoryBiz;
|
||||||
import net.mingsoft.cms.entity.CategoryEntity;
|
import net.mingsoft.cms.entity.CategoryEntity;
|
||||||
import net.mingsoft.basic.util.PinYinUtil;
|
import net.mingsoft.basic.util.PinYinUtil;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author by 铭飞开源团队
|
* @author by 铭飞开源团队
|
||||||
|
@ -17,29 +20,44 @@ import java.util.List;
|
||||||
public class Upgrade {
|
public class Upgrade {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单拼音升级
|
* 更新栏目分类的顶级节点和叶子节点
|
||||||
*/
|
*/
|
||||||
public void upgrade(){
|
public void upgrade(){
|
||||||
ICategoryBiz categoryBiz = SpringUtil.getBean(ICategoryBiz.class);
|
ICategoryBiz categoryBiz = SpringUtil.getBean(ICategoryBiz.class);
|
||||||
List<CategoryEntity> list = categoryBiz.queryAll();
|
List<CategoryEntity> list = categoryBiz.queryAll();
|
||||||
//先更新所有栏目的拼音
|
|
||||||
list.forEach(x->{
|
list.forEach(x->{
|
||||||
String pingYin = PinYinUtil.getPingYin(x.getCategoryTitle());
|
|
||||||
CategoryEntity category=new CategoryEntity();
|
//将parentId第一行设为顶级节点
|
||||||
category.setCategoryPinyin(pingYin);
|
String topId = "0";
|
||||||
CategoryEntity categoryBizEntity = (CategoryEntity)categoryBiz.getEntity(category);
|
String parentId = x.getParentid();
|
||||||
x.setCategoryPinyin(pingYin);
|
if (parentId != null) {
|
||||||
//拼音存在则拼接id
|
topId = parentId.split(",")[0];
|
||||||
if(categoryBizEntity!=null&&!categoryBizEntity.getId().equals(x.getId())){
|
|
||||||
x.setCategoryPinyin(pingYin+x.getId());
|
|
||||||
}
|
}
|
||||||
categoryBiz.update(x);
|
x.setTopId(topId);
|
||||||
});
|
|
||||||
//再更新路径
|
String id = x.getId();
|
||||||
list.forEach(x->{
|
boolean leaf = true;
|
||||||
if(StrUtil.isBlank(x.getCategoryId())||x.getCategoryId().equals("0")){
|
//判断是否叶子,循环查找,如果有节点的父节点中包含该节点的id则判断为否跳出循环
|
||||||
categoryBiz.updateEntity(x);
|
for (int i = 0; i< list.size(); i++) {
|
||||||
|
String pId = list.get(i).getParentid();
|
||||||
|
if (pId == null) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
leaf = !pId.contains(id);
|
||||||
|
//如果不是叶子就跳出循环,不需要再判断了
|
||||||
|
if (!leaf) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x.setLeaf(leaf);
|
||||||
|
//更新
|
||||||
|
Map<String, String> fields = new HashMap<>();
|
||||||
|
fields.put("leaf", x.getLeaf()?"1":"0");
|
||||||
|
fields.put("top_id", x.getTopId());
|
||||||
|
Map<String, String> where = new HashMap<>();
|
||||||
|
where.put("id", x.getId());
|
||||||
|
categoryBiz.updateBySQL("cms_category", fields, where);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,12 @@ public class AppHandler implements TenantLineHandler {
|
||||||
if(localPage!=null&&localPage.getTotal()==0){
|
if(localPage!=null&&localPage.getTotal()==0){
|
||||||
PageHelper.clearPage();
|
PageHelper.clearPage();
|
||||||
}
|
}
|
||||||
int appId = BasicUtil.getAppId();
|
//int appId = BasicUtil.getAppId();
|
||||||
if(localPage!=null&&localPage.getTotal()==0){
|
if(localPage!=null&&localPage.getTotal()==0){
|
||||||
PageHelper.startPage(localPage.getPageNum(),localPage.getPageSize(),localPage.isCount());
|
PageHelper.startPage(localPage.getPageNum(),localPage.getPageSize(),localPage.isCount());
|
||||||
PageHelper.orderBy(localPage.getOrderBy());
|
PageHelper.orderBy(localPage.getOrderBy());
|
||||||
}
|
}
|
||||||
return new LongValue(appId);
|
return new LongValue(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue