chendayu 2 lat temu
rodzic
commit
d2d6b86ce2

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/mapper/StructureMapper.java

@@ -55,7 +55,7 @@ public interface StructureMapper extends BaseMapper<Structure> {
      * @param structureId   架构id
      * @return 返回统计到的数量
      */
-    int countByparentIdAndStructureName(Integer parentId, String structureName, Integer structureId);
+    int countByparentIdAndStructureName(Integer productId, Integer parentId, String structureName, Integer structureId);
 
     /**
      * 根据id查询数据

+ 4 - 2
PAS/src/main/java/cn/cslg/pas/service/impl/StructureServiceImpl.java

@@ -62,9 +62,10 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
 
         Integer parentId = structureAddNewDTO.getParentId();
         String structureName = structureAddNewDTO.getStructureName();
+        Integer productId = structureAddNewDTO.getProductId();
         //检查名称是否被占用(检查当前架构父级下是否有同名架构)
         log.info("检查名称是否被占用(检查当前父级下是否有同名架构)");
-        int count = structureMapper.countByparentIdAndStructureName(parentId, structureName, null);
+        int count = structureMapper.countByparentIdAndStructureName(productId, parentId, structureName, null);
         if (count > 0) {
             String message = "新增架构失败,当前父级下已存在【" + structureName + "】,请尝试更换名称";
             log.info("{}", message);
@@ -159,10 +160,11 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
         String newPath = structureUpdateDTO.getParentPath() + "," + structureId;
         //获取DTO中该架构当前名称
         String newStructureName = structureUpdateDTO.getStructureName();
+        Integer productId = structureUpdateDTO.getProductId();
 
         //检查名称是否被占用(检查当前尝试修改的架构父级下是否有同名架构)
         log.info("检查名称是否被占用(检查当前尝试修改的架构的新父级下是否有同名架构)");
-        int count = structureMapper.countByparentIdAndStructureName(newParentId, newStructureName, structureId);
+        int count = structureMapper.countByparentIdAndStructureName(productId, newParentId, newStructureName, structureId);
         if (count > 0) {
             String message = "修改架构失败,当前尝试修改的架构父级下已存在【" + newStructureName + "】,请尝试更换名称";
             log.info("{}", message);

+ 3 - 2
PAS/src/main/resources/mapper/StructureMapper.xml

@@ -61,7 +61,8 @@
         select count(*)
         from structure
         where
-        parent_id = #{parentId}
+        product_id = #{productId}
+        and parent_id = #{parentId}
         and structure_name = #{structureName}
         <if test="structureId != null">
             and id != #{structureId}
@@ -109,7 +110,7 @@
     <!--        where id = #{id}-->
     <!--    </select>-->
     <select id="getStandardAndPictureById" resultMap="selectTreeMap">
-        select stru.id as stru_id,
+        select stru.id                         as stru_id,
                stru.parent_id,
                stru.structure_name,
                stru.path,