Skip to content

Commit

Permalink
#9 feat: Board생성중 호스트BoardUser에 추가하는 api 구현 / fix: 모든 엔티티 GeneratedVa…
Browse files Browse the repository at this point in the history
…lue옵션 Identity로 수정
  • Loading branch information
xhaktmchl committed Oct 9, 2022
1 parent 5560d1c commit 8b1af77
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 18 deletions.
7 changes: 4 additions & 3 deletions server/src/main/java/com/yogit/server/board/entity/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Board {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "board_id")
private Long id;

Expand Down Expand Up @@ -49,8 +50,8 @@ public class Board {

private int totalMember;

@OneToMany(mappedBy = "board")
private List<BoardUser> boardUsers;
@OneToMany(mappedBy = "board", cascade = CascadeType.ALL) // 보드 생성 순간 보드 유저 리스트 생성
private List<BoardUser> boardUsers = new ArrayList<>();

@OneToMany(mappedBy = "board")
private List<BoardImage> boardImages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class BoardImage {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "board_image_id")
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class BoardUser {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "board_user_id")
private Long id;

Expand All @@ -31,6 +31,6 @@ public class BoardUser {
public BoardUser(User user, Board board) {
this.user = user;
this.board = board;
board.addBoardUser(this);
// board.addBoardUser(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class BookMark {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "book_mark_id")
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Category {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "category_id")
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ClipBoard {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "clip_board_id")
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Comment {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "comment_id")
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ApplicationResponse<BoardRes> createBoard(CreateBoardReq dto){
board.changeBoardCurrentMember(0);// currentMember 디폴트=0

// 호스트 boardUser 생성 및 board에 추가
// board.addBoardUser(new BoardUser(host, board));
board.addBoardUser(new BoardUser(host, board));

// board 저장
Board savedBoard = boardRepository.save(board);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class City {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "city_id")
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class CountryCode {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "country_code_id")
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Interest {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "interest_id")
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Language {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "language_id")
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class User {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class UserImage {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_image_id")
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class UserInterest {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_interest_id")
private Long id;

Expand Down

0 comments on commit 8b1af77

Please sign in to comment.