Skip to content

Commit be50e1b

Browse files
committed
chore
1 parent 4029c69 commit be50e1b

File tree

4 files changed

+46
-14
lines changed

4 files changed

+46
-14
lines changed

src/main/java/com/flint/flint/community/dto/response/PostCommentResponse.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ public class PostCommentResponse {
2626
private List<PostCommentResponse> replies = new ArrayList<>();
2727

2828
@QueryProjection
29-
public PostCommentResponse(Long parentCommentId, long postCommentId, String contents, LocalDateTime createdAt, Long likeCount, WriterResponse writerResponse) {
29+
public PostCommentResponse(Long parentCommentId, long postCommentId, String contents, LocalDateTime createdAt, long memberId, Long likeCount, String logoUrl) {
3030
this.parentCommentId = parentCommentId;
3131
this.postCommentId = postCommentId;
3232
this.contents = contents;
3333
this.createdAt = createdAt;
34+
this.memberId = memberId;
3435
this.likeCount = likeCount;
35-
this.writerResponse = writerResponse;
36+
this.logoUrl = logoUrl;
3637
}
37-
}
38+
}

src/main/java/com/flint/flint/community/repository/post_comment/PostCommentRepositoryImpl.java

+14-10
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,26 @@ public List<PostCommentResponse> findByPostId(Long postId) {
3636
.from(postCommentLike)
3737
.where(postCommentLike.postComment.eq(postComment));
3838

39-
return queryFactory
39+
JPQLQuery<String> logoUrlSubQuery = JPAExpressions
40+
.select(universityAsset.logoUrl)
41+
.from(idCard)
42+
.innerJoin(universityAsset).on(universityAsset.universityName.eq(idCard.university))
43+
.where(idCard.member.id.eq(postComment.member.id));
44+
45+
List<PostCommentResponse> comments = queryFactory
4046
.select(new QPostCommentResponse(
4147
postComment.parentComment.id,
4248
postComment.id,
4349
postComment.contents,
4450
postComment.createdAt,
51+
postComment.member.id,
4552
likeCountSubQuery,
46-
new QWriterResponse(
47-
idCard.member.id,
48-
universityAsset.logoUrl,
49-
idCard.university,
50-
idCard.major)))
51-
.from(postComment, idCard)
52-
.innerJoin(universityAsset).on(universityAsset.universityName.eq(idCard.university))
53-
.where(postComment.post.id.eq(postId).and(idCard.member.id.eq(postComment.member.id)))
53+
logoUrlSubQuery))
54+
.from(postComment)
55+
.where(postComment.post.id.eq(postId))
5456
.orderBy(postComment.createdAt.asc())
5557
.fetch();
58+
59+
return comments;
5660
}
57-
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.flint.flint.config;
2+
3+
import java.util.concurrent.Executor;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.scheduling.annotation.AsyncConfigurer;
7+
import org.springframework.scheduling.annotation.EnableAsync;
8+
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
9+
10+
@Configuration
11+
@EnableAsync
12+
public class AsyncConfig implements AsyncConfigurer {
13+
14+
@Override
15+
@Bean(name = "mailExecutor")
16+
public Executor getAsyncExecutor() {
17+
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
18+
executor.setCorePoolSize(2);
19+
executor.setMaxPoolSize(5);
20+
executor.setQueueCapacity(10);
21+
executor.setThreadNamePrefix("Async-MailExecutor-");
22+
executor.initialize();
23+
return executor;
24+
}
25+
}

src/main/java/com/flint/flint/mail/service/SendMailService.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.springframework.mail.javamail.JavaMailSender;
66
import org.springframework.mail.javamail.MimeMessageHelper;
77
import org.springframework.mail.javamail.MimeMessagePreparator;
8+
import org.springframework.scheduling.annotation.Async;
89
import org.springframework.stereotype.Service;
910

1011
/**
@@ -20,6 +21,7 @@ public class SendMailService {
2021
@Value("${email.id}")
2122
private String fromId;
2223

24+
@Async("mailExecutor")
2325
public void sendEmail(String to, String subject, String content) {
2426
MimeMessagePreparator messagePreparator =
2527
mimeMessage -> {
@@ -34,4 +36,4 @@ public void sendEmail(String to, String subject, String content) {
3436
}
3537

3638

37-
}
39+
}

0 commit comments

Comments
 (0)