Browse Source

我的文章和文章管理后端

danch 2 months ago
parent
commit
7fe63eb8d4

+ 5 - 2
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/controller/ArticleController.java

@@ -28,6 +28,7 @@ import org.springframework.web.servlet.ModelAndView;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -134,7 +135,9 @@ public class ArticleController extends JeecgController<Article, IArticleService>
     @RequiresPermissions("kms:kms_knowledge_article:delete")
     @DeleteMapping(value = "/delete")
     public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
-        articleService.removeById(id);
+        List<String> ids = new ArrayList<>();
+        ids.add(id);
+        articleService.deleteBatchByIds(ids);
         return Result.OK("删除成功!");
     }
 
@@ -149,7 +152,7 @@ public class ArticleController extends JeecgController<Article, IArticleService>
     @RequiresPermissions("kms:kms_knowledge_article:deleteBatch")
     @DeleteMapping(value = "/deleteBatch")
     public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
-        this.articleService.removeByIds(Arrays.asList(ids.split(",")));
+        this.articleService.deleteBatchByIds(Arrays.asList(ids.split(",")));
         return Result.OK("批量删除成功!");
     }
 

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

@@ -110,7 +110,9 @@ public class Article implements Serializable {
      * 1待审核
      * 2已审核
      * 3驳回**/
+    @Dict(dicCode = "kms_knowledge_article_status")
     private Integer status;
+
     private String authorId;
     @TableField(exist = false)
     private List<String> tags;

+ 11 - 3
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/enums/ArticleStatusEnum.java

@@ -12,15 +12,23 @@ public enum ArticleStatusEnum {
     /**
      * 草稿
      */
-    DRAFT(0, "草稿"),
+    DRAFT(0, "创建"),
     /**
      * 发布
      */
-    PUBLISH(1, "发布"),
+    PUBLISH(1, "待审核"),
     /**
      * 删除
      */
-    AUDIT(2, "审核");
+    AUDIT(2, "已审核"),
+    /**
+     * 驳回
+     */
+    REJECT(3, "已驳回"),
+    /**
+     * 删除
+     */
+    DELETE(4, "已删除");
 
     private Integer code;
     private String msg;

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

@@ -14,9 +14,7 @@
             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

+ 1 - 0
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/service/IArticleService.java

@@ -22,4 +22,5 @@ public interface IArticleService extends IService<Article> {
     void updateArticle(Article article);
 
     void auditBatchByIds(List<String> list);
+    void deleteBatchByIds(List<String> list);
 }

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

@@ -53,7 +53,9 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
         Page<Article> pages = new Page<Article>(filterParam.getPageNo(), filterParam.getPageSize());
         String sql = QueryGenerator.installAuthJdbc(Article.class);
         IPage<Article> articleIPage = articleMapper.queryPageListByFilters(pages, filterParam.getArticleFilterParam(), sql);
+
         List<Article> articles = articleIPage.getRecords();
+        System.out.println(articles.toString());
         for (Article article : articles) {//查询该文章的标签
             List<ArticleTagR> articleTagRS = articleTagRService.list(new QueryWrapper<ArticleTagR>().lambda().eq(ArticleTagR::getArticleId, article.getId()));
             //收集标签的tagIds
@@ -139,4 +141,13 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
         });
 
     }
+
+    @Override
+    public void deleteBatchByIds(List<String> list) {
+        list.forEach(item -> {
+            Article article = this.getById(item);
+            article.setStatus(ArticleStatusEnum.DELETE.getStatus());
+            this.updateById(article);
+        });
+    }
 }