Commit 84d2fe82 authored by 姬鋆屾's avatar 姬鋆屾
parents f4bfc04e ee8846ec
......@@ -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));
}
});
}
......
package com.mortals.xhx.module.news.service.impl;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
......@@ -9,6 +10,7 @@ import com.mortals.xhx.module.news.service.NewsShareService;
import com.mortals.xhx.module.news.service.NewsUpService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
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;
......@@ -43,9 +45,20 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity
@Autowired
private UserService userService;
@Value("${domain.name:https://oa.xinhx.co}")
private String domain;
@Override
protected void findAfter(NewsEntity params, PageInfo pageInfo, Context context, List<NewsEntity> list) throws AppException {
if(CollectionUtils.isNotEmpty(list)){
String regex = "src=\"file";
String replacement;
if(domain.endsWith("/")){
replacement = "src=\"" + domain + "file";
}else {
replacement = "src=\"" + domain + "/file";
}
List<Long> userIdList = list.stream().map(NewsEntity::getCreateUserId).collect(Collectors.toList());
List<UserEntity> userList = userService.find(new UserQuery().idList(userIdList));
Map<Long,UserEntity> userMap = userList.parallelStream().collect(Collectors.toMap(x -> x.getId(), z -> z, (o, n) -> n));
......@@ -76,6 +89,15 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity
if(userEntity!=null) {
item.setPhotoPath(userEntity.getPhotoPath());
}
if(StringUtils.isNotEmpty(item.getContent())) {
item.setContent(item.getContent().replaceAll(regex, replacement));
}
}
}else {
for(NewsEntity item:list){
if(StringUtils.isNotEmpty(item.getContent())) {
item.setContent(item.getContent().replaceAll(regex, replacement));
}
}
}
}
......@@ -118,7 +140,11 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity
}
NewsQuery update = new NewsQuery();
update.setId(id);
update.setUpNumsIncrement(increment);
if(news.getUpNums()==0 && increment<0){
update.setUpNumsIncrement(0);
}else {
update.setUpNumsIncrement(increment);
}
return this.update(update);
}
......@@ -187,4 +213,5 @@ public class NewsServiceImpl extends AbstractCRUDServiceImpl<NewsDao, NewsEntity
update.setShareNumsIncrement(1);
return this.update(update);
}
}
\ No newline at end of file
......@@ -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