From 452488703f6e585d0ce97993b1b09f60272cc071 Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Fri, 25 Nov 2022 10:17:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9D=E6=8D=AE=E9=9C=80=E6=B1=82=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iasf/controller/SysColumnController.java | 47 +++++++++- .../controller/SysTemplateController.java | 35 +++++--- .../huoran/iasf/entity/SysTemplateStyle.java | 5 +- .../huoran/iasf/mapper/SysColumnMapper.java | 3 + .../huoran/iasf/mapper/SysContentMapper.java | 4 + .../iasf/mapper/xml/SysColumnMapper.xml | 71 ++++++++++++--- .../iasf/mapper/xml/SysContentMapper.xml | 88 +++++++++---------- .../huoran/iasf/service/SysColumnService.java | 3 + .../iasf/service/SysTemplateStyleService.java | 2 + .../service/impl/SysColumnServiceImpl.java | 5 ++ .../service/impl/SysContentServiceImpl.java | 8 +- .../huoran/iasf/vo/req/PageContentReqVO.java | 6 ++ .../iasf/vo/resp/PageContentRespVO.java | 8 ++ .../com/company/project/CodeGenerator.java | 2 +- 14 files changed, 207 insertions(+), 80 deletions(-) diff --git a/src/main/java/com/huoran/iasf/controller/SysColumnController.java b/src/main/java/com/huoran/iasf/controller/SysColumnController.java index e20947b..c4c60ea 100644 --- a/src/main/java/com/huoran/iasf/controller/SysColumnController.java +++ b/src/main/java/com/huoran/iasf/controller/SysColumnController.java @@ -26,6 +26,7 @@ import com.huoran.iasf.service.SysColumnService; import javax.validation.Valid; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; import java.util.List; @@ -70,6 +71,10 @@ public class SysColumnController { @PostMapping("/save") @ApiOperation(value = "新增", response = SysColumn.class) public R save(@RequestBody @Valid SysColumn sysColumn) { + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("father_id", sysColumn.getFatherId()); + Integer count = service.count(queryWrapper); + sysColumn.setSort(count+1); boolean addState = service.save(sysColumn); return addState ? R.success(sysColumn.getId()) : R.fail("新增失败"); } @@ -87,7 +92,7 @@ public class SysColumnController { boolean delState = service.removeById(id); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.in("column_id",id); + queryWrapper.in("column_id", id); //删除栏目后删除栏目下的文章 List contentId = contentService.list(queryWrapper); contentService.removeByIds(contentId); @@ -100,7 +105,7 @@ public class SysColumnController { public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestParam List ids) { boolean delState = service.removeByIds(ids); QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.in("column_id",ids); + queryWrapper.in("column_id", ids); //删除栏目后删除栏目下的文章 contentService.remove(queryWrapper); return delState ? R.success() : R.fail("删除失败"); @@ -135,5 +140,43 @@ public class SysColumnController { return R.success(); } + + @ApiOperation("获取一级下的子级栏目(包含自己)") + @PostMapping("/getsTheSubColumn") + public R getsTheSubColumn(Integer id) { + + //1 创建list集合,用于封装所有删除菜单id值 + List idList = new ArrayList<>(); + //2 向idList集合设置删除菜单id + this.selectCategoryChildById(id + "", idList);//找到当前菜单的子菜单 把结果id封装到idlist里面去 + //把当前id封装到list里面 + idList.add(id);//现在把当前id封装进去 之前都是子菜单的id + String str = ""; + for (Integer idstr : idList) { + str += idstr + ","; + } + String ids = str.substring(0, str.length() - 1); + + return service.getsTheSubColumn(id, ids); + + } + + public void selectCategoryChildById(String id, List idList) { + //查询菜单里面子菜单id + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("father_id", id); + wrapper.eq("deleted", Constant.DATA_NOT_DELETED); + wrapper.select("id");//我们只想查询id 所以只需要查询指定列的值 + List childIdList = service.list(wrapper);//当前菜单的所有子菜单 + //把childIdList里面菜单id值获取出来,封装idList里面,做递归查询 + childIdList.stream().forEach(item -> {//遍历集合得到每一个对象item + //封装idList里面 + idList.add(item.getId()); + //递归查询 + this.selectCategoryChildById(item.getId() + "", idList); + }); + } + + } diff --git a/src/main/java/com/huoran/iasf/controller/SysTemplateController.java b/src/main/java/com/huoran/iasf/controller/SysTemplateController.java index b943e78..c164ef4 100644 --- a/src/main/java/com/huoran/iasf/controller/SysTemplateController.java +++ b/src/main/java/com/huoran/iasf/controller/SysTemplateController.java @@ -3,6 +3,8 @@ package com.huoran.iasf.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.huoran.iasf.common.utils.Constant; import com.huoran.iasf.entity.SysTemplateStyle; +import com.huoran.iasf.entity.SysTemplateStyleConfiguration; +import com.huoran.iasf.service.SysTemplateStyleConfigurationService; import com.huoran.iasf.service.SysTemplateStyleService; import io.swagger.annotations.*; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -41,12 +43,13 @@ public class SysTemplateController { @Autowired public SysTemplateStyleService styleService; - + @Autowired + public SysTemplateStyleConfigurationService templateStyleConfigurationService; @PostMapping("/listOfColumnTemplates") @ApiOperation(value = "获取文章模板列表、详情样式", response = SysTemplate.class) public R listOfColumnTemplates() { - List list = templateService.list(new QueryWrapper().eq("type",1)); + List list = templateService.list(new QueryWrapper().eq("type", 1)); return R.success(list); } @@ -54,7 +57,7 @@ public class SysTemplateController { @PostMapping("/longPageListStyle") @ApiOperation(value = "长页列表样式", response = SysTemplate.class) public R longPageListStyle() { - List list = styleService.list(new QueryWrapper().eq("template_id",9)); + List list = styleService.list(new QueryWrapper().eq("is_long_page", 1)); return R.success(list); } @@ -62,28 +65,28 @@ public class SysTemplateController { @ApiOperation(value = "根据模板id获取样式", response = SysTemplateStyle.class) public R theTemplateIdGetsTheStyle(@ApiParam(name = "templateId", value = "模板id", required = true) @RequestParam Integer templateId) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("template_id",templateId); + /*QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("type", Constant.LIST_TEMPLATE_TYPES); + queryWrapper.eq("is_long_page", 0); List listingTemplateTypes = styleService.list(queryWrapper); QueryWrapper queryWrapper1 = new QueryWrapper<>(); queryWrapper1.eq("template_id",templateId); queryWrapper1.eq("type", Constant.DETAILS_TEMPLATE_TYPE); - List detailsTypeOfTheTemplate = styleService.list(queryWrapper1); + List detailsTypeOfTheTemplate = styleService.list(queryWrapper1);*/ + List listingTemplateTypes = templateStyleConfigurationService.getsTheStyleUnderTheTemplate(templateId, 0); + List detailsTypeOfTheTemplate = templateStyleConfigurationService.getsTheStyleUnderTheTemplate(templateId, 1); - Map map = new HashMap<>(); - map.put("listingTemplateTypes",listingTemplateTypes);//列表样式 - map.put("detailsTypeOfTheTemplate",detailsTypeOfTheTemplate);//详情样式 + + Map map = new HashMap<>(); + map.put("listingTemplateTypes", listingTemplateTypes);//列表样式 + map.put("detailsTypeOfTheTemplate", detailsTypeOfTheTemplate);//详情样式 return R.success(map); } - - - @PostMapping("/fullDetailsTemplateStyle") @ApiOperation(value = "全部详情模板样式", response = SysTemplateStyle.class) public R fullDetailsTemplateStyle() { @@ -93,5 +96,13 @@ public class SysTemplateController { List listingTemplateTypes = styleService.list(queryWrapper); return R.success(listingTemplateTypes); } + + + @PostMapping("/individualTemplateDetailsStyle") + @ApiOperation(value = "独立模板详情样式", response = SysTemplate.class) + public R individualTemplateDetailsStyle() { + List list = styleService.list(new QueryWrapper().eq("type", 1).eq("is_long_page", 0)); + return R.success(list); + } } diff --git a/src/main/java/com/huoran/iasf/entity/SysTemplateStyle.java b/src/main/java/com/huoran/iasf/entity/SysTemplateStyle.java index dc49b03..41552df 100644 --- a/src/main/java/com/huoran/iasf/entity/SysTemplateStyle.java +++ b/src/main/java/com/huoran/iasf/entity/SysTemplateStyle.java @@ -35,13 +35,12 @@ public class SysTemplateStyle implements Serializable { @ApiModelProperty(value = "样式名称") private String style; - @ApiModelProperty(value = "模板id") - private Integer templateId; @ApiModelProperty(value = "跳转路径") private String path; - + @ApiModelProperty(value = "是否为长页") + private Integer isLongPage; } diff --git a/src/main/java/com/huoran/iasf/mapper/SysColumnMapper.java b/src/main/java/com/huoran/iasf/mapper/SysColumnMapper.java index 09df759..e9ec93a 100644 --- a/src/main/java/com/huoran/iasf/mapper/SysColumnMapper.java +++ b/src/main/java/com/huoran/iasf/mapper/SysColumnMapper.java @@ -2,6 +2,7 @@ package com.huoran.iasf.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.huoran.iasf.common.utils.R; import com.huoran.iasf.entity.SysColumn; import com.huoran.iasf.vo.FatherContentRespVO; import com.huoran.iasf.vo.req.LongPageColumnReqVO; @@ -32,4 +33,6 @@ public interface SysColumnMapper extends BaseMapper { //依据子级查询父级 List getParentInformationBasedOnChild(@Param("id")Integer id); + + List getsTheSubColumn(@Param("parentId")Integer parentId ,@Param("ids")String ids); } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/mapper/SysContentMapper.java b/src/main/java/com/huoran/iasf/mapper/SysContentMapper.java index 8bedc5a..d61fc62 100644 --- a/src/main/java/com/huoran/iasf/mapper/SysContentMapper.java +++ b/src/main/java/com/huoran/iasf/mapper/SysContentMapper.java @@ -9,6 +9,8 @@ import org.apache.ibatis.annotations.Mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * @描述:文章管理 Mapper 接口 * @作者: Rong @@ -17,4 +19,6 @@ import org.apache.ibatis.annotations.Param; @Mapper public interface SysContentMapper extends BaseMapper { IPage articlePaginationList(Page page, @Param("req") PageContentReqVO req); + + IPage getPublishedArticles(Page page, @Param("req") PageContentReqVO req); } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/mapper/xml/SysColumnMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/SysColumnMapper.xml index 38fa860..e1ce40e 100644 --- a/src/main/java/com/huoran/iasf/mapper/xml/SysColumnMapper.xml +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysColumnMapper.xml @@ -38,20 +38,18 @@ ( SELECT t.template_type FROM sys_template t WHERE t.id = s.template_id ) AS templateName, ( SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.list_style_id ) AS listStyle, ( SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.detail_style_id ) AS detailStyle, - ( SELECT sty.path FROM sys_template_style sty WHERE sty.id = s.list_style_id ) AS path + ( SELECT sty.path FROM sys_template_style sty WHERE sty.id = s.list_style_id ) AS path FROM sys_column s WHERE - deleted = 1 and site_id = #{vo.siteId} + deleted = 1 and site_id = #{vo.siteId} and column_name LIKE CONCAT('%',#{vo.columnName},'%') ORDER BY - s.father_id, - s.sort ASC, - s.create_time desc + s.sort ASC ORDER BY @@ -78,16 +76,13 @@ T2.father_id, T2.level, T2.sort - FROM ( - SELECT @r AS _id, + FROM (SELECT @r AS _id, ( SELECT @r := father_id FROM sys_column WHERE id = _id ) AS parent_id, @l := @l + 1 AS lvl - FROM - ( SELECT @r := #{id}, @l := 0 ) vars, - sys_column h - WHERE - @r != 0 - ) T1 + FROM + ( SELECT @r := #{id}, @l := 0 ) vars, sys_column h + WHERE + @r != 0) T1 JOIN sys_column T2 ON T1._id = T2.id WHERE deleted = 1 @@ -102,7 +97,36 @@ ( SELECT u.username FROM sys_user u WHERE u.id = s.editor_id ) AS editorUser, ( SELECT t.template_type FROM sys_template t WHERE t.id = s.template_id ) AS templateName, ( SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.list_style_id ) AS listStyle, - ( SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.detail_style_id ) AS detailStyle + ( SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.detail_style_id ) AS detailStyle, + ( SELECT sty.path FROM sys_template_style sty WHERE sty.id = s.list_style_id ) AS path + FROM + sys_column s + WHERE deleted = 1 and site_id = #{vo.siteId} + and menu_visible = 0 + + and column_name LIKE CONCAT('%',#{vo.columnName},'%') + + + + ORDER BY + s.sort ASC + + + ORDER BY + s.create_time asc + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml index e842a15..2a43901 100644 --- a/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml @@ -1,50 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/service/SysColumnService.java b/src/main/java/com/huoran/iasf/service/SysColumnService.java index e88e009..4e5fe85 100644 --- a/src/main/java/com/huoran/iasf/service/SysColumnService.java +++ b/src/main/java/com/huoran/iasf/service/SysColumnService.java @@ -29,4 +29,7 @@ public interface SysColumnService extends IService { //长页栏目列表 R longPageColumnList(LongPageColumnReqVO reqVO); + + R getsTheSubColumn(Integer parentId,String ids); + } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/service/SysTemplateStyleService.java b/src/main/java/com/huoran/iasf/service/SysTemplateStyleService.java index 7d52b87..f32b1ff 100644 --- a/src/main/java/com/huoran/iasf/service/SysTemplateStyleService.java +++ b/src/main/java/com/huoran/iasf/service/SysTemplateStyleService.java @@ -3,6 +3,8 @@ package com.huoran.iasf.service; import com.huoran.iasf.entity.SysTemplateStyle; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** *

* 服务类 diff --git a/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java index 581d9d5..556bb7a 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java @@ -133,6 +133,11 @@ public class SysColumnServiceImpl extends ServiceImpl getChildren(Integer id, List allDept) { //存放子节点 diff --git a/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java index 3fa562f..11d110d 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java @@ -58,11 +58,11 @@ public class SysContentServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + /* QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("site_id", reqVO.getSiteId()); - queryWrapper.eq("is_release", Constant.ARTICLE_PUBLISHED).orderByDesc("create_time"); - Page page = new Page(reqVO.getPageNum(), reqVO.getPageSize()); - IPage pageList = baseMapper.selectPage(page, queryWrapper); + queryWrapper.eq("is_release", Constant.ARTICLE_PUBLISHED).orderByDesc("create_time");*/ + Page page = new Page(reqVO.getPageNum(), reqVO.getPageSize()); + IPage pageList = baseMapper.getPublishedArticles(page,reqVO); return R.success(pageList); } diff --git a/src/main/java/com/huoran/iasf/vo/req/PageContentReqVO.java b/src/main/java/com/huoran/iasf/vo/req/PageContentReqVO.java index 757ea7f..c98347a 100644 --- a/src/main/java/com/huoran/iasf/vo/req/PageContentReqVO.java +++ b/src/main/java/com/huoran/iasf/vo/req/PageContentReqVO.java @@ -34,5 +34,11 @@ public class PageContentReqVO extends PageReqVO { @NotNull(message = "站点id不能为空!") private Integer siteId; + @ApiModelProperty(value = "标签id(逗号隔开)") + private String lableId; + + + @ApiModelProperty(value = "分类id") + private Integer classificationId; } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java b/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java index d73fce8..87483de 100644 --- a/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java +++ b/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java @@ -95,4 +95,12 @@ public class PageContentRespVO { @ApiModelProperty(value = "是否禁用(0默认,0启用 1禁用)") private Integer isDisable; + + @ApiModelProperty(value = "是否禁用(0默认,0启用 1禁用)") + private String labelName; + + + @ApiModelProperty(value = "是否禁用(0默认,0启用 1禁用)") + private String classificationName; + } \ No newline at end of file diff --git a/src/test/java/com/company/project/CodeGenerator.java b/src/test/java/com/company/project/CodeGenerator.java index d792040..b738510 100644 --- a/src/test/java/com/company/project/CodeGenerator.java +++ b/src/test/java/com/company/project/CodeGenerator.java @@ -61,7 +61,7 @@ public class CodeGenerator { // 5、策略配置 StrategyConfig strategy = new StrategyConfig(); - strategy.setInclude("sys_template_style"); + strategy.setInclude("sys_template_style_configuration"); strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略 // strategy.setTablePrefix("sys_"); //生成实体时去掉表前缀