代码提交

master
rong.liu 2 years ago
parent 381019bc05
commit 28dcd55442
  1. 36
      src/main/java/com/huoran/iasf/controller/SysColumnController.java
  2. 18
      src/main/java/com/huoran/iasf/entity/SysColumn.java
  3. 2
      src/main/java/com/huoran/iasf/entity/SysContent.java
  4. 8
      src/main/java/com/huoran/iasf/mapper/xml/SysColumnMapper.xml
  5. 37
      src/main/java/com/huoran/iasf/vo/resp/SortColumnRespVO.java

@ -1,11 +1,17 @@
package com.huoran.iasf.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.huoran.iasf.entity.ColumnEntity;
import com.huoran.iasf.entity.SysColumn;
import com.huoran.iasf.entity.SysContent;
import com.huoran.iasf.service.SysContentService;
import com.huoran.iasf.vo.req.ColumnWeightReqVO;
import com.huoran.iasf.vo.req.PaginationColumnReqVO;
import com.huoran.iasf.vo.resp.SortColumnRespVO;
import io.swagger.annotations.*;
import com.huoran.iasf.common.utils.R;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
@ -17,6 +23,7 @@ import io.swagger.annotations.ApiOperation;
import com.huoran.iasf.service.SysColumnService;
import javax.validation.Valid;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
@ -33,6 +40,9 @@ public class SysColumnController {
@Autowired
public SysColumnService service;
@Autowired
public SysContentService contentService;
@PostMapping("/listWithTree")
@ApiOperation(value = "栏目树结构", response = SysColumn.class)
@ -77,10 +87,28 @@ public class SysColumnController {
}
@PostMapping("/sortByColumn")
@ApiOperation(value = "栏目排序", response = SysColumn.class)
public R sortByColumn(@RequestBody List<SysColumn> entityList) {
boolean updateState = service.updateBatchById(entityList);
return updateState ? R.success() : R.fail("编辑成功");
@ApiOperation(value = "栏目排序(依据id更改)", response = SysColumn.class)
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();
}
}

@ -111,4 +111,22 @@ public class SysColumn implements Serializable {
private List<SysColumn> children;
@TableField(exist = false)
@ApiModelProperty(value = "创建人")
private String creteUser;
@TableField(exist = false)
@ApiModelProperty(value = "修改人")
private String editorUser;
@TableField(exist = false)
@ApiModelProperty(value = "总浏览")
private Integer totalBrowsing;
public Integer getTotalBrowsing() {
return 0;
}
}

@ -44,7 +44,7 @@ public class SysContent implements Serializable {
private String source;
@ApiModelProperty(value = "发布时间")
@NotNull(message = "发布时间不能为空!")
// @NotNull(message = "发布时间不能为空!")
private Date releaseTime;
@ApiModelProperty(value = "摘要")

@ -31,8 +31,12 @@
</resultMap>
<select id="filter" resultType="com.huoran.iasf.entity.SysColumn">
SELECT *
FROM sys_column
SELECT
* ,
(SELECT u.username from sys_user u WHERE u.id = s.founder_id) as creteUser,
(SELECT u.username from sys_user u WHERE u.id = s.editor_id) as editorUser
FROM
sys_column s
WHERE deleted = 1 and site_id = #{vo.siteId}
<if test="vo.columnName != '' and vo.columnName!= null">
and column_name LIKE CONCAT('%',#{vo.columnName},'%')

@ -0,0 +1,37 @@
package com.huoran.iasf.vo.resp;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* @描述栏目基础信息
* @作者: Rong
* @日期: 2022-08-03
*/
@Data
public class SortColumnRespVO {
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "父id(第一级为0)")
private Integer fatherId;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "层级((1-一级分类 2-二级分类 3-三级分类以此叠加))")
private Integer level;
}
Loading…
Cancel
Save