Parcourir la source

feat: 组织架构利用id查询人员以及人员所在的部门

zhaomuran il y a 7 mois
Parent
commit
701c67f5c1

+ 9 - 3
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/controller/FrameworkController.java

@@ -6,9 +6,7 @@ import com.wx.blink.backend.service.IFrameworkService;
 import com.wx.blink.base.common.domain.ResponseDTO;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
@@ -27,4 +25,12 @@ public class FrameworkController {
         return frameworkService.supportsFrameworkQuery(qry);
     }
 
+    @Operation(summary = "查询人员")
+    @GetMapping("/supports/framework/personnel/{id}")
+    public ResponseDTO<List<FrameworkDTO>> supportsPersonnelQuery(@PathVariable("id") Long id){
+        return frameworkService.supportsPersonnelQuery(id);
+    }
+
+
+
 }

+ 28 - 0
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/manager/FrameworkServiceImpl.java

@@ -43,6 +43,34 @@ public class FrameworkServiceImpl implements IFrameworkService {
         return responseDTO;
     }
 
+    /**
+     * 查询人员
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public ResponseDTO<List<FrameworkDTO>> supportsPersonnelQuery(Long id) {
+        PersonnelDO employeeDO = pRepository.selectById(id);
+        if (!Objects.nonNull(employeeDO)){
+            return ResponseDTO.dataErrorParam("数据不存在!请检查");
+        }
+        List<DepartmentDTO> departmentDTOS = dRepository.queryDepartmentByDepartmentId(employeeDO.getDepartmentId());
+        List<FrameworkDTO> frameworkDTOS = new ArrayList<>();
+        for (DepartmentDTO departmentDTO : departmentDTOS) {
+            FrameworkDTO frameworkDTO = new FrameworkDTO();
+            if (departmentDTO.getDepartmentId().equals(employeeDO.getDepartmentId())){
+                frameworkDTO.setId(employeeDO.getEmployeeId());
+                frameworkDTO.setName(employeeDO.getActualName());
+                frameworkDTO.setNodeType("USER");
+                frameworkDTO.setParentId(employeeDO.getDepartmentId());
+                frameworkDTO.setParentName(departmentDTO.getName());
+            }
+            frameworkDTOS.add(frameworkDTO);
+        }
+        return ResponseDTO.ok(frameworkDTOS);
+    }
+
     /**
      * 查询人员
      *

+ 8 - 0
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/repository/DepartmentRepository.java

@@ -37,4 +37,12 @@ public interface DepartmentRepository extends BaseMapper<DepartmentDO> {
      */
     List<DepartmentDTO> supportsDepartmentQueryByParentIds(@Param("parentIds") List<Long> parentIds);
 
+    /**
+     * 查询部门(根据departmentId)
+     *
+     * @param departmentId
+     * @return
+     */
+    List<DepartmentDTO> queryDepartmentByDepartmentId(@Param("departmentId") Long departmentId);
+
 }

+ 7 - 0
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/service/IFrameworkService.java

@@ -16,4 +16,11 @@ public interface IFrameworkService {
      */
     ResponseDTO<List<FrameworkDTO>> supportsFrameworkQuery(FrameworkQry qry);
 
+    /**
+     * 查询人员
+     *
+     * @param id
+     * @return
+     */
+    ResponseDTO<List<FrameworkDTO>> supportsPersonnelQuery(Long id);
 }

+ 6 - 0
bound-link-api/blink-backend/src/main/resources/mapper/DepartmentRepositoryMapper.xml

@@ -2,6 +2,12 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.wx.blink.backend.repository.DepartmentRepository">
 
+    <select id="queryDepartmentByDepartmentId" resultType="com.wx.blink.backend.domain.dto.DepartmentDTO">
+        SELECT *
+        FROM mate_department
+        WHERE department_id = #{departmentId}
+    </select>
+
     <!--    查询部门-->
     <select id="supportsDepartmentQuery" resultType="com.wx.blink.backend.domain.dto.DepartmentDTO">
         select *