|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.huoran.iasf.service.impl; |
|
|
|
package com.huoran.iasf.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
@ -20,10 +21,7 @@ import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.*; |
|
|
|
import java.util.Collection; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -155,7 +153,8 @@ public class SysColumnServiceImpl extends ServiceImpl<SysColumnMapper, SysColumn |
|
|
|
pageList.getRecords().forEach(pageContentRespVO -> { |
|
|
|
pageList.getRecords().forEach(pageContentRespVO -> { |
|
|
|
if (pageContentRespVO.getLevel() > 1) { |
|
|
|
if (pageContentRespVO.getLevel() > 1) { |
|
|
|
//判断该栏目层级为第一级时候不返回上级栏目
|
|
|
|
//判断该栏目层级为第一级时候不返回上级栏目
|
|
|
|
List<FatherContentRespVO> upperLevel = baseMapper.getParentInformationBasedOnChild(pageContentRespVO.getId()); |
|
|
|
List<FatherContentRespVO> upperLevel = |
|
|
|
|
|
|
|
baseMapper.getParentInformationBasedOnChild(pageContentRespVO.getId()); |
|
|
|
pageContentRespVO.setSuperiorColumn(upperLevel); |
|
|
|
pageContentRespVO.setSuperiorColumn(upperLevel); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -192,26 +191,93 @@ public class SysColumnServiceImpl extends ServiceImpl<SysColumnMapper, SysColumn |
|
|
|
return R.success(TreeStructureUtils.forMethod(getsTheSubColumn)); |
|
|
|
return R.success(TreeStructureUtils.forMethod(getsTheSubColumn)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
/** |
|
|
|
|
|
|
|
* 根据栏目类型ID查询文章。 |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* 此方法用于根据提供的栏目类型ID字符串查询相关文章。如果ID字符串包含多个ID,则会考虑这些ID的数量来决定查询策略。 |
|
|
|
|
|
|
|
* 如果ID数量大于1,且查询到的栏目类型数量也为1,则会应用额外的文章过滤条件。 |
|
|
|
|
|
|
|
* </p> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param ids 栏目类型ID字符串,多个ID以逗号分隔。 |
|
|
|
|
|
|
|
* @param id 单个栏目类型ID,用于当提供的ID字符串包含单个ID时的查询。 |
|
|
|
|
|
|
|
* @return 返回查询结果,封装在R对象中。 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
/*@Override |
|
|
|
public R queryArticlesByColumnType(String ids, Integer id) { |
|
|
|
public R queryArticlesByColumnType(String ids, Integer id) { |
|
|
|
|
|
|
|
// 计算提供的ID字符串中包含的栏目类型ID的数量。
|
|
|
|
Integer count = 0; |
|
|
|
Integer count = 0; |
|
|
|
for (String columnId : ids.split(",")) { |
|
|
|
for (String columnId : ids.split(",")) { |
|
|
|
++count; |
|
|
|
++count; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SysColumn column = baseMapper.selectById(id); |
|
|
|
|
|
|
|
if (!ObjectUtil.isEmpty(column) && (column.getTemplateId() == 12 || (column.getTemplateId() == 9 && column |
|
|
|
|
|
|
|
.getListStyleId() == 73))) { |
|
|
|
|
|
|
|
// 根据模板ID为12的特定情况调用相应方法
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 根据提供的栏目类型ID字符串查询栏目类型。
|
|
|
|
List<SysColumn> queryByColumnType = baseMapper.queryByColumnType(ids); |
|
|
|
List<SysColumn> queryByColumnType = baseMapper.queryByColumnType(ids); |
|
|
|
|
|
|
|
// 如果提供的ID字符串中包含的栏目类型ID数量大于1,并且查询到的栏目类型数量为1,则应用额外的过滤条件。
|
|
|
|
//为1表示该层级下以及它本身列表样式模板一直则查询全部的
|
|
|
|
//为1表示该层级下以及它本身列表样式模板一直则查询全部的
|
|
|
|
if (count > 1) { |
|
|
|
if (count > 1) { |
|
|
|
if (queryByColumnType.size() == 1) { |
|
|
|
if (queryByColumnType.size() == 1) { |
|
|
|
|
|
|
|
// 使用过滤条件查询文章。
|
|
|
|
return R.success(contentMapper.columnConditionsFilterArticles(ids)); |
|
|
|
return R.success(contentMapper.columnConditionsFilterArticles(ids)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 在其他情况下,直接根据单个栏目类型ID查询文章。
|
|
|
|
//表示该层级下的全部层级不一致只查本身
|
|
|
|
//表示该层级下的全部层级不一致只查本身
|
|
|
|
return R.success(contentMapper.columnConditionsFilterArticles(id + "")); |
|
|
|
return R.success(contentMapper.columnConditionsFilterArticles(id + "")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 常量定义
|
|
|
|
|
|
|
|
private static final int TEMPLATE_ID_12 = 12; |
|
|
|
|
|
|
|
private static final int TEMPLATE_ID_9 = 9; |
|
|
|
|
|
|
|
private static final int LIST_STYLE_ID_73 = 73; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public R queryArticlesByColumnType(String ids, Integer id) { |
|
|
|
|
|
|
|
// 检查输入参数是否有效
|
|
|
|
|
|
|
|
if (StrUtil.isBlank(ids)) { |
|
|
|
|
|
|
|
return R.fail("栏目类型ID字符串不能为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ids = ids.trim(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化计数器
|
|
|
|
|
|
|
|
long count = Arrays.stream(ids.split(",")).filter(str -> !str.isEmpty()).count(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SysColumn column; |
|
|
|
|
|
|
|
List<SysColumn> queryByColumnType; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
column = baseMapper.selectById(id); |
|
|
|
|
|
|
|
queryByColumnType = baseMapper.queryByColumnType(ids); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
return R.fail("查询栏目类型时发生异常"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (column != null && (column.getTemplateId() == TEMPLATE_ID_12 || (column.getTemplateId() == TEMPLATE_ID_9 && column.getListStyleId() == LIST_STYLE_ID_73))) { |
|
|
|
|
|
|
|
if (count > 1) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<PageContentRespVO> list = contentMapper.columnConditionsFilterProductCourse(ids); |
|
|
|
|
|
|
|
return R.success(list); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
List<PageContentRespVO> list = contentMapper.columnConditionsFilterProductCourse(String.valueOf(id)); |
|
|
|
|
|
|
|
return R.success(list); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (count > 1 && queryByColumnType.size() == 1) { |
|
|
|
|
|
|
|
return R.success(contentMapper.columnConditionsFilterArticles(ids)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return R.success(contentMapper.columnConditionsFilterArticles(id.toString())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<String> getColumnNamesByIds(Collection<String> applicationScopeIds) { |
|
|
|
public List<String> getColumnNamesByIds(Collection<String> applicationScopeIds) { |
|
|
|
if (CollectionUtils.isEmpty(applicationScopeIds)) { |
|
|
|
if (CollectionUtils.isEmpty(applicationScopeIds)) { |
|
|
@ -226,13 +292,11 @@ public class SysColumnServiceImpl extends ServiceImpl<SysColumnMapper, SysColumn |
|
|
|
queryWrapper.in("id", applicationScopeIds); |
|
|
|
queryWrapper.in("id", applicationScopeIds); |
|
|
|
queryWrapper.select("column_name"); // 只选择columnName列
|
|
|
|
queryWrapper.select("column_name"); // 只选择columnName列
|
|
|
|
|
|
|
|
|
|
|
|
return baseMapper.selectObjs(queryWrapper).stream() |
|
|
|
return baseMapper.selectObjs(queryWrapper).stream().map(Object::toString) // 假设columnName为String类型,转换对象为String
|
|
|
|
.map(Object::toString) // 假设columnName为String类型,转换对象为String
|
|
|
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|