diff --git a/src/main/java/com/huoran/iasf/controller/SysColumnController.java b/src/main/java/com/huoran/iasf/controller/SysColumnController.java index fcd11ff..b82cef8 100644 --- a/src/main/java/com/huoran/iasf/controller/SysColumnController.java +++ b/src/main/java/com/huoran/iasf/controller/SysColumnController.java @@ -89,7 +89,23 @@ public class SysColumnController { @PostMapping("/sortByColumn") @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(); }