From 442600e2cb63f711418b8eb0f4ab8e2b97eb19c9 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Wed, 24 Aug 2022 18:38:19 +0800
Subject: [PATCH] fix

---
 src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java |   38 +++++++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 3 deletions(-)

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 56f8ed4..29928a0 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
@@ -115,6 +115,9 @@
         String atlas = adminAddArticleDto.getAtlas();
             articleEntity.setAtlas(atlas);
         Date releaseTime = adminAddArticleDto.getReleaseTime();
+        if (releaseTime == null) {
+            releaseTime = new Date();
+        }
             articleEntity.setReleaseTime(releaseTime);
         Integer isTop = adminAddArticleDto.getIsTop();
         articleEntity.setIsTop(isTop);
@@ -129,6 +132,10 @@
         articleEntity.setType(adminAddArticleDto.getType());
         articleEntity.setContentType(adminAddArticleDto.getContentType());
         this.baseMapper.insert(articleEntity);
+
+        if (adminAddArticleDto.getSaveState() == 2) {
+            releaseService.releaseArticle(articleEntity.getId(), articleEntity.getCompanyId());
+        }
         return Result.ok("添加成功");
     }
 
@@ -178,7 +185,12 @@
         if(ObjectUtil.isEmpty(columnEntity)){
             return Result.fail("请选择文章栏目");
         }
+
+        if (!articleEntity.getColumnId().equals(columnId) && articleEntity.getBeforeColumnId() == -1) {
+            articleEntity.setBeforeColumnId(articleEntity.getColumnId());
+        }
         articleEntity.setColumnId(columnId);
+
         Integer visits = adminUpdateArticleDto.getVisits() == null ? 0 : adminUpdateArticleDto.getVisits();
         articleEntity.setVisits(visits);
         String mainDiagram = adminUpdateArticleDto.getMainDiagram();
@@ -199,9 +211,14 @@
         articleEntity.setArticleUrl(adminUpdateArticleDto.getArticleUrl());
         articleEntity.setType(adminUpdateArticleDto.getType());
         articleEntity.setContentType(adminUpdateArticleDto.getContentType());
+
         String authorBelong = adminUpdateArticleDto.getAuthorBelong();
         articleEntity.setAuthorBelong(authorBelong);
         this.baseMapper.updateById(articleEntity);
+
+        if (adminUpdateArticleDto.getSaveState() == 2) {
+            releaseService.releaseArticle(articleEntity.getId(), articleEntity.getCompanyId());
+        }
         return Result.ok("更新成功");
     }
 
@@ -214,8 +231,11 @@
                 Long articleId = Long.valueOf(articleIdStr);
 
                 ArticleEntity articleEntity = this.baseMapper.selectById(articleId);
-                articleEntity.setDelStatus(ArticleEntity.DELETE_STATUS_YES);
-                this.baseMapper.updateById(articleEntity);
+//                articleEntity.setDelStatus(ArticleEntity.DELETE_STATUS_YES);
+//                this.baseMapper.updateById(articleEntity);
+                if (articleEntity != null) {
+                    this.baseMapper.deleteById(articleId);
+                }
             }
         }
         return Result.ok("删除成功");
@@ -229,6 +249,8 @@
         }
         articleEntity.setReleaseStatus(ArticleEntity.RELEASE_STATUS_NO);
         this.baseMapper.updateById(articleEntity);
+
+        releaseService.releaseColumn(articleEntity.getColumnId(), 2, articleEntity.getCompanyId());
         return Result.ok("操作成功");
     }
 
@@ -281,11 +303,21 @@
             articleEntity.setTimeType(timeType);
         }
         IPage<WebArticleVo> list = this.baseMapper.selectWebArticleInPage(page,articleEntity);
+
+        if (CollUtil.isNotEmpty(list.getRecords())) {
+            for (WebArticleVo record : list.getRecords()) {
+                // 站内
+                if (record.getType() == 1) {
+                    record.setArticleUrl(record.getBaseUrl() + record.getPath() + "/" + record.getId() + ".html");
+                }
+            }
+        }
         return Result.ok(list);
     }
 
     @Override
     public Result updateStatusOn(Long id) {
+        Long companyId = LoginUserUtil.getCompanyId();
         ArticleEntity articleEntity = this.baseMapper.selectById(id);
         if(ObjectUtil.isEmpty(articleEntity)){
             return Result.fail("文章不存在");
@@ -293,7 +325,7 @@
         articleEntity.setReleaseStatus(ArticleEntity.RELEASE_STATUS_YES);
         this.baseMapper.updateById(articleEntity);
 
-        releaseService.releaseArticle(articleEntity.getId());
+        releaseService.releaseArticle(articleEntity.getId(), companyId);
         return Result.ok("操作成功");
     }
 

--
Gitblit v1.9.1