-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ 기능 추가 / 수정: 멤버 타입에 따른 블랙리스트 필터링 메서드 추가 #184
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
09f0577
✨ 기능 추가 / 수정: BlacklistDTO 변환에 따른 블랙리스트 조회 코드 수정
Hellin22 4adf5cb
✨ 기능 추가 / 수정: Blacklist filter 기능을 위한 query dsl 기본 세팅
Hellin22 3664ffd
✨ 기능 추가 / 수정: Blacklist 필터링 기능 작성
Hellin22 f5ff8a8
✨ 기능 추가 / 수정: 필터링 조건 입력받는 VO 생성
Hellin22 272e8cf
✨ 기능 추가 / 수정: 필터링 DTO에 멤버타입 추가
Hellin22 d39c95e
✨ 기능 추가 / 수정: 블랙리스트 필터링 멤버타입 조건 추가
Hellin22 f3712c7
✨ 기능 추가 / 수정: 멤버 타입에 따른 블랙리스트 필터링 메서드 추가
Hellin22 942568e
Merge branch 'develop' of https://github.com/LearnsMate/LearnsMateBac…
Hellin22 99917ea
♻️ 코드 수정: api 수정
Hellin22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
17 changes: 17 additions & 0 deletions
17
...ate/src/main/java/intbyte4/learnsmate/blacklist/domain/dto/BlacklistFilterRequestDTO.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 intbyte4.learnsmate.blacklist.domain.dto; | ||
|
||
import intbyte4.learnsmate.member.domain.MemberType; | ||
import lombok.*; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
@ToString | ||
public class BlacklistFilterRequestDTO { | ||
private Long memberCode; | ||
private String memberName; | ||
private String memberEmail; | ||
private MemberType memberType; | ||
} |
17 changes: 17 additions & 0 deletions
17
.../java/intbyte4/learnsmate/blacklist/domain/vo/request/RequestFilterBlacklistMemberVO.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 intbyte4.learnsmate.blacklist.domain.vo.request; | ||
|
||
import com.fasterxml.jackson.databind.PropertyNamingStrategies; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
import lombok.*; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
@ToString | ||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) | ||
public class RequestFilterBlacklistMemberVO { | ||
private Long memberCode; | ||
private String memberName; | ||
private String memberEmail; | ||
} |
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
16 changes: 12 additions & 4 deletions
16
LearnsMate/src/main/java/intbyte4/learnsmate/blacklist/repository/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 |
---|---|---|
@@ -1,18 +1,26 @@ | ||
package intbyte4.learnsmate.blacklist.repository; | ||
|
||
import intbyte4.learnsmate.blacklist.domain.dto.BlacklistDTO; | ||
import intbyte4.learnsmate.blacklist.domain.entity.Blacklist; | ||
import intbyte4.learnsmate.member.domain.MemberType; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface BlacklistRepository extends JpaRepository<Blacklist, Long> { | ||
@Primary | ||
public interface BlacklistRepository extends JpaRepository<Blacklist, Long>, BlacklistRepositoryCustom { | ||
|
||
@Query("SELECT b FROM blacklist b " + | ||
"JOIN member m ON b.member.memberCode = m.memberCode " + | ||
@Query("SELECT new intbyte4.learnsmate.blacklist.domain.dto.BlacklistDTO(" + | ||
"b.blackCode, m.memberCode, m.memberName, m.memberEmail, b.blackReason, b.createdAt, a.adminCode, a.adminName" + | ||
") " + | ||
"FROM blacklist b " + | ||
"JOIN b.member m " + | ||
"LEFT JOIN b.admin a " + | ||
"WHERE m.memberType = :memberType") | ||
List<Blacklist> findAllBlacklistByMemberType(MemberType memberType); | ||
List<BlacklistDTO> findAllBlacklistByMemberType(@Param("memberType") MemberType memberType); | ||
} |
10 changes: 10 additions & 0 deletions
10
...ate/src/main/java/intbyte4/learnsmate/blacklist/repository/BlacklistRepositoryCustom.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 intbyte4.learnsmate.blacklist.repository; | ||
|
||
import intbyte4.learnsmate.blacklist.domain.dto.BlacklistFilterRequestDTO; | ||
import intbyte4.learnsmate.blacklist.domain.entity.Blacklist; | ||
|
||
import java.util.List; | ||
|
||
public interface BlacklistRepositoryCustom { | ||
List<Blacklist> searchBy(BlacklistFilterRequestDTO request); | ||
} |
54 changes: 54 additions & 0 deletions
54
...sMate/src/main/java/intbyte4/learnsmate/blacklist/repository/BlacklistRepositoryImpl.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,54 @@ | ||
package intbyte4.learnsmate.blacklist.repository; | ||
|
||
import com.querydsl.core.BooleanBuilder; | ||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import intbyte4.learnsmate.blacklist.domain.dto.BlacklistFilterRequestDTO; | ||
import intbyte4.learnsmate.blacklist.domain.entity.Blacklist; | ||
import intbyte4.learnsmate.blacklist.domain.entity.QBlacklist; | ||
import intbyte4.learnsmate.member.domain.MemberType; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
public class BlacklistRepositoryImpl implements BlacklistRepositoryCustom { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<Blacklist> searchBy(BlacklistFilterRequestDTO request) { | ||
QBlacklist blacklist = QBlacklist.blacklist; | ||
|
||
BooleanBuilder builder = new BooleanBuilder() | ||
.and(eqMemberCode(request.getMemberCode())) | ||
.and(likeMemberName(request.getMemberName())) | ||
.and(likeMemberEmail(request.getMemberEmail()) | ||
.and(eqMemberType(request.getMemberType()))); | ||
|
||
return queryFactory | ||
.selectFrom(blacklist) | ||
.where(builder) | ||
.fetch(); | ||
} | ||
|
||
// memberCode 검색 조건 | ||
private BooleanExpression eqMemberCode(Long memberCode) { | ||
return memberCode == null ? null : QBlacklist.blacklist.member.memberCode.eq(memberCode); | ||
} | ||
|
||
// memberName 검색 조건 | ||
private BooleanExpression likeMemberName(String memberName) { | ||
return memberName == null ? null : QBlacklist.blacklist.member.memberName.containsIgnoreCase(memberName); | ||
} | ||
|
||
// memberEmail 검색 조건 | ||
private BooleanExpression likeMemberEmail(String memberEmail) { | ||
return memberEmail == null ? null : QBlacklist.blacklist.member.memberEmail.containsIgnoreCase(memberEmail); | ||
} | ||
|
||
// memberType 검색 조건 (학생 또는 강사) | ||
private BooleanExpression eqMemberType(MemberType memberType) { | ||
return memberType == null ? null : QBlacklist.blacklist.member.memberType.eq(memberType); | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런 어노테이션도 있었네요..