Skip to content

Commit

Permalink
feat: UserProfile Entity를 추가한다. (#17)
Browse files Browse the repository at this point in the history
* feat: UserProfile Entity를 추가한다.

* chore: 누락된 @Enumerated를 추가한다.
  • Loading branch information
rlarltj authored Aug 4, 2024
1 parent dc618ca commit d2c7ef8
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 0 deletions.
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<>();
}
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;
}
}
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
}
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;
}
}
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;
}
}
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> {
}

0 comments on commit d2c7ef8

Please sign in to comment.