From bc43681f185af1edf833cf6c94833cb1cdd44a8e Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Thu, 07 Jul 2022 17:42:18 +0800
Subject: [PATCH] 20220606

---
 src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java |   63 ++++++++++++++++++++++++++-----
 1 files changed, 53 insertions(+), 10 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 6a2ce1d..db10d13 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
@@ -8,20 +8,16 @@
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xcong.farmer.cms.common.response.Result;
 import com.xcong.farmer.cms.modules.core.service.ICmsCoreService;
-import com.xcong.farmer.cms.modules.system.dto.AdminAddArticleDto;
-import com.xcong.farmer.cms.modules.system.dto.AdminArticleDto;
-import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto;
-import com.xcong.farmer.cms.modules.system.dto.AdminUpdateArticleDto;
-import com.xcong.farmer.cms.modules.system.entity.ArticleEntity;
-import com.xcong.farmer.cms.modules.system.entity.ColumnEntity;
-import com.xcong.farmer.cms.modules.system.entity.UserEntity;
-import com.xcong.farmer.cms.modules.system.entity.UserRoleEntity;
+import com.xcong.farmer.cms.modules.system.dto.*;
+import com.xcong.farmer.cms.modules.system.entity.*;
 import com.xcong.farmer.cms.modules.system.mapper.ArticleMapper;
 import com.xcong.farmer.cms.modules.system.mapper.ColumnMapper;
+import com.xcong.farmer.cms.modules.system.mapper.CompanyMapper;
 import com.xcong.farmer.cms.modules.system.service.IArticleService;
 import com.xcong.farmer.cms.modules.system.util.LoginUserUtil;
 import com.xcong.farmer.cms.modules.system.vo.AdminArticleVo;
 import com.xcong.farmer.cms.modules.system.vo.AdminSeeArticleInfoVo;
+import com.xcong.farmer.cms.modules.system.vo.WebArticleVo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -35,6 +31,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 
 @Service
 @Slf4j
@@ -42,6 +39,9 @@
 
     @Resource
     private ColumnMapper columnMapper;
+
+    @Resource
+    private CompanyMapper companyMapper;
 
     @Autowired
     private ICmsCoreService cmsCoreService;
@@ -116,6 +116,9 @@
         articleEntity.setIsTop(isTop);
         Integer releaseStatus = adminAddArticleDto.getReleaseStatus();
         articleEntity.setReleaseStatus(releaseStatus);
+        if(ArticleEntity.RELEASE_STATUS_YES == releaseStatus){
+            articleEntity.setReleaseTime(new Date());
+        }
         String articleDetails = adminAddArticleDto.getArticleDetails();
             articleEntity.setArticleDetails(articleDetails);
         String uploadFile = adminAddArticleDto.getUploadFile();
@@ -160,8 +163,6 @@
         }
         Integer isTop = adminUpdateArticleDto.getIsTop();
         articleEntity.setIsTop(isTop);
-        Integer releaseStatus = adminUpdateArticleDto.getReleaseStatus();
-        articleEntity.setReleaseStatus(releaseStatus);
         String title = adminUpdateArticleDto.getTitle();
         articleEntity.setTitle(title);
         String childTitle = adminUpdateArticleDto.getChildTitle();
@@ -187,7 +188,11 @@
         if(ObjectUtil.isNotEmpty(releaseTime)){
             articleEntity.setReleaseTime(releaseTime);
         }
+        Integer releaseStatus = adminUpdateArticleDto.getReleaseStatus();
         articleEntity.setReleaseStatus(releaseStatus);
+        if(ArticleEntity.RELEASE_STATUS_YES == releaseStatus){
+            articleEntity.setReleaseTime(new Date());
+        }
         String articleDetails = adminUpdateArticleDto.getArticleDetails();
         articleEntity.setArticleDetails(articleDetails);
         String uploadFile = adminUpdateArticleDto.getUploadFile();
@@ -196,6 +201,8 @@
         articleEntity.setArticleUrl(adminUpdateArticleDto.getArticleUrl());
         articleEntity.setType(adminUpdateArticleDto.getType());
         articleEntity.setContentType(adminUpdateArticleDto.getContentType());
+        String authorBelong = adminUpdateArticleDto.getAuthorBelong();
+        articleEntity.setAuthorBelong(authorBelong);
         this.baseMapper.updateById(articleEntity);
         return Result.ok("更新成功");
     }
@@ -250,12 +257,48 @@
     }
 
     @Override
+    public Result webArticleInPage(HttpServletRequest request, WebArticleInPageDto webArticleInPageDto) {
+        StringBuffer requestURL = request.getRequestURL();
+        List<CompanyEntity> companyEntities = companyMapper.selectList(new QueryWrapper<>());
+        Long companyId = 0L;
+        if(CollUtil.isNotEmpty(companyEntities)){
+            for(CompanyEntity companyEntity : companyEntities){
+                boolean contains = StrUtil.contains(requestURL, companyEntity.getWebAddress());
+                if(contains){
+                    companyId = companyEntity.getId();
+                }
+            }
+        }
+
+        Page<WebArticleVo> page = new Page<>(webArticleInPageDto.getPageNum(), webArticleInPageDto.getPageSize());
+        ArticleEntity articleEntity = new ArticleEntity();
+        Long columnId = webArticleInPageDto.getColumnId() == null ? 0L : webArticleInPageDto.getColumnId();
+        if(columnId != 0L){
+            articleEntity.setColumnId(columnId);
+        }
+        String author = webArticleInPageDto.getAuthor();
+        if(StrUtil.isNotEmpty(author)){
+            articleEntity.setAuthor(author);
+        }
+        String queryKey = webArticleInPageDto.getQueryKey();
+        if(StrUtil.isNotEmpty(queryKey)){
+            articleEntity.setTitle(queryKey);
+        }
+        if(UserEntity.USER_BELONG_TOP != companyId){
+            articleEntity.setCompanyId(companyId);
+        }
+        IPage<WebArticleVo> list = this.baseMapper.selectWebArticleInPage(page,articleEntity);
+        return Result.ok(list);
+    }
+
+    @Override
     public Result updateStatusOn(Long id) {
         ArticleEntity articleEntity = this.baseMapper.selectById(id);
         if(ObjectUtil.isEmpty(articleEntity)){
             return Result.fail("文章不存在");
         }
         articleEntity.setReleaseStatus(ArticleEntity.RELEASE_STATUS_YES);
+        articleEntity.setReleaseTime(new Date());
         this.baseMapper.updateById(articleEntity);
         return Result.ok("操作成功");
     }

--
Gitblit v1.9.1