-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: UserProfile Entity를 추가한다. (#17)
* feat: UserProfile Entity를 추가한다. * chore: 누락된 @Enumerated를 추가한다.
- Loading branch information
Showing
6 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/main/java/com/dnd/accompany/domain/user/entity/UserProfile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.dnd.accompany.domain.user.entity; | ||
|
||
import com.dnd.accompany.domain.user.entity.enums.FoodPreference; | ||
import com.dnd.accompany.domain.user.entity.enums.Gender; | ||
import com.dnd.accompany.domain.user.entity.enums.TravelPreference; | ||
import com.dnd.accompany.domain.user.entity.enums.TravelStyle; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import org.hibernate.annotations.SQLDelete; | ||
import org.hibernate.annotations.SQLRestriction; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Table(name = "user_profiles") | ||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@SQLRestriction("deleted = false") | ||
@SQLDelete(sql = "UPDATE user_profiles SET deleted = true WHERE id = ?") | ||
public class UserProfile { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private Long userId; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private Gender gender; | ||
|
||
private int birthYear; | ||
|
||
@ElementCollection(targetClass = TravelPreference.class) | ||
@Enumerated(EnumType.STRING) | ||
private List<TravelPreference> travelPreferences = new ArrayList<>(); | ||
|
||
@ElementCollection(targetClass = TravelStyle.class) | ||
@Enumerated(EnumType.STRING) | ||
private List<TravelStyle> travelStyles = new ArrayList<>(); | ||
|
||
@ElementCollection(targetClass = FoodPreference.class) | ||
private List<FoodPreference> foodPreferences = new ArrayList<>(); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/dnd/accompany/domain/user/entity/enums/FoodPreference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.dnd.accompany.domain.user.entity.enums; | ||
|
||
public enum FoodPreference { | ||
MEAT("육류"), | ||
SEAFOOD("해산물"), | ||
|
||
RICE("밥류"), | ||
VEGETABLES("채소"), | ||
|
||
COFFEE("커피"), | ||
DESSERT("디저트"), | ||
|
||
FAST_FOOD("패스트푸드"), | ||
STREET_FOOD("스트릿푸드"); | ||
|
||
private String description; | ||
|
||
FoodPreference(String description) { | ||
this.description = description; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/dnd/accompany/domain/user/entity/enums/Gender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.dnd.accompany.domain.user.entity.enums; | ||
|
||
public enum Gender { | ||
MALE, FEMALE | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/dnd/accompany/domain/user/entity/enums/TravelPreference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.dnd.accompany.domain.user.entity.enums; | ||
|
||
public enum TravelPreference { | ||
PLANNED("계획적"), | ||
UNPLANNED("무계획"), | ||
|
||
PUBLIC_MONEY("공금"), | ||
DUTCH_PAY("더치페이"), | ||
|
||
LOOKING_FOR("찾아본 곳"), | ||
DRAWN_TO("끌리는 곳"), | ||
|
||
QUICKLY("빨리빨리"), | ||
LEISURELY("느긋하게"); | ||
|
||
private String description; | ||
|
||
TravelPreference(String description) { | ||
this.description = description; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/dnd/accompany/domain/user/entity/enums/TravelStyle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.dnd.accompany.domain.user.entity.enums; | ||
|
||
public enum TravelStyle { | ||
RESTAURANT_TOUR("맛집탐방"), | ||
CAFE_TOUR("카페투어"), | ||
|
||
LIFE_SHOT("인생샷"), | ||
TOURIST_DESTINATION("관광지"), | ||
|
||
ACTIVITY("액티비티"), | ||
HEALING("힐링"), | ||
|
||
DRIVE("드라이브"), | ||
PACKAGE_TOUR("패키지 여행"), | ||
|
||
SHOPPING("쇼핑"), | ||
CULTURE_AND_ARTS("문화 예술"); | ||
|
||
private String description; | ||
|
||
TravelStyle(String description) { | ||
this.description = description; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/dnd/accompany/domain/user/infrastructure/UserProfileRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.dnd.accompany.domain.user.infrastructure; | ||
|
||
import com.dnd.accompany.domain.user.entity.UserProfile; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface UserProfileRepository extends JpaRepository<UserProfile, Long> { | ||
} |