From ab9066e00429cec617724a943da45d91cb812835 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Fri, 08 Jul 2022 16:36:06 +0800
Subject: [PATCH] fix
---
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ColumnServiceImpl.java | 65 ++++++++++++++++++++++++++++++--
1 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ColumnServiceImpl.java b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ColumnServiceImpl.java
index 684a206..7510d74 100644
--- a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ColumnServiceImpl.java
+++ b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ColumnServiceImpl.java
@@ -6,21 +6,21 @@
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xcong.farmer.cms.common.contants.AppContants;
import com.xcong.farmer.cms.common.response.Result;
import com.xcong.farmer.cms.modules.system.dto.AdminAddColumnDto;
import com.xcong.farmer.cms.modules.system.dto.AdminColumnDto;
import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto;
import com.xcong.farmer.cms.modules.system.dto.AdminUpdateColumnDto;
-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.NavigationBarEntity;
-import com.xcong.farmer.cms.modules.system.entity.UserEntity;
+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.IColumnService;
import com.xcong.farmer.cms.modules.system.util.LoginUserUtil;
import com.xcong.farmer.cms.modules.system.vo.AdminColumnVo;
import com.xcong.farmer.cms.modules.system.vo.AdminSeeColumnInfoVo;
+import com.xcong.farmer.cms.modules.system.vo.WebColumnVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -29,6 +29,7 @@
import cn.hutool.core.util.ObjectUtil;
import org.springframework.transaction.annotation.Transactional;
+import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@@ -38,6 +39,8 @@
@Autowired
private ArticleMapper articleMapper;
+ @Autowired
+ private CompanyMapper companyMapper;
@Override
public Result getColumnInPage(AdminColumnDto adminColumnDto) {
@@ -106,8 +109,11 @@
Long parentId = adminAddColumnDto.getParentId();
if(ObjectUtil.isEmpty(parentId)){
columnEntity.setParentId(ColumnEntity.PARENTID_DEFAULT);
+ columnEntity.setPath("/" + columnEntity.getColumnCode());
}else{
columnEntity.setParentId(parentId);
+ ColumnEntity parent = this.baseMapper.selectById(parentId);
+ columnEntity.setPath(parent.getPath() + "/" + columnEntity.getColumnCode());
}
columnEntity.setListTemplate(adminAddColumnDto.getListTemplate());
@@ -116,8 +122,9 @@
columnEntity.setTargetType(adminAddColumnDto.getTargetType());
columnEntity.setTargetUrl(adminAddColumnDto.getTargetUrl());
columnEntity.setIsNav(adminAddColumnDto.getIsNav());
+ columnEntity.setContentType(adminAddColumnDto.getContentType());
this.baseMapper.insert(columnEntity);
- return Result.ok("添加成功");
+ return Result.ok("添加成功", columnEntity.getId());
}
@Override
@@ -156,6 +163,7 @@
adminSeeColumnInfoVo.setIsNav(columnEntity.getIsNav());
adminSeeColumnInfoVo.setType(columnEntity.getType());
adminSeeColumnInfoVo.setTargetType(columnEntity.getTargetType());
+ adminSeeColumnInfoVo.setContentType(columnEntity.getContentType());
if (columnEntity.getType() == 2) {
if (columnEntity.getTargetType() == 1) {
ArticleEntity articleEntity = articleMapper.selectById(Long.parseLong(columnEntity.getTargetUrl()));
@@ -206,8 +214,11 @@
Long parentId = adminUpdateColumnDto.getParentId();
if(ObjectUtil.isEmpty(parentId)){
columnEntity.setParentId(ColumnEntity.PARENTID_DEFAULT);
+ columnEntity.setPath("/" + columnEntity.getColumnCode());
}else{
columnEntity.setParentId(parentId);
+ ColumnEntity parent = this.baseMapper.selectById(parentId);
+ columnEntity.setPath(parent.getPath() + "/" + columnEntity.getColumnCode());
}
columnEntity.setListTemplate(adminUpdateColumnDto.getListTemplate());
@@ -216,6 +227,7 @@
columnEntity.setTargetType(adminUpdateColumnDto.getTargetType());
columnEntity.setTargetUrl(adminUpdateColumnDto.getTargetUrl());
columnEntity.setIsNav(adminUpdateColumnDto.getIsNav());
+ columnEntity.setContentType(adminUpdateColumnDto.getContentType());
this.baseMapper.updateById(columnEntity);
return Result.ok("更新成功");
}
@@ -242,6 +254,7 @@
child.setRemark(columnEntityChild.getRemark());
child.setPic(columnEntityChild.getPic());
child.setOrderNum(columnEntityChild.getOrderNum());
+ child.setContentType(columnEntityChild.getContentType());
adminColumnVoChilds.add(child);
}
}
@@ -267,4 +280,46 @@
}
return Result.ok("删除成功");
}
+
+ @Override
+ public Result getWebColumnInList(HttpServletRequest request) {
+ String website = request.getHeader(AppContants.WEBSITE_HEADER);
+ Long companyId = getCompanyIdFromWebsite(website);
+ List<WebColumnVo> records = this.baseMapper.selectWebColumnInListByParentId(ColumnEntity.PARENTID_DEFAULT,companyId);
+ if(CollUtil.isNotEmpty(records)){
+ for(WebColumnVo webColumnVo : records){
+ Long id = webColumnVo.getId();
+ QueryWrapper<ColumnEntity> objectQueryWrapper = new QueryWrapper<>();
+ objectQueryWrapper.eq("parent_id",id);
+ objectQueryWrapper.eq("company_id",companyId);
+ List<ColumnEntity> columnEntities = this.baseMapper.selectList(objectQueryWrapper);
+ List<WebColumnVo> adminColumnVoChilds = new ArrayList<>();
+ if(CollUtil.isNotEmpty(columnEntities)){
+ for(ColumnEntity columnEntityChild : columnEntities){
+ WebColumnVo child = new WebColumnVo();
+ child.setId(columnEntityChild.getId());
+ child.setColumnName(columnEntityChild.getColumnName());
+ child.setColumnCode(columnEntityChild.getColumnCode());
+ adminColumnVoChilds.add(child);
+ }
+ }
+ webColumnVo.setChild(adminColumnVoChilds);
+ }
+ }
+ return Result.ok(records);
+ }
+
+ private Long getCompanyIdFromWebsite(String website){
+ List<CompanyEntity> companyEntities = companyMapper.selectList(new QueryWrapper<>());
+ Long companyId = 0L;
+ if(CollUtil.isNotEmpty(companyEntities)){
+ for(CompanyEntity companyEntity : companyEntities){
+ boolean contains = StrUtil.contains(companyEntity.getWebAddress(), website);
+ if(contains){
+ companyId = companyEntity.getId();
+ }
+ }
+ }
+ return companyId;
+ }
}
--
Gitblit v1.9.1