diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/CmsCategoryController.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/CmsCategoryController.java index 9df3e43..a8db61a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/CmsCategoryController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/CmsCategoryController.java @@ -1,8 +1,11 @@ package com.ruoyi.cms.controller; import java.util.List; +import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; +import cn.hutool.core.bean.BeanUtil; +import com.ruoyi.cms.domain.vo.NewCategoryVo; import com.ruoyi.cms.query.CmsContentQuery; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.utils.StringUtils; @@ -84,10 +87,6 @@ public class CmsCategoryController extends BaseController { return error("新增栏目'" + cmsCategory.getCategoryName() + "'失败,栏目名称已存在"); } - else if (UserConstants.NO_FRAME.equals(cmsCategory.getIsFrame()) && !StringUtils.ishttp(cmsCategory.getCategoryUrl())) - { - return error("新增栏目'" + cmsCategory.getCategoryName() + "'失败,地址必须以http(s)://开头"); - } return toAjax(cmsCategoryService.insertCmsCategory(cmsCategory)); } @@ -103,10 +102,6 @@ public class CmsCategoryController extends BaseController { return error("新增栏目'" + cmsCategory.getCategoryName() + "'失败,栏目名称已存在"); } - else if (UserConstants.NO_FRAME.equals(cmsCategory.getIsFrame()) && !StringUtils.ishttp(cmsCategory.getCategoryUrl())) - { - return error("新增栏目'" + cmsCategory.getCategoryName() + "'失败,地址必须以http(s)://开头"); - } else if (cmsCategory.getId().equals(cmsCategory.getParentId())) { return error("修改栏目'" + cmsCategory.getCategoryName() + "'失败,上级栏目不能选择自己"); @@ -136,4 +131,20 @@ public class CmsCategoryController extends BaseController public AjaxResult getContentByCategoryId(CmsContentQuery contentQuery){ return success(cmsCategoryService.getContentById(contentQuery)); } + + /** + * 获取所有的叶子节点,除了自己 + */ + @GetMapping("/leavesCategory") + public AjaxResult getLeavesCategory(Long id){ + List list = cmsCategoryService.getLeavesCategoryList(); + List result = list.stream().filter(item -> item.getId() != id).collect(Collectors.toList()); + List collect = result.stream().map(item -> { + NewCategoryVo categoryVo = new NewCategoryVo(); + BeanUtil.copyProperties(item, categoryVo); + categoryVo.setContents(cmsCategoryService.getLeavesContentList(item.getId())); + return categoryVo; + }).collect(Collectors.toList()); + return success(collect); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/core/NewTreeSelect.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/core/NewTreeSelect.java index dd7e171..70960aa 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/core/NewTreeSelect.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/core/NewTreeSelect.java @@ -25,6 +25,9 @@ public class NewTreeSelect{ /** 跳转路径 */ private String jumpUrl; + /** 栏目模板 */ + private String temp; + /** 子节点 */ @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children; @@ -39,6 +42,7 @@ public class NewTreeSelect{ this.id = category.getId(); this.label = category.getCategoryName(); this.jumpUrl = category.getCategoryUrl(); + this.temp = category.getTemp(); this.children = category.getChildren().stream().map(NewTreeSelect::new).collect(Collectors.toList()); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsCategory.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsCategory.java index 0cb5750..e8a2227 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsCategory.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsCategory.java @@ -42,9 +42,9 @@ public class CmsCategory extends BaseEntity @Excel(name = "父栏目ID") private Long parentId; - /** 是否外链(0:否,1:是) */ - @Excel(name = "是否外链", readConverterExp = "0=:否,1:是") - private String isFrame; + /** 栏目模板*/ + @Excel(name = "栏目模板") + private String temp; /** 是否显示(0:显示,1:不显示,默认0) */ @Excel(name = "是否显示(0:显示,1:不显示,默认0)") diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsContent.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsContent.java index 3302287..4e94b3b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsContent.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsContent.java @@ -103,6 +103,12 @@ public class CmsContent extends BaseEntity @Excel(name = "视频地址") private List videoUrl; + /** 链接类型(0=内链,1=外链) */ + private String linkType; + + /** 链接地址 */ + private String link; + /** 逻辑删除0未删除1真删除 */ private Integer delFlag; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/vo/NewCategoryVo.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/vo/NewCategoryVo.java new file mode 100644 index 0000000..451bf5d --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/vo/NewCategoryVo.java @@ -0,0 +1,47 @@ +package com.ruoyi.cms.domain.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.ruoyi.cms.domain.CmsContent; +import com.ruoyi.common.annotation.Excel; +import lombok.Data; + +import java.util.List; + +@Data +public class NewCategoryVo { + + @JsonSerialize(using = ToStringSerializer.class) + /** 栏目ID */ + private Long id; + + /** 栏目名称 */ + @Excel(name = "栏目名称") + private String categoryName; + + /** 栏目排序(默认0) */ + @Excel(name = "栏目排序(默认0)") + private Long categorySort; + + /** 栏目路径 */ + @Excel(name = "栏目路径") + private String categoryUrl; + + @JsonSerialize(using = ToStringSerializer.class) + /** 父栏目ID */ + @Excel(name = "父栏目ID") + private Long parentId; + + /** 是否外链(0:否,1:是) */ + @Excel(name = "是否外链", readConverterExp = "0=:否,1:是") + private String isFrame; + + /** 是否显示(0:显示,1:不显示,默认0) */ + @Excel(name = "是否显示(0:显示,1:不显示,默认0)") + private String isDisable; + + /** 逻辑删除0未删除1真删除 */ + private Integer delFlag; + + private List contents; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/ICmsCategoryService.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/ICmsCategoryService.java index 68e2d50..4cd4b6c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/ICmsCategoryService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/ICmsCategoryService.java @@ -118,4 +118,9 @@ public interface ICmsCategoryService extends IService * @return */ List getLeavesCategoryList(); + + /** + * 按ID查询所有文章 + */ + List getLeavesContentList(Long id); } 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 8f1ca7e..67ef794 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 @@ -256,4 +256,15 @@ public class CmsCategoryServiceImpl extends ServiceImpl getLeavesCategoryList() { return baseMapper.selectList(new QueryWrapper().ne("parent_id", 0)); } + + /** + * 按ID查询所有文章 + */ + @Override + public List getLeavesContentList(Long id){ + return contentMapper.selectList(new QueryWrapper().and(item -> { + item.eq("category_id", id) + .eq("del_flag", 0); + })); + } } diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index b0cb94c..37b2d64 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -5,6 +5,10 @@ spring: driverClassName: com.mysql.cj.jdbc.Driver druid: # 主库数据源 +# master: +# url: jdbc:mysql://122.51.230.86:3306/hgd_website?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: hgdRoot +# password: qqzcy@1014 master: url: jdbc:mysql://localhost:3306/ry-cms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root diff --git a/ruoyi-admin/src/main/resources/mapper/cms/CmsCategoryMapper.xml b/ruoyi-admin/src/main/resources/mapper/cms/CmsCategoryMapper.xml index 2e271d4..30c0c27 100644 --- a/ruoyi-admin/src/main/resources/mapper/cms/CmsCategoryMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/cms/CmsCategoryMapper.xml @@ -10,7 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + @@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, category_name, category_sort, category_url, parent_id, is_frame, is_disable, remark, del_flag, create_time, create_by, update_time, update_by from cms_category + select id, category_name, category_sort, category_url, parent_id, temp, is_disable, remark, del_flag, create_time, create_by, update_time, update_by from cms_category @@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and category_sort = #{categorySort} and category_url = #{categoryUrl} and parent_id = #{parentId} - and is_frame = #{isFrame} + and temp = #{temp} and is_disable = #{isDisable} and del_flag = 0 @@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" category_sort, category_url, parent_id, - is_frame, + temp, is_disable, remark, del_flag, @@ -66,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{categorySort}, #{categoryUrl}, #{parentId}, - #{isFrame}, + #{temp}, #{isDisable}, #{remark}, #{delFlag}, @@ -84,7 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" category_sort = #{categorySort}, category_url = #{categoryUrl}, parent_id = #{parentId}, - is_frame = #{isFrame}, + temp = #{temp}, is_disable = #{isDisable}, remark = #{remark}, del_flag = #{delFlag}, diff --git a/ruoyi-admin/target/classes/mapper/cms/CmsContentMapper.xml b/ruoyi-admin/target/classes/mapper/cms/CmsContentMapper.xml index 67de817..e422657 100644 --- a/ruoyi-admin/target/classes/mapper/cms/CmsContentMapper.xml +++ b/ruoyi-admin/target/classes/mapper/cms/CmsContentMapper.xml @@ -33,6 +33,8 @@ typeHandler="com.ruoyi.system.handler.MysqlTypeHandler"/> + + @@ -60,7 +62,9 @@ create_time, create_by, update_time, - update_by + update_by, + link_type, + link from cms_content @@ -121,6 +125,8 @@ create_by, update_time, update_by, + link_type, + link, image_url, video_url, @@ -150,6 +156,8 @@ #{createBy}, #{updateTime}, #{updateBy}, + #{linkType}, + #{link}, #{imageUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler}, @@ -184,6 +192,8 @@ create_by = #{createBy}, update_time = #{updateTime}, update_by = #{updateBy}, + link_type = #{linkType}, + link = #{link}, image_url = #{imageUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler}, video_url = #{videoUrl,jdbcType=OTHER,typeHandler=com.ruoyi.system.handler.MysqlTypeHandler}, diff --git a/ruoyi-ui/src/api/cms/category.js b/ruoyi-ui/src/api/cms/category.js index 29a7105..20ed2b1 100644 --- a/ruoyi-ui/src/api/cms/category.js +++ b/ruoyi-ui/src/api/cms/category.js @@ -42,3 +42,11 @@ export function delCategory(id) { method: 'delete' }) } + +// 取所有的叶子节点 +export function getLeavesCategory(id){ + return request({ + url: "/cms/category/leavesCategory", + params: id + }) +} diff --git a/ruoyi-ui/src/views/cms/category/index.vue b/ruoyi-ui/src/views/cms/category/index.vue index c5d6749..1c67ae1 100644 --- a/ruoyi-ui/src/views/cms/category/index.vue +++ b/ruoyi-ui/src/views/cms/category/index.vue @@ -132,17 +132,15 @@ - - - - - - 是否外链 - - - - - + + + + @@ -192,7 +190,7 @@ import {getMenu} from "@/api/system/menu"; export default { name: "Category", - dicts: ['cms_category_disable'], + dicts: ['cms_category_disable', "category_temp"], components: { Treeselect, IconSelect }, data() { return { @@ -233,7 +231,7 @@ export default { { required: true, message: "栏目名称不能为空", trigger: "blur" } ], categorySort: [ - { required: true, message: "栏目排序(默认0)不能为空", trigger: "blur" } + { required: true, message: "栏目排序不能为空", trigger: "blur" } ], categoryUrl: [ { required: true, message: "栏目路径不能为空", trigger: "blur" } @@ -242,7 +240,7 @@ export default { { required: true, message: "父栏目不能为空", trigger: "change" } ], isDisable: [ - { required: true, message: "是否显示(0:显示,1:不显示,默认0)不能为空", trigger: "blur" } + { required: true, message: "是否显示不能为空", trigger: "blur" } ], } }; @@ -288,7 +286,7 @@ export default { createBy: null, updateTime: null, updateBy: null, - isFrame: "0", + temp: "0", }; this.resetForm("form"); }, diff --git a/ruoyi-ui/src/views/cms/content/contentList.vue b/ruoyi-ui/src/views/cms/content/contentList.vue index 69f3d34..6a36f48 100644 --- a/ruoyi-ui/src/views/cms/content/contentList.vue +++ b/ruoyi-ui/src/views/cms/content/contentList.vue @@ -175,6 +175,11 @@ export default { type: String, defaultValue: undefined, required: false + }, + temp: { + type: String, + defaultValue: undefined, + required: false } }, data() { @@ -193,6 +198,7 @@ export default { delFlag: "0", }, total: 0, + tempType: "0", } }, watch: { @@ -201,10 +207,13 @@ export default { pageNum: 1, pageSize: 10, categoryId: newVal, - delFlag: "0" + delFlag: "0", } this.getList() - } + }, + temp(newVal){ + this.tempType = newVal + }, }, created() { if (this.cid === "") { @@ -217,7 +226,7 @@ export default { methods: { /** 新增按钮操作 */ handleAdd() { - this.$router.push({path: '/content/editor', query: {"categoryId": this.queryParams.categoryId}}) + this.$router.push({path: '/content/editor', query: {"categoryId": this.queryParams.categoryId, "temp": this.tempType}}) }, /** 删除按钮操作 */ handleDelete(row) { diff --git a/ruoyi-ui/src/views/cms/content/index.vue b/ruoyi-ui/src/views/cms/content/index.vue index b3239f6..9dd331b 100644 --- a/ruoyi-ui/src/views/cms/content/index.vue +++ b/ruoyi-ui/src/views/cms/content/index.vue @@ -30,7 +30,7 @@ - + @@ -93,6 +93,7 @@ export default { {key: 3, label: `内容状态`, visible: true}, {key: 4, label: `创建时间`, visible: true}, ], + temp: "0" } }, watch: { @@ -161,6 +162,7 @@ export default { // 节点单击事件 handleNodeClick(data) { this.selectCategoryId = data.id; + this.temp = data.temp; }, /** 查询栏目下拉树结构 */ getCategoryTree() { diff --git a/ruoyi-ui/src/views/cms/editor/index.vue b/ruoyi-ui/src/views/cms/editor/index.vue index eafa5d3..c34ddbc 100644 --- a/ruoyi-ui/src/views/cms/editor/index.vue +++ b/ruoyi-ui/src/views/cms/editor/index.vue @@ -32,6 +32,37 @@ +
+ + + + {{ dict.label }} + + + +
+
+ + + +
+
+ + + + +
@@ -83,7 +114,7 @@ - + @@ -92,13 +123,13 @@ - - - + + + + + + + @@ -121,11 +152,12 @@