SEO增加相应参数

课程产品文章关联查询栏目下的文章(根据选择栏目若选中栏目与子级全部栏目类型一致返回全部文章,反之查询选中栏目下的文章)
master
rong.liu 5 months ago
parent 7f9c3577ac
commit efab276536
  1. 11
      src/main/java/com/huoran/iasf/entity/Seo.java
  2. 3
      src/main/java/com/huoran/iasf/mapper/SysContentMapper.java
  3. 4
      src/main/java/com/huoran/iasf/mapper/xml/SysColumnMapper.xml
  4. 32
      src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml
  5. 98
      src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java
  6. 6
      src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java

@ -42,4 +42,15 @@ public class Seo implements Serializable {
@ApiModelProperty(value = "站点")
private Integer siteId;
@ApiModelProperty(value = "图标")
private String iconUrl;
@ApiModelProperty(value = "图标后缀")
private String iconSuffix;
}

@ -33,6 +33,9 @@ public interface SysContentMapper extends BaseMapper<SysContent> {
List<PageContentRespVO> columnConditionsFilterArticles(@Param("columnId")String columnId);
List<PageContentRespVO> columnConditionsFilterProductCourse(@Param("columnId")String columnId);
/*Integer selectNextId(@Param("content")SysContent sysContent);
Integer updateSortById(@Param("content")SysContent sysContent);

@ -187,9 +187,7 @@
T1.lvl DESC limit 0, 1
</select>
<select id="queryByColumnType" resultType="com.huoran.iasf.entity.SysColumn">
SELECT id,
father_id,
column_name,
SELECT
list_style_id
FROM sys_column s
WHERE FIND_IN_SET(s.id, #{ids})

@ -286,6 +286,38 @@
s.total_browsing DESC
LIMIT 0,5
</select>
<select id="columnConditionsFilterProductCourse" resultType="com.huoran.iasf.vo.resp.PageContentRespVO">
SELECT
t.*,
( SELECT cl.list_style_id FROM sys_column cl WHERE cl.id = t.column_id ) AS listStyleId
FROM
(
SELECT
d.id,
d.column_id,
d.is_top,
d.top_time,
d.NAME AS title,
d.cover_image_url AS titleImg,
d.release_time,
d.create_time,
( SELECT c.NAME FROM sys_category c WHERE c.category_id = d.classification_tag_id ) AS classificationName,
( SELECT GROUP_CONCAT(c.NAME) FROM sys_category c WHERE FIND_IN_SET( c.category_id, d.category_id ) ) AS labelName
FROM
sys_product_details d
WHERE
d.deleted = 1
AND is_disable = 0
AND publish_status = 1
) t
WHERE
FIND_IN_SET( t.column_id, #{columnId} )
ORDER BY
t.is_top = 1 DESC,
t.top_time DESC,
t.release_time DESC,
create_time DESC
</select>
</mapper>

@ -1,6 +1,7 @@
package com.huoran.iasf.service.impl;
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.metadata.IPage;
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.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -155,7 +153,8 @@ public class SysColumnServiceImpl extends ServiceImpl<SysColumnMapper, SysColumn
pageList.getRecords().forEach(pageContentRespVO -> {
if (pageContentRespVO.getLevel() > 1) {
//判断该栏目层级为第一级时候不返回上级栏目
List<FatherContentRespVO> upperLevel = baseMapper.getParentInformationBasedOnChild(pageContentRespVO.getId());
List<FatherContentRespVO> upperLevel =
baseMapper.getParentInformationBasedOnChild(pageContentRespVO.getId());
pageContentRespVO.setSuperiorColumn(upperLevel);
}
@ -192,26 +191,93 @@ public class SysColumnServiceImpl extends ServiceImpl<SysColumnMapper, SysColumn
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) {
// 计算提供的ID字符串中包含的栏目类型ID的数量。
Integer count = 0;
for (String columnId : ids.split(",")) {
++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);
// 如果提供的ID字符串中包含的栏目类型ID数量大于1,并且查询到的栏目类型数量为1,则应用额外的过滤条件。
//为1表示该层级下以及它本身列表样式模板一直则查询全部的
if (count > 1) {
if (queryByColumnType.size() == 1) {
// 使用过滤条件查询文章。
return R.success(contentMapper.columnConditionsFilterArticles(ids));
}
}
// 在其他情况下,直接根据单个栏目类型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;
List<SysColumn> queryByColumnType = baseMapper.queryByColumnType(ids);
//为1表示该层级下以及它本身列表样式模板一直则查询全部的
if (count > 1) {
if (queryByColumnType.size() == 1) {
return R.success(contentMapper.columnConditionsFilterArticles(ids));
@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);
}
}
//表示该层级下的全部层级不一致只查本身
return R.success(contentMapper.columnConditionsFilterArticles(id + ""));
if (count > 1 && queryByColumnType.size() == 1) {
return R.success(contentMapper.columnConditionsFilterArticles(ids));
}
return R.success(contentMapper.columnConditionsFilterArticles(id.toString()));
}
@Override
public List<String> getColumnNamesByIds(Collection<String> applicationScopeIds) {
if (CollectionUtils.isEmpty(applicationScopeIds)) {
@ -226,13 +292,11 @@ public class SysColumnServiceImpl extends ServiceImpl<SysColumnMapper, SysColumn
queryWrapper.in("id", applicationScopeIds);
queryWrapper.select("column_name"); // 只选择columnName列
return baseMapper.selectObjs(queryWrapper).stream()
.map(Object::toString) // 假设columnName为String类型,转换对象为String
return baseMapper.selectObjs(queryWrapper).stream().map(Object::toString) // 假设columnName为String类型,转换对象为String
.collect(Collectors.toList());
}
}

@ -253,4 +253,10 @@ public class PageContentRespVO {
@ApiModelProperty(value = "文章附件")
@TableField(exist = false)
List<SysContentFile> fileList;
/*@ApiModelProperty(value = "分类/标签")
private String categoryName;
@ApiModelProperty(value = "类型")
private String classificationTagName;*/
}
Loading…
Cancel
Save