DeptInfoFacade.java 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.diagbot.facade;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.diagbot.client.TranServiceClient;
  4. import com.diagbot.dto.DeptInfoDTO;
  5. import com.diagbot.dto.HospitalDeptInfoDTO;
  6. import com.diagbot.dto.RespDTO;
  7. import com.diagbot.entity.DeptInfo;
  8. import com.diagbot.enums.IsDeleteEnum;
  9. import com.diagbot.exception.CommonErrorCode;
  10. import com.diagbot.exception.CommonException;
  11. import com.diagbot.service.impl.DeptInfoServiceImpl;
  12. import com.diagbot.util.BeanUtil;
  13. import com.diagbot.vo.DeptInfoVO;
  14. import com.diagbot.vo.HospitalDeptInfoVO;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.stereotype.Component;
  17. /**
  18. * @Description:
  19. * @author: wangyu
  20. * @time: 2018/11/19 19:21
  21. */
  22. @Component
  23. public class DeptInfoFacade extends DeptInfoServiceImpl {
  24. @Autowired
  25. TranServiceClient tranServiceClient;
  26. /**
  27. * 获取科室信息
  28. *
  29. * @param deptInfoVO
  30. * @return
  31. */
  32. public DeptInfoDTO getDeptInfo(DeptInfoVO deptInfoVO) {
  33. HospitalDeptInfoVO hospitalDeptInfoVO = new HospitalDeptInfoVO();
  34. BeanUtil.copyProperties(deptInfoVO,hospitalDeptInfoVO);
  35. RespDTO<HospitalDeptInfoDTO> hospitalDeptInfoDTORespDTO = tranServiceClient.getHospitalDeptInfo(hospitalDeptInfoVO);
  36. if (hospitalDeptInfoDTORespDTO == null
  37. || !CommonErrorCode.OK.getCode().equals(hospitalDeptInfoDTORespDTO.code)) {
  38. throw new CommonException(CommonErrorCode.RPC_ERROR,
  39. "获取科室信息失败");
  40. }
  41. QueryWrapper<DeptInfo> deptInfoDTOQueryWrapper = new QueryWrapper<>();
  42. deptInfoDTOQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
  43. .eq("id",hospitalDeptInfoDTORespDTO.data.getDeptId());
  44. DeptInfo deptInfo = this.getOne(deptInfoDTOQueryWrapper);
  45. DeptInfoDTO deptInfoDTO = new DeptInfoDTO();
  46. BeanUtil.copyProperties(deptInfo,deptInfoDTO);
  47. return deptInfoDTO;
  48. }
  49. }