Browse Source

获取医院信息

wangyu 6 years ago
parent
commit
e8a6fac1af

+ 15 - 0
icss-service/src/main/java/com/diagbot/dto/HospitalInfoDTO.java

@@ -0,0 +1,15 @@
+package com.diagbot.dto;
+
+import com.diagbot.entity.HospitalInfo;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: wangyu
+ * @time: 2018/11/22 13:42
+ */
+@Getter
+@Setter
+public class HospitalInfoDTO extends HospitalInfo {
+}

+ 35 - 0
icss-service/src/main/java/com/diagbot/facade/HospitalInfoFacade.java

@@ -0,0 +1,35 @@
+package com.diagbot.facade;
+
+import com.diagbot.dto.HospitalInfoDTO;
+import com.diagbot.dto.IntroduceDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.impl.HospitalInfoServiceImpl;
+import com.diagbot.vo.HospitalInfoVO;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: wangyu
+ * @time: 2018/11/22 13:43
+ */
+@Component
+public class HospitalInfoFacade extends HospitalInfoServiceImpl {
+
+    /**
+     * 获取医院信息
+     * @param hospitalInfoVO
+     * @return
+     */
+    public RespDTO<IntroduceDTO> getHospitalInfo(HospitalInfoVO hospitalInfoVO) {
+        List<HospitalInfoDTO> hospitalInfoDTOList = this.getHospitalInfos(hospitalInfoVO);
+        if(hospitalInfoDTOList == null || hospitalInfoDTOList.size() == 0){
+            throw new CommonException(CommonErrorCode.NOT_EXISTS,
+                    "获取医院信息失败");
+        }
+        return RespDTO.onSuc( hospitalInfoDTOList);
+    }
+}

+ 12 - 1
icss-service/src/main/java/com/diagbot/mapper/HospitalInfoMapper.java

@@ -1,7 +1,11 @@
 package com.diagbot.mapper;
 
-import com.diagbot.entity.HospitalInfo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.dto.HospitalInfoDTO;
+import com.diagbot.entity.HospitalInfo;
+import com.diagbot.vo.HospitalInfoVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +17,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface HospitalInfoMapper extends BaseMapper<HospitalInfo> {
 
+
+    /**
+     * 获取医院信息
+     * @param hospitalInfoVO
+     * @return
+     */
+    public List<HospitalInfoDTO> getHospitalInfos(HospitalInfoVO hospitalInfoVO);
 }

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

@@ -1,7 +1,11 @@
 package com.diagbot.service;
 
-import com.diagbot.entity.HospitalInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.dto.HospitalInfoDTO;
+import com.diagbot.entity.HospitalInfo;
+import com.diagbot.vo.HospitalInfoVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +17,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface HospitalInfoService extends IService<HospitalInfo> {
 
+    /**
+     * 获取医院信息
+     * @param hospitalInfoVO
+     * @return
+     */
+    public List<HospitalInfoDTO> getHospitalInfos(HospitalInfoVO hospitalInfoVO);
 }

+ 12 - 0
icss-service/src/main/java/com/diagbot/service/impl/HospitalInfoServiceImpl.java

@@ -1,11 +1,16 @@
 package com.diagbot.service.impl;
 
+import com.diagbot.dto.HospitalInfoDTO;
 import com.diagbot.entity.HospitalInfo;
 import com.diagbot.mapper.HospitalInfoMapper;
 import com.diagbot.service.HospitalInfoService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.vo.HospitalInfoVO;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 医院信息表 服务实现类
@@ -17,4 +22,11 @@ import org.springframework.stereotype.Service;
 @Service
 public class HospitalInfoServiceImpl extends ServiceImpl<HospitalInfoMapper, HospitalInfo> implements HospitalInfoService {
 
+    @Override
+    public List<HospitalInfoDTO> getHospitalInfos(HospitalInfoVO hospitalInfoVO) {
+        if(StringUtils.isNotEmpty(hospitalInfoVO.getNotIds())) {
+            hospitalInfoVO.setNotIdsArr(hospitalInfoVO.getNotIds().split(","));
+        }
+        return baseMapper.getHospitalInfos(hospitalInfoVO);
+    }
 }

+ 43 - 0
icss-service/src/main/java/com/diagbot/vo/HospitalInfoVO.java

@@ -0,0 +1,43 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: wangyu
+ * @time: 2018/11/22 13:42
+ */
+@Getter
+@Setter
+public class HospitalInfoVO{
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 医院编码
+     */
+    private String code;
+
+    /**
+     * 医院名称
+     */
+    private String name;
+
+    /**
+     * 医院名称拼音
+     */
+    private String spell;
+
+    /**
+     * 状态:0.禁用1.启用
+     */
+    private Integer status;
+
+    private String notIds;    				//过滤已选
+
+    private String[] notIdsArr; 			//过滤已选数组
+}

+ 40 - 0
icss-service/src/main/java/com/diagbot/web/HospitalInfoController.java

@@ -0,0 +1,40 @@
+package com.diagbot.web;
+
+import com.diagbot.dto.IntroduceDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.HospitalInfoFacade;
+import com.diagbot.vo.HospitalInfoVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+
+/**
+ * @Description:
+ * @author: wangyu
+ * @time: 2018/11/22 13:41
+ */
+@RestController
+@RequestMapping("/deptInfo")
+@Api(value = "医院信息API", tags = { "医院信息API" })
+public class HospitalInfoController {
+
+    @Autowired
+    private HospitalInfoFacade hospitalInfoFacade;
+
+    @ApiOperation(value = "根据标签id获取提示信息[by:wangyu]",
+            notes = "id: 医院id<br>" +
+                    "code:医院编码<br>" +
+                    "name:医院名称<br>" +
+                    "spell:医院拼音<br>" +
+                    "status:状态:0.禁用1.启用<br>")
+    @PostMapping("/getHospitalInfo")
+    public RespDTO<IntroduceDTO> getHospitalInfo(@RequestBody @Valid HospitalInfoVO hospitalInfoVO) {
+        return RespDTO.onSuc( hospitalInfoFacade.getHospitalInfo(hospitalInfoVO));
+    }
+}

+ 29 - 0
icss-service/src/main/resources/mapper/HospitalInfoMapper.xml

@@ -19,4 +19,33 @@
         <result column="remark" property="remark" />
     </resultMap>
 
+    <select id="getHospitalInfos"  resultType="com.diagbot.dto.HospitalInfoDTO">
+        select * from tran_hospital_info i where status = 1
+        <if test="id != null and id != ''">
+            and id = #{id}
+        </if>
+        <if test="code != null and code != ''">
+            and code = #{code}
+        </if>
+        <if test="name != null and name != ''">
+            and (name like concat('%',#{name},'%') or spell like concat('%',#{name},'%'))
+        </if>
+        <if test="notIdsArr != null and notIdsArr.length > 0">
+            and id not in
+            <foreach item="item" index="index" collection="notIdsArr"
+                     open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <!-- name必须放最后,有order_no-->
+        <choose>
+            <when test="name != null and name != ''">
+                and (name like concat('%',#{name},'%') or spell like concat('%',#{name},'%'))
+            </when>
+            <otherwise>
+                order by order_no
+            </otherwise>
+        </choose>
+
+    </select>
 </mapper>