|
|
|
@ -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<SysContent> queryWrap = new QueryWrapper<>(); |
|
|
|
|
/* QueryWrapper<SysContent> 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("请输入正确的序号!"); |
|
|
|
|
} |
|
|
|
|
SysContent content = service.getById(articleId); |
|
|
|
|
//获取当前排序的序号
|
|
|
|
|
Integer currentSerialNumber = content.getSequence(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取当前文章所属栏目id
|
|
|
|
|
Integer columnId = content.getColumnId(); |
|
|
|
|
|
|
|
|
|
//获取当前栏目下的全部文章
|
|
|
|
|
*//*QueryWrapper<SysContent> queryWrap = new QueryWrapper<>();
|
|
|
|
|
queryWrap.eq("column_id", columnId); |
|
|
|
|
queryWrap.eq("deleted", 1); |
|
|
|
|
List<SysContent> contentList = service.list(queryWrap);*//*
|
|
|
|
|
|
|
|
|
|
//判断排序是值改小还是改大,大改小比如53改5那就加一个语句“大于等于5并且小于53”
|
|
|
|
|
//如果是小改大比如3改50那就是“大于3并且小于等于50”
|
|
|
|
|
//改小那就是拿到的数据都减一,改大那就是加一
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//对剩余的
|
|
|
|
|
UpdateWrapper<SysContent> 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<SysContent> 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); |
|
|
|
|
} |
|
|
|
|
//是否置顶(默认为0 不置顶 1为置顶)
|
|
|
|
|
UpdateWrapper<SysContent> updateWrap = new UpdateWrapper<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/modifiedArticleSort") |
|
|
|
|
@ApiOperation(value = "修改文章排序", response = SysContent.class) |
|
|
|
|
public R modifiedSort(@RequestBody List<ArticleModifiedSortReq> reqList) { |
|
|
|
|
return service.modifiedSort(reqList); |
|
|
|
|
if (isTop == 1) { |
|
|
|
|
//置顶时间(置顶一次更新一次)
|
|
|
|
|
updateWrap.set("top_time", new Date()); |
|
|
|
|
} else { |
|
|
|
|
updateWrap.set("top_time", null); |
|
|
|
|
} |
|
|
|
|
updateWrap.set("is_top", isTop); |
|
|
|
|
updateWrap.eq("id", articleId); |
|
|
|
|
updateWrap.eq("deleted", 1); |
|
|
|
|
boolean ret = service.update(updateWrap); |
|
|
|
|
return ret ? R.success() : R.fail("操作失败"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/sort") |
|
|
|
|
@ApiOperation(value = "排序(自设置排序号) 上线后注释", response = SysContent.class) |
|
|
|
|
public R sort() { |
|
|
|
|
|
|
|
|
|
//获取当前栏目
|
|
|
|
|
QueryWrapper<SysContent> queryWrap = new QueryWrapper<>(); |
|
|
|
|
queryWrap.eq("deleted", 1); |
|
|
|
|
queryWrap.groupBy("column_id"); |
|
|
|
|
queryWrap.orderByAsc("sequence"); |
|
|
|
|
List<SysContent> columnList = service.list(queryWrap); |
|
|
|
|
|
|
|
|
|
for (SysContent content : columnList) { |
|
|
|
|
Integer columnId = content.getColumnId(); |
|
|
|
|
QueryWrapper<SysContent> queryWrap1 = new QueryWrapper<>(); |
|
|
|
|
queryWrap1.eq("column_id", columnId); |
|
|
|
|
queryWrap1.eq("deleted", 1); |
|
|
|
|
queryWrap1.orderByDesc("release_time"); |
|
|
|
|
List<SysContent> list = service.list(queryWrap1); |
|
|
|
|
|
|
|
|
|
Integer count = 0; |
|
|
|
|
for (SysContent c : list) { |
|
|
|
|
++count; |
|
|
|
|
c.setSequence(count); |
|
|
|
|
service.updateById(c); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return R.success(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|