-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Style: 코드 리펙토링
- Loading branch information
Showing
36 changed files
with
111 additions
and
127 deletions.
There are no files selected for viewing
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
4 changes: 1 addition & 3 deletions
4
src/main/java/com/dnd/gooding/filestore/infra/S3ServiceStore.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
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 |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
|
||
public interface EmailSender { | ||
|
||
void sendLoginSuccess(String toMail); | ||
void sendLoginSuccess(String toMail); | ||
} |
6 changes: 3 additions & 3 deletions
6
src/main/java/com/dnd/gooding/mail/exception/EmailSendException.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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package com.dnd.gooding.mail.exception; | ||
|
||
public class EmailSendException extends RuntimeException { | ||
public EmailSendException(Exception e) { | ||
super(e); | ||
} | ||
public EmailSendException(Exception e) { | ||
super(e); | ||
} | ||
} |
77 changes: 37 additions & 40 deletions
77
src/main/java/com/dnd/gooding/mail/infra/DefaultEmailEventAdapter.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 |
---|---|---|
@@ -1,55 +1,52 @@ | ||
package com.dnd.gooding.mail.infra; | ||
|
||
import com.dnd.gooding.mail.application.adapter.EmailSender; | ||
import com.dnd.gooding.mail.exception.EmailSendException; | ||
import javax.mail.internet.MimeMessage; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.mail.javamail.JavaMailSender; | ||
import org.springframework.mail.javamail.MimeMessageHelper; | ||
import org.springframework.stereotype.Component; | ||
import org.thymeleaf.context.Context; | ||
import org.thymeleaf.spring5.SpringTemplateEngine; | ||
|
||
import com.dnd.gooding.mail.application.adapter.EmailSender; | ||
import com.dnd.gooding.mail.exception.EmailSendException; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@Component | ||
public class DefaultEmailEventAdapter implements EmailSender { | ||
|
||
private final JavaMailSender mailSender; | ||
private final SpringTemplateEngine springTemplateEngine; | ||
@Value("${spring.mail.username}") | ||
private String fromMail; | ||
|
||
public DefaultEmailEventAdapter(JavaMailSender mailSender, | ||
SpringTemplateEngine springTemplateEngine) { | ||
this.mailSender = mailSender; | ||
this.springTemplateEngine = springTemplateEngine; | ||
} | ||
|
||
@Override | ||
public void sendLoginSuccess(String toMail) { | ||
Context context = new Context(); | ||
String text = springTemplateEngine.process(EmailMetaData.LOGIN_SUCCESS_TEMPLATE, context); | ||
sendMail(EmailMetaData.LOGIN_SUCCESS_TITLE, toMail, text); | ||
} | ||
|
||
private void sendMail(String subject, String toEmail, String text) { | ||
try { | ||
MimeMessage message = mailSender.createMimeMessage(); | ||
MimeMessageHelper helper = new MimeMessageHelper(message, true); | ||
|
||
helper.setSubject(subject); | ||
helper.setTo(toEmail); | ||
helper.setText(text); | ||
helper.setFrom(fromMail, "gooding"); | ||
|
||
mailSender.send(message); | ||
} catch (Exception e) { | ||
throw new EmailSendException(e); | ||
} | ||
|
||
} | ||
private final JavaMailSender mailSender; | ||
private final SpringTemplateEngine springTemplateEngine; | ||
|
||
@Value("${spring.mail.username}") | ||
private String fromMail; | ||
|
||
public DefaultEmailEventAdapter( | ||
JavaMailSender mailSender, SpringTemplateEngine springTemplateEngine) { | ||
this.mailSender = mailSender; | ||
this.springTemplateEngine = springTemplateEngine; | ||
} | ||
|
||
@Override | ||
public void sendLoginSuccess(String toMail) { | ||
Context context = new Context(); | ||
String text = springTemplateEngine.process(EmailMetaData.LOGIN_SUCCESS_TEMPLATE, context); | ||
sendMail(EmailMetaData.LOGIN_SUCCESS_TITLE, toMail, text); | ||
} | ||
|
||
private void sendMail(String subject, String toEmail, String text) { | ||
try { | ||
MimeMessage message = mailSender.createMimeMessage(); | ||
MimeMessageHelper helper = new MimeMessageHelper(message, true); | ||
|
||
helper.setSubject(subject); | ||
helper.setTo(toEmail); | ||
helper.setText(text); | ||
helper.setFrom(fromMail, "gooding"); | ||
|
||
mailSender.send(message); | ||
} catch (Exception e) { | ||
throw new EmailSendException(e); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.dnd.gooding.mail.infra; | ||
|
||
public class EmailMetaData { | ||
static String LOGIN_SUCCESS_TEMPLATE = "login-sucess"; | ||
static String LOGIN_SUCCESS_TITLE = "gooding 서비스에 가입해주셔서 감사합니다."; | ||
static String LOGIN_SUCCESS_TEMPLATE = "login-sucess"; | ||
static String LOGIN_SUCCESS_TITLE = "gooding 서비스에 가입해주셔서 감사합니다."; | ||
} |
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 |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
|
||
public interface CreateOAuthUseCase { | ||
|
||
Token create(String code); | ||
Token create(String code); | ||
} |
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
5 changes: 2 additions & 3 deletions
5
src/main/java/com/dnd/gooding/oauth/command/domain/repository/OAuthRepository.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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/dnd/gooding/oauth/infra/ExternalGoogleLoginAdapter.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/dnd/gooding/oauth/infra/ExternalKakaoLoginAdapter.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
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
5 changes: 2 additions & 3 deletions
5
src/main/java/com/dnd/gooding/record/command/application/in/CreateRecordUseCase.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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
package com.dnd.gooding.record.command.application.in; | ||
|
||
import java.io.IOException; | ||
|
||
import com.dnd.gooding.record.ui.dto.request.RecordRequest; | ||
import java.io.IOException; | ||
|
||
public interface CreateRecordUseCase { | ||
|
||
void create(RecordRequest recordRequest) throws IOException; | ||
void create(RecordRequest recordRequest) throws IOException; | ||
} |
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 |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
|
||
public interface DeleteRecordUseCase { | ||
|
||
void delete(String recordNo); | ||
void delete(String recordNo); | ||
} |
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
5 changes: 2 additions & 3 deletions
5
src/main/java/com/dnd/gooding/record/command/domain/repository/RecordRepository.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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/dnd/gooding/record/query/application/RecordQueryService.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
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
29 changes: 14 additions & 15 deletions
29
src/main/java/com/dnd/gooding/springconfig/log/MDCCopyTaskDecorator.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 |
---|---|---|
@@ -1,24 +1,23 @@ | ||
package com.dnd.gooding.springconfig.log; | ||
|
||
import java.util.Map; | ||
|
||
import org.slf4j.MDC; | ||
import org.springframework.core.task.TaskDecorator; | ||
|
||
public class MDCCopyTaskDecorator implements TaskDecorator { | ||
|
||
@Override | ||
public Runnable decorate(Runnable runnable) { | ||
Map<String, String> contextMap = MDC.getCopyOfContextMap(); | ||
return () -> { | ||
try { | ||
if (contextMap != null) { | ||
MDC.setContextMap(contextMap); | ||
} | ||
runnable.run(); | ||
} finally { | ||
MDC.clear(); | ||
} | ||
}; | ||
} | ||
@Override | ||
public Runnable decorate(Runnable runnable) { | ||
Map<String, String> contextMap = MDC.getCopyOfContextMap(); | ||
return () -> { | ||
try { | ||
if (contextMap != null) { | ||
MDC.setContextMap(contextMap); | ||
} | ||
runnable.run(); | ||
} finally { | ||
MDC.clear(); | ||
} | ||
}; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/com/dnd/gooding/springconfig/security/JwtAuthenticationFilter.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
3 changes: 1 addition & 2 deletions
3
src/main/java/com/dnd/gooding/springconfig/web/WebMvcConfig.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
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
3 changes: 1 addition & 2 deletions
3
src/main/java/com/dnd/gooding/token/command/domain/repository/RefreshTokenRepository.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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package com.dnd.gooding.token.command.domain.repository; | ||
|
||
import org.springframework.data.repository.CrudRepository; | ||
|
||
import com.dnd.gooding.token.command.domain.RefreshToken; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface RefreshTokenRepository extends CrudRepository<RefreshToken, String> {} |
Oops, something went wrong.