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

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

parent 8edc7208
......@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.common.Rest;
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.service.UserService;
import com.mortals.xhx.common.code.SourceEnum;
......@@ -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.service.StaffRecordService;
import com.mortals.xhx.module.staff.service.StaffService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -86,6 +88,9 @@ public class CompanyServiceImpl extends AbstractCRUDServiceImpl<CompanyDao, Comp
@Autowired
private LabelsService labelsService;
@Value("${domain.name:https://oa.xinhx.co}")
private String domain;
@Override
protected void findAfter(CompanyEntity params,PageInfo pageInfo, Context context, List<CompanyEntity> list) throws AppException {
fillSubData(list);
......@@ -98,6 +103,13 @@ public class CompanyServiceImpl extends AbstractCRUDServiceImpl<CompanyDao, Comp
}
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());
if(ObjectUtils.isEmpty(idList))return;
Map<Long, List<CompanyLabelsEntity>> companyLabelsListMap = companyLabelsService
......@@ -110,6 +122,9 @@ public class CompanyServiceImpl extends AbstractCRUDServiceImpl<CompanyDao, Comp
list.forEach(item -> {
item.setCompanyLabelsList(companyLabelsListMap.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;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
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.service.CategoryService;
import com.mortals.xhx.module.company.model.CompanyEntity;
......@@ -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.product.model.*;
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 com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
......@@ -50,6 +53,8 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
@Autowired
private CompanyService companyService;
@Value("${domain.name:https://oa.xinhx.co}")
private String domain;
@Override
public Result<ProductEntity> find(ProductEntity entity, PageInfo pageInfo, Context context) throws AppException {
......@@ -104,7 +109,20 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
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;
}
......
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