|
|
@ -6,7 +6,8 @@ import com.huoran.iasf.common.utils.Constant; |
|
|
|
import com.huoran.iasf.entity.ColumnEntity; |
|
|
|
import com.huoran.iasf.entity.ColumnEntity; |
|
|
|
import com.huoran.iasf.entity.SysColumn; |
|
|
|
import com.huoran.iasf.entity.SysColumn; |
|
|
|
import com.huoran.iasf.entity.SysContent; |
|
|
|
import com.huoran.iasf.entity.SysContent; |
|
|
|
import com.huoran.iasf.service.SysContentService; |
|
|
|
import com.huoran.iasf.entity.SysTemplateStyle; |
|
|
|
|
|
|
|
import com.huoran.iasf.service.*; |
|
|
|
import com.huoran.iasf.vo.req.ColumnWeightReqVO; |
|
|
|
import com.huoran.iasf.vo.req.ColumnWeightReqVO; |
|
|
|
import com.huoran.iasf.vo.req.PaginationColumnReqVO; |
|
|
|
import com.huoran.iasf.vo.req.PaginationColumnReqVO; |
|
|
|
import com.huoran.iasf.vo.resp.SortColumnRespVO; |
|
|
|
import com.huoran.iasf.vo.resp.SortColumnRespVO; |
|
|
@ -22,11 +23,13 @@ import org.springframework.web.bind.annotation.RestController; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
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 com.huoran.iasf.service.SysColumnService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -45,6 +48,13 @@ public class SysColumnController { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
public SysContentService contentService; |
|
|
|
public SysContentService contentService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
public SysTemplateService templateService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
public SysTemplateStyleService styleService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
public SysTemplateStyleConfigurationService templateStyleConfigurationService; |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/listWithTree") |
|
|
|
@PostMapping("/listWithTree") |
|
|
|
@ApiOperation(value = "栏目树结构", response = SysColumn.class) |
|
|
|
@ApiOperation(value = "栏目树结构", response = SysColumn.class) |
|
|
@ -63,6 +73,12 @@ public class SysColumnController { |
|
|
|
@ApiOperation(value = "查询详情", response = SysColumn.class) |
|
|
|
@ApiOperation(value = "查询详情", response = SysColumn.class) |
|
|
|
public R findById(@RequestParam("id") @ApiParam(value = "序号") Integer id) { |
|
|
|
public R findById(@RequestParam("id") @ApiParam(value = "序号") Integer id) { |
|
|
|
SysColumn sysColumn = service.getById(id); |
|
|
|
SysColumn sysColumn = service.getById(id); |
|
|
|
|
|
|
|
SysTemplateStyle sysTemplateStyle = styleService.getById(sysColumn.getListStyleId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sysTemplateStyle.getPath() != null) { |
|
|
|
|
|
|
|
sysColumn.setPath(sysTemplateStyle.getPath()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return R.success(sysColumn); |
|
|
|
return R.success(sysColumn); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -70,6 +86,10 @@ public class SysColumnController { |
|
|
|
@PostMapping("/save") |
|
|
|
@PostMapping("/save") |
|
|
|
@ApiOperation(value = "新增", response = SysColumn.class) |
|
|
|
@ApiOperation(value = "新增", response = SysColumn.class) |
|
|
|
public R save(@RequestBody @Valid SysColumn sysColumn) { |
|
|
|
public R save(@RequestBody @Valid SysColumn sysColumn) { |
|
|
|
|
|
|
|
QueryWrapper<SysColumn> queryWrapper = new QueryWrapper<SysColumn>(); |
|
|
|
|
|
|
|
queryWrapper.eq("father_id", sysColumn.getFatherId()); |
|
|
|
|
|
|
|
Integer count = service.count(queryWrapper); |
|
|
|
|
|
|
|
sysColumn.setSort(count + 1); |
|
|
|
boolean addState = service.save(sysColumn); |
|
|
|
boolean addState = service.save(sysColumn); |
|
|
|
return addState ? R.success(sysColumn.getId()) : R.fail("新增失败"); |
|
|
|
return addState ? R.success(sysColumn.getId()) : R.fail("新增失败"); |
|
|
|
} |
|
|
|
} |
|
|
@ -119,21 +139,76 @@ public class SysColumnController { |
|
|
|
SysColumn sysColumn = new SysColumn(); |
|
|
|
SysColumn sysColumn = new SysColumn(); |
|
|
|
BeanUtils.copyProperties(sort, sysColumn); |
|
|
|
BeanUtils.copyProperties(sort, sysColumn); |
|
|
|
service.updateById(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(); |
|
|
|
@ApiOperation("获取一级下的子级栏目(包含自己)") |
|
|
|
|
|
|
|
@PostMapping("/getsTheSubColumn") |
|
|
|
|
|
|
|
public R getsTheSubColumn(Integer id) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String ids = this.getIds(id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return service.getsTheSubColumn(id, ids); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getIds(Integer id) { |
|
|
|
|
|
|
|
//1 创建list集合,用于封装所有删除菜单id值
|
|
|
|
|
|
|
|
List<Integer> idList = new ArrayList<>(); |
|
|
|
|
|
|
|
//2 向idList集合设置删除菜单id
|
|
|
|
|
|
|
|
this.selectCategoryChildById(id + "", idList);//找到当前菜单的子菜单 把结果id封装到idlist里面去
|
|
|
|
|
|
|
|
//把当前id封装到list里面
|
|
|
|
|
|
|
|
idList.add(id);//现在把当前id封装进去 之前都是子菜单的id
|
|
|
|
|
|
|
|
String str = ""; |
|
|
|
|
|
|
|
for (Integer idstr : idList) { |
|
|
|
|
|
|
|
str += idstr + ","; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String ids = str.substring(0, str.length() - 1); |
|
|
|
|
|
|
|
return ids; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void selectCategoryChildById(String id, List<Integer> idList) { |
|
|
|
|
|
|
|
//查询菜单里面子菜单id
|
|
|
|
|
|
|
|
QueryWrapper<SysColumn> wrapper = new QueryWrapper<SysColumn>(); |
|
|
|
|
|
|
|
wrapper.eq("father_id", id); |
|
|
|
|
|
|
|
wrapper.eq("deleted", Constant.DATA_NOT_DELETED); |
|
|
|
|
|
|
|
wrapper.select("id");//我们只想查询id 所以只需要查询指定列的值
|
|
|
|
|
|
|
|
List<SysColumn> childIdList = service.list(wrapper);//当前菜单的所有子菜单
|
|
|
|
|
|
|
|
//把childIdList里面菜单id值获取出来,封装idList里面,做递归查询
|
|
|
|
|
|
|
|
childIdList.stream().forEach(item -> {//遍历集合得到每一个对象item
|
|
|
|
|
|
|
|
//封装idList里面
|
|
|
|
|
|
|
|
idList.add(item.getId()); |
|
|
|
|
|
|
|
//递归查询
|
|
|
|
|
|
|
|
this.selectCategoryChildById(item.getId() + "", idList); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取一级下的子级栏目以及下的全部文章标签") |
|
|
|
|
|
|
|
@PostMapping("/getTheFullArticleByColumn") |
|
|
|
|
|
|
|
public R getTheFullArticleByColumn(@ApiParam(name = "id", value = "一级栏目id", required = true) @RequestParam Integer id) { |
|
|
|
|
|
|
|
String ids = this.getIds(id); |
|
|
|
|
|
|
|
return contentService.getTheFullArticleByColumn(ids); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取子级栏目id") |
|
|
|
|
|
|
|
@PostMapping("/getsTheChildColumnId") |
|
|
|
|
|
|
|
public R getsTheSublevelColumnIdOfTheNextLevel(@ApiParam(name = "id", value = "一级栏目id", required = true) @RequestParam Integer id) { |
|
|
|
|
|
|
|
//1 创建list集合,用于封装所有删除菜单id值
|
|
|
|
|
|
|
|
List<Integer> idList = new ArrayList<>(); |
|
|
|
|
|
|
|
//2 向idList集合设置删除菜单id
|
|
|
|
|
|
|
|
this.selectCategoryChildById(id + "", idList);//找到当前菜单的子菜单 把结果id封装到idlist里面去
|
|
|
|
|
|
|
|
//把当前id封装到list里面
|
|
|
|
|
|
|
|
idList.add(id);//现在把当前id封装进去 之前都是子菜单的id
|
|
|
|
|
|
|
|
return R.success(idList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|