Commit ee8846ec authored by 廖旭伟's avatar 廖旭伟

公司,产品富文本添加domain链接

parent 8edc7208
...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil; ...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.user.model.UserQuery; import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.SourceEnum; import com.mortals.xhx.common.code.SourceEnum;
...@@ -32,6 +33,7 @@ import com.mortals.xhx.module.staff.model.StaffRecordEntity; ...@@ -32,6 +33,7 @@ import com.mortals.xhx.module.staff.model.StaffRecordEntity;
import com.mortals.xhx.module.staff.model.StaffRecordQuery; import com.mortals.xhx.module.staff.model.StaffRecordQuery;
import com.mortals.xhx.module.staff.service.StaffRecordService; import com.mortals.xhx.module.staff.service.StaffRecordService;
import com.mortals.xhx.module.staff.service.StaffService; import com.mortals.xhx.module.staff.service.StaffService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -86,6 +88,9 @@ public class CompanyServiceImpl extends AbstractCRUDServiceImpl<CompanyDao, Comp ...@@ -86,6 +88,9 @@ public class CompanyServiceImpl extends AbstractCRUDServiceImpl<CompanyDao, Comp
@Autowired @Autowired
private LabelsService labelsService; private LabelsService labelsService;
@Value("${domain.name:https://oa.xinhx.co}")
private String domain;
@Override @Override
protected void findAfter(CompanyEntity params,PageInfo pageInfo, Context context, List<CompanyEntity> list) throws AppException { protected void findAfter(CompanyEntity params,PageInfo pageInfo, Context context, List<CompanyEntity> list) throws AppException {
fillSubData(list); fillSubData(list);
...@@ -98,6 +103,13 @@ public class CompanyServiceImpl extends AbstractCRUDServiceImpl<CompanyDao, Comp ...@@ -98,6 +103,13 @@ public class CompanyServiceImpl extends AbstractCRUDServiceImpl<CompanyDao, Comp
} }
private void fillSubData(List<CompanyEntity> list) { private void fillSubData(List<CompanyEntity> list) {
String regex = "src=\"file";
String replacement;
if(domain.endsWith("/")){
replacement = "src=\"" + domain + "file";
}else {
replacement = "src=\"" + domain + "/file";
}
List<Long> idList = list.stream().map(i -> i.getId()).collect(Collectors.toList()); List<Long> idList = list.stream().map(i -> i.getId()).collect(Collectors.toList());
if(ObjectUtils.isEmpty(idList))return; if(ObjectUtils.isEmpty(idList))return;
Map<Long, List<CompanyLabelsEntity>> companyLabelsListMap = companyLabelsService Map<Long, List<CompanyLabelsEntity>> companyLabelsListMap = companyLabelsService
...@@ -110,6 +122,9 @@ public class CompanyServiceImpl extends AbstractCRUDServiceImpl<CompanyDao, Comp ...@@ -110,6 +122,9 @@ public class CompanyServiceImpl extends AbstractCRUDServiceImpl<CompanyDao, Comp
list.forEach(item -> { list.forEach(item -> {
item.setCompanyLabelsList(companyLabelsListMap.get(item.getId())); item.setCompanyLabelsList(companyLabelsListMap.get(item.getId()));
item.setCompanyPatentsList(companyPatentListMap.get(item.getId())); item.setCompanyPatentsList(companyPatentListMap.get(item.getId()));
if(StringUtils.isNotEmpty(item.getCompanyIntroduction())) {
item.setCompanyIntroduction(item.getCompanyIntroduction().replaceAll(regex, replacement));
}
}); });
} }
......
...@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.module.category.model.CategoryEntity; import com.mortals.xhx.module.category.model.CategoryEntity;
import com.mortals.xhx.module.category.service.CategoryService; import com.mortals.xhx.module.category.service.CategoryService;
import com.mortals.xhx.module.company.model.CompanyEntity; import com.mortals.xhx.module.company.model.CompanyEntity;
...@@ -13,6 +14,8 @@ import com.mortals.xhx.module.company.service.CompanyProductService; ...@@ -13,6 +14,8 @@ import com.mortals.xhx.module.company.service.CompanyProductService;
import com.mortals.xhx.module.company.service.CompanyService; import com.mortals.xhx.module.company.service.CompanyService;
import com.mortals.xhx.module.product.model.*; import com.mortals.xhx.module.product.model.*;
import com.mortals.xhx.module.product.service.ProductCategoryService; import com.mortals.xhx.module.product.service.ProductCategoryService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
...@@ -50,6 +53,8 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao, ...@@ -50,6 +53,8 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
@Autowired @Autowired
private CompanyService companyService; private CompanyService companyService;
@Value("${domain.name:https://oa.xinhx.co}")
private String domain;
@Override @Override
public Result<ProductEntity> find(ProductEntity entity, PageInfo pageInfo, Context context) throws AppException { public Result<ProductEntity> find(ProductEntity entity, PageInfo pageInfo, Context context) throws AppException {
...@@ -104,7 +109,20 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao, ...@@ -104,7 +109,20 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
productEntityResult.setDict(companyProductEntityResult.getDict()); productEntityResult.setDict(companyProductEntityResult.getDict());
} }
} }
if(CollectionUtils.isNotEmpty(productEntityResult.getList())){
String regex = "src=\"file";
String replacement;
if(domain.endsWith("/")){
replacement = "src=\"" + domain + "file";
}else {
replacement = "src=\"" + domain + "/file";
}
productEntityResult.getList().forEach(item -> {
if(StringUtils.isNotEmpty(item.getProductDetail())) {
item.setProductDetail(item.getProductDetail().replaceAll(regex, replacement));
}
});
}
return productEntityResult; return productEntityResult;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment