From 27b714831bb62bbf64211d6120bc7b624bf18089 Mon Sep 17 00:00:00 2001 From: jschoi-96 Date: Wed, 11 Dec 2024 02:07:46 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=EC=9E=84=EC=8B=9C=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=ED=95=9C=20=EA=B2=8C=EC=9E=84=20=EC=98=B5=EC=85=98?= =?UTF-8?q?=EB=B3=B4=EB=8B=A4=20=EC=83=88=EB=A1=9C=20=EC=A0=80=EC=9E=A5?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EC=98=B5=EC=85=98=20=EC=88=98=EA=B0=80=20?= =?UTF-8?q?=EB=A7=8E=EC=9D=80=EA=B2=BD=EC=9A=B0=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../balancetalk/game/domain/TempGame.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/balancetalk/game/domain/TempGame.java b/src/main/java/balancetalk/game/domain/TempGame.java index 0ac78bfb6..a5314c877 100644 --- a/src/main/java/balancetalk/game/domain/TempGame.java +++ b/src/main/java/balancetalk/game/domain/TempGame.java @@ -39,7 +39,6 @@ public class TempGame extends BaseTimeEntity { @OneToMany(mappedBy = "tempGame", cascade = CascadeType.ALL) private List tempGameOptions = new ArrayList<>(); - @NotBlank @Size(max = 100) private String description; @@ -47,16 +46,22 @@ public void assignTempGameSet(TempGameSet tempGameSet) { this.tempGameSet = tempGameSet; } + public void addTempGameOption(TempGameOption tempGameOption) { + tempGameOption.assignTempGame(this); + tempGameOptions.add(tempGameOption); + } + public void updateTempGame(TempGame newTempGame) { this.description = newTempGame.getDescription(); IntStream.range(0, newTempGame.getTempGameOptions().size()).forEach(i -> { - TempGameOption currentOption = this.tempGameOptions.get(i); - TempGameOption newOption = newTempGame.getTempGameOptions().get(i); - currentOption.updateTempGameOption(newOption); + if (i < this.tempGameOptions.size()) { + TempGameOption currentOption = this.tempGameOptions.get(i); + TempGameOption newOption = newTempGame.getTempGameOptions().get(i); + currentOption.updateTempGameOption(newOption); + } else { + TempGameOption newOption = newTempGame.getTempGameOptions().get(i); + this.addTempGameOption(newOption); + } }); } - - public List getGameOptionIds() { - return tempGameOptions.stream().map(TempGameOption::getId).toList(); - } } From d32176492c9dd143a282416f30bbe622027b1a95 Mon Sep 17 00:00:00 2001 From: jschoi-96 Date: Wed, 11 Dec 2024 02:08:20 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=EC=97=94=ED=8B=B0=ED=8B=B0=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=A0=9C=EC=95=BD=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/balancetalk/game/domain/TempGameOption.java | 2 -- src/main/java/balancetalk/game/domain/TempGameSet.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/main/java/balancetalk/game/domain/TempGameOption.java b/src/main/java/balancetalk/game/domain/TempGameOption.java index fdd74ada3..2e32a69e4 100644 --- a/src/main/java/balancetalk/game/domain/TempGameOption.java +++ b/src/main/java/balancetalk/game/domain/TempGameOption.java @@ -11,7 +11,6 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; -import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -31,7 +30,6 @@ public class TempGameOption { @Column(name = "id") private Long id; - @NotBlank @Size(max = 30) private String name; diff --git a/src/main/java/balancetalk/game/domain/TempGameSet.java b/src/main/java/balancetalk/game/domain/TempGameSet.java index 7afac867e..91f9bf79f 100644 --- a/src/main/java/balancetalk/game/domain/TempGameSet.java +++ b/src/main/java/balancetalk/game/domain/TempGameSet.java @@ -12,7 +12,6 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.OneToMany; import jakarta.persistence.OneToOne; -import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; import java.util.ArrayList; import java.util.List; @@ -39,7 +38,6 @@ public class TempGameSet extends BaseTimeEntity { @OneToMany(mappedBy = "tempGameSet", cascade = CascadeType.ALL) private List tempGames = new ArrayList<>(); - @NotBlank @Size(max = 50) private String title; From db4ab3038944714fd8190ddc6e75565625caaad6 Mon Sep 17 00:00:00 2001 From: jschoi-96 Date: Wed, 11 Dec 2024 02:09:00 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=EA=B2=8C=EC=9E=84=EC=9D=B4=2010?= =?UTF-8?q?=EA=B0=9C=EA=B0=80=20=EC=95=88=EB=90=A0=20=EB=95=8C=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EB=B0=A9=EC=A7=80=ED=95=98=EB=8A=94=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=EC=B2=98=EB=A6=AC=EB=AC=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/balancetalk/game/dto/TempGameSetDto.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/balancetalk/game/dto/TempGameSetDto.java b/src/main/java/balancetalk/game/dto/TempGameSetDto.java index abc99c007..276912a62 100644 --- a/src/main/java/balancetalk/game/dto/TempGameSetDto.java +++ b/src/main/java/balancetalk/game/dto/TempGameSetDto.java @@ -3,8 +3,6 @@ import balancetalk.game.domain.TempGameSet; import balancetalk.game.dto.TempGameDto.CreateTempGameRequest; import balancetalk.game.dto.TempGameDto.TempGameResponse; -import balancetalk.global.exception.BalanceTalkException; -import balancetalk.global.exception.ErrorCode; import balancetalk.member.domain.Member; import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.v3.oas.annotations.media.Schema; @@ -17,9 +15,7 @@ import lombok.Data; public class TempGameSetDto { - - private static final int GAME_SIZE = 10; - + @Data public static class CreateTempGameSetRequest { @@ -34,9 +30,6 @@ public static class CreateTempGameSetRequest { private List tempGames; public TempGameSet toEntity(Member member) { - if (tempGames == null || tempGames.size() < GAME_SIZE) { - throw new BalanceTalkException(ErrorCode.BALANCE_GAME_SIZE_TEN); - } return TempGameSet.builder() .title(title) .member(member) From e2fe7f0fd96d588404f7dfe08d7d26d84868a095 Mon Sep 17 00:00:00 2001 From: jschoi-96 Date: Wed, 11 Dec 2024 02:09:54 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=EC=9E=84=EC=8B=9C=20=EA=B2=8C?= =?UTF-8?q?=EC=9E=84=20=EC=A0=80=EC=9E=A5=20=EC=8B=9C=20=EA=B2=8C=EC=9E=84?= =?UTF-8?q?=20=EB=82=B4=EC=9A=A9=EC=9D=B4=20=EC=97=86=EB=8A=94=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=ED=8C=8C=EC=9D=BC=20=EC=9E=AC=EB=B0=B0=EC=B9=98?= =?UTF-8?q?=EB=A5=BC=20=EC=88=98=ED=96=89=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/balancetalk/game/application/TempGameService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/balancetalk/game/application/TempGameService.java b/src/main/java/balancetalk/game/application/TempGameService.java index 1cd5f3963..1532dc74a 100644 --- a/src/main/java/balancetalk/game/application/TempGameService.java +++ b/src/main/java/balancetalk/game/application/TempGameService.java @@ -43,6 +43,12 @@ public void createTempGame(CreateTempGameSetRequest request, ApiMember apiMember Member member = apiMember.toMember(memberRepository); List tempGames = request.getTempGames(); + + if (request.getTempGames() == null || request.getTempGames().isEmpty()) { + TempGameSet tempGameSet = request.toEntity(member); + tempGameSetRepository.save(tempGameSet); + return; + } validateFileIds(tempGames); // 파일이 DB에 존재하는지 검사 List newTempGames = tempGames.stream()