Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import kr.co.knuserver.domain.booth.entity.Booth;
import kr.co.knuserver.domain.booth.entity.BoothImage;
import kr.co.knuserver.domain.booth.repository.BoothImageRepository;
import kr.co.knuserver.domain.booth.repository.BoothLikeDailyRepository;
import kr.co.knuserver.domain.booth.repository.BoothRepository;
import kr.co.knuserver.global.dto.CursorPaginationResponse;
import kr.co.knuserver.global.exception.BusinessErrorCode;
Expand All @@ -33,6 +34,7 @@ public class BoothQueryService {

private final BoothRepository boothRepository;
private final BoothImageRepository boothImageRepository;
private final BoothLikeDailyRepository boothLikeDailyRepository;
private final BoothLikeService boothLikeService;

public BoothCountResponseDto getBoothCount() {
Expand Down Expand Up @@ -122,6 +124,10 @@ public List<BoothTop3ResponseDto> getTop3BoothRanking() {
.toList();
}

public List<BoothRankingResponseDto> getDailyRanking(String date) {
return boothLikeDailyRepository.findTopByDate(date, 3);
}

public CursorPaginationResponse<BoothListResponseDto> searchBoothsByKeyword2(String keyword, Long lastId, int size) {
Pageable pageable = PageRequest.of(0, size + 1);
List<Booth> booths;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package kr.co.knuserver.domain.booth.repository;

import java.util.List;
import kr.co.knuserver.presentation.booth.dto.BoothRankingResponseDto;
import lombok.RequiredArgsConstructor;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
@RequiredArgsConstructor
public class BoothLikeDailyRepository {

private final JdbcTemplate jdbcTemplate;

public List<BoothRankingResponseDto> findTopByDate(String date, int limit) {
return jdbcTemplate.query(
"SELECT booth_id, name, like_count FROM booth_like_daily WHERE event_date = ? ORDER BY like_count DESC LIMIT ?",
(rs, rowNum) -> new BoothRankingResponseDto(
rs.getLong("booth_id"),
rs.getString("name"),
rs.getLong("like_count")
),
date, limit
);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package kr.co.knuserver.presentation.booth;

import jakarta.validation.Valid;
import java.util.List;
import kr.co.knuserver.application.booth.BoothCommandService;
import kr.co.knuserver.application.booth.BoothQueryService;
import kr.co.knuserver.global.dto.CursorPaginationResponse;
import kr.co.knuserver.global.exception.ApiResponse;
Expand All @@ -12,29 +10,23 @@
import kr.co.knuserver.presentation.booth.dto.BoothListResponseDto;
import kr.co.knuserver.presentation.booth.dto.BoothRankingResponseDto;
import kr.co.knuserver.presentation.booth.dto.BoothTop3ResponseDto;
import kr.co.knuserver.presentation.booth.dto.BoothUpdateRequestDto;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.time.LocalDate;
import java.time.ZoneId;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/booths")
@RequiredArgsConstructor
public class BoothApiController implements BoothApiControllerDocs {

private final BoothQueryService boothQueryService;
private final BoothCommandService boothCommandService;

// 가두모집 부스 개수 조회
@Override
Expand Down Expand Up @@ -94,4 +86,19 @@ public ResponseEntity<ApiResponse<List<BoothTop3ResponseDto>>> getTop3BoothRanki
List<BoothTop3ResponseDto> result = boothQueryService.getTop3BoothRanking();
return ResponseEntity.ok(ApiResponse.success(result));
}

@GetMapping("/ranking/daily")
public ResponseEntity<ApiResponse<List<BoothRankingResponseDto>>> getTodayDailyRanking() {
String today = LocalDate.now(ZoneId.of("Asia/Seoul")).toString();
List<BoothRankingResponseDto> result = boothQueryService.getDailyRanking(today);
return ResponseEntity.ok(ApiResponse.success(result));
}

@GetMapping("/ranking/daily/{date}")
public ResponseEntity<ApiResponse<List<BoothRankingResponseDto>>> getDailyRanking(
@PathVariable(name = "date") String date
) {
List<BoothRankingResponseDto> result = boothQueryService.getDailyRanking(date);
return ResponseEntity.ok(ApiResponse.success(result));
}
}
Loading