-
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.
- Loading branch information
Showing
13 changed files
with
161 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.join.core.auth.domain; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
public class TermCommand { | ||
|
||
private TermCommand() { | ||
} | ||
|
||
@Builder | ||
@Getter | ||
public static class Agree { | ||
private final List<AgreeTerm> terms; | ||
} | ||
|
||
@Builder | ||
@Getter | ||
public static class AgreeTerm { | ||
private final Long id; | ||
private final String version; | ||
private final TermAgreeHistory.AcceptStatus status; | ||
|
||
public Term.Key toKey() { | ||
return new Term.Key(id, version); | ||
} | ||
|
||
} | ||
|
||
} |
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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/join/core/auth/repository/TermAgreeHistoryStoreImpl.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,37 @@ | ||
package com.join.core.auth.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.join.core.auth.domain.Term; | ||
import com.join.core.auth.domain.TermCommand; | ||
import com.join.core.auth.domain.User; | ||
import com.join.core.auth.service.TermAgreeHistoryStore; | ||
import com.join.core.auth.service.TermReader; | ||
import com.join.core.common.exception.ErrorCode; | ||
import com.join.core.common.exception.impl.TermAgreeException; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class TermAgreeHistoryStoreImpl implements TermAgreeHistoryStore { | ||
|
||
private final TermReader termReader; | ||
|
||
@Transactional | ||
@Override | ||
public void store(User user, TermCommand.Agree agree) { | ||
List<Term.Key> keys = agree.getTerms().stream().map(TermCommand.AgreeTerm::toKey).toList(); | ||
List<Term> terms = termReader.getTerms(keys); | ||
terms.forEach(t -> { | ||
Term.Key key = t.getKey(); | ||
TermCommand.AgreeTerm agreeTerm = agree.getTerms().stream().filter(at -> at.toKey().equals(key)).findFirst() | ||
.orElseThrow(() -> new TermAgreeException(ErrorCode.TERM_NOT_EXIST)); | ||
user.agree(t, agreeTerm.getStatus()); | ||
}); | ||
|
||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
src/main/java/com/join/core/auth/service/TermAgreeHistoryStore.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,10 @@ | ||
package com.join.core.auth.service; | ||
|
||
import com.join.core.auth.domain.TermCommand; | ||
import com.join.core.auth.domain.User; | ||
|
||
public interface TermAgreeHistoryStore { | ||
|
||
void store(User user, TermCommand.Agree agree); | ||
|
||
} |
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,11 +1,15 @@ | ||
package com.join.core.auth.service; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import com.join.core.auth.domain.Term; | ||
import com.join.core.auth.domain.TermInfo; | ||
|
||
public interface TermReader { | ||
|
||
List<TermInfo.Main> getRequiredConsentTerms(Long userId); | ||
|
||
List<Term> getTerms(Collection<Term.Key> keys); | ||
|
||
} |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/join/core/common/exception/impl/TermAgreeException.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,12 @@ | ||
package com.join.core.common.exception.impl; | ||
|
||
import com.join.core.common.exception.ErrorCode; | ||
import com.join.core.common.exception.GeneralException; | ||
|
||
public class TermAgreeException extends GeneralException { | ||
|
||
public TermAgreeException(ErrorCode errorCode) { | ||
super(errorCode); | ||
} | ||
|
||
} |