提交代码

master
rong.liu 2 years ago
parent adec7258a7
commit 1db80e42e9
  1. 57
      src/main/java/com/huoran/iasf/controller/SysColumnController.java
  2. 114
      src/main/java/com/huoran/iasf/controller/SysContentController.java
  3. 10
      src/main/java/com/huoran/iasf/entity/SysContent.java
  4. 52
      src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml
  5. 4
      src/main/java/com/huoran/iasf/service/SysContentService.java
  6. 10
      src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java
  7. 7
      src/main/java/com/huoran/iasf/vo/req/PageContentReqVO.java
  8. 7
      src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java

@ -24,6 +24,7 @@ import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.validation.Valid;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
@ -54,6 +55,9 @@ public class SysColumnController {
@Autowired @Autowired
public SysTemplateStyleService styleService; public SysTemplateStyleService styleService;
@Autowired
public SysColumnLongPageService sysColumnLongPageService;
@Autowired @Autowired
public SysTemplateStyleConfigurationService templateStyleConfigurationService; public SysTemplateStyleConfigurationService templateStyleConfigurationService;
@ -108,7 +112,7 @@ public class SysColumnController {
return updateState ? R.success() : R.fail("编辑失败"); return updateState ? R.success() : R.fail("编辑失败");
} }
@NoRepeatSubmit /*@NoRepeatSubmit
@PostMapping("/delete") @PostMapping("/delete")
@ApiOperation(value = "删除", response = SysContent.class) @ApiOperation(value = "删除", response = SysContent.class)
public R delete(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { public R delete(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) {
@ -127,7 +131,7 @@ public class SysColumnController {
contentService.removeByIds(contentId); contentService.removeByIds(contentId);
return delState ? R.success() : R.fail("删除失败"); return delState ? R.success() : R.fail("删除失败");
} }*/
@NoRepeatSubmit @NoRepeatSubmit
@PostMapping("/batchDeletion") @PostMapping("/batchDeletion")
@ -153,6 +157,13 @@ public class SysColumnController {
queryWrapper.in("column_id", idList); queryWrapper.in("column_id", idList);
//删除栏目后删除栏目下的文章 //删除栏目后删除栏目下的文章
contentService.remove(queryWrapper); contentService.remove(queryWrapper);
//删除长页栏目
QueryWrapper<SysColumnLongPage> queryWrapper1 = new QueryWrapper<SysColumnLongPage>();
queryWrapper1.in("column_id", idList);
//删除栏目后删除栏目下的文章
sysColumnLongPageService.remove(queryWrapper1);
ret = service.removeByIds(idList); ret = service.removeByIds(idList);
} }
@ -290,5 +301,47 @@ public class SysColumnController {
return service.queryArticlesByColumnType(ids, columnId); return service.queryArticlesByColumnType(ids, columnId);
} }
@NoRepeatSubmit
@PostMapping("/deleteUselessData")
@ApiOperation(value = "删除无用数据", response = SysColumn.class)
public R deleteUselessData() {
QueryWrapper<SysColumn> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("deleted", 0).select("id");
List<SysColumn> list = service.list(queryWrapper);
for (SysColumn column : list) {
UpdateWrapper<SysFilesEntity> filesEntityUpdateWrapper = new UpdateWrapper<>();
filesEntityUpdateWrapper.eq("quote_id", column.getId());
filesEntityUpdateWrapper.eq("quote_type", 1);
filesEntityUpdateWrapper.set("is_del", 1);
sysFilesService.update(filesEntityUpdateWrapper);
//1 创建list集合,用于封装所有删除菜单id值
List<Integer> idList = new ArrayList<>();
//2 向idList集合设置删除菜单id
//找到当前菜单的子菜单 把结果id封装到idlist里面去
this.selectCategoryChildById(column.getId() + "", idList);
//把当前id封装到list里面 //现在把当前id封装进去 之前都是子菜单的id
idList.add(column.getId());
//删除当前栏目以及栏目下的文章
QueryWrapper<SysContent> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.in("column_id", idList);
//删除栏目后删除栏目下的文章
contentService.remove(queryWrapper1);
//删除长页栏目
QueryWrapper<SysColumnLongPage> queryWrapper2 = new QueryWrapper<SysColumnLongPage>();
queryWrapper2.in("column_id", idList);
//删除栏目后删除栏目下的文章
sysColumnLongPageService.remove(queryWrapper2);
service.removeByIds(idList);
}
return R.success();
}
} }

