Browse Source

修改:文章新增isPublic变量,标记是否公开,并根据此变量控制显示

GDW 10 months ago
parent
commit
6e34835d7f

+ 4 - 0
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/entity/Article.java

@@ -114,4 +114,8 @@ public class Article implements Serializable {
     private String authorId;
     @TableField(exist = false)
     private List<String> tags;
+
+    @Excel(name = "是否公开", width = 15)
+    @ApiModelProperty(value = "是否公开")
+    private String isPublic;
 }

+ 27 - 1
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/mapper/xml/ArticleMapper.xml

@@ -4,8 +4,9 @@
 
     <select id="queryPageListByFilters" resultType="org.jeecg.modules.kms.knowledge.entity.Article">
         select distinct t0.* from kms_knowledge_article t0
-                          inner join kms_article_category_r t1 on t0.id = t1.article_id
+        inner join kms_article_category_r t1 on t0.id = t1.article_id
         where t0.status = 2
+        AND t0.is_public != '1'
         <if test="filterParam.categoryId != null and filterParam.categoryId != ''">
             AND t1.category_id = #{filterParam.categoryId}
         </if>
@@ -13,5 +14,30 @@
             AND t0.title like CONCAT(CONCAT('%', #{filterParam.keyWords}), '%')
         </if>
         ${sql}
+
+        UNION
+
+        select distinct t0.* from kms_knowledge_article t0
+        inner join kms_article_category_r t1 on t0.id = t1.article_id
+        where t0.status = 2
+        AND t0.is_public != '0'
+        <if test="filterParam.categoryId != null and filterParam.categoryId != ''">
+            AND t1.category_id = #{filterParam.categoryId}
+        </if>
+        <if test="filterParam.keyWords != null and filterParam.keyWords != ''">
+            AND t0.title like CONCAT(CONCAT('%', #{filterParam.keyWords}), '%')
+        </if>
     </select>
+<!--    <select id="queryPageListByFilters" resultType="org.jeecg.modules.kms.knowledge.entity.Article">-->
+<!--            select distinct t0.* from kms_knowledge_article t0-->
+<!--                              inner join kms_article_category_r t1 on t0.id = t1.article_id-->
+<!--            where t0.status = 2 AND t0.is_public != '1'-->
+<!--            <if test="filterParam.categoryId != null and filterParam.categoryId != ''">-->
+<!--                AND t1.category_id = #{filterParam.categoryId}-->
+<!--            </if>-->
+<!--            <if test="filterParam.keyWords != null and filterParam.keyWords != ''">-->
+<!--                AND t0.title like CONCAT(CONCAT('%', #{filterParam.keyWords}), '%')-->
+<!--            </if>-->
+<!--            ${sql}-->
+<!--    </select>-->
 </mapper>

+ 8 - 0
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/service/impl/ArticleServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.kms.bas.entity.Category;
 import org.jeecg.modules.kms.bas.service.ICategoryService;
 import org.jeecg.modules.kms.knowledge.entity.Article;
 import org.jeecg.modules.kms.knowledge.entity.ArticleCategoryR;
@@ -66,6 +67,13 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Article addArticle(Article article) {
+        String categoryId = article.getCategoryId();
+        Category category = categoryService.getById(categoryId);
+        if (category.getIsPublic().equals("1")){
+            article.setIsPublic("1");
+        } else {
+            article.setIsPublic("0");
+        }
         this.saveOrUpdate(article);
         this.updateCategoryR(article);
         this.saveOrUpdateTagR(article);