-
Notifications
You must be signed in to change notification settings - Fork 3
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 #313 from JNU-econovation/be
[BE] merge to main
- Loading branch information
Showing
58 changed files
with
604 additions
and
511 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
14 changes: 0 additions & 14 deletions
14
BE/eeos/resources/test-develop-environment/docker-compose.yml
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...ava/com/blackcompany/eeos/auth/application/domain/converter/OauthInfoEntityConverter.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...a/com/blackcompany/eeos/auth/application/domain/converter/OauthMemberEntityConverter.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,24 @@ | ||
package com.blackcompany.eeos.auth.application.domain.converter; | ||
|
||
import com.blackcompany.eeos.auth.application.domain.OauthMemberModel; | ||
import com.blackcompany.eeos.auth.persistence.OAuthMemberEntity; | ||
import com.blackcompany.eeos.common.support.converter.AbstractEntityConverter; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class OauthMemberEntityConverter | ||
implements AbstractEntityConverter<OAuthMemberEntity, OauthMemberModel> { | ||
@Override | ||
public OauthMemberModel from(final OAuthMemberEntity entity) { | ||
return OauthMemberModel.builder().oauthId(entity.getOauthId()).build(); | ||
} | ||
|
||
@Override | ||
public OAuthMemberEntity toEntity(final OauthMemberModel model) { | ||
return OAuthMemberEntity.builder().oauthId(model.getOauthId()).build(); | ||
} | ||
|
||
public OAuthMemberEntity toEntity(final String oauthId, Long memberId) { | ||
return OAuthMemberEntity.builder().oauthId(oauthId).memberId(memberId).build(); | ||
} | ||
} |
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
BE/eeos/src/main/java/com/blackcompany/eeos/auth/application/event/DeletedMemberEvent.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.blackcompany.eeos.auth.application.event; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class DeletedMemberEvent { | ||
private final Long memberId; | ||
private final String token; | ||
|
||
private DeletedMemberEvent(Long memberId, String token) { | ||
this.memberId = memberId; | ||
this.token = token; | ||
} | ||
|
||
/** | ||
* 멤버 탈퇴 이벤트를 발행한다. | ||
* | ||
* @param memberId 회원 탈퇴를 원하는 멤버 id | ||
* @param token 회원 탈퇴 시 사용한 토큰 | ||
* @return | ||
*/ | ||
public static DeletedMemberEvent of(Long memberId, String token) { | ||
return new DeletedMemberEvent(memberId, token); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...rc/main/java/com/blackcompany/eeos/auth/application/event/DeletedMemberEventListener.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,42 @@ | ||
package com.blackcompany.eeos.auth.application.event; | ||
|
||
import com.blackcompany.eeos.auth.application.domain.token.TokenResolver; | ||
import com.blackcompany.eeos.auth.persistence.BlackAuthenticationRepository; | ||
import com.blackcompany.eeos.target.persistence.AttendRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Propagation; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class DeletedMemberEventListener { | ||
private final AttendRepository attendRepository; | ||
private final BlackAuthenticationRepository blackAuthenticationRepository; | ||
private final TokenResolver tokenResolver; | ||
|
||
@Async | ||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
public void handleDeletedProgram(DeletedMemberEvent event) { | ||
deleteTargetData(event.getMemberId()); | ||
saveUsedToken(event.getToken(), event.getMemberId()); | ||
} | ||
|
||
private void deleteTargetData(Long memberId) { | ||
attendRepository.deleteAllByMemberId(memberId); | ||
} | ||
|
||
private void saveUsedToken(String token, Long memberId) { | ||
blackAuthenticationRepository.save(token, memberId, getExpiredDate(token)); | ||
} | ||
|
||
private Long getExpiredDate(String token) { | ||
return tokenResolver.getExpiredDateByRefreshToken(token); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...src/main/java/com/blackcompany/eeos/auth/application/exception/TokenParsingException.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,20 @@ | ||
package com.blackcompany.eeos.auth.application.exception; | ||
|
||
import com.blackcompany.eeos.common.exception.BusinessException; | ||
import org.springframework.http.HttpStatus; | ||
|
||
/** JWT 파싱 중 발생한 예외 */ | ||
public class TokenParsingException extends BusinessException { | ||
private static final String FAIL_CODE = "4007"; | ||
private String message; | ||
|
||
public TokenParsingException(Exception e) { | ||
super(FAIL_CODE, HttpStatus.BAD_REQUEST); | ||
message = e.getMessage(); | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return String.format("JWT 파싱 중 오류 발생: {}", message); | ||
} | ||
} |
Oops, something went wrong.