|
|
|
@ -3,13 +3,16 @@ package com.huoran.iasf.controller; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; |
|
|
|
|
import com.huoran.iasf.entity.SysColumn; |
|
|
|
|
import com.huoran.iasf.entity.SysContentFile; |
|
|
|
|
import com.huoran.iasf.entity.SysFilesEntity; |
|
|
|
|
import com.huoran.iasf.service.SysColumnService; |
|
|
|
|
import com.huoran.iasf.service.SysContentFileService; |
|
|
|
|
import com.huoran.iasf.service.SysFilesService; |
|
|
|
|
import com.huoran.iasf.vo.req.ArticleModifiedSortReq; |
|
|
|
|
import com.huoran.iasf.vo.req.ContentHeavyTitleReqVO; |
|
|
|
|
import com.huoran.iasf.vo.req.ContentReq; |
|
|
|
|
import com.huoran.iasf.vo.req.PageContentReqVO; |
|
|
|
@ -30,7 +33,9 @@ import com.huoran.iasf.service.SysContentService; |
|
|
|
|
import com.huoran.iasf.entity.SysContent; |
|
|
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -55,7 +60,6 @@ public class SysContentController { |
|
|
|
|
public SysFilesService sysFilesService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/pagingQuery") |
|
|
|
|
@ApiOperation(value = "分页查询文章列表", response = PageContentRespVO.class) |
|
|
|
|
public R pagingQuery(@RequestBody @Valid @ApiParam(name = "分页查询参数", value = "传入json格式", required = true) PageContentReqVO sysContent) { |
|
|
|
@ -81,7 +85,15 @@ public class SysContentController { |
|
|
|
|
@PostMapping("/save") |
|
|
|
|
@ApiOperation(value = "新增", response = SysContent.class) |
|
|
|
|
public R save(@RequestBody @Valid @ApiParam(name = "文章管理对象", value = "传入json格式", required = true) SysContent sysContent) { |
|
|
|
|
|
|
|
|
|
QueryWrapper<SysContent> queryWrap = new QueryWrapper<>(); |
|
|
|
|
queryWrap.eq("column_id", sysContent.getColumnId()); |
|
|
|
|
queryWrap.eq("deleted", 1); |
|
|
|
|
Integer count = service.count(queryWrap); |
|
|
|
|
sysContent.setSequence(count++); |
|
|
|
|
boolean addState = service.save(sysContent); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return addState ? R.success(sysContent.getId()) : R.fail("新增失败"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -98,9 +110,9 @@ public class SysContentController { |
|
|
|
|
@ApiOperation(value = "删除", response = SysContent.class) |
|
|
|
|
public R delete(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { |
|
|
|
|
UpdateWrapper<SysFilesEntity> queryWrapper = new UpdateWrapper<>(); |
|
|
|
|
queryWrapper.eq("quote_id",id); |
|
|
|
|
queryWrapper.eq("quote_type",0); |
|
|
|
|
queryWrapper.set("is_del",1); |
|
|
|
|
queryWrapper.eq("quote_id", id); |
|
|
|
|
queryWrapper.eq("quote_type", 0); |
|
|
|
|
queryWrapper.set("is_del", 1); |
|
|
|
|
sysFilesService.update(queryWrapper); |
|
|
|
|
boolean delState = service.removeById(id); |
|
|
|
|
return delState ? R.success() : R.fail("删除失败"); |
|
|
|
@ -112,9 +124,9 @@ public class SysContentController { |
|
|
|
|
public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestParam List<Integer> ids) { |
|
|
|
|
for (Integer id : ids) { |
|
|
|
|
UpdateWrapper<SysFilesEntity> queryWrapper = new UpdateWrapper<>(); |
|
|
|
|
queryWrapper.eq("quote_id",id); |
|
|
|
|
queryWrapper.eq("quote_type",0); |
|
|
|
|
queryWrapper.set("is_del",1); |
|
|
|
|
queryWrapper.eq("quote_id", id); |
|
|
|
|
queryWrapper.eq("quote_type", 0); |
|
|
|
|
queryWrapper.set("is_del", 1); |
|
|
|
|
sysFilesService.update(queryWrapper); |
|
|
|
|
} |
|
|
|
|
boolean delState = service.removeByIds(ids); |
|
|
|
@ -190,5 +202,110 @@ public class SysContentController { |
|
|
|
|
return service.siteSearchArticles(req); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*@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) { |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/modifiedArticleSort") |
|
|
|
|
@ApiOperation(value = "修改文章排序", response = SysContent.class) |
|
|
|
|
public R modifiedSort(@RequestBody List<ArticleModifiedSortReq> reqList) { |
|
|
|
|
return service.modifiedSort(reqList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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); |
|
|
|
|
List<SysContent> list = service.list(queryWrap1); |
|
|
|
|
|
|
|
|
|
Integer count = 0; |
|
|
|
|
for (SysContent c : list) { |
|
|
|
|
++count; |
|
|
|
|
c.setSequence(count); |
|
|
|
|
service.updateById(c); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return R.success(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|