From 28dcd554425fffa650f5b0b0fb2d6717be60ab75 Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Mon, 29 Aug 2022 14:46:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iasf/controller/SysColumnController.java | 36 ++++++++++++++++-- .../com/huoran/iasf/entity/SysColumn.java | 18 +++++++++ .../com/huoran/iasf/entity/SysContent.java | 2 +- .../iasf/mapper/xml/SysColumnMapper.xml | 8 +++- .../huoran/iasf/vo/resp/SortColumnRespVO.java | 37 +++++++++++++++++++ 5 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/huoran/iasf/vo/resp/SortColumnRespVO.java diff --git a/src/main/java/com/huoran/iasf/controller/SysColumnController.java b/src/main/java/com/huoran/iasf/controller/SysColumnController.java index e93bfef..138d120 100644 --- a/src/main/java/com/huoran/iasf/controller/SysColumnController.java +++ b/src/main/java/com/huoran/iasf/controller/SysColumnController.java @@ -1,11 +1,17 @@ package com.huoran.iasf.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.huoran.iasf.entity.ColumnEntity; import com.huoran.iasf.entity.SysColumn; import com.huoran.iasf.entity.SysContent; +import com.huoran.iasf.service.SysContentService; import com.huoran.iasf.vo.req.ColumnWeightReqVO; import com.huoran.iasf.vo.req.PaginationColumnReqVO; +import com.huoran.iasf.vo.resp.SortColumnRespVO; import io.swagger.annotations.*; import com.huoran.iasf.common.utils.R; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping; @@ -17,6 +23,7 @@ import io.swagger.annotations.ApiOperation; import com.huoran.iasf.service.SysColumnService; import javax.validation.Valid; +import java.lang.reflect.InvocationTargetException; import java.util.List; @@ -33,6 +40,9 @@ public class SysColumnController { @Autowired public SysColumnService service; + @Autowired + public SysContentService contentService; + @PostMapping("/listWithTree") @ApiOperation(value = "栏目树结构", response = SysColumn.class) @@ -77,10 +87,28 @@ public class SysColumnController { } @PostMapping("/sortByColumn") - @ApiOperation(value = "栏目排序", response = SysColumn.class) - public R sortByColumn(@RequestBody List entityList) { - boolean updateState = service.updateBatchById(entityList); - return updateState ? R.success() : R.fail("编辑成功"); + @ApiOperation(value = "栏目排序(依据id更改)", response = SysColumn.class) + public R sortByColumn(@RequestBody List sortColumnRespVOList) { + + for (SortColumnRespVO sort : sortColumnRespVOList) { + SysColumn sysColumn = new SysColumn(); + BeanUtils.copyProperties(sort, sysColumn); + service.updateById(sysColumn); + + //更改栏目下的文章 设置栏目id为新的栏目id + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("column_id", sysColumn.getId()); + List contentList = contentService.list(queryWrapper); + if (contentList.size() > 0) { + for (SysContent content : contentList) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("column_id", sysColumn.getId()); + contentService.update(content,updateWrapper); + } + } + + } + return R.success(); } } diff --git a/src/main/java/com/huoran/iasf/entity/SysColumn.java b/src/main/java/com/huoran/iasf/entity/SysColumn.java index 44d6a95..df3e16b 100644 --- a/src/main/java/com/huoran/iasf/entity/SysColumn.java +++ b/src/main/java/com/huoran/iasf/entity/SysColumn.java @@ -111,4 +111,22 @@ public class SysColumn implements Serializable { private List children; + @TableField(exist = false) + @ApiModelProperty(value = "创建人") + private String creteUser; + + + @TableField(exist = false) + @ApiModelProperty(value = "修改人") + private String editorUser; + + + @TableField(exist = false) + @ApiModelProperty(value = "总浏览") + private Integer totalBrowsing; + + public Integer getTotalBrowsing() { + return 0; + } + } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/entity/SysContent.java b/src/main/java/com/huoran/iasf/entity/SysContent.java index 1a39c49..03c6160 100644 --- a/src/main/java/com/huoran/iasf/entity/SysContent.java +++ b/src/main/java/com/huoran/iasf/entity/SysContent.java @@ -44,7 +44,7 @@ public class SysContent implements Serializable { private String source; @ApiModelProperty(value = "发布时间") - @NotNull(message = "发布时间不能为空!") +// @NotNull(message = "发布时间不能为空!") private Date releaseTime; @ApiModelProperty(value = "摘要") 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 d96fd49..49f3db7 100644 --- a/src/main/java/com/huoran/iasf/mapper/xml/SysColumnMapper.xml +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysColumnMapper.xml @@ -31,8 +31,12 @@