Helius
2022-07-09 72e4c1f558c3a0ae7a3730a3b80da11f3e7729a7
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ColumnServiceImpl.java
@@ -6,7 +6,9 @@
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.configurations.properties.CmsProperties;
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;
@@ -40,6 +42,8 @@
    private ArticleMapper articleMapper;
    @Autowired
    private CompanyMapper companyMapper;
    @Autowired
    private CmsProperties cmsProperties;
    @Override
    public Result getColumnInPage(AdminColumnDto adminColumnDto) {
@@ -167,10 +171,14 @@
            if (columnEntity.getTargetType() == 1) {
                ArticleEntity articleEntity = articleMapper.selectById(Long.parseLong(columnEntity.getTargetUrl()));
                adminSeeColumnInfoVo.setTargetName(articleEntity.getTitle());
                adminSeeColumnInfoVo.setUrl(cmsProperties.getBaseUrl() + columnEntity.getPath() + "/" + columnEntity.getTargetUrl() + ".html");
            } else if (columnEntity.getTargetType() == 2) {
                ColumnEntity column = this.baseMapper.selectByCodeAndCompanyId(columnEntity.getTargetUrl(), LoginUserUtil.getCompanyId());
                adminSeeColumnInfoVo.setTargetName(column.getColumnName());
                adminSeeColumnInfoVo.setUrl(cmsProperties.getBaseUrl() + column.getPath());
            }
        } else {
            adminSeeColumnInfoVo.setUrl(cmsProperties.getBaseUrl() + columnEntity.getPath());
        }
        adminSeeColumnInfoVo.setTargetUrl(columnEntity.getTargetUrl());
        return Result.ok(adminSeeColumnInfoVo);
@@ -282,17 +290,8 @@
    @Override
    public Result getWebColumnInList(HttpServletRequest request) {
        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();
                }
            }
        }
        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){
@@ -316,4 +315,18 @@
        }
        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;
    }
}