From 92bde025388decea0aacffbc0439fb4ff7c1dd03 Mon Sep 17 00:00:00 2001 From: gabang2 Date: Sun, 2 Jun 2024 15:52:16 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EC=B5=9C=EA=B7=BC=20=EA=B2=80=EC=83=89?= =?UTF-8?q?=EC=96=B4=20=EC=A0=80=EC=9E=A5=20&=20isDeleted=20->=20isRecent?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/keyword/entity/CulturalEventSearchKeyword.java | 4 ++-- .../repository/CulturalEventSearchKeywordRepository.java | 7 ++++--- .../keyword/service/CulturalEventSearchKeywordService.java | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/project/backend/domain/keyword/entity/CulturalEventSearchKeyword.java b/src/main/java/project/backend/domain/keyword/entity/CulturalEventSearchKeyword.java index e07a780..d93e83c 100644 --- a/src/main/java/project/backend/domain/keyword/entity/CulturalEventSearchKeyword.java +++ b/src/main/java/project/backend/domain/keyword/entity/CulturalEventSearchKeyword.java @@ -19,7 +19,7 @@ public class CulturalEventSearchKeyword extends BaseEntity { public String keyword; - public Boolean isDeleted; + public Boolean isRecent; @ManyToOne(fetch = FetchType.LAZY) public Member member; @@ -27,7 +27,7 @@ public class CulturalEventSearchKeyword extends BaseEntity { @Builder public CulturalEventSearchKeyword(String keyword) { this.keyword = keyword; - this.isDeleted = false; + this.isRecent = true; } public void setMember(Member member) { diff --git a/src/main/java/project/backend/domain/keyword/repository/CulturalEventSearchKeywordRepository.java b/src/main/java/project/backend/domain/keyword/repository/CulturalEventSearchKeywordRepository.java index 84ccad0..611519f 100644 --- a/src/main/java/project/backend/domain/keyword/repository/CulturalEventSearchKeywordRepository.java +++ b/src/main/java/project/backend/domain/keyword/repository/CulturalEventSearchKeywordRepository.java @@ -10,7 +10,8 @@ public interface CulturalEventSearchKeywordRepository extends JpaRepository { - List findCulturalEventSearchKeywordsByIsDeletedFalseAndMember(Member member); - @Query("SELECT CASE WHEN COUNT(c) > 0 THEN true ELSE false END FROM CulturalEventSearchKeyword c WHERE c.isDeleted = false AND c.member = :member AND c.keyword = :keyword") - Boolean existsByIsDeletedFalseAndMemberAndKeyword(@Param("member") Member member, @Param("keyword") String keyword); + List findCulturalEventSearchKeywordsByIsRecentFalseAndMember(Member member); + + @Query("SELECT CASE WHEN COUNT(c) > 0 THEN true ELSE false END FROM CulturalEventSearchKeyword c WHERE c.isRecent = false AND c.member = :member AND c.keyword = :keyword") + Boolean existsByIsRecentFalseAndMemberAndKeyword(@Param("member") Member member, @Param("keyword") String keyword); } diff --git a/src/main/java/project/backend/domain/keyword/service/CulturalEventSearchKeywordService.java b/src/main/java/project/backend/domain/keyword/service/CulturalEventSearchKeywordService.java index d7cac9e..b0f136d 100644 --- a/src/main/java/project/backend/domain/keyword/service/CulturalEventSearchKeywordService.java +++ b/src/main/java/project/backend/domain/keyword/service/CulturalEventSearchKeywordService.java @@ -22,7 +22,7 @@ public class CulturalEventSearchKeywordService { // 사용자, 키워드 등록 public void createCulturalEventSearchKeyword(Member member, String keyword) { - if (!culturalEventSearchKeywordRepository.existsByIsDeletedFalseAndMemberAndKeyword(member, keyword)) { + if (!culturalEventSearchKeywordRepository.existsByIsRecentFalseAndMemberAndKeyword(member, keyword)) { CulturalEventSearchKeyword culturalEventSearchKeyword = CulturalEventSearchKeyword.builder() .keyword(keyword).build(); @@ -34,12 +34,12 @@ public void createCulturalEventSearchKeyword(Member member, String keyword) { // 키워드 삭제 public void deleteCulturalEventSearchKeyword(Long id) { CulturalEventSearchKeyword culturalEventSearchKeyword = verifiedCulturalEventSearchKeyword(id); - culturalEventSearchKeyword.isDeleted = true; + culturalEventSearchKeyword.isRecent = true; } // 사용자 키워드 목록 조회 public List getCulturalEventSearchKeywordList(Member member) { - return culturalEventSearchKeywordRepository.findCulturalEventSearchKeywordsByIsDeletedFalseAndMember(member); + return culturalEventSearchKeywordRepository.findCulturalEventSearchKeywordsByIsRecentFalseAndMember(member); }