Browse Source

代码优化

wangyu 6 years ago
parent
commit
b0a11db9bb

+ 3 - 12
icss-service/src/main/java/com/diagbot/facade/PatientInfoFacade.java

@@ -4,18 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.GetTopPatientInfoDTO;
 import com.diagbot.dto.PatientInfoDTO;
 import com.diagbot.entity.PatientInfo;
-import com.diagbot.exception.CommonErrorCode;
-import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.PatientInfoServiceImpl;
 import com.diagbot.util.DateUtil;
-import com.diagbot.util.ListUtil;
 import com.diagbot.vo.GetTopPatientInfoVO;
 import com.diagbot.vo.PatientInfoVO;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.RequestBody;
 
-import java.util.List;
-
 /**
  * @Description: 患者业务逻辑
  * @author: wangyu
@@ -30,13 +25,9 @@ public class PatientInfoFacade extends PatientInfoServiceImpl {
      * @param patientInfoVO
      * @return
      */
-    public List<PatientInfoDTO> getPatientInfo(@RequestBody PatientInfoVO patientInfoVO) {
-        List<PatientInfoDTO> patientInfoDTOList = this.getPatientInfos(patientInfoVO.getPatientCode(), patientInfoVO.getHospitalCode());
-        if (ListUtil.isEmpty(patientInfoDTOList)) {
-            throw new CommonException(CommonErrorCode.NOT_EXISTS,
-                    "获取患者信息失败");
-        }
-        return patientInfoDTOList;
+    public PatientInfoDTO getPatientInfo(@RequestBody PatientInfoVO patientInfoVO) {
+        PatientInfoDTO patientInfoDTO = this.getPatientInfos(patientInfoVO.getPatientCode(), patientInfoVO.getHospitalCode());
+        return patientInfoDTO;
     }
 
     /**

+ 3 - 6
icss-service/src/main/java/com/diagbot/mapper/PatientInfoMapper.java

@@ -1,15 +1,12 @@
 package com.diagbot.mapper;
 
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-import org.springframework.web.bind.annotation.RequestBody;
-
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.diagbot.dto.GetTopPatientInfoDTO;
 import com.diagbot.dto.PatientInfoDTO;
 import com.diagbot.entity.PatientInfo;
 import com.diagbot.vo.GetTopPatientInfoVO;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.web.bind.annotation.RequestBody;
 
 /**
  * @Description: 患者信息
@@ -22,7 +19,7 @@ public interface PatientInfoMapper extends BaseMapper<PatientInfo> {
      * @param patientCode,hospitalCode
      * @return
      */
-    public List<PatientInfoDTO> getPatientInfos(@Param("patientCode") String patientCode, @Param("hospitalCode") String hospitalCode);
+    public PatientInfoDTO getPatientInfos(@Param("patientCode") String patientCode, @Param("hospitalCode") String hospitalCode);
     
     /**
      * 顶部病人医生科室信息查询

+ 1 - 1
icss-service/src/main/java/com/diagbot/service/PatientInfoService.java

@@ -16,5 +16,5 @@ import java.util.List;
  */
 public interface PatientInfoService extends IService<PatientInfo> {
 
-    public List<PatientInfoDTO> getPatientInfos(String patientCode, String hospitalCode);
+    public PatientInfoDTO getPatientInfos(String patientCode, String hospitalCode);
 }

+ 1 - 1
icss-service/src/main/java/com/diagbot/service/impl/PatientInfoServiceImpl.java

@@ -21,7 +21,7 @@ import java.util.List;
 public class PatientInfoServiceImpl extends ServiceImpl<PatientInfoMapper, PatientInfo> implements PatientInfoService {
 
     @Override
-    public List<PatientInfoDTO> getPatientInfos(String patientCode, String hospitalCode) {
+    public PatientInfoDTO getPatientInfos(String patientCode, String hospitalCode) {
         return baseMapper.getPatientInfos(patientCode, hospitalCode);
     }
 }

+ 2 - 3
icss-service/src/main/java/com/diagbot/web/PatientInfoController.java

@@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
-import java.util.List;
 
 /**
  * <p>
@@ -40,8 +39,8 @@ public class PatientInfoController {
                     "hospitalCode:医院编号,必填<br>")
     @PostMapping("/getPatientInfo")
     @SysLogger("getPatientInfo")
-    public RespDTO<List<PatientInfoDTO>> getPatientInfo(@Valid @RequestBody PatientInfoVO patientInfoVO) {
-        List<PatientInfoDTO> data = patientInfoFacade.getPatientInfo(patientInfoVO);
+    public RespDTO<PatientInfoDTO> getPatientInfo(@Valid @RequestBody PatientInfoVO patientInfoVO) {
+        PatientInfoDTO data = patientInfoFacade.getPatientInfo(patientInfoVO);
         return RespDTO.onSuc(data);
     }