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 | 99 ++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 80 insertions(+), 19 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 601c2bc..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
@@ -1,5 +1,6 @@
package com.xcong.farmer.cms.modules.system.service.Impl;
+import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
@@ -7,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;
@@ -34,6 +32,7 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
@Service
@Slf4j
@@ -42,8 +41,11 @@
@Resource
private ColumnMapper columnMapper;
+ @Resource
+ private CompanyMapper companyMapper;
+
@Autowired
- private ICmsCoreService cmsCoreService;
+ private IReleaseService releaseService;
@Override
public Result getArticleInPage(AdminArticleDto adminArticleDto) {
@@ -58,6 +60,20 @@
String title = adminArticleDto.getTitle();
if(StrUtil.isNotEmpty(title)){
articleEntity.setTitle(title);
+ }
+ Integer contentType = adminArticleDto.getContentType() == null ? 0 : adminArticleDto.getContentType();
+ if(contentType != 0){
+ QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>();
+ objectQueryWrapper.eq("content_type",contentType);
+ List<ColumnEntity> columnEntities = columnMapper.selectList(objectQueryWrapper);
+ if(CollUtil.isNotEmpty(columnEntities)){
+ List<Long> columIds = new ArrayList<>();
+ for(ColumnEntity columnEntity : columnEntities){
+ Long id = columnEntity.getId();
+ columIds.add(id);
+ }
+ articleEntity.setColumnIds(columIds);
+ }
}
if(UserEntity.USER_BELONG_TOP != companyId){
articleEntity.setCompanyId(companyId);
@@ -101,10 +117,17 @@
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();
articleEntity.setUploadFile(uploadFile);
+
+ articleEntity.setArticleUrl(adminAddArticleDto.getArticleUrl());
+ articleEntity.setType(adminAddArticleDto.getType());
+ articleEntity.setContentType(adminAddArticleDto.getContentType());
this.baseMapper.insert(articleEntity);
return Result.ok("添加成功");
}
@@ -141,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();
@@ -168,11 +189,21 @@
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();
articleEntity.setUploadFile(uploadFile);
+
+ 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("更新成功");
}
@@ -227,21 +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("操作成功");
- }
-
- @Override
- public void releaseArticle(Long id) {
- ArticleEntity article = this.baseMapper.selectById(id);
-
- ColumnEntity column = columnMapper.selectById(article.getColumnId());
- cmsCoreService.articleProcess(article.getId(), column.getArticleTemplate());
}
}
--
Gitblit v1.9.1