-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c97846
commit 34b2884
Showing
11 changed files
with
403 additions
and
94 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
upupor-framework/src/main/java/com/upupor/framework/thread/UpuporForkJoin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.upupor.framework.thread; | ||
|
||
import java.util.concurrent.ForkJoinPool; | ||
|
||
/** | ||
* UpuporForkJoin | ||
* | ||
* @author Yang Runkang (cruise) | ||
* @date 1/9/23 15:39 | ||
*/ | ||
public class UpuporForkJoin { | ||
static final ForkJoinPool commentListForkJoin = new ForkJoinPool(); | ||
|
||
public static ForkJoinPool commentListForkJoin() { | ||
return commentListForkJoin; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...or-service/src/main/java/com/upupor/service/business/comment/list/ContentCommentList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2021-2022 yangrunkang | ||
* | ||
* Author: yangrunkang | ||
* Email: [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package com.upupor.service.business.comment.list; | ||
|
||
import com.upupor.data.dao.entity.Comment; | ||
import com.upupor.data.dao.entity.Content; | ||
import com.upupor.data.dao.entity.enhance.CommentEnhance; | ||
import com.upupor.data.dao.entity.enhance.ContentEnhance; | ||
import com.upupor.data.dto.page.comment.CommentDto; | ||
import com.upupor.data.types.ContentStatus; | ||
import com.upupor.data.types.ContentType; | ||
import com.upupor.service.base.ContentService; | ||
import com.upupor.service.business.comment.list.abstracts.AbstractCommentList; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.Resource; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* @author Yang Runkang (cruise) | ||
* @date 2023年01月09日 15:01 | ||
* @email: [email protected] | ||
*/ | ||
@Component | ||
public class ContentCommentList extends AbstractCommentList<Content> { | ||
|
||
@Resource | ||
private ContentService contentService; | ||
|
||
@Override | ||
protected Boolean isFit(ContentType commentSource) { | ||
return ContentType.isContent(commentSource); | ||
} | ||
|
||
@Override | ||
protected List<String> filterTargetIdList() { | ||
return commentEnhanceList.stream() | ||
.map(CommentEnhance::getComment) | ||
.filter(s -> ContentType.isContent(s.getCommentSource())) | ||
.map(Comment::getTargetId) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@Override | ||
protected Map<String, Content> filteredIdConvertToTMap(List<String> filteredIdList) { | ||
Map<String, Content> contentMap = new HashMap<>(); | ||
List<ContentEnhance> contentEnhances = contentService.listByContentIdList(filteredIdList); | ||
contentEnhances.stream() | ||
.map(ContentEnhance::getContent) | ||
.filter(content -> ContentStatus.NORMAL.equals(content.getStatus())) | ||
.forEach(s -> contentMap.putIfAbsent(s.getContentId(), s)) | ||
; | ||
return contentMap; | ||
} | ||
|
||
@Override | ||
protected void createCommentDto(Map<String, Content> contentMap, CommentEnhance commentEnhance) { | ||
Comment comment = commentEnhance.getComment(); | ||
String targetId = comment.getTargetId(); | ||
|
||
Content content = contentMap.get(targetId); | ||
commentDtoList.add(CommentDto.create(comment.getCommentContent(), | ||
"/u/" + content.getContentId(), content.getTitle(), commentEnhance | ||
)); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
...ervice/src/main/java/com/upupor/service/business/comment/list/MemberBoardCommentList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2021-2022 yangrunkang | ||
* | ||
* Author: yangrunkang | ||
* Email: [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package com.upupor.service.business.comment.list; | ||
|
||
import com.upupor.data.dao.entity.Comment; | ||
import com.upupor.data.dao.entity.Member; | ||
import com.upupor.data.dao.entity.enhance.CommentEnhance; | ||
import com.upupor.data.dao.entity.enhance.MemberEnhance; | ||
import com.upupor.data.dto.page.comment.CommentDto; | ||
import com.upupor.data.types.ContentType; | ||
import com.upupor.service.base.MemberService; | ||
import com.upupor.service.business.comment.list.abstracts.AbstractCommentList; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.Resource; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* @author Yang Runkang (cruise) | ||
* @date 2023年01月09日 15:01 | ||
* @email: [email protected] | ||
*/ | ||
@Component | ||
public class MemberBoardCommentList extends AbstractCommentList<Member> { | ||
@Resource | ||
private MemberService memberService; | ||
|
||
@Override | ||
protected Boolean isFit(ContentType commentSource) { | ||
return ContentType.isMessagetBoard(commentSource); | ||
} | ||
|
||
@Override | ||
protected List<String> filterTargetIdList() { | ||
return commentEnhanceList.stream() | ||
.map(CommentEnhance::getComment) | ||
.filter(s -> ContentType.isMessagetBoard(s.getCommentSource())) | ||
.map(Comment::getTargetId) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@Override | ||
protected void createCommentDto(Map<String, Member> memberMap, CommentEnhance commentEnhance) { | ||
Comment comment = commentEnhance.getComment(); | ||
String targetId = comment.getTargetId(); | ||
|
||
Member member = memberMap.get(targetId); | ||
commentDtoList.add(CommentDto.create(comment.getCommentContent(), | ||
"/profile/" + member.getUserId() + "/message", member.getUserName(), commentEnhance | ||
)); | ||
} | ||
|
||
@Override | ||
protected Map<String, Member> filteredIdConvertToTMap(List<String> filteredIdList) { | ||
Map<String, Member> memberMap = new HashMap<>(); | ||
List<MemberEnhance> memberEnhances = memberService.listByUserIdList(filteredIdList); | ||
memberEnhances.stream() | ||
.map(MemberEnhance::getMember) | ||
.forEach(s -> memberMap.putIfAbsent(s.getUserId(), s)) | ||
; | ||
return memberMap; | ||
} | ||
} |
Oops, something went wrong.