-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 로그인 시 프로필 등록되지 않은 상태이면 isNewUser 응답 필드값 true 반환
- Loading branch information
Showing
4 changed files
with
47 additions
and
7 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
5 changes: 5 additions & 0 deletions
5
src/main/java/com/project/coalba/domain/auth/repository/UserRepositoryCustom.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,5 @@ | ||
package com.project.coalba.domain.auth.repository; | ||
|
||
public interface UserRepositoryCustom { | ||
Boolean existsByProfile(Long userId); | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/project/coalba/domain/auth/repository/impl/UserRepositoryImpl.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,34 @@ | ||
package com.project.coalba.domain.auth.repository.impl; | ||
|
||
import com.project.coalba.domain.auth.entity.enums.Role; | ||
import com.project.coalba.domain.auth.repository.UserRepositoryCustom; | ||
import com.querydsl.jpa.JPAExpressions; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import static com.project.coalba.domain.auth.entity.QUser.*; | ||
import static com.project.coalba.domain.profile.entity.QBoss.*; | ||
import static com.project.coalba.domain.profile.entity.QStaff.*; | ||
|
||
@RequiredArgsConstructor | ||
public class UserRepositoryImpl implements UserRepositoryCustom { | ||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public Boolean existsByProfile(Long userId) { | ||
return queryFactory.selectFrom(user) | ||
.where(user.id.eq(userId), | ||
user.role.eq(Role.BOSS).and( | ||
JPAExpressions.selectFrom(boss) | ||
.where(boss.user.id.eq(userId)) | ||
.exists() | ||
).or(user.role.eq(Role.STAFF).and( | ||
JPAExpressions.selectFrom(staff) | ||
.where(staff.user.id.eq(userId)) | ||
.exists() | ||
) | ||
) | ||
) | ||
.fetchOne() != null; | ||
} | ||
} |
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