Skip to content

Commit

Permalink
Feat: 최근 검색어 저장 & isDeleted -> isRecent로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
rrosiee committed Jun 2, 2024
1 parent 22b194e commit 92bde02
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public class CulturalEventSearchKeyword extends BaseEntity {

public String keyword;

public Boolean isDeleted;
public Boolean isRecent;

@ManyToOne(fetch = FetchType.LAZY)
public Member member;

@Builder
public CulturalEventSearchKeyword(String keyword) {
this.keyword = keyword;
this.isDeleted = false;
this.isRecent = true;
}

public void setMember(Member member) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

public interface CulturalEventSearchKeywordRepository extends JpaRepository<CulturalEventSearchKeyword, Long> {

List<CulturalEventSearchKeyword> 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<CulturalEventSearchKeyword> 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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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<CulturalEventSearchKeyword> getCulturalEventSearchKeywordList(Member member) {
return culturalEventSearchKeywordRepository.findCulturalEventSearchKeywordsByIsDeletedFalseAndMember(member);
return culturalEventSearchKeywordRepository.findCulturalEventSearchKeywordsByIsRecentFalseAndMember(member);
}


Expand Down

0 comments on commit 92bde02

Please sign in to comment.