Browse Source

科室维护——查询(添加操作人)

wangyu 6 years ago
parent
commit
b1fedcc6d1

+ 20 - 0
icssman-service/src/main/java/com/diagbot/dto/GetDeptInfoDTO.java

@@ -0,0 +1,20 @@
+package com.diagbot.dto;
+
+import com.diagbot.entity.DeptInfo;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: wangyu
+ * @time: 2018/12/14 15:24
+ */
+@Getter
+@Setter
+public class GetDeptInfoDTO extends DeptInfo {
+
+    /**
+     * 操作人姓名
+     */
+    private String userName;
+}

+ 23 - 2
icssman-service/src/main/java/com/diagbot/facade/DeptInfoFacade.java

@@ -2,7 +2,10 @@ package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.client.UserServiceClient;
 import com.diagbot.dto.DeptInfoDTO;
+import com.diagbot.dto.GetDeptInfoDTO;
+import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.DeptInfo;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
@@ -16,10 +19,13 @@ import com.diagbot.vo.AddDeptInfoVO;
 import com.diagbot.vo.GetDeptInfoDetialsVO;
 import com.diagbot.vo.GetDeptInfoVO;
 import com.diagbot.vo.UpdateDeptInfoVO;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description:
@@ -29,6 +35,9 @@ import java.util.List;
 @Component
 public class DeptInfoFacade extends DeptInfoServiceImpl {
 
+    @Autowired
+    private UserServiceClient userServiceClient;
+
     /**
      * 添加科室信息
      * @param addDeptInfoVO
@@ -88,8 +97,20 @@ public class DeptInfoFacade extends DeptInfoServiceImpl {
      * @param getDeptInfoVO
      * @return
      */
-    public IPage<DeptInfo> getDeptInfo(GetDeptInfoVO getDeptInfoVO){
-        IPage iPage = this.getAllDeptInfo(getDeptInfoVO);
+    public IPage<GetDeptInfoDTO> getDeptInfo(GetDeptInfoVO getDeptInfoVO){
+        IPage<GetDeptInfoDTO> iPage = this.getAllDeptInfo(getDeptInfoVO);
+        List<String> ids = new ArrayList<>();
+        for (GetDeptInfoDTO getDeptInfoDTO:iPage.getRecords()) {
+            ids.add(getDeptInfoDTO.getModifier());
+        }
+        RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
+        if (respDTO == null || !"0".equals(respDTO.code)) {
+            throw new CommonException(CommonErrorCode.RPC_ERROR,
+                    "获取用户信息失败");
+        }
+        for (GetDeptInfoDTO getDeptInfoDTO:iPage.getRecords()) {
+            getDeptInfoDTO.setUserName(respDTO.data.get(getDeptInfoDTO.getModifier()));
+        }
         return iPage;
     }
 

+ 2 - 1
icssman-service/src/main/java/com/diagbot/mapper/DeptInfoMapper.java

@@ -3,6 +3,7 @@ package com.diagbot.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.DeptInfoDTO;
+import com.diagbot.dto.GetDeptInfoDTO;
 import com.diagbot.entity.DeptInfo;
 import com.diagbot.vo.GetDeptInfoVO;
 import org.apache.ibatis.annotations.Param;
@@ -24,7 +25,7 @@ public interface DeptInfoMapper extends BaseMapper<DeptInfo> {
      * @param getDeptInfoVO
      * @return
      */
-    public IPage<DeptInfo> getAllDeptInfo(GetDeptInfoVO getDeptInfoVO);
+    public IPage<GetDeptInfoDTO> getAllDeptInfo(GetDeptInfoVO getDeptInfoVO);
 
     /**
      *  获取科室信息和

+ 2 - 1
icssman-service/src/main/java/com/diagbot/service/DeptInfoService.java

@@ -3,6 +3,7 @@ package com.diagbot.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.diagbot.dto.DeptInfoDTO;
+import com.diagbot.dto.GetDeptInfoDTO;
 import com.diagbot.entity.DeptInfo;
 import com.diagbot.vo.GetDeptInfoVO;
 
@@ -23,7 +24,7 @@ public interface DeptInfoService extends IService<DeptInfo> {
      * @param getDeptInfoVO
      * @return
      */
-    public IPage<DeptInfo> getAllDeptInfo(GetDeptInfoVO getDeptInfoVO);
+    public IPage<GetDeptInfoDTO> getAllDeptInfo(GetDeptInfoVO getDeptInfoVO);
 
     /**
      *  获取科室信息

+ 2 - 1
icssman-service/src/main/java/com/diagbot/service/impl/DeptInfoServiceImpl.java

@@ -3,6 +3,7 @@ package com.diagbot.service.impl;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.dto.DeptInfoDTO;
+import com.diagbot.dto.GetDeptInfoDTO;
 import com.diagbot.entity.DeptInfo;
 import com.diagbot.mapper.DeptInfoMapper;
 import com.diagbot.service.DeptInfoService;
@@ -23,7 +24,7 @@ import java.util.List;
 public class DeptInfoServiceImpl extends ServiceImpl<DeptInfoMapper, DeptInfo> implements DeptInfoService {
 
     @Override
-    public IPage<DeptInfo> getAllDeptInfo(GetDeptInfoVO getDeptInfoVO) {
+    public IPage<GetDeptInfoDTO> getAllDeptInfo(GetDeptInfoVO getDeptInfoVO) {
         return baseMapper.getAllDeptInfo(getDeptInfoVO);
     }
 

+ 3 - 2
icssman-service/src/main/java/com/diagbot/web/DeptInfoController.java

@@ -3,6 +3,7 @@ package com.diagbot.web;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.GetDeptInfoDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.DeptInfo;
 import com.diagbot.facade.DeptInfoFacade;
@@ -73,8 +74,8 @@ public class DeptInfoController {
             notes = "name: 科室名称 <br>")
     @PostMapping("/getDeptInfo")
     @SysLogger("getDeptInfo")
-    public RespDTO<IPage<DeptInfo>> getDeptInfo(@Valid @RequestBody GetDeptInfoVO getDeptInfoVO) {
-        IPage<DeptInfo> data = deptInfoFacade.getDeptInfo(getDeptInfoVO);
+    public RespDTO<IPage<GetDeptInfoDTO>> getDeptInfo(@Valid @RequestBody GetDeptInfoVO getDeptInfoVO) {
+        IPage<GetDeptInfoDTO> data = deptInfoFacade.getDeptInfo(getDeptInfoVO);
         return RespDTO.onSuc(data);
     }
 

+ 2 - 2
icssman-service/src/main/resources/mapper/DeptInfoMapper.xml

@@ -14,12 +14,12 @@
         <result column="remark" property="remark" />
     </resultMap>
 
-    <select id="getAllDeptInfo" resultType="com.diagbot.dto.DeptInfoDTO">
+    <select id="getAllDeptInfo" resultType="com.diagbot.dto.GetDeptInfoDTO">
         SELECT * FROM `icss_dept_info` WHERE is_deleted = 'N'
          <if test="name != null and name != ''">
              AND `name` LIKE CONCAT('%',#{name},'%')
          </if>
-        order by id desc
+        order by gmt_modified desc
     </select>
 
     <select id="getDeptInfos" resultType="com.diagbot.dto.DeptInfoDTO">