-
Notifications
You must be signed in to change notification settings - Fork 1
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 #75 from SMWU-POCHAK/develop
애플로그인 버그 수정 버전 배포
- Loading branch information
Showing
34 changed files
with
630 additions
and
242 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
18 changes: 18 additions & 0 deletions
18
src/main/java/com/apps/pochak/global/config/QuerydslConfig.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,18 @@ | ||
package com.apps.pochak.global.config; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import jakarta.persistence.EntityManager; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class QuerydslConfig { | ||
private final EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
} |
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
61 changes: 61 additions & 0 deletions
61
src/main/java/com/apps/pochak/post/domain/repository/PostCustomRepository.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,61 @@ | ||
package com.apps.pochak.post.domain.repository; | ||
|
||
import com.apps.pochak.global.BaseEntityStatus; | ||
import com.apps.pochak.global.api_payload.exception.GeneralException; | ||
import com.apps.pochak.post.domain.Post; | ||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.apps.pochak.block.domain.QBlock.block; | ||
import static com.apps.pochak.global.api_payload.code.status.ErrorStatus.BLOCKED_POST; | ||
import static com.apps.pochak.post.domain.QPost.post; | ||
import static com.apps.pochak.tag.domain.QTag.tag; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class PostCustomRepository { | ||
private final JPAQueryFactory query; | ||
|
||
public Post findPostByIdWithoutBlockPost( | ||
final Long postId, | ||
final Long loginMemberId | ||
) { | ||
return findByIdWithoutBlockPost(postId, loginMemberId).orElseThrow(() -> new GeneralException(BLOCKED_POST)); | ||
} | ||
|
||
public Optional<Post> findByIdWithoutBlockPost( | ||
final Long postId, | ||
final Long loginMemberId | ||
) { | ||
return Optional.ofNullable( | ||
query.selectFrom(post) | ||
.join(post.owner).fetchJoin() | ||
.join(tag).on(tag.post.eq(post)) | ||
.leftJoin(block).on( | ||
checkOwnerOrTaggedMemberBlockLoginMember(loginMemberId) | ||
.or(checkLoginMemberBlockOwnerOrTaggedMember(loginMemberId)) | ||
) | ||
.groupBy(post) | ||
.having(block.id.count().eq(0L)) | ||
.where( | ||
post.id.eq(postId), | ||
post.status.eq(BaseEntityStatus.ACTIVE) | ||
) | ||
.fetchOne() | ||
); | ||
} | ||
|
||
private BooleanExpression checkOwnerOrTaggedMemberBlockLoginMember(final Long loginMemberId) { | ||
return (block.blocker.eq(tag.member).or(block.blocker.eq(post.owner))) | ||
.and(block.blockedMember.id.eq(loginMemberId)); | ||
} | ||
|
||
private BooleanExpression checkLoginMemberBlockOwnerOrTaggedMember(final Long loginMemberId) { | ||
return (block.blocker.id.eq(loginMemberId)) | ||
.and(block.blockedMember.eq(tag.member).or(block.blockedMember.eq(post.owner))); | ||
} | ||
} |
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
Oops, something went wrong.