diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwPortalConfigController.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwPortalConfigController.java index 97ac1ef..5cd01c6 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwPortalConfigController.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwPortalConfigController.java @@ -8,7 +8,9 @@ import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.common.security.annotation.RequiresPermissions; import com.ruoyi.portal.domain.HwPortalConfig; +import com.ruoyi.portal.domain.HwPortalConfigType; import com.ruoyi.portal.service.IHwPortalConfigService; +import com.ruoyi.portal.service.IHwPortalConfigTypeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -28,6 +30,9 @@ public class HwPortalConfigController extends BaseController @Autowired private IHwPortalConfigService hwPortalConfigService; + @Autowired + private IHwPortalConfigTypeService hwPortalConfigTypeService; + /** * 查询门户网站配置列表 */ @@ -36,7 +41,7 @@ public class HwPortalConfigController extends BaseController public TableDataInfo list(HwPortalConfig hwPortalConfig) { startPage(); - List list = hwPortalConfigService.selectHwPortalConfigList(hwPortalConfig); + List list = hwPortalConfigService.selectHwPortalConfigJoinList(hwPortalConfig); return getDataTable(list); } @@ -95,4 +100,15 @@ public class HwPortalConfigController extends BaseController { return toAjax(hwPortalConfigService.deleteHwPortalConfigByPortalConfigIds(portalConfigIds)); } + + + /** + * 获取部门树列表 + */ + @RequiresPermissions("portal:portalConfig:list") + @GetMapping("/portalConfigTypeTree") + public AjaxResult portalConfigTypeTree(HwPortalConfigType hwPortalConfigType) { + + return success(hwPortalConfigTypeService.selectPortalConfigTypeTreeList(hwPortalConfigType)); + } } diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwPortalConfig.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwPortalConfig.java index 58dce9d..6340da4 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwPortalConfig.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwPortalConfig.java @@ -49,6 +49,8 @@ public class HwPortalConfig extends BaseEntity @Excel(name = "主图地址") private String portalConfigPic; + private String configTypeName; + public void setPortalConfigId(Long portalConfigId) { this.portalConfigId = portalConfigId; @@ -131,6 +133,14 @@ public class HwPortalConfig extends BaseEntity return portalConfigPic; } + public String getConfigTypeName() { + return configTypeName; + } + + public void setConfigTypeName(String configTypeName) { + this.configTypeName = configTypeName; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwPortalConfigType.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwPortalConfigType.java index fec425d..b181749 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwPortalConfigType.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwPortalConfigType.java @@ -1,10 +1,12 @@ package com.ruoyi.portal.domain; import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; import com.ruoyi.common.core.web.domain.TreeEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import java.util.ArrayList; import java.util.List; /** @@ -13,7 +15,7 @@ import java.util.List; * @author xins * @date 2024-12-11 */ -public class HwPortalConfigType extends TreeEntity +public class HwPortalConfigType extends BaseEntity { private static final long serialVersionUID = 1L; @@ -44,8 +46,14 @@ public class HwPortalConfigType extends TreeEntity @Excel(name = "首页图片地址") private String homeConfigTypePic; + private Long parentId; + + private String ancestors; + private List hwProductCaseInfoList; + /** 子类型 */ + private List children = new ArrayList(); public void setConfigTypeId(Long configTypeId) { @@ -111,6 +119,22 @@ public class HwPortalConfigType extends TreeEntity return homeConfigTypePic; } + public Long getParentId() { + return parentId; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public String getAncestors() { + return ancestors; + } + + public void setAncestors(String ancestors) { + this.ancestors = ancestors; + } + public List getHwProductCaseInfoList() { return hwProductCaseInfoList; } @@ -119,6 +143,14 @@ public class HwPortalConfigType extends TreeEntity this.hwProductCaseInfoList = hwProductCaseInfoList; } + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/vo/TreeSelect.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/vo/TreeSelect.java new file mode 100644 index 0000000..e6f9e2e --- /dev/null +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/vo/TreeSelect.java @@ -0,0 +1,69 @@ +package com.ruoyi.portal.domain.vo; + +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.ruoyi.portal.domain.HwPortalConfigType; + +/** + * Treeselect树结构实体类 + * + * @author ruoyi + */ +public class TreeSelect implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 节点ID */ + private Long id; + + /** 节点名称 */ + private String label; + + /** 子节点 */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children; + + public TreeSelect() + { + + } + + public TreeSelect(HwPortalConfigType portalConfigType) + { + this.id = portalConfigType.getConfigTypeId(); + this.label = portalConfigType.getConfigTypeName(); + this.children = portalConfigType.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + public Long getId() + { + return id; + } + + public void setId(Long id) + { + this.id = id; + } + + public String getLabel() + { + return label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public List getChildren() + { + return children; + } + + public void setChildren(List children) + { + this.children = children; + } +} diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/mapper/HwPortalConfigMapper.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/mapper/HwPortalConfigMapper.java index b104877..6cb3d47 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/mapper/HwPortalConfigMapper.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/mapper/HwPortalConfigMapper.java @@ -59,4 +59,14 @@ public interface HwPortalConfigMapper * @return 结果 */ public int deleteHwPortalConfigByPortalConfigIds(Long[] portalConfigIds); + + /** + * 查询门户网站配置列表,join hw_portal_config_type + * + * @param hwPortalConfig 门户网站配置 + * @return 门户网站配置集合 + */ + public List selectHwPortalConfigJoinList(HwPortalConfig hwPortalConfig); + + } diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigService.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigService.java index 2894a95..0af15dc 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigService.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigService.java @@ -59,4 +59,12 @@ public interface IHwPortalConfigService * @return 结果 */ public int deleteHwPortalConfigByPortalConfigId(Long portalConfigId); + + /** + * 查询门户网站配置列表,Join hw_portal_config_type + * + * @param hwPortalConfig 门户网站配置 + * @return 门户网站配置 + */ + public List selectHwPortalConfigJoinList(HwPortalConfig hwPortalConfig); } diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigTypeService.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigTypeService.java index 41cb672..c998607 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigTypeService.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwPortalConfigTypeService.java @@ -1,6 +1,7 @@ package com.ruoyi.portal.service; import com.ruoyi.portal.domain.HwPortalConfigType; +import com.ruoyi.portal.domain.vo.TreeSelect; import java.util.List; @@ -59,4 +60,28 @@ public interface IHwPortalConfigTypeService * @return 结果 */ public int deleteHwPortalConfigTypeByConfigTypeId(Long configTypeId); + + /** + * 查询门户网站配置类型树结构信息 + * + * @param portalConfigType 门户网站配置类型信息 + * @return 门户网站配置类型树信息集合 + */ + public List selectPortalConfigTypeTreeList(HwPortalConfigType portalConfigType); + + /** + * 构建前端所需要下拉树结构 + * + * @param portalConfigTypes 门户网站配置类型列表 + * @return 下拉树结构列表 + */ + public List buildPortalConfigTypeTreeSelect(List portalConfigTypes); + /** + * 构建前端所需要树结构 + * + * @param portalConfigTypes 门户网站配置类型列表 + * @return 树结构列表 + */ + public List buildPortalConfigTypeTree(List portalConfigTypes); + } diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigServiceImpl.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigServiceImpl.java index 0ae8927..c5c63b2 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigServiceImpl.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigServiceImpl.java @@ -94,4 +94,18 @@ public class HwPortalConfigServiceImpl implements IHwPortalConfigService { return hwPortalConfigMapper.deleteHwPortalConfigByPortalConfigId(portalConfigId); } + + + + /** + * 查询门户网站配置列表,Join hw_portal_config_type + * + * @param hwPortalConfig 门户网站配置 + * @return 门户网站配置 + */ + @Override + public List selectHwPortalConfigJoinList(HwPortalConfig hwPortalConfig) + { + return hwPortalConfigMapper.selectHwPortalConfigJoinList(hwPortalConfig); + } } diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigTypeServiceImpl.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigTypeServiceImpl.java index 61fbdaf..5b5fde3 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigTypeServiceImpl.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwPortalConfigTypeServiceImpl.java @@ -1,13 +1,20 @@ package com.ruoyi.portal.service.impl; import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.core.utils.SpringUtils; +import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.portal.domain.HwPortalConfigType; +import com.ruoyi.portal.domain.vo.TreeSelect; import com.ruoyi.portal.mapper.HwPortalConfigTypeMapper; import com.ruoyi.portal.service.IHwPortalConfigTypeService; +import com.ruoyi.system.api.domain.SysDept; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; +import java.util.stream.Collectors; /** * 门户网站配置类型Service业务层处理 @@ -94,4 +101,91 @@ public class HwPortalConfigTypeServiceImpl implements IHwPortalConfigTypeService { return hwPortalConfigTypeMapper.deleteHwPortalConfigTypeByConfigTypeId(configTypeId); } + + + /** + * 查询门户网站配置类型树结构信息 + * + * @param portalConfigType 门户网站配置类型信息 + * @return 门户网站配置类型树信息集合 + */ + @Override + public List selectPortalConfigTypeTreeList(HwPortalConfigType portalConfigType) { + List portalConfigTypes = this.selectHwPortalConfigTypeList(portalConfigType); + System.out.println("1"); + return buildPortalConfigTypeTreeSelect(portalConfigTypes); + } + + /** + * 构建前端所需要下拉树结构 + * + * @param portalConfigTypes 门户网站配置类型列表 + * @return 下拉树结构列表 + */ + @Override + public List buildPortalConfigTypeTreeSelect(List portalConfigTypes) { + List deptTrees = buildPortalConfigTypeTree(portalConfigTypes); + return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + + /** + * 构建前端所需要树结构 + * + * @param portalConfigTypes 门户网站配置类型列表 + * @return 树结构列表 + */ + @Override + public List buildPortalConfigTypeTree(List portalConfigTypes) { + List returnList = new ArrayList(); + List tempList = portalConfigTypes.stream().map(HwPortalConfigType::getConfigTypeId).collect(Collectors.toList()); + for (HwPortalConfigType portalConfigType : portalConfigTypes) { + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(portalConfigType.getParentId())) { + recursionFn(portalConfigTypes, portalConfigType); + returnList.add(portalConfigType); + } + } + if (returnList.isEmpty()) { + returnList = portalConfigTypes; + } + return returnList; + } + + + /** + * 递归列表 + */ + private void recursionFn(List list, HwPortalConfigType t) { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildren(childList); + for (HwPortalConfigType tChild : childList) { + if (hasChild(list, tChild)) { + recursionFn(list, tChild); + } + } + } + + /** + * 得到子节点列表 + */ + private List getChildList(List list, HwPortalConfigType t) { + List tlist = new ArrayList(); + Iterator it = list.iterator(); + while (it.hasNext()) { + HwPortalConfigType n = (HwPortalConfigType) it.next(); + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getConfigTypeId().longValue()) { + tlist.add(n); + } + } + return tlist; + } + + /** + * 判断是否有子节点 + */ + private boolean hasChild(List list, HwPortalConfigType t) { + return getChildList(list, t).size() > 0 ? true : false; + } } diff --git a/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwPortalConfigMapper.xml b/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwPortalConfigMapper.xml index f5660a5..4e39e7d 100644 --- a/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwPortalConfigMapper.xml +++ b/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwPortalConfigMapper.xml @@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -29,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and portal_config_type = #{portalConfigType} and portal_config_type_id = #{portalConfigTypeId} - and portal_config_title = #{portalConfigTitle} + and portal_config_title like concat('%', #{portalConfigTitle}, '%') and portal_config_order = #{portalConfigOrder} and portal_config_desc = #{portalConfigDesc} and button_name like concat('%', #{buttonName}, '%') @@ -104,4 +105,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{portalConfigId} + + + + + select hpc.portal_config_id, hpc.portal_config_type,hpc.portal_config_type_id, + hpc.portal_config_title, hpc.portal_config_order, hpc.portal_config_desc, + hpc.button_name, hpc.router_address, hpc.portal_config_pic, + hpc.create_time, hpc.create_by, hpc.update_time, hpc.update_by,hpct.config_type_name from hw_portal_config hpc + left join hw_portal_config_type hpct on hpc.portal_config_type_id = hpct.config_type_id + + + + \ No newline at end of file diff --git a/ruoyi-ui/src/api/portal/portalConfig.js b/ruoyi-ui/src/api/portal/portalConfig.js index 4eb1382..4ee5d33 100644 --- a/ruoyi-ui/src/api/portal/portalConfig.js +++ b/ruoyi-ui/src/api/portal/portalConfig.js @@ -42,3 +42,12 @@ export function delPortalConfig(portalConfigId) { method: 'delete' }) } + +// 查询门户网站配置类型下拉树结构 +export function portalConfigTypeTree(query) { + return request({ + url: '/portal/portalConfig/portalConfigTypeTree', + method: 'get', + params: query + }) +} diff --git a/ruoyi-ui/src/views/portal/portalConfig/index.vue b/ruoyi-ui/src/views/portal/portalConfig/index.vue index 979c907..4bbf274 100644 --- a/ruoyi-ui/src/views/portal/portalConfig/index.vue +++ b/ruoyi-ui/src/views/portal/portalConfig/index.vue @@ -9,37 +9,15 @@ @keyup.enter.native="handleQuery" /> - - - - - - - - - - - + + + + 搜索 @@ -96,8 +74,13 @@ - - + + + + + @@ -134,13 +117,18 @@ - + - - + + + + + + @@ -222,10 +210,13 @@