@ -97,14 +97,14 @@ public class SysContentController {
@ApiOperation(value = "新增", response = SysContent.class) @ApiOperation(value = "新增", response = SysContent.class)
public R save(@RequestBody @Valid @ApiParam(name = "文章管理对象", value = "传入json格式", required = true) SysContent sysContent) { 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("column_id", sysContent.getColumnId());
queryWrap.eq("deleted", 1); queryWrap.eq("deleted", 1);
Integer count = service.count(queryWrap); Integer count = service.count(queryWrap);
if (count == 0) { if (count == 0) {
count = 1; count = 1;
} }
sysContent.setSequence(count + 1); sysContent.setSequence(count + 1);*/
boolean addState = service.save(sysContent); boolean addState = service.save(sysContent);
@ -218,106 +218,28 @@ public class SysContentController {
} }
/*@PostMapping("/modifiedSort") @PostMapping("/articleTopOperation")
@ApiOperation(value = "修改排序", response = SysContent.class) @ApiOperation(value = "文章置顶/取消置顶", response = SysContent.class)
public R modifiedSort( public R articleTopOperation(
@ApiParam(name = "sequenceNumber", value = "要排序的序号", required = true) @RequestParam Integer sequenceNumber, @ApiParam(name = "isTop", value = "是否置顶(默认为0 不置顶 1为置顶)", required = true) @RequestParam Integer isTop,
@ApiParam(name = "articleId", value = "文章Id", required = true) @RequestParam Integer articleId) { @ApiParam(name = "articleId", value = "文章Id", required = true) @RequestParam Integer articleId) {
if (sequenceNumber<=0){ //是否置顶(默认为0 不置顶 1为置顶)
return R.fail("请输入正确的序号!"); UpdateWrapper<SysContent> updateWrap = new UpdateWrapper<>();
}
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);
}
if (isTop == 1) {
@PostMapping("/modifiedArticleSort") //置顶时间(置顶一次更新一次)
@ApiOperation(value = "修改文章排序", response = SysContent.class) updateWrap.set("top_time", new Date());
public R modifiedSort(@RequestBody List<ArticleModifiedSortReq> reqList) { } else {
return service.modifiedSort(reqList); 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();
}
} }

@ -173,7 +173,13 @@ public class SysContent implements Serializable {
@ApiModelProperty(value = "文章关键字") @ApiModelProperty(value = "文章关键字")
private String articleKeyWord; private String articleKeyWord;
@ApiModelProperty(value = "顺序(排序号)") /*@ApiModelProperty(value = "顺序(排序号)")
private Integer sequence; private Integer sequence;*/
@ApiModelProperty(value = "是否置顶(默认为0 不置顶 1为置顶)")
private Integer isTop;
@ApiModelProperty(value = "置顶时间")
private Date topTime;
} }

