Skip to content

Commit

Permalink
Merge pull request #38 from 9oormthon-univ/dev
Browse files Browse the repository at this point in the history
token fix
  • Loading branch information
sumin220 authored Nov 23, 2024
2 parents 5e1fa4f + 37d32c9 commit 8aa4c8b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import univ.yesummit.domain.board.api.dto.response.BoardInfoResDto;
import univ.yesummit.domain.board.application.BoardService;
import univ.yesummit.domain.board.domain.Board;
import univ.yesummit.domain.board.domain.BoardPicture;
import univ.yesummit.global.resolver.LoginUser;
import univ.yesummit.global.resolver.User;

Expand All @@ -36,7 +37,6 @@ public BoardController(BoardService boardService) {
@PostMapping(value= "/summit/{summitId}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<String> boardSave(@User LoginUser loginUser,
@RequestBody BoardSaveReqDto boardSaveReqDto) {

Long boardId = boardService.boardSave(loginUser.getMemberId(), boardSaveReqDto);
String message = String.format("%d번 게시글 등록!", boardId);
return new ResponseEntity<>(message, HttpStatus.CREATED);
Expand Down Expand Up @@ -65,7 +65,6 @@ public ResponseEntity<BoardInfoResDto> boardInfo(@PathVariable(name = "boardId")
return new ResponseEntity<>(boardInfo, HttpStatus.OK);
}


@Operation(summary = "내가 작성한 PT 영상 게시글 조회", description = "특정 사용자가 작성한 PT 영상 게시글을 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package univ.yesummit.domain.board.api.dto.request;

import univ.yesummit.domain.board.domain.Board;
import univ.yesummit.domain.board.domain.BoardPicture;
import univ.yesummit.domain.member.entity.Member;

import java.util.List;
Expand All @@ -12,13 +13,26 @@ public record BoardSaveReqDto(
String serviceUrl,
String PTUrl
) {
public BoardSaveReqDto {
if (imageUrl == null) {
throw new IllegalArgumentException("이미지 URL null");
}
}
public Board toEntity(Member member) {
List<BoardPicture> boardPictures = imageUrl.stream()
.map(url -> BoardPicture.builder()
.imageUrl(url)
.build())
.toList();

return Board.builder()
.title(title)
.content(content)
.pictures(boardPictures)
.writer(member)
.serviceUrl(serviceUrl)
.PTUrl(PTUrl)
.build();
}

}
5 changes: 2 additions & 3 deletions src/main/java/univ/yesummit/domain/board/domain/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public class Board {
@Schema(description = "피칭 게시글 id", example = "1")
private Long boardId;

// 게시글 써밋 아이디 필드 만들기 (숫자만 저장하는 컬럼)

@Schema(description = "피칭 제목", example = "제목")
@NotNull(message = "필수 입력 항목입니다.")
private String title;
Expand Down Expand Up @@ -72,9 +70,10 @@ public class Board {
private List<Comment> comments = new ArrayList<>();

@Builder
private Board(String title, String content, String serviceUrl, String PTUrl, Member writer,Long isSummit) {
private Board(String title, String content, String serviceUrl, String PTUrl, Member writer,Long isSummit, List<BoardPicture> pictures) {
this.title = title;
this.content = content;
this.pictures = pictures;
this.serviceUrl = serviceUrl;
this.PTUrl = PTUrl;
this.boardDate = String.valueOf(LocalDateTime.now(ZoneId.of("Asia/Seoul")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import univ.yesummit.domain.feed.entity.Feed;

@Entity
@Getter
Expand All @@ -27,10 +28,15 @@ public class BoardPicture {
@JoinColumn(name = "board_id")
private Board board;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "feed_id")
private Feed feed;

@Builder
private BoardPicture(String imageUrl, Board board) {
private BoardPicture(String imageUrl, Board board, Feed feed) {
this.imageUrl = imageUrl;
this.board = board;
this.feed = feed;
}

}

0 comments on commit 8aa4c8b

Please sign in to comment.