|
@@ -1,8 +1,24 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.dto.ConceptDetailDTO;
|
|
|
+import com.diagbot.dto.ConceptIntroduceDTO;
|
|
|
+import com.diagbot.entity.Concept;
|
|
|
+import com.diagbot.entity.ConceptDetail;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.ConceptDetailServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.vo.ConceptIntroduceVO;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @Description:
|
|
|
* @Author:zhaops
|
|
@@ -10,4 +26,41 @@ import org.springframework.stereotype.Component;
|
|
|
*/
|
|
|
@Component
|
|
|
public class ConceptDetailFacade extends ConceptDetailServiceImpl {
|
|
|
+ @Autowired
|
|
|
+ private ConceptFacade conceptFacade;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取提示信息
|
|
|
+ *
|
|
|
+ * @param conceptIntroduceVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ConceptIntroduceDTO getConceptDetail(ConceptIntroduceVO conceptIntroduceVO) {
|
|
|
+ if (StringUtil.isBlank(conceptIntroduceVO.getName())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入概念名称");
|
|
|
+ }
|
|
|
+ QueryWrapper<Concept> conceptQueryWrapper = new QueryWrapper<>();
|
|
|
+ conceptQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ eq("lib_name", conceptIntroduceVO.getName()).
|
|
|
+ eq("lib_type", conceptIntroduceVO.getLibType());
|
|
|
+ Concept concept = conceptFacade.getOne(conceptQueryWrapper);
|
|
|
+ if (concept == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "概念不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<ConceptDetail> conceptDetailQueryWrapper = new QueryWrapper<>();
|
|
|
+ conceptDetailQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
+ eq("concept_id", concept.getId()).
|
|
|
+ apply("find_in_set({0},position)", conceptIntroduceVO.getPosition()).
|
|
|
+ orderByAsc("order_no");
|
|
|
+ List<ConceptDetail> conceptDetailList = this.list(conceptDetailQueryWrapper);
|
|
|
+ List<ConceptDetailDTO> conceptDetailDTOList = Lists.newLinkedList();
|
|
|
+ if (ListUtil.isNotEmpty(conceptDetailList)) {
|
|
|
+ conceptDetailDTOList = BeanUtil.listCopyTo(conceptDetailList, ConceptDetailDTO.class);
|
|
|
+ }
|
|
|
+ ConceptIntroduceDTO conceptIntroduceDTO = new ConceptIntroduceDTO();
|
|
|
+ conceptIntroduceDTO.setName(concept.getLibName());
|
|
|
+ conceptIntroduceDTO.setDetails(conceptDetailDTOList);
|
|
|
+ return conceptIntroduceDTO;
|
|
|
+ }
|
|
|
}
|