Skip to content

Commit

Permalink
Merge pull request #209 from miIlicon/feature/209-findByTitle
Browse files Browse the repository at this point in the history
[#209] Title로  Booth조회
  • Loading branch information
angelSuho authored Sep 14, 2023
2 parents 9a90fb6 + 5f567ac commit 3ba5268
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public ResponseEntity<Void> deleteBooth(@PathVariable("boothId") Long id) {
public ResponseEntity<BoothRes> getBooth(@PathVariable("boothId") Long id, HttpServletRequest httpServletRequest) {
return ResponseEntity.ok().body(boothService.getBooth(id,httpServletRequest.getRemoteAddr()));
}
@PreAuthorize("permitAll()")
@GetMapping()
public ResponseEntity<BoothRes> getBoothByTitle(@RequestParam("boothTitle") String title, HttpServletRequest httpServletRequest) {
return ResponseEntity.ok().body(boothService.getBoothByTitle(title,httpServletRequest.getRemoteAddr()));
}

@PreAuthorize("permitAll()")
@GetMapping("/query/{boothId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
import org.springframework.data.jpa.repository.JpaRepository;

public interface BoothRepository extends JpaRepository<Booth, Long>, BoothRepositoryCustom {
Booth getBoothByTitle(String title);

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
public interface BoothRepositoryCustom {
BoothPageRes getList(BoothListSearchCond boothListSearchCond);
List<BoothSearchRes> searchBoothList(String keyword);


}
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,11 @@ private Booth checkingDeletedStatus(Optional<Booth> booth) {
return booth.get();
}

public BoothRes getBoothByTitle(String title, String remoteAddr) {
Booth booth = boothRepository.getBoothByTitle(title);
if(redisService.isDuplicateAccess(remoteAddr, "Booth_" + booth.getId())) {
redisService.increaseRedisViewCount("Booth_Id_" + booth.getId());
}
return BoothRes.of(booth);
}
}

0 comments on commit 3ba5268

Please sign in to comment.