Skip to content

Commit

Permalink
refactor: 페이지네이션 쿼리 파람 및 스프링부트 로컬 실행 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
dlwhsk0 committed Oct 31, 2024
1 parent e584c86 commit c0b809f
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 38 deletions.
34 changes: 17 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ services:
networks:
- alchive

springboot:
container_name: springboot
build:
context: .
dockerfile: Dockerfile
restart: always
depends_on:
- mysql
ports:
- "8080:8080"
environment:
SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL}
SPRING_DATASOURCE_USERNAME: ${SPRING_DATASOURCE_USERNAME}
SPRING_DATASOURCE_PASSWORD: ${SPRING_DATASOURCE_PASSWORD}
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE}
networks:
- alchive
# springboot:
# container_name: springboot
# build:
# context: .
# dockerfile: Dockerfile
# restart: always
# depends_on:
# - mysql
# ports:
# - "8080:8080"
# environment:
# SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL}
# SPRING_DATASOURCE_USERNAME: ${SPRING_DATASOURCE_USERNAME}
# SPRING_DATASOURCE_PASSWORD: ${SPRING_DATASOURCE_PASSWORD}
# SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE}
# networks:
# - alchive

# Monitoring
prometheus:
Expand Down
3 changes: 2 additions & 1 deletion monitoring/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ scrape_configs:
- job_name: 'springboot' # 스프링부트 애플리케이션 모니터링
metrics_path: '/actuator/prometheus'
static_configs:
- targets: [ 'springboot:8080' ] # springboot 서비스의 주소
# - targets: [ 'springboot:8080' ] # springboot 서비스의 주소
- targets: [ 'localhost:8080' ] # springboot 서비스의 주소 (로컬)

- job_name: 'cadvisor' # cAdvisor 모니터링
static_configs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class DataInitializer implements CommandLineRunner {
private final SolutionRepository solutionRepository;
private final BoardRepository boardRepository;
private final AlgorithmRepository algorithmRepository;
private final AlgorithmProblemRepository algorithmProblemRepository;

public DataInitializer(UserRepository userRepository,
ProblemRepository problemRepository,
Expand All @@ -40,7 +39,6 @@ public DataInitializer(UserRepository userRepository,
this.solutionRepository = solutionRepository;
this.boardRepository = boardRepository;
this.algorithmRepository = algorithmRepository;
this.algorithmProblemRepository = algorithmProblemRepository;
}

@Override
Expand All @@ -51,7 +49,7 @@ public void run(String... args) throws Exception {
log.info("데이터가 이미 존재하므로 초기화 작업을 건너뜁니다.");
return;
}

// User 목업 데이터 생성
User user1 = User.builder()
.userEmail("[email protected]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.Alchive.backend.config.result.ResultResponse;
import com.Alchive.backend.dto.request.BoardCreateRequest;
import com.Alchive.backend.dto.request.BoardMemoUpdateRequest;
import com.Alchive.backend.dto.request.PaginationRequest;
import com.Alchive.backend.dto.request.ProblemNumberRequest;
import com.Alchive.backend.dto.response.BoardDetailResponseDTO;
import com.Alchive.backend.dto.response.BoardResponseDTO;
Expand Down Expand Up @@ -46,8 +45,10 @@ public ResponseEntity<ResultResponse> isBoardSaved(HttpServletRequest tokenReque

@Operation(summary = "게시물 목록 조회", description = "게시물 목록을 조회하는 메서드입니다. ")
@GetMapping("")
public ResponseEntity<ResultResponse> getBoardList(@ModelAttribute PaginationRequest paginationRequest) {
Page<List<BoardDetailResponseDTO>> boardList = boardService.getBoardList(paginationRequest);
public ResponseEntity<ResultResponse> getBoardList(@RequestParam(value = "offset", defaultValue = "0") int offset,
@RequestParam(value = "limit", defaultValue = "10") int limit) {
log.info("paginationRequest: {}, {}", offset, limit);
Page<List<BoardDetailResponseDTO>> boardList = boardService.getBoardList(offset, limit);
return ResponseEntity.ok(ResultResponse.of(BOARD_LIST_INFO_SUCCESS, boardList));
}

Expand Down

This file was deleted.

10 changes: 7 additions & 3 deletions src/main/java/com/Alchive/backend/service/BoardService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
import com.Alchive.backend.domain.problem.Problem;
import com.Alchive.backend.domain.solution.Solution;
import com.Alchive.backend.domain.user.User;
import com.Alchive.backend.dto.request.*;
import com.Alchive.backend.dto.request.BoardCreateRequest;
import com.Alchive.backend.dto.request.BoardMemoUpdateRequest;
import com.Alchive.backend.dto.request.ProblemCreateRequest;
import com.Alchive.backend.dto.request.ProblemNumberRequest;
import com.Alchive.backend.dto.response.BoardDetailResponseDTO;
import com.Alchive.backend.dto.response.BoardResponseDTO;
import com.Alchive.backend.dto.response.ProblemResponseDTO;
Expand Down Expand Up @@ -65,8 +68,9 @@ public BoardDetailResponseDTO isBoardSaved(HttpServletRequest tokenRequest, Prob
return board.map(this::toBoardDetailResponseDTO).orElse(null);
}

public Page<List<BoardDetailResponseDTO>> getBoardList(PaginationRequest paginationRequest) {
Pageable pageable = PageRequest.of(paginationRequest.getOffset(), paginationRequest.getLimit());
public Page<List<BoardDetailResponseDTO>> getBoardList(int offset, int limit) {
Pageable pageable = PageRequest.of(offset, limit);
log.info("pageable: {}", pageable);
Page<Board> boardPage = boardRepository.findAll(pageable);

// Board를 BoardDetailResponseDTO로 변환
Expand Down

0 comments on commit c0b809f

Please sign in to comment.