From b95699652357c6218b45eceb81170ddfebb30e1d Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 05 Jul 2022 16:06:25 +0800
Subject: [PATCH] fix conflect

---
 src/main/java/com/xcong/farmer/cms/modules/system/entity/ArticleEntity.java            |    3 +++
 src/main/resources/mapper/ArticleMapper.xml                                            |    7 +++++--
 src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java |   13 ++++++++++++-
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/xcong/farmer/cms/modules/system/entity/ArticleEntity.java b/src/main/java/com/xcong/farmer/cms/modules/system/entity/ArticleEntity.java
index 671d97f..d258867 100644
--- a/src/main/java/com/xcong/farmer/cms/modules/system/entity/ArticleEntity.java
+++ b/src/main/java/com/xcong/farmer/cms/modules/system/entity/ArticleEntity.java
@@ -7,6 +7,7 @@
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 文章表
@@ -95,5 +96,7 @@
      */
     @TableField(exist = false)
     private String path;
+    @TableField(exist = false)
+    private List<Long> columnIds;
 
 }
diff --git a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java
index a50d269..6a2ce1d 100644
--- a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java
+++ b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java
@@ -1,5 +1,6 @@
 package com.xcong.farmer.cms.modules.system.service.Impl;
 
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
@@ -61,7 +62,17 @@
         }
         Integer contentType = adminArticleDto.getContentType() == null ? 0 : adminArticleDto.getContentType();
         if(contentType != 0){
-            articleEntity.setContentType(adminArticleDto.getContentType());
+            QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>();
+            objectQueryWrapper.eq("content_type",contentType);
+            List<ColumnEntity> columnEntities = columnMapper.selectList(objectQueryWrapper);
+            if(CollUtil.isNotEmpty(columnEntities)){
+                List<Long> columIds = new ArrayList<>();
+                for(ColumnEntity columnEntity : columnEntities){
+                    Long id = columnEntity.getId();
+                    columIds.add(id);
+                }
+                articleEntity.setColumnIds(columIds);
+            }
         }
         if(UserEntity.USER_BELONG_TOP != companyId){
             articleEntity.setCompanyId(companyId);
diff --git a/src/main/resources/mapper/ArticleMapper.xml b/src/main/resources/mapper/ArticleMapper.xml
index 533fdca..aa86fa6 100644
--- a/src/main/resources/mapper/ArticleMapper.xml
+++ b/src/main/resources/mapper/ArticleMapper.xml
@@ -21,8 +21,11 @@
                 <if test="record.title!=null">
                     and a.title like concat ('%',#{record.title},'%')
                 </if>
-                <if test="record.contentType != null">
-                    and a.content_type = #{record.contentType}
+                <if test="record.columnIds != null">
+                    and a.column_id =
+                    <foreach collection="record.columnIds" separator="," close=")" open="(" item="item">
+                        #{item}
+                    </foreach>
                 </if>
             </if>
         </where>

--
Gitblit v1.9.1