member tag update
This commit is contained in:
parent
e61e98ed7d
commit
1ddcfc3ad3
@ -1,23 +1,48 @@
|
|||||||
package com.ktds.hi.member.domain;
|
package com.ktds.hi.member.domain;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 태그 유형 열거형
|
* 태그 유형 열거형
|
||||||
* 취향 태그의 카테고리를 정의
|
* 취향 태그의 카테고리를 정의
|
||||||
*/
|
*/
|
||||||
public enum TagType {
|
public enum TagType {
|
||||||
CUISINE("음식 종류"),
|
TASTE("맛"),
|
||||||
FLAVOR("맛"),
|
|
||||||
DIETARY("식이 제한"),
|
|
||||||
ATMOSPHERE("분위기"),
|
ATMOSPHERE("분위기"),
|
||||||
PRICE("가격대");
|
ALLERGY("알러지"),
|
||||||
|
SERVICE("서비스"),
|
||||||
|
PRICE_RANGE("가격대"),
|
||||||
|
CUISINE_TYPE("음식 종류"),
|
||||||
|
HEALTH_INFO("건강 정보");
|
||||||
|
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
||||||
TagType(String description) {
|
TagType(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 설명으로 TagType 찾기
|
||||||
|
*/
|
||||||
|
public static TagType fromDescription(String description) {
|
||||||
|
for (TagType type : TagType.values()) {
|
||||||
|
if (type.description.equals(description)) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unknown tag type description: " + description);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 모든 태그 타입 설명 목록 반환
|
||||||
|
*/
|
||||||
|
public static String[] getAllDescriptions() {
|
||||||
|
return Arrays.stream(TagType.values())
|
||||||
|
.map(TagType::getDescription)
|
||||||
|
.toArray(String[]::new);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.ktds.hi.member.repository.entity;
|
||||||
|
|
||||||
|
public enum TagCategory {
|
||||||
|
TASTE("맛"), // 매운맛, 단맛, 짠맛 등
|
||||||
|
ATMOSPHERE("분위기"), // 깨끗한, 혼밥, 데이트 등
|
||||||
|
ALLERGY("알러지"), // 유제품, 견과류, 갑각류 등
|
||||||
|
SERVICE("서비스"), // 빠른서비스, 친절한, 조용한 등
|
||||||
|
PRICE("가격대"), // 저렴한, 합리적인, 가성비 등
|
||||||
|
FOOD_TYPE("음식 종류"), // 한식, 중식, 일식 등
|
||||||
|
HEALTH("건강 정보"); // 저염, 저당, 글루텐프리 등
|
||||||
|
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
TagCategory(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package com.ktds.hi.member.repository.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "tags")
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class TagEntity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "tag_name", nullable = false, length = 50)
|
||||||
|
private String tagName; // 매운맛, 깨끗한, 유제품 등
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
@Column(name = "tag_category", nullable = false)
|
||||||
|
private TagCategory tagCategory; // TASTE, ATMOSPHERE, ALLERGY 등
|
||||||
|
|
||||||
|
@Column(name = "tag_color", length = 7)
|
||||||
|
private String tagColor; // #FF5722
|
||||||
|
|
||||||
|
@Column(name = "sort_order")
|
||||||
|
private Integer sortOrder;
|
||||||
|
|
||||||
|
@Column(name = "is_active")
|
||||||
|
@Builder.Default
|
||||||
|
private Boolean isActive = true;
|
||||||
|
}
|
||||||
@ -11,6 +11,7 @@ import lombok.NoArgsConstructor;
|
|||||||
* 취향 태그 엔티티 클래스
|
* 취향 태그 엔티티 클래스
|
||||||
* 데이터베이스 taste_tags 테이블과 매핑되는 JPA 엔티티
|
* 데이터베이스 taste_tags 테이블과 매핑되는 JPA 엔티티
|
||||||
*/
|
*/
|
||||||
|
// TasteTagEntity.java
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "taste_tags")
|
@Table(name = "taste_tags")
|
||||||
@Getter
|
@Getter
|
||||||
@ -18,22 +19,32 @@ import lombok.NoArgsConstructor;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TasteTagEntity {
|
public class TasteTagEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column(name = "tag_name", unique = true, nullable = false, length = 50)
|
@Column(name = "tag_name", unique = true, nullable = false, length = 50)
|
||||||
private String tagName;
|
private String tagName; // 매운맛, 단맛, 짠맛 등
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Column(name = "tag_color", length = 7)
|
||||||
@Column(name = "tag_type", nullable = false)
|
private String tagColor; // #FF5722
|
||||||
private TagType tagType;
|
|
||||||
|
@Column(name = "sort_order")
|
||||||
@Column(length = 200)
|
private Integer sortOrder;
|
||||||
private String description;
|
|
||||||
|
|
||||||
@Column(name = "is_active")
|
@Column(name = "is_active")
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private Boolean isActive = true;
|
private Boolean isActive = true;
|
||||||
}
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
@Column(name = "tag_type", nullable = false)
|
||||||
|
private TagType tagType;
|
||||||
|
|
||||||
|
@Column(length = 200)
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
@Column(name = "tag_category", nullable = false)
|
||||||
|
private TagCategory tagCategory; // 추가된 필드
|
||||||
|
}
|
||||||
@ -1,31 +1,30 @@
|
|||||||
|
/*
|
||||||
|
*/
|
||||||
package com.ktds.hi.member.repository.jpa;
|
package com.ktds.hi.member.repository.jpa;
|
||||||
|
|
||||||
import com.ktds.hi.member.domain.TagType;
|
import com.ktds.hi.member.domain.TagType;
|
||||||
|
import com.ktds.hi.member.repository.entity.TagCategory;
|
||||||
import com.ktds.hi.member.repository.entity.TasteTagEntity;
|
import com.ktds.hi.member.repository.entity.TasteTagEntity;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
|
||||||
* 취향 태그 JPA 리포지토리 인터페이스
|
|
||||||
* 취향 태그 데이터의 CRUD 작업을 담당
|
|
||||||
*/
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface TasteTagRepository extends JpaRepository<TasteTagEntity, Long> {
|
public interface TasteTagRepository extends JpaRepository<TasteTagEntity, Long> {
|
||||||
|
|
||||||
/**
|
|
||||||
* 활성화된 태그 목록 조회
|
|
||||||
*/
|
|
||||||
List<TasteTagEntity> findByIsActiveTrue();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 태그 유형별 태그 목록 조회
|
|
||||||
*/
|
|
||||||
List<TasteTagEntity> findByTagTypeAndIsActiveTrue(TagType tagType);
|
List<TasteTagEntity> findByTagTypeAndIsActiveTrue(TagType tagType);
|
||||||
|
|
||||||
/**
|
List<TasteTagEntity> findByIsActiveTrue();
|
||||||
* 태그명으로 태그 조회
|
|
||||||
*/
|
|
||||||
List<TasteTagEntity> findByTagNameIn(List<String> tagNames);
|
List<TasteTagEntity> findByTagNameIn(List<String> tagNames);
|
||||||
}
|
|
||||||
|
List<TasteTagEntity> findByTagCategoryAndIsActiveTrue(TagCategory tagCategory);
|
||||||
|
|
||||||
|
List<TasteTagEntity> findByIsActiveTrueOrderBySortOrder();
|
||||||
|
|
||||||
|
Optional<TasteTagEntity> findByTagNameAndTagCategory(String tagName, TagCategory tagCategory);
|
||||||
|
|
||||||
|
boolean existsByTagNameAndTagCategory(String tagName, TagCategory tagCategory);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user