chendayu 2 năm trước cách đây
mục cha
commit
4113db9fd6

+ 26 - 0
PAS/src/main/java/cn/cslg/pas/common/model/dto/QueryPathStructureNameDTO.java

@@ -0,0 +1,26 @@
+package cn.cslg.pas.common.model.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 查询所有架构的路径和路径拼接成的架构名称
+ *
+ * @Author chenyu
+ * @Date 2023/3/16
+ */
+@Accessors(chain = true)
+@Data
+public class QueryPathStructureNameDTO implements Serializable {
+    /**
+     * 产品id
+     */
+    private Integer productId;
+    /**
+     * 架构id
+     */
+    private Integer structureId;
+
+}

+ 5 - 4
PAS/src/main/java/cn/cslg/pas/controller/StructureController.java

@@ -1,6 +1,7 @@
 package cn.cslg.pas.controller;
 
 import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.model.dto.QueryPathStructureNameDTO;
 import cn.cslg.pas.common.model.dto.StructureAddNewDTO;
 import cn.cslg.pas.common.model.dto.StructureQueryPageDTO;
 import cn.cslg.pas.common.model.dto.StructureUpdateDTO;
@@ -74,10 +75,10 @@ public class StructureController {
     }
 
     @Operation(summary = "查询拼接路径名")
-    @GetMapping("/queryPathStructureName")
-    public String queryPathStructureName(Integer productId) {
-        log.info("开始处理【查询所有架构路径和路径架构名称】的业务,参数为:{}", productId);
-        List<PathStructureNameVO> queryResults = structureService.queryPathStructureName(productId);
+    @PostMapping("/queryPathStructureName")
+    public String queryPathStructureName(@RequestBody QueryPathStructureNameDTO queryPathStructureNameDTO) {
+        log.info("开始处理【查询所有架构路径和路径架构名称】的业务,参数为:{}", queryPathStructureNameDTO);
+        List<PathStructureNameVO> queryResults = structureService.queryPathStructureName(queryPathStructureNameDTO);
         return Response.success(queryResults);
     }
 

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

@@ -98,4 +98,12 @@ public interface StructureMapper extends BaseMapper<Structure> {
      */
     List<StructureVO> selectAllByProductId(Integer productId);
 
+    /**
+     * 根据架构id查询数据
+     *
+     * @param structureId 架构id
+     * @return 返回查询到的数据
+     */
+    List<StructureVO> selectAllByStructureId(Integer structureId);
+
 }

+ 3 - 1
PAS/src/main/java/cn/cslg/pas/service/IStructureService.java

@@ -1,5 +1,6 @@
 package cn.cslg.pas.service;
 
+import cn.cslg.pas.common.model.dto.QueryPathStructureNameDTO;
 import cn.cslg.pas.common.model.dto.StructureAddNewDTO;
 import cn.cslg.pas.common.model.dto.StructureQueryPageDTO;
 import cn.cslg.pas.common.model.dto.StructureUpdateDTO;
@@ -48,9 +49,10 @@ public interface IStructureService {
     /**
      * 查询所有架构的路径和路径拼接成的架构名称
      *
+     * @param queryPathStructureNameDTO   数据DTO对象
      * @return 返回查询到的数据
      */
-    List<PathStructureNameVO> queryPathStructureName(Integer productId);
+    List<PathStructureNameVO> queryPathStructureName(QueryPathStructureNameDTO queryPathStructureNameDTO);
 
     /**
      * 删除架构

+ 12 - 3
PAS/src/main/java/cn/cslg/pas/service/impl/StructureServiceImpl.java

@@ -319,17 +319,26 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
     /**
      * 查询所有架构的路径和路径拼接成的架构名称
      *
+     * @param queryPathStructureNameDTO   数据DTO对象
      * @return 返回查询到的数据
      */
     @Override
-    public List<PathStructureNameVO> queryPathStructureName(Integer productId) {
-        log.info("开始处理【查询所有架构路径和路径架构名称】的业务,参数为:{}", productId);
+    public List<PathStructureNameVO> queryPathStructureName(QueryPathStructureNameDTO queryPathStructureNameDTO) {
+        log.info("开始处理【查询所有架构路径和路径架构名称】的业务,参数为:{}", queryPathStructureNameDTO);
+        Integer productId = queryPathStructureNameDTO.getProductId();
+        Integer structureId = queryPathStructureNameDTO.getStructureId();
 
         ArrayList<PathStructureNameVO> pathStructureNames = new ArrayList<>();
 
         log.info("根据产品id查询所有架构数据");
         HashMap<String, String> map = getStructureIdAndStructureNameMap(productId);
-        List<StructureVO> structures = structureMapper.selectAllByProductId(productId);
+        List<StructureVO> structures;
+        //若有架构id则只查该架构底下的树,若没有架构id则查整棵产品的架构树
+        if (structureId == null) {
+            structures = structureMapper.selectAllByProductId(productId);
+        } else {
+            structures = structureMapper.selectAllByStructureId(structureId);
+        }
         for (StructureVO structure : structures) {
             Integer id = structure.getId();
             String path = structure.getPath();

+ 14 - 0
PAS/src/main/resources/mapper/StructureMapper.xml

@@ -211,4 +211,18 @@
         order by path
     </select>
 
+    <!--根据架构id查询数据-->
+    <!--List<StructureVO> selectAllByStructureId(Integer structureId);-->
+    <select id="selectAllByStructureId" resultMap="selectByFindInSetPathMap">
+        select id,
+               parent_id,
+               structure_name,
+               path,
+               remark,
+               product_id
+        from structure
+        where find_in_set(#{structureId}, path)
+        order by path
+    </select>
+
 </mapper>