From 1db80e42e91bb2b7260b8f0f6ec1f79200c13ba5 Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Mon, 3 Apr 2023 18:00:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iasf/controller/SysColumnController.java | 57 ++++++++- .../iasf/controller/SysContentController.java | 116 +++--------------- .../com/huoran/iasf/entity/SysContent.java | 10 +- .../iasf/mapper/xml/SysContentMapper.xml | 52 +++----- .../iasf/service/SysContentService.java | 4 +- .../service/impl/SysContentServiceImpl.java | 10 +- .../huoran/iasf/vo/req/PageContentReqVO.java | 7 +- .../iasf/vo/resp/PageContentRespVO.java | 7 +- 8 files changed, 117 insertions(+), 146 deletions(-) diff --git a/src/main/java/com/huoran/iasf/controller/SysColumnController.java b/src/main/java/com/huoran/iasf/controller/SysColumnController.java index 84c237b..dcbe8d6 100644 --- a/src/main/java/com/huoran/iasf/controller/SysColumnController.java +++ b/src/main/java/com/huoran/iasf/controller/SysColumnController.java @@ -24,6 +24,7 @@ import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.RequestParam; import io.swagger.annotations.ApiOperation; +import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; @@ -54,6 +55,9 @@ public class SysColumnController { @Autowired public SysTemplateStyleService styleService; + @Autowired + public SysColumnLongPageService sysColumnLongPageService; + @Autowired public SysTemplateStyleConfigurationService templateStyleConfigurationService; @@ -108,7 +112,7 @@ public class SysColumnController { return updateState ? R.success() : R.fail("编辑失败"); } - @NoRepeatSubmit + /*@NoRepeatSubmit @PostMapping("/delete") @ApiOperation(value = "删除", response = SysContent.class) public R delete(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { @@ -127,7 +131,7 @@ public class SysColumnController { contentService.removeByIds(contentId); return delState ? R.success() : R.fail("删除失败"); - } + }*/ @NoRepeatSubmit @PostMapping("/batchDeletion") @@ -153,6 +157,13 @@ public class SysColumnController { queryWrapper.in("column_id", idList); //删除栏目后删除栏目下的文章 contentService.remove(queryWrapper); + + + //删除长页栏目 + QueryWrapper queryWrapper1 = new QueryWrapper(); + queryWrapper1.in("column_id", idList); + //删除栏目后删除栏目下的文章 + sysColumnLongPageService.remove(queryWrapper1); ret = service.removeByIds(idList); } @@ -290,5 +301,47 @@ public class SysColumnController { return service.queryArticlesByColumnType(ids, columnId); } + + @NoRepeatSubmit + @PostMapping("/deleteUselessData") + @ApiOperation(value = "删除无用数据", response = SysColumn.class) + public R deleteUselessData() { + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("deleted", 0).select("id"); + List list = service.list(queryWrapper); + + for (SysColumn column : list) { + UpdateWrapper filesEntityUpdateWrapper = new UpdateWrapper<>(); + filesEntityUpdateWrapper.eq("quote_id", column.getId()); + filesEntityUpdateWrapper.eq("quote_type", 1); + filesEntityUpdateWrapper.set("is_del", 1); + sysFilesService.update(filesEntityUpdateWrapper); + //1 创建list集合,用于封装所有删除菜单id值 + List idList = new ArrayList<>(); + //2 向idList集合设置删除菜单id + //找到当前菜单的子菜单 把结果id封装到idlist里面去 + this.selectCategoryChildById(column.getId() + "", idList); + //把当前id封装到list里面 //现在把当前id封装进去 之前都是子菜单的id + idList.add(column.getId()); + + //删除当前栏目以及栏目下的文章 + QueryWrapper queryWrapper1 = new QueryWrapper<>(); + queryWrapper1.in("column_id", idList); + //删除栏目后删除栏目下的文章 + contentService.remove(queryWrapper1); + + + //删除长页栏目 + QueryWrapper queryWrapper2 = new QueryWrapper(); + queryWrapper2.in("column_id", idList); + //删除栏目后删除栏目下的文章 + sysColumnLongPageService.remove(queryWrapper2); + service.removeByIds(idList); + } + + + return R.success(); + } } diff --git a/src/main/java/com/huoran/iasf/controller/SysContentController.java b/src/main/java/com/huoran/iasf/controller/SysContentController.java index d080158..372920d 100644 --- a/src/main/java/com/huoran/iasf/controller/SysContentController.java +++ b/src/main/java/com/huoran/iasf/controller/SysContentController.java @@ -97,14 +97,14 @@ public class SysContentController { @ApiOperation(value = "新增", response = SysContent.class) public R save(@RequestBody @Valid @ApiParam(name = "文章管理对象", value = "传入json格式", required = true) SysContent sysContent) { - QueryWrapper queryWrap = new QueryWrapper<>(); + /* QueryWrapper queryWrap = new QueryWrapper<>(); queryWrap.eq("column_id", sysContent.getColumnId()); queryWrap.eq("deleted", 1); Integer count = service.count(queryWrap); if (count == 0) { count = 1; } - sysContent.setSequence(count + 1); + sysContent.setSequence(count + 1);*/ boolean addState = service.save(sysContent); @@ -218,106 +218,28 @@ public class SysContentController { } - /*@PostMapping("/modifiedSort") - @ApiOperation(value = "修改排序", response = SysContent.class) - public R modifiedSort( - @ApiParam(name = "sequenceNumber", value = "要排序的序号", required = true) @RequestParam Integer sequenceNumber, + @PostMapping("/articleTopOperation") + @ApiOperation(value = "文章置顶/取消置顶", response = SysContent.class) + public R articleTopOperation( + @ApiParam(name = "isTop", value = "是否置顶(默认为0 不置顶 1为置顶)", required = true) @RequestParam Integer isTop, @ApiParam(name = "articleId", value = "文章Id", required = true) @RequestParam Integer articleId) { - if (sequenceNumber<=0){ - return R.fail("请输入正确的序号!"); + //是否置顶(默认为0 不置顶 1为置顶) + UpdateWrapper updateWrap = new UpdateWrapper<>(); + + if (isTop == 1) { + //置顶时间(置顶一次更新一次) + updateWrap.set("top_time", new Date()); + } else { + updateWrap.set("top_time", null); } - SysContent content = service.getById(articleId); - //获取当前排序的序号 - Integer currentSerialNumber = content.getSequence(); + updateWrap.set("is_top", isTop); + updateWrap.eq("id", articleId); + updateWrap.eq("deleted", 1); + boolean ret = service.update(updateWrap); + return ret ? R.success() : R.fail("操作失败"); - - - //获取当前文章所属栏目id - Integer columnId = content.getColumnId(); - - //获取当前栏目下的全部文章 - *//*QueryWrapper queryWrap = new QueryWrapper<>(); - queryWrap.eq("column_id", columnId); - queryWrap.eq("deleted", 1); - List contentList = service.list(queryWrap);*//* - - //判断排序是值改小还是改大,大改小比如53改5那就加一个语句“大于等于5并且小于53” - //如果是小改大比如3改50那就是“大于3并且小于等于50” - //改小那就是拿到的数据都减一,改大那就是加一 - - - //对剩余的 - UpdateWrapper updateWrapper1 = new UpdateWrapper<>(); - updateWrapper1.ne("id",articleId); - - if (currentSerialNumber >= sequenceNumber) { - //改小 - updateWrapper1.setSql(" sequence = sequence + 1"); - } else if (currentSerialNumber <= sequenceNumber) { - //改大 - updateWrapper1.setSql(" sequence = sequence - 1"); - } - - updateWrapper1.eq("column_id",columnId); - updateWrapper1.eq("deleted", 1); - service.update(new SysContent(),updateWrapper1); - - - //修改当前序号 - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.set("sequence",sequenceNumber); - updateWrapper.eq("id",articleId); - service.update(new SysContent(),updateWrapper); - - - return R.success(); - }*/ - - - @PostMapping("/modifiedSort") - @ApiOperation(value = "修改排序", response = SysContent.class) - public R modifiedSort(@ApiParam(name = "sequenceNumber", value = "要排序的序号", required = true) @RequestParam Integer sequenceNumber, @ApiParam(name = "articleId", value = "文章Id", required = true) @RequestParam Integer articleId) { - return service.modifiedSort(sequenceNumber, articleId); } - @PostMapping("/modifiedArticleSort") - @ApiOperation(value = "修改文章排序", response = SysContent.class) - public R modifiedSort(@RequestBody List reqList) { - return service.modifiedSort(reqList); - } - - - @PostMapping("/sort") - @ApiOperation(value = "排序(自设置排序号) 上线后注释", response = SysContent.class) - public R sort() { - - //获取当前栏目 - QueryWrapper queryWrap = new QueryWrapper<>(); - queryWrap.eq("deleted", 1); - queryWrap.groupBy("column_id"); - queryWrap.orderByAsc("sequence"); - List columnList = service.list(queryWrap); - - for (SysContent content : columnList) { - Integer columnId = content.getColumnId(); - QueryWrapper queryWrap1 = new QueryWrapper<>(); - queryWrap1.eq("column_id", columnId); - queryWrap1.eq("deleted", 1); - queryWrap1.orderByDesc("release_time"); - List list = service.list(queryWrap1); - - Integer count = 0; - for (SysContent c : list) { - ++count; - c.setSequence(count); - service.updateById(c); - } - } - - - return R.success(); - } - } diff --git a/src/main/java/com/huoran/iasf/entity/SysContent.java b/src/main/java/com/huoran/iasf/entity/SysContent.java index 9b938d3..bbd4594 100644 --- a/src/main/java/com/huoran/iasf/entity/SysContent.java +++ b/src/main/java/com/huoran/iasf/entity/SysContent.java @@ -173,7 +173,13 @@ public class SysContent implements Serializable { @ApiModelProperty(value = "文章关键字") private String articleKeyWord; - @ApiModelProperty(value = "顺序(排序号)") - private Integer sequence; + /*@ApiModelProperty(value = "顺序(排序号)") + private Integer sequence;*/ + + @ApiModelProperty(value = "是否置顶(默认为0 不置顶 1为置顶)") + private Integer isTop; + + @ApiModelProperty(value = "置顶时间") + private Date topTime; } \ 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 baa6174..7ea11b0 100644 --- a/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml @@ -7,7 +7,8 @@ (SELECT u.real_name FROM sys_user u WHERE u.id = c.founder_id) AS founderName, (SELECT u.real_name FROM sys_user u WHERE u.id = c.editor_id) AS editorName, (SELECT type_id from sys_column WHERE sys_column.id = c.column_id) as typeId, - IFNULL( ( SELECT c1.classification_name FROM sys_content_classification c1 WHERE c1.id = c.classification_id ), '暂无' ) AS classificationName + IFNULL( ( SELECT c1.classification_name FROM sys_content_classification c1 WHERE c1.id = c.classification_id ), + '暂无' ) AS classificationName FROM sys_content c WHERE c.deleted = 1 and site_id = #{req.siteId} @@ -59,12 +60,12 @@ ORDER BY c.release_time asc - - ORDER BY sequence asc + + ORDER BY is_top asc - - ORDER BY sequence desc + + ORDER BY is_top desc @@ -135,7 +136,10 @@ ORDER BY - t.sequence asc + is_top = 1 DESC, + top_time DESC, + release_time DESC, + create_time DESC @@ -175,10 +179,12 @@ FROM (SELECT s.*, (SELECT GROUP_CONCAT(label_name) FROM sys_content_label l - WHERE deleted = 1 AND FIND_IN_SET(l.id, s.lable_id)) AS labelName, + WHERE deleted = 1 + AND FIND_IN_SET(l.id, s.lable_id)) AS labelName, (SELECT c.classification_name FROM sys_content_classification c - WHERE deleted = 1 AND s.classification_id = c.id) AS classificationName + WHERE deleted = 1 + AND s.classification_id = c.id) AS classificationName FROM sys_content s WHERE s.deleted = 1 AND is_disable = 0 @@ -186,34 +192,12 @@ WHERE FIND_IN_SET(t.column_id, #{columnId}) ORDER BY - t.sequence ASC + is_top = 1 DESC, + top_time DESC, + release_time DESC, + create_time DESC - \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/service/SysContentService.java b/src/main/java/com/huoran/iasf/service/SysContentService.java index bf9bb07..42fc556 100644 --- a/src/main/java/com/huoran/iasf/service/SysContentService.java +++ b/src/main/java/com/huoran/iasf/service/SysContentService.java @@ -39,8 +39,8 @@ public interface SysContentService extends IService { R siteSearchArticles(PageContentReqVO req); - R modifiedSort(List reqList); +// R modifiedSort(List reqList); - R modifiedSort(Integer sequenceNumber, Integer articleId); +// R modifiedSort(Integer sequenceNumber, Integer articleId); } \ No newline at end of file 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 a6c2d11..cccfd70 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java @@ -66,7 +66,7 @@ public class SysContentServiceImpl extends ServiceImpl page = new Page(reqVO.getPageNum(), reqVO.getPageSize()); //没传任何排序参数时候 默认以发布时间排序 - if (reqVO.getModifiedTimeSort() == null && reqVO.getPublicationTimeSort() == null && reqVO.getOrdinalSort() == null) { + if (reqVO.getModifiedTimeSort() == null && reqVO.getPublicationTimeSort() == null && reqVO.getTopSort() == null) { reqVO.setPublicationTimeSort(0); } /*if (reqVO.getIsDisable()!=null){ @@ -146,7 +146,7 @@ public class SysContentServiceImpl extends ServiceImpl reqList) { for (ArticleModifiedSortReq req : reqList) { SysContent content = new SysContent(); @@ -192,11 +192,11 @@ public class SysContentServiceImpl extends ServiceImpl sequenceNumber) { //改大 gt > updateWrapper1.setSql(" sequence = sequence + 1"); @@ -221,7 +221,7 @@ public class SysContentServiceImpl extends ServiceImpl