栏目排序

master
rong.liu 2 years ago
parent a5bc0662e2
commit f10e4866fc
  1. 16
      src/main/java/com/huoran/iasf/controller/SysColumnController.java

@ -89,7 +89,23 @@ public class SysColumnController {
@PostMapping("/sortByColumn") @PostMapping("/sortByColumn")
@ApiOperation(value = "栏目排序(依据id更改)", response = SysColumn.class) @ApiOperation(value = "栏目排序(依据id更改)", response = SysColumn.class)
public R sortByColumn(@RequestBody List<SortColumnRespVO> sortColumnRespVOList) { public R sortByColumn(@RequestBody List<SortColumnRespVO> sortColumnRespVOList) {
for (SortColumnRespVO sort : sortColumnRespVOList) {
SysColumn sysColumn = new SysColumn();
BeanUtils.copyProperties(sort, sysColumn);
service.updateById(sysColumn);
//依据当前循环获取的栏目id,查询到引用当前栏目的文章对其进行修改栏目id
QueryWrapper<SysContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("column_id", sysColumn.getId());
List<SysContent> contentList = contentService.list(queryWrapper);
if (contentList.size() > 0) {
for (SysContent content : contentList) {
UpdateWrapper<SysContent> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("column_id", sysColumn.getId());
contentService.update(content, updateWrapper);
}
}
}
return R.success(); return R.success();
} }

Loading…
Cancel
Save