-
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.
- Loading branch information
1 parent
f610335
commit 08e3b95
Showing
8 changed files
with
113 additions
and
12 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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/server/capple/domain/boardSubscribeMember/entity/BoardSubscribeMember.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,24 @@ | ||
package com.server.capple.domain.boardSubscribeMember.entity; | ||
|
||
import com.server.capple.domain.board.entity.Board; | ||
import com.server.capple.domain.member.entity.Member; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Getter | ||
@Entity | ||
@AllArgsConstructor | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class BoardSubscribeMember { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@ManyToOne | ||
@JoinColumn(name = "member_id", nullable = false) | ||
private Member member; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "board_id", nullable = false) | ||
private Board board; | ||
} |
13 changes: 13 additions & 0 deletions
13
.../server/capple/domain/boardSubscribeMember/reposiotry/BoardSubscribeMemberRepository.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,13 @@ | ||
package com.server.capple.domain.boardSubscribeMember.reposiotry; | ||
|
||
import com.server.capple.domain.boardSubscribeMember.entity.BoardSubscribeMember; | ||
import com.server.capple.domain.member.entity.Member; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface BoardSubscribeMemberRepository extends JpaRepository<BoardSubscribeMember, Long> { | ||
Boolean existsByMemberIdAndBoardId(Long memberId, Long boardId); | ||
List<BoardSubscribeMember> findBoardSubscribeMembersByBoardId(Long boardId); | ||
void deleteBoardSubscribeMemberByBoardId(Long boardId); | ||
} |
12 changes: 12 additions & 0 deletions
12
...va/com/server/capple/domain/boardSubscribeMember/service/BoardSubscribeMemberService.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.server.capple.domain.boardSubscribeMember.service; | ||
|
||
import com.server.capple.domain.board.entity.Board; | ||
import com.server.capple.domain.member.entity.Member; | ||
|
||
import java.util.List; | ||
|
||
public interface BoardSubscribeMemberService { | ||
void createBoardSubscribeMember(Member member, Board board); | ||
List<Member> findBoardSubscribeMembers(Long boardId); | ||
void deleteBoardSubscribeMemberByBoardId(Long boardId); | ||
} |
33 changes: 33 additions & 0 deletions
33
...om/server/capple/domain/boardSubscribeMember/service/BoardSubscribeMemberServiceImpl.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,33 @@ | ||
package com.server.capple.domain.boardSubscribeMember.service; | ||
|
||
import com.server.capple.domain.board.entity.Board; | ||
import com.server.capple.domain.boardSubscribeMember.entity.BoardSubscribeMember; | ||
import com.server.capple.domain.boardSubscribeMember.reposiotry.BoardSubscribeMemberRepository; | ||
import com.server.capple.domain.member.entity.Member; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class BoardSubscribeMemberServiceImpl implements BoardSubscribeMemberService { | ||
private final BoardSubscribeMemberRepository boardSubscribeMemberRepository; | ||
@Override | ||
public void createBoardSubscribeMember(Member member, Board board) { | ||
if(boardSubscribeMemberRepository.existsByMemberIdAndBoardId(member.getId(), board.getId())) { | ||
return; | ||
} | ||
boardSubscribeMemberRepository.save(BoardSubscribeMember.builder().member(member).board(board).build()); | ||
} | ||
|
||
@Override | ||
public List<Member> findBoardSubscribeMembers(Long boardId) { | ||
return boardSubscribeMemberRepository.findBoardSubscribeMembersByBoardId(boardId).stream().map(BoardSubscribeMember::getMember).toList(); | ||
} | ||
|
||
@Override | ||
public void deleteBoardSubscribeMemberByBoardId(Long boardId) { | ||
boardSubscribeMemberRepository.deleteBoardSubscribeMemberByBoardId(boardId); | ||
} | ||
} |