Browse Source

恢复功能恢复到删除前的状态

danch 1 month ago
parent
commit
8a2c3b0ab2

+ 13 - 1
jeecg-module-kms/src/main/java/org/jeecg/modules/kms/knowledge/controller/ArticleController.java

@@ -169,7 +169,19 @@ public class ArticleController extends JeecgController<Article, IArticleService>
             return Result.OK("批量审核成功!");
         }
     }
-
+    @AutoLog(value = "知识管理-文章-批量恢复")
+    @ApiOperation(value = "知识管理-文章-批量恢复", notes = "知识管理-文章-批量恢复")
+    @RequiresPermissions("kms:kms_knowledge_article:deleteAudit")
+    @GetMapping(value = "/restoreBatch")
+    public Result<String> restoreBatch(@RequestParam(name = "ids", required = true) String ids) {
+        List<String> idList = Arrays.asList(ids.split(","));
+        this.articleService.restoreBatchByIds(idList);
+        if (idList.size() == 1) {
+            return Result.OK("审核成功!");
+        } else {
+            return Result.OK("批量审核成功!");
+        }
+    }
     /**
      * 通过id查询
      *

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

@@ -112,6 +112,8 @@ public class Article implements Serializable {
      * 3驳回**/
     @Dict(dicCode = "kms_knowledge_article_status")
     private Integer status;
+    @ApiModelProperty(value = "删除前状态")
+    private Integer preDeletionStatus;
 
     private String authorId;
     @TableField(exist = false)

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

@@ -23,4 +23,6 @@ public interface IArticleService extends IService<Article> {
 
     void auditBatchByIds(List<String> list);
     void deleteBatchByIds(List<String> list);
+
+    void restoreBatchByIds(List<String> list);
 }

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

@@ -146,8 +146,18 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
     public void deleteBatchByIds(List<String> list) {
         list.forEach(item -> {
             Article article = this.getById(item);
+            article.setPreDeletionStatus(article.getStatus());
             article.setStatus(ArticleStatusEnum.DELETE.getStatus());
             this.updateById(article);
         });
     }
+
+    @Override
+    public void restoreBatchByIds(List<String> list) {
+        list.forEach(item -> {
+            Article article = this.getById(item);
+            article.setStatus(article.getPreDeletionStatus());
+            this.updateById(article);
+        });
+    }
 }