@ -7,7 +7,8 @@
(SELECT u.real_name FROM sys_user u WHERE u.id = c.founder_id) AS founderName, (SELECT u.real_name FROM sys_user u WHERE u.id = c.founder_id) AS founderName,
(SELECT u.real_name FROM sys_user u WHERE u.id = c.editor_id) AS editorName, (SELECT u.real_name FROM sys_user u WHERE u.id = c.editor_id) AS editorName,
(SELECT type_id from sys_column WHERE sys_column.id = c.column_id) as typeId, (SELECT type_id from sys_column WHERE sys_column.id = c.column_id) as typeId,
IFNULL( ( SELECT c1.classification_name FROM sys_content_classification c1 WHERE c1.id = c.classification_id ), '暂无' ) AS classificationName IFNULL( ( SELECT c1.classification_name FROM sys_content_classification c1 WHERE c1.id = c.classification_id ),
'暂无' ) AS classificationName
FROM sys_content c FROM sys_content c
WHERE c.deleted = 1 and site_id = #{req.siteId} WHERE c.deleted = 1 and site_id = #{req.siteId}
<if test="req.columnIds != null and req.columnIds.size() > 0 "> <if test="req.columnIds != null and req.columnIds.size() > 0 ">
@ -59,12 +60,12 @@
ORDER BY c.release_time asc ORDER BY c.release_time asc
</if> </if>
<if test="req.ordinalSort ==0"> <if test="req.topSort ==0">
ORDER BY sequence asc ORDER BY is_top asc
</if> </if>
<if test="req.ordinalSort ==1"> <if test="req.topSort ==1">
ORDER BY sequence desc ORDER BY is_top desc
</if> </if>
@ -135,7 +136,10 @@
</when> </when>
<otherwise> <otherwise>
ORDER BY ORDER BY
t.sequence asc is_top = 1 DESC,
top_time DESC,
release_time DESC,
create_time DESC
</otherwise> </otherwise>
</choose> </choose>
@ -175,10 +179,12 @@
FROM (SELECT s.*, FROM (SELECT s.*,
(SELECT GROUP_CONCAT(label_name) (SELECT GROUP_CONCAT(label_name)
FROM sys_content_label l FROM sys_content_label l
WHERE deleted = 1 AND FIND_IN_SET(l.id, s.lable_id)) AS labelName, WHERE deleted = 1
AND FIND_IN_SET(l.id, s.lable_id)) AS labelName,
(SELECT c.classification_name (SELECT c.classification_name
FROM sys_content_classification c FROM sys_content_classification c
WHERE deleted = 1 AND s.classification_id = c.id) AS classificationName WHERE deleted = 1
AND s.classification_id = c.id) AS classificationName
FROM sys_content s FROM sys_content s
WHERE s.deleted = 1 WHERE s.deleted = 1
AND is_disable = 0 AND is_disable = 0
@ -186,34 +192,12 @@
WHERE FIND_IN_SET(t.column_id, #{columnId}) WHERE FIND_IN_SET(t.column_id, #{columnId})
ORDER BY ORDER BY
t.sequence ASC is_top = 1 DESC,
top_time DESC,
release_time DESC,
create_time DESC
</select> </select>
<!-- &lt;!&ndash;根据 sequence 查询下一条记录主键&ndash;&gt;
<select id="selectNextId" resultType="java.lang.Integer">
SELECT
IFNULL(
( SELECT id FROM sys_content WHERE sequence &gt; #{content.sequence} AND column_id = #{content.columnId} AND deleted = 1
ORDER BY sequence ASC LIMIT 0, 1 ),
1
) AS nextTypeId
</select>
&lt;!&ndash;根据主键更新排序号&ndash;&gt;
<update id="updateSortById" parameterType="java.lang.Integer" >
update sys_content
set sequence = #{content.sequence},update_time = now()
where id = #{content.id}
</update>
&lt;!&ndash;根据 sequence 查询上一条记录主键&ndash;&gt;
<select id="selectPreviousId" resultType="java.lang.Integer" >
SELECT IFNULL(
(SELECT id FROM sys_content WHERE sequence &lt; #{content.sequence} AND column_id = #{content.columnId} AND deleted = 1
ORDER BY sequence DESC LIMIT 0,1),1
) AS preTypeId
</select>-->
</mapper> </mapper>

@ -39,8 +39,8 @@ public interface SysContentService extends IService<SysContent> {
R siteSearchArticles(PageContentReqVO req); R siteSearchArticles(PageContentReqVO req);
R modifiedSort(List<ArticleModifiedSortReq> reqList); // R modifiedSort(List<ArticleModifiedSortReq> reqList);
R modifiedSort(Integer sequenceNumber, Integer articleId); // R modifiedSort(Integer sequenceNumber, Integer articleId);
} }

@ -66,7 +66,7 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont
Page<PageContentRespVO> page = new Page<PageContentRespVO>(reqVO.getPageNum(), reqVO.getPageSize()); Page<PageContentRespVO> page = new Page<PageContentRespVO>(reqVO.getPageNum(), reqVO.getPageSize());
//没传任何排序参数时候 默认以发布时间排序 //没传任何排序参数时候 默认以发布时间排序
if (reqVO.getModifiedTimeSort() == null && reqVO.getPublicationTimeSort() == null && reqVO.getOrdinalSort() == null) { if (reqVO.getModifiedTimeSort() == null && reqVO.getPublicationTimeSort() == null && reqVO.getTopSort() == null) {
reqVO.setPublicationTimeSort(0); reqVO.setPublicationTimeSort(0);
} }
/*if (reqVO.getIsDisable()!=null){ /*if (reqVO.getIsDisable()!=null){
@ -146,7 +146,7 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont
return R.success(pageList); return R.success(pageList);
} }
@Override /*@Override
public R modifiedSort(List<ArticleModifiedSortReq> reqList) { public R modifiedSort(List<ArticleModifiedSortReq> reqList) {
for (ArticleModifiedSortReq req : reqList) { for (ArticleModifiedSortReq req : reqList) {
SysContent content = new SysContent(); SysContent content = new SysContent();
@ -192,11 +192,11 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont
//currentSerialNumber 当前文章的序号 //currentSerialNumber 当前文章的序号
//sequenceNumber 要更改的序号 //sequenceNumber 要更改的序号
/** *//**
* 就要判断排序是值改小还是改大 * 就要判断排序是值改小还是改大
* 大改小比如53改5那就加一个语句大于等于5并且小于53 * 大改小比如53改5那就加一个语句大于等于5并且小于53
* 如果是小改大比如3改50那就是大于3并且小于等于50" * 如果是小改大比如3改50那就是大于3并且小于等于50"
*/ *//*
if (currentSerialNumber > sequenceNumber) { if (currentSerialNumber > sequenceNumber) {
//改大 gt > //改大 gt >
updateWrapper1.setSql(" sequence = sequence + 1"); updateWrapper1.setSql(" sequence = sequence + 1");
@ -221,7 +221,7 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont
} }
} }*/
/*@Override /*@Override
public R modifiedSort(Integer newIndex, Integer articleId,Integer sort) { public R modifiedSort(Integer newIndex, Integer articleId,Integer sort) {

@ -79,9 +79,12 @@ public class PageContentReqVO extends PageReqVO {
@ApiModelProperty(value = "发布时间排序(0默认倒序 1升序)") @ApiModelProperty(value = "发布时间排序(0默认倒序 1升序)")
private Integer publicationTimeSort; private Integer publicationTimeSort;
@ApiModelProperty(value = "序号排序(0默认升序 1倒序)") /* @ApiModelProperty(value = "序号排序(0默认升序 1倒序)")
private Integer ordinalSort; private Integer ordinalSort;*/
@ApiModelProperty(value = "置顶排序(0默认升序 1倒序)")
private Integer topSort;
/* @ApiModelProperty(value = "模板状态(0禁用;1启用)") /* @ApiModelProperty(value = "模板状态(0禁用;1启用)")
private Integer templateStatus;*/ private Integer templateStatus;*/

@ -182,6 +182,9 @@ public class PageContentRespVO {
@ApiModelProperty(value = "样式id(用于前端区分是会议还是文章跳转界面)") @ApiModelProperty(value = "样式id(用于前端区分是会议还是文章跳转界面)")
private Integer listStyleId; private Integer listStyleId;
@ApiModelProperty(value = "顺序(排序号)") /*@ApiModelProperty(value = "顺序(排序号)")
private Integer sequence; private Integer sequence;*/
@ApiModelProperty(value = "是否置顶(默认为0 不置顶 1为置顶)")
private Integer isTop;
} }
Loading…
Cancel
Save