diff --git a/src/main/java/com/gxwebsoft/cms/entity/CmsNavigation.java b/src/main/java/com/gxwebsoft/cms/entity/CmsNavigation.java index 449cf54..1170bc8 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/CmsNavigation.java +++ b/src/main/java/com/gxwebsoft/cms/entity/CmsNavigation.java @@ -227,6 +227,10 @@ public class CmsNavigation implements Serializable { @TableField(exist = false) private String text; + @Schema(description = "栏目文章") + @TableField(exist = false) + private List articles; + public String getCategoryName() { return this.title; } diff --git a/src/main/java/com/gxwebsoft/cms/service/impl/CmsNavigationServiceImpl.java b/src/main/java/com/gxwebsoft/cms/service/impl/CmsNavigationServiceImpl.java index 7a541ba..8cf2af8 100644 --- a/src/main/java/com/gxwebsoft/cms/service/impl/CmsNavigationServiceImpl.java +++ b/src/main/java/com/gxwebsoft/cms/service/impl/CmsNavigationServiceImpl.java @@ -4,9 +4,11 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.cms.entity.CmsArticle; import com.gxwebsoft.cms.entity.CmsDesign; import com.gxwebsoft.cms.entity.CmsModel; import com.gxwebsoft.cms.mapper.CmsNavigationMapper; +import com.gxwebsoft.cms.service.CmsArticleService; import com.gxwebsoft.cms.service.CmsDesignService; import com.gxwebsoft.cms.service.CmsModelService; import com.gxwebsoft.cms.service.CmsNavigationService; @@ -38,6 +40,8 @@ public class CmsNavigationServiceImpl extends ServiceImpl pageRel(CmsNavigationParam param) { @@ -53,6 +57,11 @@ public class CmsNavigationServiceImpl extends ServiceImpl page = new PageParam<>(); page.setDefaultOrder("sort_number asc, position asc,navigation_id asc"); + list.forEach(item -> { + // 关联信息 + final List articleList = cmsArticleService.list(new LambdaQueryWrapper().eq(CmsArticle::getCategoryId, item.getNavigationId()).last("limit 5")); + item.setArticles(articleList); + }); return page.sortRecords(list); }