|
@@ -1,14 +1,29 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.diagbot.dto.HospitalInfoDTO;
|
|
|
+import com.diagbot.entity.DiseaseConfig;
|
|
|
import com.diagbot.entity.HospitalInfo;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.HospitalInfoService;
|
|
|
import com.diagbot.service.impl.HospitalInfoServiceImpl;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.UserUtils;
|
|
|
+import com.diagbot.vo.HospitalInfoListVO;
|
|
|
+import com.diagbot.vo.HospitalInfoPageVO;
|
|
|
+import com.diagbot.vo.IdListVO;
|
|
|
+import com.diagbot.vo.IdVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -18,6 +33,9 @@ import java.util.List;
|
|
|
*/
|
|
|
@Component
|
|
|
public class HospitalInfoFacade extends HospitalInfoServiceImpl {
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("hospitalInfoServiceImpl")
|
|
|
+ private HospitalInfoService hospitalInfoService;
|
|
|
|
|
|
public List<HospitalInfoDTO> getHospitalInfo() {
|
|
|
QueryWrapper<HospitalInfo> hospitalInfo = new QueryWrapper<>();
|
|
@@ -27,4 +45,111 @@ public class HospitalInfoFacade extends HospitalInfoServiceImpl {
|
|
|
data = BeanUtil.listCopyTo(list, HospitalInfoDTO.class);
|
|
|
return data;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存记录-单条
|
|
|
+ *
|
|
|
+ * @param hospitalInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean saveOrUpdateRecord(HospitalInfo hospitalInfo) {
|
|
|
+ String userId = UserUtils.getCurrentPrincipleID();
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ hospitalInfo.setModifier(userId);
|
|
|
+ hospitalInfo.setGmtModified(now);
|
|
|
+ //新增数据
|
|
|
+ if (hospitalInfo.getId() == null) {
|
|
|
+ hospitalInfo.setCreator(userId);
|
|
|
+ hospitalInfo.setGmtCreate(now);
|
|
|
+ }
|
|
|
+ if (hospitalInfo.getIsDeleted() == null) {
|
|
|
+ hospitalInfo.setIsDeleted(IsDeleteEnum.N.getKey());
|
|
|
+ }
|
|
|
+ this.saveOrUpdate(hospitalInfo);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存记录-批量
|
|
|
+ *
|
|
|
+ * @param hospitalInfoListVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean saveOrUpdateRecords(HospitalInfoListVO hospitalInfoListVO) {
|
|
|
+ if (ListUtil.isEmpty(hospitalInfoListVO.getHospitalInfoList())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ String userId = UserUtils.getCurrentPrincipleID();
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ hospitalInfoListVO.getHospitalInfoList().forEach(item -> {
|
|
|
+ item.setModifier(userId);
|
|
|
+ item.setGmtModified(now);
|
|
|
+ if (item.getId() == null) {
|
|
|
+ item.setCreator(userId);
|
|
|
+ item.setGmtCreate(now);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ hospitalInfoService.saveOrUpdateBatch(hospitalInfoListVO.getHospitalInfoList());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除记录-单条
|
|
|
+ *
|
|
|
+ * @param idVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean deleteRecord(IdVO idVO) {
|
|
|
+ String userId = UserUtils.getCurrentPrincipleID();
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ HospitalInfo hospitalInfo = hospitalInfoService.getById(idVO.getId());
|
|
|
+ if (hospitalInfo == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "数据不存在");
|
|
|
+ }
|
|
|
+ if (hospitalInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "数据已删除");
|
|
|
+ }
|
|
|
+ hospitalInfo.setIsDeleted(IsDeleteEnum.Y.getKey());
|
|
|
+ hospitalInfo.setModifier(userId);
|
|
|
+ hospitalInfo.setGmtModified(now);
|
|
|
+ hospitalInfoService.updateById(hospitalInfo);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除记录-批量
|
|
|
+ *
|
|
|
+ * @param idListVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean deleteRecords(IdListVO idListVO) {
|
|
|
+ String userId = UserUtils.getCurrentPrincipleID();
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ if (ListUtil.isEmpty(idListVO.getIds())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ List<HospitalInfo> hospitalInfoList = new ArrayList<>(hospitalInfoService.listByIds(idListVO.getIds()));
|
|
|
+
|
|
|
+ if (ListUtil.isEmpty(hospitalInfoList)) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "数据不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ hospitalInfoList.forEach(hospitalInfo -> {
|
|
|
+ hospitalInfo.setIsDeleted(IsDeleteEnum.Y.getKey());
|
|
|
+ hospitalInfo.setModifier(userId);
|
|
|
+ hospitalInfo.setGmtModified(now);
|
|
|
+ });
|
|
|
+ hospitalInfoService.updateBatchById(hospitalInfoList);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询
|
|
|
+ *
|
|
|
+ * @param hospitalInfoPageVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IPage<DiseaseConfig> getPage(HospitalInfoPageVO hospitalInfoPageVO) {
|
|
|
+ return hospitalInfoService.getPage(hospitalInfoPageVO);
|
|
|
+ }
|
|
|
}
|