|
@@ -1,13 +1,20 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.dto.ModuleDetailDTO;
|
|
|
import com.diagbot.dto.ModuleInfoDTO;
|
|
|
+import com.diagbot.entity.ModuleDetail;
|
|
|
import com.diagbot.entity.ModuleInfo;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.service.impl.ModuleInfoServiceImpl;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.vo.ModuleVO;
|
|
|
+import com.diagbot.vo.QuestionIdsVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -18,17 +25,43 @@ import java.util.List;
|
|
|
@Component
|
|
|
public class ModuleFacade extends ModuleInfoServiceImpl {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ModuleDetailFacade moduleDetailFacade;
|
|
|
+ @Autowired
|
|
|
+ QuestionFacade questionFacade;
|
|
|
|
|
|
/**
|
|
|
* 返回所有的模型结构
|
|
|
*
|
|
|
* @return 模型结构
|
|
|
*/
|
|
|
- public List<ModuleInfoDTO> getAll() {
|
|
|
+ public List<ModuleInfoDTO> getAll(ModuleVO moduleVO) {
|
|
|
+ List<ModuleInfoDTO> data = new ArrayList<>();
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
List<ModuleInfo> list = this.list(queryWrapper);
|
|
|
- return BeanUtil.listCopyTo(list, ModuleInfoDTO.class);
|
|
|
+ data = BeanUtil.listCopyTo(list, ModuleInfoDTO.class);
|
|
|
+ for (ModuleInfoDTO bean : data) {
|
|
|
+ QueryWrapper wrapper = new QueryWrapper();
|
|
|
+ wrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ wrapper.eq("module_id", bean.getId());
|
|
|
+ wrapper.orderByAsc("order_no");
|
|
|
+ List<ModuleDetail> moduleDetailList = moduleDetailFacade.list(wrapper);
|
|
|
+ List<ModuleDetailDTO> moduleDetailDTOList = BeanUtil.listCopyTo(moduleDetailList, ModuleDetailDTO.class);
|
|
|
+ bean.setModuleDetailDTOList(moduleDetailDTOList);
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (ModuleDetailDTO detailDTO : moduleDetailDTOList) {
|
|
|
+ sb.append(detailDTO.getQuestionId()).append(",");
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(moduleDetailDTOList)) {
|
|
|
+ QuestionIdsVO questionIdsVO = new QuestionIdsVO();
|
|
|
+ questionIdsVO.setIds(sb.toString().substring(0, sb.toString().length()-1));
|
|
|
+ questionIdsVO.setSexType(moduleVO.getSexType());
|
|
|
+ questionIdsVO.setAge(moduleVO.getAge());
|
|
|
+ bean.setQuestionList(questionFacade.getByIds(questionIdsVO));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return data;
|
|
|
}
|
|
|
|
|
|
}
|