From d5319cffb668574b726a52d08afd3aa5323e3d7b Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 07 Jul 2022 19:47:23 +0800
Subject: [PATCH] fix
---
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java | 69 ++++++++++++++++++++++++++++------
1 files changed, 57 insertions(+), 12 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 4cb2c13..8435fda 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,17 @@
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.service.IReleaseService;
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 +32,7 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
@Service
@Slf4j
@@ -43,9 +41,11 @@
@Resource
private ColumnMapper columnMapper;
- @Autowired
- private ICmsCoreService cmsCoreService;
+ @Resource
+ private CompanyMapper companyMapper;
+ @Autowired
+ private IReleaseService releaseService;
@Override
public Result getArticleInPage(AdminArticleDto adminArticleDto) {
@@ -117,6 +117,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();
@@ -161,8 +164,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();
@@ -188,7 +189,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();
@@ -197,6 +202,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("更新成功");
}
@@ -251,13 +258,51 @@
}
@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);
+
+ releaseService.releaseArticle(articleEntity.getId());
return Result.ok("操作成功");
}
}
--
Gitblit v1.9.1