-
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.
refactor(persist): refactor persist login (#92)
* refactor(member): move imageAuth field into ProfileImage * refactor(persist): change PersistResponseDto field * refactor(persist): remove PersistRepository from MemberRepository * refactor(test): change PersistLoginRepository bean type * test: add test before query refactoring * fix(test): make test red to green (#91) * test: fix test authorization to green * test: fix test red to green * refactor(auth): make load Member code clean * test(auth): add findByPhoneNumber query test * fix(auth): fix bug MemberPrincipal-toString() * feat(code): add CodePk format validator * test(code): test validateCodePkFormat method * feat(code): add query find Code list by CodePk list * refactor(code): refactoring findCodeList and test * style(test): change display name --------- Co-authored-by: KAispread <[email protected]> * feat(persist): implement persist login * fix(persist): fix compile error * feat(profileImage): Add a method that returns boolean value --------- Co-authored-by: KAispread <[email protected]>
- Loading branch information
Showing
16 changed files
with
260 additions
and
124 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
3 changes: 1 addition & 2 deletions
3
src/main/java/com/e2i/wemeet/domain/member/MemberRepository.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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/e2i/wemeet/domain/member/persist/PersistData.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.e2i.wemeet.domain.member.persist; | ||
|
||
import com.e2i.wemeet.domain.member.data.ProfileImage; | ||
|
||
public record PersistData( | ||
String nickname, | ||
String email, | ||
ProfileImage profileImage, | ||
Long teamId | ||
) { | ||
|
||
} |
24 changes: 0 additions & 24 deletions
24
src/main/java/com/e2i/wemeet/domain/member/persist/PersistLoginData.java
This file was deleted.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
src/main/java/com/e2i/wemeet/domain/member/persist/PersistLoginRepository.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,8 +1,9 @@ | ||
package com.e2i.wemeet.domain.member.persist; | ||
|
||
import com.e2i.wemeet.dto.response.persist.PersistResponseDto; | ||
import java.util.Optional; | ||
|
||
public interface PersistLoginRepository { | ||
|
||
PersistResponseDto findPersistResponseById(Long memberId); | ||
Optional<PersistResponseDto> findPersistResponseById(Long memberId); | ||
} |
37 changes: 22 additions & 15 deletions
37
src/main/java/com/e2i/wemeet/domain/member/persist/PersistLoginRepositoryImpl.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,32 +1,39 @@ | ||
package com.e2i.wemeet.domain.member.persist; | ||
|
||
import static com.e2i.wemeet.domain.member.QMember.member; | ||
import static com.e2i.wemeet.domain.team.QTeam.team; | ||
|
||
import com.e2i.wemeet.dto.response.persist.PersistResponseDto; | ||
import com.querydsl.core.types.Projections; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import java.util.Optional; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
// TODO :: service refactoring | ||
@Repository | ||
@RequiredArgsConstructor | ||
public class PersistLoginRepositoryImpl implements PersistLoginRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
// TODO :: service refactoring | ||
@Override | ||
public PersistResponseDto findPersistResponseById(Long memberId) { | ||
// Optional<PersistLoginData> persistLoginData = Optional.ofNullable(queryFactory | ||
// .select(Projections.constructor( | ||
// PersistLoginData.class, | ||
// member.nickname, | ||
// member.collegeInfo.mail.as("email"), | ||
// team.teamId | ||
// )) | ||
// .from(member) | ||
// .leftJoin(member.team, team) | ||
// .where(member.memberId.eq(memberId)) | ||
// .fetchOne()); | ||
public Optional<PersistResponseDto> findPersistResponseById(Long memberId) { | ||
PersistData findPersistData = queryFactory | ||
.select(Projections.constructor( | ||
PersistData.class, | ||
member.nickname, | ||
member.email, | ||
member.profileImage, | ||
team.teamId | ||
)) | ||
.from(member) | ||
.leftJoin(member.team, team) | ||
.where(member.memberId.eq(memberId)) | ||
.fetchOne(); | ||
|
||
return null; | ||
if (findPersistData == null) { | ||
return Optional.empty(); | ||
} | ||
return Optional.ofNullable(PersistResponseDto.of(findPersistData)); | ||
} | ||
} |
53 changes: 48 additions & 5 deletions
53
src/main/java/com/e2i/wemeet/dto/response/persist/PersistResponseDto.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,21 +1,64 @@ | ||
package com.e2i.wemeet.dto.response.persist; | ||
|
||
import com.e2i.wemeet.domain.member.data.ProfileImage; | ||
import com.e2i.wemeet.domain.member.persist.PersistData; | ||
import java.util.Objects; | ||
import lombok.Builder; | ||
|
||
// TODO :: service refactoring | ||
@Builder | ||
public record PersistResponseDto( | ||
String nickname, | ||
boolean emailAuthenticated, | ||
boolean preferenceCompleted, | ||
boolean hasMainProfileImage, | ||
String basicProfileImage, | ||
String lowProfileImage, | ||
boolean profileImageAuthenticated, | ||
boolean hasTeam | ||
) { | ||
|
||
public static PersistResponseDto of(PersistData persistData) { | ||
final boolean emailAuthenticated = persistData.email() != null; | ||
final boolean hasTeam = persistData.teamId() != null; | ||
|
||
PersistResponseDtoBuilder builder = PersistResponseDto.builder() | ||
.nickname(persistData.nickname()) | ||
.emailAuthenticated(emailAuthenticated) | ||
.hasTeam(hasTeam); | ||
|
||
if (Objects.isNull(persistData.profileImage())) { | ||
return createResponseHasNoImage(builder); | ||
} | ||
return createResponse(persistData.profileImage(), builder); | ||
} | ||
|
||
private static PersistResponseDto createResponse(ProfileImage profileImage, PersistResponseDtoBuilder builder) { | ||
return builder | ||
.hasMainProfileImage(profileImage.hasProfileImage()) | ||
.profileImageAuthenticated(profileImage.isImageAuthenticated()) | ||
.basicProfileImage(profileImage.getBasicUrl()) | ||
.lowProfileImage(profileImage.getLowUrl()) | ||
.build(); | ||
} | ||
|
||
private static PersistResponseDto createResponseHasNoImage(PersistResponseDtoBuilder builder) { | ||
return builder | ||
.hasMainProfileImage(false) | ||
.profileImageAuthenticated(false) | ||
.basicProfileImage(null) | ||
.lowProfileImage(null) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "PersistResponseDto(nickname=" + this.nickname() + ", emailAuthenticated=" + this.emailAuthenticated() + ", preferenceCompleted=" | ||
+ this.preferenceCompleted() + ", hasMainProfileImage=" + this.hasMainProfileImage() + ", profileImageAuthenticated=" | ||
+ this.profileImageAuthenticated() + ", hasTeam=" + this.hasTeam() + ")"; | ||
return "PersistResponseDto{" + | ||
"nickname='" + nickname + '\'' + | ||
", emailAuthenticated=" + emailAuthenticated + | ||
", hasMainProfileImage=" + hasMainProfileImage + | ||
", basicProfileImage='" + basicProfileImage + '\'' + | ||
", lowProfileImage='" + lowProfileImage + '\'' + | ||
", profileImageAuthenticated=" + profileImageAuthenticated + | ||
", hasTeam=" + hasTeam + | ||
'}'; | ||
} | ||
} |
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
Oops, something went wrong.