diff --git a/build.gradle b/build.gradle index 9333dde6..79c0cee8 100644 --- a/build.gradle +++ b/build.gradle @@ -57,7 +57,6 @@ dependencies { } // Querydsl 설정 추가 - def querydslDir = "$buildDir/generated/querydsl" querydsl { jpa = true diff --git a/src/main/java/co/kr/jurumarble/vote/dto/request/CreateDrinkVoteRequest.java b/src/main/java/co/kr/jurumarble/vote/dto/request/CreateDrinkVoteRequest.java index abd60207..0e432c42 100644 --- a/src/main/java/co/kr/jurumarble/vote/dto/request/CreateDrinkVoteRequest.java +++ b/src/main/java/co/kr/jurumarble/vote/dto/request/CreateDrinkVoteRequest.java @@ -26,12 +26,17 @@ public class CreateDrinkVoteRequest { @Positive(message = "전통주 아이디는 양수값의 정수여야합니다.") private Long drinkBId; + @Schema(description = "전통주 투표 상세 내용") + @NotBlank(message = "전통주 투표 내용은 필수 입니다.") + private String detail; + public CreateDrinkVoteServiceRequest toServiceRequest() { return CreateDrinkVoteServiceRequest.builder() .title(title) .drinkAId(drinkAId) .drinkBId(drinkBId) .voteType(VoteType.DRINK) + .detail(detail) .build(); } } diff --git a/src/main/java/co/kr/jurumarble/vote/service/request/CreateDrinkVoteServiceRequest.java b/src/main/java/co/kr/jurumarble/vote/service/request/CreateDrinkVoteServiceRequest.java index 0b3284f4..dec0806e 100644 --- a/src/main/java/co/kr/jurumarble/vote/service/request/CreateDrinkVoteServiceRequest.java +++ b/src/main/java/co/kr/jurumarble/vote/service/request/CreateDrinkVoteServiceRequest.java @@ -14,15 +14,17 @@ public class CreateDrinkVoteServiceRequest { private final Long voteId; private final Long drinkAId; private final Long drinkBId; + private final String detail; @Builder - public CreateDrinkVoteServiceRequest(String title, VoteType voteType, Long voteId, Long drinkAId, Long drinkBId) { + public CreateDrinkVoteServiceRequest(String title, VoteType voteType, Long voteId, Long drinkAId, Long drinkBId, String detail) { validVoteType(voteType); this.title = title; this.voteType = voteType; this.voteId = voteId; this.drinkAId = drinkAId; this.drinkBId = drinkBId; + this.detail = detail; } private void validVoteType(VoteType voteType) { @@ -40,6 +42,7 @@ public Vote toVote(Long userId) { .postedUserId(userId) .voteType(voteType) .title(title) + .detail(detail) .build(); } diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 08518bfe..4ab26618 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -103,11 +103,11 @@ CREATE TABLE drink CREATE TABLE bookmark ( - id BIGINT NOT NULL AUTO_INCREMENT, - user_id BIGINT NOT NULL, - vote_id BIGINT NOT NULL, - created_date TIMESTAMP DEFAULT NULL, - modified_date TIMESTAMP DEFAULT NULL, + id BIGINT NOT NULL AUTO_INCREMENT, + user_id BIGINT NOT NULL, + vote_id BIGINT NOT NULL, + created_date TIMESTAMP DEFAULT NULL, + modified_date TIMESTAMP DEFAULT NULL, PRIMARY KEY (id) ); @@ -128,6 +128,9 @@ CREATE TABLE comment vote_id BIGINT DEFAULT NULL, drink_id BIGINT DEFAULT NULL, content VARCHAR(255) NOT NULL, + age VARCHAR(255) DEFAULT NULL, + mbti VARCHAR(4) DEFAULT NULL, + gender VARCHAR(6) DEFAULT NULL, like_count INTEGER DEFAULT NULL, hate_count INTEGER DEFAULT NULL, parent_id BIGINT DEFAULT NULL, diff --git a/src/test/java/co/kr/jurumarble/drink/domain/EnjoyDrinkValidatorTest.java b/src/test/java/co/kr/jurumarble/drink/domain/EnjoyDrinkValidatorTest.java deleted file mode 100644 index d25c8a41..00000000 --- a/src/test/java/co/kr/jurumarble/drink/domain/EnjoyDrinkValidatorTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package co.kr.jurumarble.drink.domain; - -import co.kr.jurumarble.drink.domain.entity.EnjoyDrink; -import co.kr.jurumarble.drink.repository.EnjoyDrinkRepository; -import co.kr.jurumarble.exception.drink.AlreadyEnjoyedDrinkException; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.when; - -@ExtendWith(MockitoExtension.class) -class EnjoyDrinkValidatorTest { - - @InjectMocks - private EnjoyDrinkValidator enjoyDrinkValidator; - - @Mock - private EnjoyDrinkRepository enjoyDrinkRepository; - - @DisplayName("이미 즐긴 전통주 일 때 AlreadyEnjoyedDrinkException을 throw한다.") - @Test - void checkIsAlreadyEnjoyed() { - // given - when(enjoyDrinkRepository.findByUserIdAndDrinkId(anyLong(), anyLong())) - .thenReturn(Optional.of(new EnjoyDrink(anyLong(), anyLong()))); - - // when // then - assertThrows(AlreadyEnjoyedDrinkException.class, - () -> enjoyDrinkValidator.checkIsAlreadyEnjoyed(1L, 1L)); - } - - @DisplayName("아직 즐기지 않은 전통주의 경우 에러를 터트리지 않는다.") - @Test - void checkIsAlreadyEnjoyedWithNotThrowException() { - // given - when(enjoyDrinkRepository.findByUserIdAndDrinkId(anyLong(), anyLong())) - .thenReturn(Optional.empty()); - - // when // then - assertDoesNotThrow(() -> enjoyDrinkValidator.checkIsAlreadyEnjoyed(1L, 1L)); - } - -} \ No newline at end of file