-
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.
feat(block): Adding Blocking Features (#153)
* feat(block): add 'Block' Entity and Table * feat(block): add read block list query & test * feat(block): add blocking member business code & test * feat(block): add block API Controller & test * feat(block): add find block member list query * refactor(suggestion): except blocked member from suggestion and history query * refactor(heart): except blocked member from find sent or received hearts query * refactor(meeting): except blocked member from find meeting and meeting request * docs(block): add documentation block api to oas3 file * feat(team): add query check blocked team & test * feat(block): add BlockedException * feat(block): prevent blocked users from checking when read team
- Loading branch information
Showing
28 changed files
with
1,297 additions
and
81 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/com/e2i/wemeet/controller/member/BlockController.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,32 @@ | ||
package com.e2i.wemeet.controller.member; | ||
|
||
import com.e2i.wemeet.config.resolver.member.MemberId; | ||
import com.e2i.wemeet.dto.response.ResponseDto; | ||
import com.e2i.wemeet.service.member.BlockService; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/v1/member/block") | ||
@RestController | ||
public class BlockController { | ||
|
||
private final BlockService blockService; | ||
|
||
@PostMapping("/{blockMemberId}") | ||
public ResponseDto<Long> blockMember(@MemberId Long memberId, @PathVariable Long blockMemberId) { | ||
final Long blockedMemberId = blockService.block(memberId, blockMemberId); | ||
return ResponseDto.success("Block Member Success", blockedMemberId); | ||
} | ||
|
||
@GetMapping | ||
public ResponseDto<List<Long>> readBlockMembers(@MemberId Long memberId) { | ||
final List<Long> blockList = blockService.readBlockList(memberId); | ||
return ResponseDto.success("Read Block Member Success", blockList); | ||
} | ||
} |
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,39 @@ | ||
package com.e2i.wemeet.domain.member; | ||
|
||
import com.e2i.wemeet.domain.base.CreateTimeEntity; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
public class Block extends CreateTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long blockId; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member", referencedColumnName = "memberId", nullable = false) | ||
private Member member; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "blockMember", referencedColumnName = "memberId", nullable = false) | ||
private Member blockMember; | ||
|
||
@Builder | ||
public Block(Member member, Member blockMember) { | ||
this.member = member; | ||
this.blockMember = blockMember; | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/e2i/wemeet/domain/member/BlockRepository.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,27 @@ | ||
package com.e2i.wemeet.domain.member; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface BlockRepository extends JpaRepository<Block, Long> { | ||
|
||
// 차단 목록 조회 | ||
@Query("select b from Block b join fetch b.blockMember where b.member.memberId = :memberId") | ||
List<Block> findAllByMemberId(@Param("memberId") Long memberId); | ||
|
||
// 차단한 사용자 목록 조회 (ID) | ||
@Query("select b.blockMember.memberId from Block b where b.member.memberId = :memberId") | ||
List<Long> findBlockMemberIds(@Param("memberId") Long memberId); | ||
|
||
// 차단한 사용자 목록 조회 (ID) | ||
@Query(""" | ||
select b.blockMember.memberId | ||
from Block b | ||
join Team t on t.teamLeader.memberId = b.member.memberId | ||
where t.teamId = :teamId | ||
""") | ||
List<Long> findBlockMemberIdsByTeamId(@Param("teamId") Long teamId); | ||
|
||
} |
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.