From 6371c43df25a8c9ad6b63b84f00191418b69c9b5 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期四, 22 五月 2025 15:35:27 +0800 Subject: [PATCH] 配置禁止热部署启动 --- pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/util/PrivilegeListener.java | 41 +++++++++++++++++++++++++++++++---------- 1 files changed, 31 insertions(+), 10 deletions(-) diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/util/PrivilegeListener.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/util/PrivilegeListener.java index d8d7aa5..b12e7f1 100644 --- a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/util/PrivilegeListener.java +++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/util/PrivilegeListener.java @@ -1,13 +1,10 @@ package com.dy.pmsBase.util; import com.dy.common.util.ConfigXml; -import com.dy.common.util.MD5; import com.dy.common.util.NumUtil; import com.dy.common.webListener.ConfigListener; import com.dy.pmsGlobal.daoBa.BaPrivilegeMapper; -import com.dy.pmsGlobal.daoBa.BaPrivilegeMapper; import com.dy.pmsGlobal.pojoBa.BaPrivilege; -import com.dy.pmsGlobal.pojoBa.BaUser; import org.jdom2.Document; import org.jdom2.Element; import org.springframework.beans.factory.annotation.Autowired; @@ -48,9 +45,12 @@ } catch (InterruptedException e) { e.printStackTrace(); }finally { + /* if(!this.existPrivileges()){ this.init(event); } + */ + this.init(event); } } @@ -76,11 +76,16 @@ if(prs != null){ List<Element> list = prs.getChildren() ; if(list != null){ - for(Element ele : list){ - String num = ele.getAttributeValue("num") ; - String name = ele.getAttributeValue("name") ; - String type = ele.getAttributeValue("type") ; - this.savePrivilege(num, name, type); + Long totalInDb = this.countTotalPrivileges() ; + if(list.size() != totalInDb){ + this.deleteAllPrivilegesInDb(); + for(Element ele : list){ + String num = ele.getAttributeValue("num") ; + String name = ele.getAttributeValue("name") ; + String type = ele.getAttributeValue("type") ; + String typeName = ele.getAttributeValue("typeName") ; + this.savePrivilege(num, name, type,typeName); + } } } } @@ -89,7 +94,7 @@ /** - * 鏁版嵁搴撲腑鏄惁瀛樺湪琛屾斂鍖哄垝鏁版嵁 + * 鏁版嵁搴撲腑鏄惁瀛樺湪鐩稿叧鏁版嵁 * @return 瀛樺湪鍚� */ private boolean existPrivileges(){ @@ -97,14 +102,29 @@ return (total != null && total > 0) ; } + /** + * 鏁版嵁搴撲腑鏄惁瀛樺湪鐩稿叧鏁版嵁 + * @return 瀛樺湪鍚� + */ + private Long countTotalPrivileges(){ + return this.privilegeDao.selectCount() ; + } + + /** + * 鏁版嵁搴撲腑鏄惁瀛樺湪鐩稿叧鏁版嵁 + * @return 瀛樺湪鍚� + */ + private void deleteAllPrivilegesInDb(){ + this.privilegeDao.deleteAll() ; + } /** * 淇濆瓨鏉冮檺 * @param name 缂栫爜 * @param name 鍚嶇О * @param type 绫诲瀷 */ - private void savePrivilege(String num, String name, String type) throws Exception{ + private void savePrivilege(String num, String name, String type,String typeName) throws Exception{ if((num != null && !num.trim().equals("")) && (name != null && !name.trim().equals("")) && (type != null && !type.trim().equals(""))){ @@ -113,6 +133,7 @@ po.num = Integer.parseInt(num) ; po.name = name ; po.type = Integer.parseInt(type) ; + po.typeName = typeName ; this.privilegeDao.insertSelective(po) ; } } -- Gitblit v1.8.0