Skip to content

Commit 51bb0c7

Browse files
authored
[feat] cocktail엔티티, 리포지토리, DTO 추가 #9
* {feat} : domain * {fix}:Cocktail-Wishlist relation * {fix}: add profileImgUrl
1 parent 9bda000 commit 51bb0c7

File tree

7 files changed

+144
-2
lines changed

7 files changed

+144
-2
lines changed

db_dev.mv.db

4 KB
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.back.domain.cocktail.dto;
2+
3+
import com.back.domain.cocktail.entity.Cocktail;
4+
import jakarta.validation.constraints.NotBlank;
5+
import jakarta.validation.constraints.NotNull;
6+
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
8+
import lombok.Setter;
9+
10+
@Getter
11+
@Setter
12+
@NoArgsConstructor
13+
public class CocktailRequestDto {
14+
15+
@NotBlank
16+
private String cocktailName;
17+
18+
@NotNull
19+
private Cocktail.AlcoholStrength alcoholStrength;
20+
21+
private String cocktailStory;
22+
private Cocktail.CocktailType cocktailType;
23+
private String ingredient;
24+
private String recipe;
25+
private String imageUrl;
26+
27+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.back.domain.cocktail.dto;
2+
3+
import com.back.domain.cocktail.entity.Cocktail;
4+
import lombok.Getter;
5+
import lombok.NoArgsConstructor;
6+
import lombok.Setter;
7+
8+
import java.time.LocalDateTime;
9+
10+
@Getter
11+
@Setter
12+
@NoArgsConstructor
13+
public class CocktailResponseDto {
14+
15+
private long cocktailId;
16+
private String cocktailName;
17+
private Cocktail.AlcoholStrength alcoholStrength;
18+
private String cocktailStory;
19+
private Cocktail.CocktailType cocktailType;
20+
private String ingredient;
21+
private String recipe;
22+
private String imageUrl;
23+
private LocalDateTime createdAt;
24+
private LocalDateTime updatedAt;
25+
26+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.back.domain.cocktail.entity;
2+
3+
import jakarta.persistence.*;
4+
import lombok.Getter;
5+
import lombok.NoArgsConstructor;
6+
import lombok.Setter;
7+
8+
import java.time.LocalDateTime;
9+
10+
import static jakarta.persistence.GenerationType.IDENTITY;
11+
12+
13+
@Getter
14+
@Setter
15+
@NoArgsConstructor
16+
@Entity
17+
public class Cocktail {
18+
@Id
19+
@GeneratedValue(strategy = IDENTITY)
20+
private long cocktailId;
21+
22+
private String cocktailName;
23+
24+
@Enumerated(EnumType.STRING)
25+
private AlcoholStrength alcoholStrength; // 칵테일 알콜 도수
26+
27+
public enum AlcoholStrength {
28+
NON_ALCOHOLIC("논알콜 (0%)"),
29+
WEAK("약한 도수 (1~5%)"),
30+
LIGHT("가벼운 도수 (6~15%)"),
31+
MEDIUM("중간 도수 (16~25%)"),
32+
STRONG("센 도수 (26~35%)"),
33+
VERY_STRONG("매우 센 도수 (36%~)");
34+
35+
private final String description;
36+
37+
AlcoholStrength(String description) {
38+
this.description = description;
39+
}
40+
41+
public String getDescription() {
42+
return description;
43+
}
44+
}
45+
46+
private String cocktailStory; // 칵테일 유래 등 이야기
47+
48+
@Enumerated(EnumType.STRING)
49+
private CocktailType cocktailType; // 칵테일 컵에 따른 분류
50+
51+
public enum CocktailType {
52+
SHORT("숏"),
53+
LONG("롱"),
54+
SHOOTER("슈터"),
55+
CLASSIC("클래식");
56+
57+
private final String description;
58+
59+
CocktailType(String description) {
60+
this.description = description;
61+
}
62+
63+
public String getDescription() {
64+
return description;
65+
}
66+
}
67+
68+
private String ingredient;
69+
70+
private String recipe;
71+
72+
private String imageUrl;
73+
74+
private LocalDateTime createdAt;
75+
76+
private LocalDateTime updatedAt;
77+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.back.domain.cocktail.repository;
2+
3+
import com.back.domain.cocktail.entity.Cocktail;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.stereotype.Repository;
6+
7+
@Repository
8+
public interface CocktailRepository extends JpaRepository<Cocktail, Long> {
9+
}

src/main/java/com/back/domain/user/entity/User.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ public class User {
3535
@Builder.Default
3636
@Column(nullable = false, length = 20)
3737
private String role = "USER";
38+
39+
private String profileImgUrl;
3840
}

src/main/java/com/back/domain/wishlist/entity/Wishlist.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.back.domain.wishlist.entity;
22

3+
import com.back.domain.cocktail.entity.Cocktail;
34
import com.back.domain.user.entity.User;
45
import com.back.domain.wishlist.enums.WishlistStatus;
56
import jakarta.persistence.*;
@@ -25,8 +26,8 @@ public class Wishlist {
2526
private User user; // 찜한 사용자 (위시리스트의 주인)
2627

2728
// TODO: Cocktail 도메인 추가 후 활성화
28-
// @ManyToOne
29-
// private Cocktail cocktail;
29+
@ManyToOne
30+
private Cocktail cocktail;
3031

3132
@Enumerated(EnumType.STRING)
3233
@Column(nullable = false)

0 commit comments

Comments
 (0)