From 06b65f40f6f2e7aba19148934279f34e967b3f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Thu, 6 Mar 2025 10:28:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CmsCategoryServiceImpl.java | 22 +++++++++------ .../mapper/system/SysDictDataMapper.xml | 27 ++++++++++++++++++- ruoyi-ui/src/views/cms/editor/index.vue | 1 + ruoyi-ui/src/views/officialWebsite/about.vue | 2 +- .../src/views/officialWebsite/committee.vue | 2 +- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsCategoryServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsCategoryServiceImpl.java index 72f9dc9..aed169d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsCategoryServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsCategoryServiceImpl.java @@ -302,26 +302,32 @@ public class CmsCategoryServiceImpl extends ServiceImpl getLeavesCategoryTree() { - List cmsCategories = baseMapper.selectList(new QueryWrapper()); + List cmsCategories = baseMapper.selectList(new QueryWrapper<>()); List cmsCategories1 = buildCategoryTree(cmsCategories); List treeVos = new ArrayList<>(); + for (CmsCategory cmsCategory : cmsCategories1) { TreeVo treeVo = new TreeVo(); treeVo.setLabel(cmsCategory.getCategoryName()); treeVo.setValue(cmsCategory.getId().toString()); List children = new ArrayList<>(); - cmsCategory.getChildren().forEach(cmsCategory1 -> { - TreeVo treeVo1 = new TreeVo(); - treeVo1.setLabel(cmsCategory1.getCategoryName()); - treeVo1.setValue(cmsCategory1.getId().toString()); - children.add(treeVo1); - }); + + if (cmsCategory.getChildren() != null && !cmsCategory.getChildren().isEmpty()) { + for (CmsCategory cmsCategory1 : cmsCategory.getChildren()) { + TreeVo treeVo1 = new TreeVo(); + treeVo1.setLabel(cmsCategory1.getCategoryName()); + treeVo1.setValue(cmsCategory1.getId().toString()); + children.add(treeVo1); + } + } + treeVo.setChildren(children); - treeVos.add(treeVo); + treeVos.add(treeVo); // 确保即使没有子分类,也要添加进去 } return treeVos; } + /** * 将栏目列表转换为树形结构 * diff --git a/ruoyi-system/target/classes/mapper/system/SysDictDataMapper.xml b/ruoyi-system/target/classes/mapper/system/SysDictDataMapper.xml index 3b94b7f..67d582a 100644 --- a/ruoyi-system/target/classes/mapper/system/SysDictDataMapper.xml +++ b/ruoyi-system/target/classes/mapper/system/SysDictDataMapper.xml @@ -120,5 +120,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sysdate() ) - + + insert into sys_dict_data( + dict_sort, + dict_label, + dict_value, + dict_type, + create_time + ) + values + + ( + #{dictData.dictSort}, + #{dictData.dictLabel}, + #{dictData.dictValue}, + #{dictData.dictType}, + #{dictData.cssClass}, + #{dictData.listClass}, + #{dictData.isDefault}, + #{dictData.status}, + #{dictData.remark}, + #{dictData.createBy}, + sysdate() + ) + + + \ No newline at end of file diff --git a/ruoyi-ui/src/views/cms/editor/index.vue b/ruoyi-ui/src/views/cms/editor/index.vue index 79a43f0..a97d85a 100644 --- a/ruoyi-ui/src/views/cms/editor/index.vue +++ b/ruoyi-ui/src/views/cms/editor/index.vue @@ -384,6 +384,7 @@ export default { getContentById(contentId) { getContent(contentId).then(res => { this.form = res.data + this.form.selectCategoryId = this.form.categoryId this.listLeavesCategory(this.form.categoryId) this.isType = this.form.contentType this.linkType = this.form.linkType diff --git a/ruoyi-ui/src/views/officialWebsite/about.vue b/ruoyi-ui/src/views/officialWebsite/about.vue index dd0f3b7..6678cd8 100644 --- a/ruoyi-ui/src/views/officialWebsite/about.vue +++ b/ruoyi-ui/src/views/officialWebsite/about.vue @@ -357,7 +357,7 @@ export default { .about-conts .about-conts-item1 { padding: 30px 2%; - width: 76%; + width: 84%; margin: 0 auto; background-color: #fff; z-index: 999 !important; diff --git a/ruoyi-ui/src/views/officialWebsite/committee.vue b/ruoyi-ui/src/views/officialWebsite/committee.vue index df27044..4d1fb25 100644 --- a/ruoyi-ui/src/views/officialWebsite/committee.vue +++ b/ruoyi-ui/src/views/officialWebsite/committee.vue @@ -206,7 +206,7 @@ export default { getCategoryByParentId(this.routeParam.categoryId).then(res => { this.nav = res.data this.$nextTick(() => { - this.categoryId = this.nav[1].id + this.categoryId = this.nav[this.currentActive].id }) if (this.currentActive != 0) { this.getContentDetail()