From 8b1af7778249e285322ab2ebef2f4d3d8fdc6878 Mon Sep 17 00:00:00 2001 From: xhaktmchl Date: Sun, 9 Oct 2022 21:40:27 +0900 Subject: [PATCH] =?UTF-8?q?#9=20feat:=20Board=EC=83=9D=EC=84=B1=EC=A4=91?= =?UTF-8?q?=20=ED=98=B8=EC=8A=A4=ED=8A=B8BoardUser=EC=97=90=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=98=EB=8A=94=20api=20=EA=B5=AC=ED=98=84=20/=20fi?= =?UTF-8?q?x:=20=EB=AA=A8=EB=93=A0=20=EC=97=94=ED=8B=B0=ED=8B=B0=20Generat?= =?UTF-8?q?edValue=EC=98=B5=EC=85=98=20Identity=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/yogit/server/board/entity/Board.java | 7 ++++--- .../java/com/yogit/server/board/entity/BoardImage.java | 2 +- .../main/java/com/yogit/server/board/entity/BoardUser.java | 4 ++-- .../main/java/com/yogit/server/board/entity/BookMark.java | 2 +- .../main/java/com/yogit/server/board/entity/Category.java | 2 +- .../main/java/com/yogit/server/board/entity/ClipBoard.java | 2 +- .../main/java/com/yogit/server/board/entity/Comment.java | 2 +- .../com/yogit/server/board/service/BoardServiceImpl.java | 2 +- .../src/main/java/com/yogit/server/user/entity/City.java | 2 +- .../java/com/yogit/server/user/entity/CountryCode.java | 2 +- .../main/java/com/yogit/server/user/entity/Interest.java | 2 +- .../main/java/com/yogit/server/user/entity/Language.java | 2 +- .../src/main/java/com/yogit/server/user/entity/User.java | 2 +- .../main/java/com/yogit/server/user/entity/UserImage.java | 2 +- .../java/com/yogit/server/user/entity/UserInterest.java | 2 +- 15 files changed, 19 insertions(+), 18 deletions(-) diff --git a/server/src/main/java/com/yogit/server/board/entity/Board.java b/server/src/main/java/com/yogit/server/board/entity/Board.java index 927510e..df5385a 100644 --- a/server/src/main/java/com/yogit/server/board/entity/Board.java +++ b/server/src/main/java/com/yogit/server/board/entity/Board.java @@ -10,6 +10,7 @@ import javax.persistence.*; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; @Entity @@ -17,7 +18,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Board { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "board_id") private Long id; @@ -49,8 +50,8 @@ public class Board { private int totalMember; - @OneToMany(mappedBy = "board") - private List boardUsers; + @OneToMany(mappedBy = "board", cascade = CascadeType.ALL) // 보드 생성 순간 보드 유저 리스트 생성 + private List boardUsers = new ArrayList<>(); @OneToMany(mappedBy = "board") private List boardImages; diff --git a/server/src/main/java/com/yogit/server/board/entity/BoardImage.java b/server/src/main/java/com/yogit/server/board/entity/BoardImage.java index 58299b3..559c04a 100644 --- a/server/src/main/java/com/yogit/server/board/entity/BoardImage.java +++ b/server/src/main/java/com/yogit/server/board/entity/BoardImage.java @@ -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; diff --git a/server/src/main/java/com/yogit/server/board/entity/BoardUser.java b/server/src/main/java/com/yogit/server/board/entity/BoardUser.java index f460fc2..6d00bfa 100644 --- a/server/src/main/java/com/yogit/server/board/entity/BoardUser.java +++ b/server/src/main/java/com/yogit/server/board/entity/BoardUser.java @@ -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; @@ -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); } } diff --git a/server/src/main/java/com/yogit/server/board/entity/BookMark.java b/server/src/main/java/com/yogit/server/board/entity/BookMark.java index 56665ab..1f668fb 100644 --- a/server/src/main/java/com/yogit/server/board/entity/BookMark.java +++ b/server/src/main/java/com/yogit/server/board/entity/BookMark.java @@ -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; diff --git a/server/src/main/java/com/yogit/server/board/entity/Category.java b/server/src/main/java/com/yogit/server/board/entity/Category.java index 5f4a907..6ae09b7 100644 --- a/server/src/main/java/com/yogit/server/board/entity/Category.java +++ b/server/src/main/java/com/yogit/server/board/entity/Category.java @@ -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; diff --git a/server/src/main/java/com/yogit/server/board/entity/ClipBoard.java b/server/src/main/java/com/yogit/server/board/entity/ClipBoard.java index 43d6af9..7a5804c 100644 --- a/server/src/main/java/com/yogit/server/board/entity/ClipBoard.java +++ b/server/src/main/java/com/yogit/server/board/entity/ClipBoard.java @@ -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; diff --git a/server/src/main/java/com/yogit/server/board/entity/Comment.java b/server/src/main/java/com/yogit/server/board/entity/Comment.java index 438fcee..9d21fd0 100644 --- a/server/src/main/java/com/yogit/server/board/entity/Comment.java +++ b/server/src/main/java/com/yogit/server/board/entity/Comment.java @@ -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; diff --git a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java index 0df86a7..7f86229 100644 --- a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java +++ b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java @@ -48,7 +48,7 @@ public ApplicationResponse 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); diff --git a/server/src/main/java/com/yogit/server/user/entity/City.java b/server/src/main/java/com/yogit/server/user/entity/City.java index 3d6e639..9bd1392 100644 --- a/server/src/main/java/com/yogit/server/user/entity/City.java +++ b/server/src/main/java/com/yogit/server/user/entity/City.java @@ -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; diff --git a/server/src/main/java/com/yogit/server/user/entity/CountryCode.java b/server/src/main/java/com/yogit/server/user/entity/CountryCode.java index 22841b7..8bcc6e5 100644 --- a/server/src/main/java/com/yogit/server/user/entity/CountryCode.java +++ b/server/src/main/java/com/yogit/server/user/entity/CountryCode.java @@ -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; diff --git a/server/src/main/java/com/yogit/server/user/entity/Interest.java b/server/src/main/java/com/yogit/server/user/entity/Interest.java index d4d87bb..d26de6f 100644 --- a/server/src/main/java/com/yogit/server/user/entity/Interest.java +++ b/server/src/main/java/com/yogit/server/user/entity/Interest.java @@ -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; diff --git a/server/src/main/java/com/yogit/server/user/entity/Language.java b/server/src/main/java/com/yogit/server/user/entity/Language.java index 181f898..76a0b43 100644 --- a/server/src/main/java/com/yogit/server/user/entity/Language.java +++ b/server/src/main/java/com/yogit/server/user/entity/Language.java @@ -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; diff --git a/server/src/main/java/com/yogit/server/user/entity/User.java b/server/src/main/java/com/yogit/server/user/entity/User.java index ff77823..75308bd 100644 --- a/server/src/main/java/com/yogit/server/user/entity/User.java +++ b/server/src/main/java/com/yogit/server/user/entity/User.java @@ -15,7 +15,7 @@ public class User { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "user_id") private Long id; diff --git a/server/src/main/java/com/yogit/server/user/entity/UserImage.java b/server/src/main/java/com/yogit/server/user/entity/UserImage.java index 76341ca..a3a43f9 100644 --- a/server/src/main/java/com/yogit/server/user/entity/UserImage.java +++ b/server/src/main/java/com/yogit/server/user/entity/UserImage.java @@ -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; diff --git a/server/src/main/java/com/yogit/server/user/entity/UserInterest.java b/server/src/main/java/com/yogit/server/user/entity/UserInterest.java index 1ffeede..0ca5cdb 100644 --- a/server/src/main/java/com/yogit/server/user/entity/UserInterest.java +++ b/server/src/main/java/com/yogit/server/user/entity/UserInterest.java @@ -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;