feat: 多线程
This commit is contained in:
@@ -252,8 +252,6 @@ public class SchisandraShareCommentReplyController {
|
||||
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getDetailId(), "分享文章id不能为空");
|
||||
Preconditions.checkNotNull(schisandraShareCommentReplyDTO.getUserId(), "发布人id不能为空");
|
||||
SchisandraShareCommentReplyBO schisandraShareCommentReplyBO = SchisandraShareCommentReplyDTOConverter.INSTANCE.convertDTOToBO(schisandraShareCommentReplyDTO);
|
||||
// String result = SensitiveWordHelper.replace(schisandraShareCommentReplyBO.getContent());
|
||||
// schisandraShareCommentReplyBO.setContent(result);
|
||||
caffeineUtil.caffeineBuild().invalidate("listcommenthot" + schisandraShareCommentReplyBO.getDetailId());
|
||||
caffeineUtil.caffeineBuild().invalidate("listcomment" + schisandraShareCommentReplyBO.getDetailId());
|
||||
return Result.ok(schisandraShareCommentReplyDomainService.addComment(schisandraShareCommentReplyBO));
|
||||
|
@@ -1,8 +1,5 @@
|
||||
package com.schisandra.share.domain.service.impl;
|
||||
|
||||
import com.jd.platform.async.executor.Async;
|
||||
import com.jd.platform.async.worker.WorkResult;
|
||||
import com.jd.platform.async.wrapper.WorkerWrapper;
|
||||
import com.schisandra.share.common.enums.IsDeletedFlagEnum;
|
||||
import com.schisandra.share.domain.bo.SchisandraShareCommentReplyBO;
|
||||
import com.schisandra.share.domain.convert.SchisandraShareCommentReplyBOConverter;
|
||||
@@ -20,8 +17,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
||||
/**
|
||||
@@ -97,13 +94,17 @@ public class SchisandraShareCommentReplyDomainServiceImpl implements SchisandraS
|
||||
public List<SchisandraShareCommentReplyBO> listComment(String detailId, String userId) {
|
||||
List<SchisandraShareCommentReply> schisandraShareComments = schisandraShareCommentReplyService.listComment(detailId);
|
||||
List<SchisandraShareCommentReplyBO> schisandraShareCommentBOS = SchisandraShareCommentReplyBOConverter.INSTANCE.convertEntityToBOList(schisandraShareComments);
|
||||
schisandraShareCommentBOS.forEach(schisandraShareCommentReplyBO -> {
|
||||
for (SchisandraShareCommentReplyBO schisandraShareCommentReplyBO : schisandraShareCommentBOS) {
|
||||
SchisandraUserLikesComment schisandraUserLikesComment =
|
||||
schisandraUserLikesCommentService.queryByuserIdAndCommentId(schisandraShareCommentReplyBO.getId(), userId);
|
||||
if (schisandraUserLikesComment != null) {
|
||||
schisandraShareCommentReplyBO.setIsLike(true);
|
||||
}
|
||||
AuthUserInfoEntity userInfo = userRpc.getUserInfo(schisandraShareCommentReplyBO.getUserId());
|
||||
CompletableFuture<AuthUserInfoEntity> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||
AuthUserInfoEntity info = userRpc.getUserInfo(schisandraShareCommentReplyBO.getUserId());
|
||||
return info;
|
||||
});
|
||||
AuthUserInfoEntity userInfo = futurePrice.join();
|
||||
schisandraShareCommentReplyBO.setNick(userInfo.getNickName());
|
||||
schisandraShareCommentReplyBO.setAvatar(userInfo.getAvatar());
|
||||
|
||||
@@ -113,7 +114,7 @@ public class SchisandraShareCommentReplyDomainServiceImpl implements SchisandraS
|
||||
schisandraShareCommentReplyBO.setBrowser(userAddress.getBrowser());
|
||||
schisandraShareCommentReplyBO.setBrowserVersion(userAddress.getBrowserVersion());
|
||||
}
|
||||
});
|
||||
}
|
||||
return schisandraShareCommentBOS;
|
||||
}
|
||||
|
||||
@@ -127,7 +128,11 @@ public class SchisandraShareCommentReplyDomainServiceImpl implements SchisandraS
|
||||
if(schisandraUserLikesComment!=null){
|
||||
schisandraShareCommentReplyBO.setIsLike(true);
|
||||
}
|
||||
AuthUserInfoEntity userInfo = userRpc.getUserInfo(schisandraShareCommentReplyBO.getUserId());
|
||||
CompletableFuture<AuthUserInfoEntity> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||
AuthUserInfoEntity info = userRpc.getUserInfo(schisandraShareCommentReplyBO.getUserId());
|
||||
return info;
|
||||
});
|
||||
AuthUserInfoEntity userInfo = futurePrice.join();
|
||||
schisandraShareCommentReplyBO.setNick(userInfo.getNickName());
|
||||
schisandraShareCommentReplyBO.setAvatar(userInfo.getAvatar());
|
||||
AuthUserAddressEntity userAddress = addressRpc.getUserAddress(schisandraShareCommentReplyBO.getUserId());
|
||||
@@ -150,7 +155,11 @@ public class SchisandraShareCommentReplyDomainServiceImpl implements SchisandraS
|
||||
if(schisandraUserLikesComment!=null){
|
||||
schisandraShareReplyBO.setIsLike(true);
|
||||
}
|
||||
AuthUserInfoEntity userInfo = userRpc.getUserInfo(schisandraShareReplyBO.getUserId());
|
||||
CompletableFuture<AuthUserInfoEntity> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||
AuthUserInfoEntity info = userRpc.getUserInfo(schisandraShareReplyBO.getUserId());
|
||||
return info;
|
||||
});
|
||||
AuthUserInfoEntity userInfo = futurePrice.join();
|
||||
|
||||
if (schisandraShareReplyBO.getReplyUser() != null) {
|
||||
AuthUserInfoEntity userInfo2 = userRpc.getUserInfo(schisandraShareReplyBO.getReplyUser());
|
||||
|
@@ -18,6 +18,7 @@ import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.schisandra.share.common.enums.TypeName.getByType;
|
||||
@@ -79,7 +80,13 @@ public class SchisandraShareDetailDomainServiceImpl implements SchisandraShareDe
|
||||
List<SchisandraShareDetailBO> shareDetailBOList = SchisandraShareDetailBOConverter.INSTANCE.convertEntityToBOList(schisandraShareDetails);
|
||||
LinkedList<SchisandraShareDetailBO> resultList = new LinkedList<>();
|
||||
shareDetailBOList.forEach(shareDetailBO -> {
|
||||
AuthUserInfoEntity userInfo = userRpc.getUserInfo(shareDetailBO.getUserId());
|
||||
|
||||
CompletableFuture<AuthUserInfoEntity> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||
AuthUserInfoEntity info = userRpc.getUserInfo(shareDetailBO.getUserId());
|
||||
return info;
|
||||
});
|
||||
AuthUserInfoEntity userInfo = futurePrice.join();
|
||||
|
||||
SchisandraShareDetailBO schisandraShareDetailBO = new SchisandraShareDetailBO();
|
||||
SchisandraUserLikesComment schisandraUserLikesComment =
|
||||
schisandraUserLikesCommentService.queryByuserIdAndCommentId(shareDetailBO.getId(), userId);
|
||||
@@ -193,7 +200,11 @@ public class SchisandraShareDetailDomainServiceImpl implements SchisandraShareDe
|
||||
List<SchisandraShareDetailBO> shareDetailBOList = SchisandraShareDetailBOConverter.INSTANCE.convertEntityToBOList(schisandraShareDetails);
|
||||
LinkedList<SchisandraShareDetailBO> resultList = new LinkedList<>();
|
||||
shareDetailBOList.forEach(shareDetailBO -> {
|
||||
AuthUserInfoEntity userInfo = userRpc.getUserInfo(shareDetailBO.getUserId());
|
||||
CompletableFuture<AuthUserInfoEntity> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||
AuthUserInfoEntity info = userRpc.getUserInfo(shareDetailBO.getUserId());
|
||||
return info;
|
||||
});
|
||||
AuthUserInfoEntity userInfo = futurePrice.join();
|
||||
SchisandraShareDetailBO schisandraShareDetailBO = new SchisandraShareDetailBO();
|
||||
schisandraShareDetailBO.setCircleId(shareDetailBO.getCircleId());
|
||||
schisandraShareDetailBO.setIcon(shareDetailBO.getIcon());
|
||||
|
Reference in New Issue
Block a user