Browse Source

阿米吧修改下级同步修改开发

anderx 3 years ago
parent
commit
98695c18d1

+ 12 - 1
src/main/java/com/goafanti/ambSystem/service/Impl/AmbServiceImpl.java

@@ -42,14 +42,25 @@ public class AmbServiceImpl extends BaseMybatisDao<AmbSystemMapper> implements A
 
     @Override
     public int updateAmb(InputAmb in) {
-        if (in.getParentId()!=null){
+        AmbSystem use = ambSystemMapper.selectByPrimaryKey(in.getId());
+        int i=0;
+        if (in.getParentId()!=use.getParentId()){
             getParentParam(in);
+            i=updateAncestorsNames(in,use.getName(),i);
+        }
+        if (!in.getName().equals(use.getName())){
+            i=updateAncestorsNames(in,use.getName(),i);
         }
         in.setUpdateBy(TokenManager.getAdminId());
         in.setUpdateTime(new Date());
         return ambSystemMapper.updateByPrimaryKeySelective(in);
     }
 
+    private int updateAncestorsNames(InputAmb in,String useName,Integer i) {
+        if (i>0)return i;
+        return ambSystemMapper.updateAncestorsNames(in.getId(),in.getName(),useName);
+    }
+
     @Override
     public Pagination<OutAmb> selectAmb(InputAmb in) {
         HashMap<String, Object> param = new HashMap<>();

+ 4 - 1
src/main/java/com/goafanti/common/dao/AmbSystemMapper.java

@@ -1,9 +1,9 @@
 package com.goafanti.common.dao;
 
 import com.goafanti.ambSystem.bo.AmbAll;
-import com.goafanti.ambSystem.bo.OutAmb;
 import com.goafanti.ambSystem.bo.OutAmbDtails;
 import com.goafanti.common.model.AmbSystem;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -27,4 +27,7 @@ public interface AmbSystemMapper {
     int selectByName(String name);
 
     OutAmbDtails selectDtailsAmb(Long id);
+
+
+    int updateAncestorsNames(@Param(value = "id") Long id, @Param(value = "name")String name, @Param(value = "useName")String useName);
 }

+ 5 - 0
src/main/java/com/goafanti/common/mapper/AmbSystemMapper.xml

@@ -214,6 +214,11 @@
       remarks = #{remarks,jdbcType=VARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>
+  <update id="updateAncestorsNames">
+    update amb_system
+    set  ancestors_names=replace(ancestors_names,#{useName},#{name})
+    where FIND_IN_SET( #{id},ancestors)
+  </update>
 
   <select id="getAncestorsList" resultType="com.goafanti.ambSystem.bo.AmbAll">
     select id,name,lvl,parent_id parentId