-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from YAPP-Github/develop
fix: Resolve conflict.
- Loading branch information
Showing
20 changed files
with
263 additions
and
4 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
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
25 changes: 25 additions & 0 deletions
25
src/main/java/com/fullcar/member/domain/blacklist/Blacklist.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,25 @@ | ||
package com.fullcar.member.domain.blacklist; | ||
|
||
import jakarta.persistence.EmbeddedId; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EntityListeners; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = PROTECTED) | ||
@AllArgsConstructor(access = PROTECTED) | ||
@EntityListeners(AuditingEntityListener.class) | ||
@Builder | ||
public class Blacklist { | ||
@EmbeddedId | ||
private BlacklistId id; | ||
|
||
private String email; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/fullcar/member/domain/blacklist/BlacklistId.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,21 @@ | ||
package com.fullcar.member.domain.blacklist; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
|
||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
@Embeddable | ||
@Getter | ||
@NoArgsConstructor(access = PROTECTED) | ||
@AllArgsConstructor | ||
public class BlacklistId implements Serializable { | ||
|
||
@Column(name = "id") | ||
private Long id; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/fullcar/member/domain/blacklist/BlacklistRepository.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,17 @@ | ||
package com.fullcar.member.domain.blacklist; | ||
|
||
import com.fullcar.core.exception.CustomException; | ||
import com.fullcar.core.response.ErrorCode; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface BlacklistRepository extends JpaRepository<Blacklist, BlacklistId> { | ||
boolean existsByEmail(String email); | ||
|
||
default void findByEmailThrow(String email) { | ||
if (existsByEmail(email)) { | ||
throw new CustomException(ErrorCode.EMAIL_ADDRESS_IN_BLACKLIST); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/fullcar/member/domain/blacklist/service/BlacklistIdService.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.fullcar.member.domain.blacklist.service; | ||
|
||
import com.fullcar.core.id.SnowFlake; | ||
import com.fullcar.member.domain.blacklist.BlacklistId; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class BlacklistIdService { | ||
private final SnowFlake snowFlake; | ||
|
||
public BlacklistIdService() { | ||
snowFlake = new SnowFlake(255); | ||
} | ||
|
||
public BlacklistId nextId() { | ||
return new BlacklistId(snowFlake.nextId()); | ||
} | ||
} |
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,7 @@ | ||
package com.fullcar.member.domain.member; | ||
|
||
public enum Gender { | ||
FEMALE, | ||
MALE, | ||
NONE | ||
} |
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
9 changes: 9 additions & 0 deletions
9
src/main/java/com/fullcar/member/domain/member/service/MailService.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,9 @@ | ||
package com.fullcar.member.domain.member.service; | ||
|
||
import com.fullcar.member.presentation.member.dto.request.EmailRequestDto; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Transactional | ||
public interface MailService { | ||
void sendMail(EmailRequestDto emailRequestDto); | ||
} |
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,11 @@ | ||
package com.fullcar.member.infra; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class EmailMessage { | ||
private String to; | ||
private String subject; | ||
} |
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,50 @@ | ||
package com.fullcar.member.infra; | ||
|
||
import com.fullcar.member.application.member.MemberMapper; | ||
import com.fullcar.member.domain.blacklist.BlacklistRepository; | ||
import com.fullcar.member.domain.member.service.MailService; | ||
import com.fullcar.member.presentation.member.dto.request.EmailRequestDto; | ||
import jakarta.mail.MessagingException; | ||
import jakarta.mail.internet.MimeMessage; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.mail.javamail.JavaMailSender; | ||
import org.springframework.mail.javamail.MimeMessageHelper; | ||
import org.springframework.stereotype.Service; | ||
import org.thymeleaf.context.Context; | ||
import org.thymeleaf.spring6.SpringTemplateEngine; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MailClient implements MailService { | ||
private final BlacklistRepository blacklistRepository; | ||
private final JavaMailSender javaMailSender; | ||
private final SpringTemplateEngine templateEngine; | ||
private final MemberMapper memberMapper; | ||
|
||
@Override | ||
public void sendMail(EmailRequestDto emailRequestDto) { | ||
String email = emailRequestDto.getEmail(); | ||
String emailDomain = email.substring(email.lastIndexOf("@")+1); | ||
blacklistRepository.findByEmailThrow(emailDomain); | ||
|
||
EmailMessage emailMessage = memberMapper.toEntity(emailRequestDto); | ||
MimeMessage mimeMessage = javaMailSender.createMimeMessage(); | ||
|
||
try { | ||
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8"); | ||
mimeMessageHelper.setTo(emailMessage.getTo()); | ||
mimeMessageHelper.setSubject(emailMessage.getSubject()); | ||
mimeMessageHelper.setText(setContext(),true); | ||
mimeMessageHelper.addInline("image", new ClassPathResource("static/images/fullcar_logo.png")); | ||
javaMailSender.send(mimeMessage); | ||
} catch (MessagingException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public String setContext() { | ||
Context context = new Context(); | ||
return templateEngine.process("email", context); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/fullcar/member/presentation/member/dto/request/EmailRequestDto.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,15 @@ | ||
package com.fullcar.member.presentation.member.dto.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class EmailRequestDto { | ||
@Schema(description = "회사 이메일", example = "[email protected]") | ||
private String email; | ||
} |
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,5 +1,7 @@ | ||
package com.fullcar.member.presentation.member.dto.response; | ||
|
||
import com.fullcar.member.domain.car.CarId; | ||
import com.fullcar.member.domain.member.Gender; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.*; | ||
|
||
|
@@ -15,4 +17,14 @@ public class MemberGetResponseDto { | |
|
||
@Schema(description = "회사명", example = "현대 자동차") | ||
private String companyName; | ||
|
||
@Schema(description = "회사 이메일", example = "[email protected]") | ||
private String email; | ||
|
||
@Schema(description = "성별", example = "MALE") | ||
private Gender gender; | ||
|
||
@Schema(description = "차량 id") | ||
private CarId carId; | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,40 @@ | ||
<!DOCTYPE html> | ||
<html xmlns:th="http://www.thymeleaf.org" lang="UTF-8"> | ||
|
||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
</head> | ||
|
||
<body style="font-family: 'Noto Sans', 'Arial', 'sans-serif'; margin: 0; padding: 0;"> | ||
<div class="container" style="margin: auto;"> | ||
<div class="logo"> | ||
<img src="cid:image" alt="Fullcar 로고"> | ||
</div> | ||
<p style="margin-top: 20px; padding: 0;">안녕하세요.</p><br> | ||
<p style="margin-top: 10px;">회사 메일 인증을 통한 안전한 <span class="highlight" style="color: #6C7AF1; font-weight: bold;">카풀 서비스 풀카</span>입니다.</p> | ||
<p style="margin-top: 10px; margin-bottom: 10px;">풀카 이용을 위해 <span class="highlight" style="color: #6C7AF1; font-weight: bold;">아래 버튼을 클릭</span>해 인증을 진행해 주세요.</p> | ||
|
||
<script th:inline="javascript"> | ||
$("#bt").click(function() { | ||
alert('성공'); | ||
}); | ||
|
||
</script> | ||
|
||
<button type="button" id="bt" onclick="alert('성공')" style="display: inline-block; text-decoration: none; font-weight: 500; | ||
color: #fff; | ||
background-color: #6C7AF1; | ||
padding: 15px 36px; | ||
border-color: #6C7AF1; | ||
border-radius: 8px; | ||
font-size: 14px; | ||
margin-top: 20px; | ||
transition: background-color 0.3s;">회사 메일 인증하기</button> | ||
<div class="help-text"> | ||
<a href="#" style="display: block; color: #505967; margin-top: 20px; text-decoration: underline;">인증이 잘 되지 않나요?</a> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> | ||
|