|
@@ -0,0 +1,40 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.dto.QcModeDTO;
|
|
|
+import com.diagbot.entity.QcMode;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.service.impl.QcModeServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @author: zhoutg
|
|
|
+ * @time: 2020/4/12 11:39
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class QcModeFacade extends QcModeServiceImpl {
|
|
|
+
|
|
|
+ public List<QcModeDTO> getMenu() {
|
|
|
+ List<QcMode> qcModeList = this.list(new QueryWrapper<QcMode>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .orderByAsc("parent_id", "order_no")
|
|
|
+ );
|
|
|
+ Map<Long, List<QcMode>> map = EntityUtil.makeEntityListMap(qcModeList, "parentId");
|
|
|
+ // 获取根节点
|
|
|
+ List<QcMode> root = map.get(-1L);
|
|
|
+ List<QcModeDTO> res = BeanUtil.listCopyTo(root, QcModeDTO.class);
|
|
|
+
|
|
|
+ for(QcModeDTO qcModeDTO : res) {
|
|
|
+ if (map.containsKey(qcModeDTO.getId())) {
|
|
|
+ qcModeDTO.setSonMode(BeanUtil.listCopyTo(map.get(qcModeDTO.getId()), QcModeDTO.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+}
|