From c0b809fc05457364a3ee712dc67acecad7914ddd Mon Sep 17 00:00:00 2001 From: dlwhsk0 Date: Thu, 31 Oct 2024 17:36:53 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EC=85=98=20=EC=BF=BC=EB=A6=AC=20=ED=8C=8C?= =?UTF-8?q?=EB=9E=8C=20=EB=B0=8F=20=EC=8A=A4=ED=94=84=EB=A7=81=EB=B6=80?= =?UTF-8?q?=ED=8A=B8=20=EB=A1=9C=EC=BB=AC=20=EC=8B=A4=ED=96=89=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 34 +++++++++---------- monitoring/prometheus/prometheus.yml | 3 +- .../backend/config/DataInitializer.java | 4 +-- .../backend/controller/BoardController.java | 7 ++-- .../dto/request/PaginationRequest.java | 11 ------ .../Alchive/backend/service/BoardService.java | 10 ++++-- 6 files changed, 31 insertions(+), 38 deletions(-) delete mode 100644 src/main/java/com/Alchive/backend/dto/request/PaginationRequest.java diff --git a/docker-compose.yml b/docker-compose.yml index f662567..298f729 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/monitoring/prometheus/prometheus.yml b/monitoring/prometheus/prometheus.yml index 1cff57b..8733a86 100644 --- a/monitoring/prometheus/prometheus.yml +++ b/monitoring/prometheus/prometheus.yml @@ -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: diff --git a/src/main/java/com/Alchive/backend/config/DataInitializer.java b/src/main/java/com/Alchive/backend/config/DataInitializer.java index c375613..81043cc 100644 --- a/src/main/java/com/Alchive/backend/config/DataInitializer.java +++ b/src/main/java/com/Alchive/backend/config/DataInitializer.java @@ -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, @@ -40,7 +39,6 @@ public DataInitializer(UserRepository userRepository, this.solutionRepository = solutionRepository; this.boardRepository = boardRepository; this.algorithmRepository = algorithmRepository; - this.algorithmProblemRepository = algorithmProblemRepository; } @Override @@ -51,7 +49,7 @@ public void run(String... args) throws Exception { log.info("데이터가 이미 존재하므로 초기화 작업을 건너뜁니다."); return; } - + // User 목업 데이터 생성 User user1 = User.builder() .userEmail("chohana@alchive.com") diff --git a/src/main/java/com/Alchive/backend/controller/BoardController.java b/src/main/java/com/Alchive/backend/controller/BoardController.java index 583c5a9..2ef8568 100644 --- a/src/main/java/com/Alchive/backend/controller/BoardController.java +++ b/src/main/java/com/Alchive/backend/controller/BoardController.java @@ -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; @@ -46,8 +45,10 @@ public ResponseEntity isBoardSaved(HttpServletRequest tokenReque @Operation(summary = "게시물 목록 조회", description = "게시물 목록을 조회하는 메서드입니다. ") @GetMapping("") - public ResponseEntity getBoardList(@ModelAttribute PaginationRequest paginationRequest) { - Page> boardList = boardService.getBoardList(paginationRequest); + public ResponseEntity getBoardList(@RequestParam(value = "offset", defaultValue = "0") int offset, + @RequestParam(value = "limit", defaultValue = "10") int limit) { + log.info("paginationRequest: {}, {}", offset, limit); + Page> boardList = boardService.getBoardList(offset, limit); return ResponseEntity.ok(ResultResponse.of(BOARD_LIST_INFO_SUCCESS, boardList)); } diff --git a/src/main/java/com/Alchive/backend/dto/request/PaginationRequest.java b/src/main/java/com/Alchive/backend/dto/request/PaginationRequest.java deleted file mode 100644 index 8cc932f..0000000 --- a/src/main/java/com/Alchive/backend/dto/request/PaginationRequest.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.Alchive.backend.dto.request; - -import lombok.Getter; -import lombok.NoArgsConstructor; - -@NoArgsConstructor -@Getter -public class PaginationRequest { - private int offset = 0; - private int limit = 20; -} diff --git a/src/main/java/com/Alchive/backend/service/BoardService.java b/src/main/java/com/Alchive/backend/service/BoardService.java index c618a99..88c792d 100644 --- a/src/main/java/com/Alchive/backend/service/BoardService.java +++ b/src/main/java/com/Alchive/backend/service/BoardService.java @@ -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; @@ -65,8 +68,9 @@ public BoardDetailResponseDTO isBoardSaved(HttpServletRequest tokenRequest, Prob return board.map(this::toBoardDetailResponseDTO).orElse(null); } - public Page> getBoardList(PaginationRequest paginationRequest) { - Pageable pageable = PageRequest.of(paginationRequest.getOffset(), paginationRequest.getLimit()); + public Page> getBoardList(int offset, int limit) { + Pageable pageable = PageRequest.of(offset, limit); + log.info("pageable: {}", pageable); Page boardPage = boardRepository.findAll(pageable); // Board를 BoardDetailResponseDTO로 변환