-
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 #20 from IT-Cotato/feature/16-university-board
[FEAT] university board 기능 구현
- Loading branch information
Showing
20 changed files
with
197 additions
and
36 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
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
36 changes: 36 additions & 0 deletions
36
src/main/java/com/cotato/kampus/domain/board/application/UniversityBoardReader.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,36 @@ | ||
package com.cotato.kampus.domain.board.application; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.cotato.kampus.domain.board.dao.UniversityBoardRepository; | ||
import com.cotato.kampus.domain.board.domain.UniversityBoard; | ||
import com.cotato.kampus.domain.board.dto.BoardDto; | ||
import com.cotato.kampus.domain.common.application.ApiUserResolver; | ||
import com.cotato.kampus.domain.user.domain.User; | ||
import com.cotato.kampus.global.error.ErrorCode; | ||
import com.cotato.kampus.global.error.exception.AppException; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class UniversityBoardReader { | ||
private final UniversityBoardRepository universityBoardRepository; | ||
private final ApiUserResolver apiUserResolver; | ||
|
||
public BoardDto read(){ | ||
User user = apiUserResolver.getUser(); | ||
|
||
Long universityId = user.getUniversityId(); | ||
|
||
UniversityBoard universityBoard = universityBoardRepository.findByUniversityId(universityId) | ||
.orElseThrow(() -> new AppException(ErrorCode.UNIVERSITY_NOT_FOUND)); | ||
|
||
return BoardDto.of( | ||
universityBoard.getId(), | ||
universityBoard.getBoardName()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/cotato/kampus/domain/board/dao/UniversityBoardRepository.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,11 @@ | ||
package com.cotato.kampus.domain.board.dao; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.cotato.kampus.domain.board.domain.UniversityBoard; | ||
|
||
public interface UniversityBoardRepository extends JpaRepository<UniversityBoard, Long> { | ||
Optional<UniversityBoard> findByUniversityId(Long universityId); | ||
} |
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
21 changes: 21 additions & 0 deletions
21
src/main/java/com/cotato/kampus/domain/board/domain/UniversityBoard.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,21 @@ | ||
package com.cotato.kampus.domain.board.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class UniversityBoard extends Board { | ||
|
||
@Column(name = "university_id", nullable = false) | ||
private Long universityId; | ||
|
||
public UniversityBoard(Long universityId, String boardName) { | ||
super(boardName); | ||
this.universityId = universityId; | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/cotato/kampus/domain/board/dto/BoardWithFavoriteStatusDto.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,11 @@ | ||
package com.cotato.kampus.domain.board.dto; | ||
|
||
public record BoardWithFavoriteStatusDto( | ||
Long boardId, | ||
String boardName, | ||
boolean isFavorite | ||
){ | ||
public static BoardWithFavoriteStatusDto of(Long boardId, String boardName, boolean isFavorite) { | ||
return new BoardWithFavoriteStatusDto(boardId, boardName, isFavorite); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/cotato/kampus/domain/board/dto/response/BoardListResponse.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.cotato.kampus.domain.board.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import com.cotato.kampus.domain.board.dto.BoardWithFavoriteStatusDto; | ||
|
||
public record BoardListResponse( | ||
List<BoardWithFavoriteStatusDto> boards | ||
) { | ||
public static BoardListResponse of(List<BoardWithFavoriteStatusDto> boards){ | ||
return new BoardListResponse(boards); | ||
} | ||
} |
8 changes: 3 additions & 5 deletions
8
src/main/java/com/cotato/kampus/domain/board/dto/response/BoardResponse.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,13 +1,11 @@ | ||
package com.cotato.kampus.domain.board.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import com.cotato.kampus.domain.board.dto.BoardDto; | ||
|
||
public record BoardResponse( | ||
List<BoardDto> boards | ||
BoardDto boardDto | ||
) { | ||
public static BoardResponse of(List<BoardDto> boards){ | ||
return new BoardResponse(boards); | ||
public static BoardResponse of(BoardDto boardDto) { | ||
return new BoardResponse(boardDto); | ||
} | ||
} |
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.