Skip to content

Commit

Permalink
Feat: 문화생활 검색어 삭제 API
Browse files Browse the repository at this point in the history
  • Loading branch information
rrosiee committed Jun 2, 2024
1 parent e7e14be commit 85e68ff
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ public ResponseEntity<List<CulturalEventSearchKeywordListDto>> getCulturalEventR

return ResponseEntity.status(HttpStatus.OK).body(culturalEventSearchKeywordListDtoList);
}

@ApiOperation(value = "문화생활 최근 검색어 삭제")
@DeleteMapping("/recent-keywords/{id}")
public ResponseEntity deleteCulturalEventRecentKeyword(@Positive @PathVariable Long id) {
culturalEventSearchKeywordService.deleteCulturalEventSearchKeyword(id);
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(null);
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import project.backend.domain.keyword.entity.CulturalEventSearchKeyword;
import project.backend.domain.keyword.repository.CulturalEventSearchKeywordRepository;
import project.backend.domain.member.entity.Member;
import project.backend.domain.member.service.MemberJwtService;
import project.backend.global.error.exception.BusinessException;
import project.backend.global.error.exception.ErrorCode;

Expand All @@ -21,6 +22,7 @@
public class CulturalEventSearchKeywordService {

private final CulturalEventSearchKeywordRepository culturalEventSearchKeywordRepository;
private final MemberJwtService memberJwtService;


/**
Expand Down Expand Up @@ -68,10 +70,20 @@ public List<CulturalEventSearchKeyword> getCulturalEventRecentKeywordList(Member
return culturalEventSearchKeywordRepository.findByIsRecentTrueAndMemberOrderByUpdatedDateDesc(member);
}

// 키워드 삭제
/**
* 최근 검색어 삭제
*
* @param id
*/
public void deleteCulturalEventSearchKeyword(Long id) {
// 내가 검색한 키워드인지 확인
Member member = memberJwtService.getMember();
CulturalEventSearchKeyword culturalEventSearchKeyword = verifiedCulturalEventSearchKeyword(id);
culturalEventSearchKeyword.isRecent = true;

if (member != culturalEventSearchKeyword.getMember()) {
throw new BusinessException(ErrorCode.CULTURAL_EVENT_SEARCH_KEYWORD_DELETE_FAIL);
}
culturalEventSearchKeyword.isRecent = false;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public enum ErrorCode {
CULTURAL_EVENT_CATEGORY_NOT_FOUND(404, "CEC001", "문화생활 카테고리를 찾을 수 없습니다."),

// Traffic
VERSION_NOT_FOUND(404, "V001", "버전을 찾을 수 없습니다.")
VERSION_NOT_FOUND(404, "V001", "버전을 찾을 수 없습니다."),


;
// Cultural Event Search Keyword
CULTURAL_EVENT_SEARCH_KEYWORD_DELETE_FAIL(400, "CESK001", "내 최근 검색어만 삭제할 수 있습니다.");

private final String code;
private final String message;
Expand Down

0 comments on commit 85e68ff

Please sign in to comment.