From a9ddd7f341e7c536dd5a2885888ed04eb9755bc1 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Fri, 19 Jul 2024 16:24:36 +0900 Subject: [PATCH 1/7] =?UTF-8?q?FLASH-172=20feat:=20=EC=84=B9=ED=84=B0=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EC=8B=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20publish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sector/application/SectorService.java | 3 +++ .../sector/domain/SectorInfoUpdatedEvent.java | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/sector/domain/SectorInfoUpdatedEvent.java diff --git a/src/main/java/com/first/flash/climbing/sector/application/SectorService.java b/src/main/java/com/first/flash/climbing/sector/application/SectorService.java index 1239f467..5203b5ca 100644 --- a/src/main/java/com/first/flash/climbing/sector/application/SectorService.java +++ b/src/main/java/com/first/flash/climbing/sector/application/SectorService.java @@ -6,6 +6,7 @@ import com.first.flash.climbing.sector.application.dto.SectorUpdateRemovalDateRequestDto; import com.first.flash.climbing.sector.domain.Sector; import com.first.flash.climbing.sector.domain.SectorExpiredEvent; +import com.first.flash.climbing.sector.domain.SectorInfoUpdatedEvent; import com.first.flash.climbing.sector.domain.SectorRemovalDateUpdatedEvent; import com.first.flash.climbing.sector.domain.SectorRepository; import com.first.flash.climbing.sector.exception.exceptions.SectorNotFoundException; @@ -55,6 +56,8 @@ public SectorWriteDetailResponseDto updateSector( foundSector.updateSector(updateRequestDto.sectorName(), updateRequestDto.adminSectorName(), updateRequestDto.settingDate(), updateRequestDto.removalDate(), updateRequestDto.gymId()); + Events.raise(SectorInfoUpdatedEvent.of(foundSector.getId(), updateRequestDto.sectorName(), + updateRequestDto.settingDate())); return SectorWriteDetailResponseDto.toDto(foundSector); } diff --git a/src/main/java/com/first/flash/climbing/sector/domain/SectorInfoUpdatedEvent.java b/src/main/java/com/first/flash/climbing/sector/domain/SectorInfoUpdatedEvent.java new file mode 100644 index 00000000..cdcf1dc2 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/domain/SectorInfoUpdatedEvent.java @@ -0,0 +1,19 @@ +package com.first.flash.climbing.sector.domain; + +import java.time.LocalDate; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class SectorInfoUpdatedEvent { + + private Long id; + private String sectorName; + private LocalDate settingDate; + + public static SectorInfoUpdatedEvent of(final Long id, final String sectorName, + final LocalDate settingDate) { + return new SectorInfoUpdatedEvent(id, sectorName, settingDate); + } +} From 86517f9dcecd85a70d4b6cd4f48571c439fd8d6e Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Fri, 19 Jul 2024 16:25:36 +0900 Subject: [PATCH 2/7] =?UTF-8?q?FLASH-172=20feat:=20=EC=84=B9=ED=84=B0=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=EC=97=90=20=EB=8C=80=ED=95=B4=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=AA=A8=EB=8D=B8=EC=9D=B4=20=EB=B0=98?= =?UTF-8?q?=EC=A0=95=EA=B7=9C=ED=99=94=EB=90=9C=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../climbing/problem/application/ProblemEventHandler.java | 8 ++++++++ .../climbing/problem/application/ProblemsService.java | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/com/first/flash/climbing/problem/application/ProblemEventHandler.java b/src/main/java/com/first/flash/climbing/problem/application/ProblemEventHandler.java index cad1e0f0..c4a6bee7 100644 --- a/src/main/java/com/first/flash/climbing/problem/application/ProblemEventHandler.java +++ b/src/main/java/com/first/flash/climbing/problem/application/ProblemEventHandler.java @@ -1,6 +1,7 @@ package com.first.flash.climbing.problem.application; import com.first.flash.climbing.sector.domain.SectorExpiredEvent; +import com.first.flash.climbing.sector.domain.SectorInfoUpdatedEvent; import com.first.flash.climbing.sector.domain.SectorRemovalDateUpdatedEvent; import com.first.flash.climbing.solution.domain.SolutionSavedEvent; import lombok.RequiredArgsConstructor; @@ -31,4 +32,11 @@ public void expireProblem(final SectorExpiredEvent event) { public void updateProblemSolutionInfo(final SolutionSavedEvent event) { problemsService.updateProblemSolutionInfo(event.getProblemId()); } + + @EventListener + @Transactional + public void updateQueryProblemInfo(final SectorInfoUpdatedEvent event) { + problemsService.updateQueryProblemInfo(event.getId(), event.getSectorName(), + event.getSettingDate()); + } } diff --git a/src/main/java/com/first/flash/climbing/problem/application/ProblemsService.java b/src/main/java/com/first/flash/climbing/problem/application/ProblemsService.java index 49aea4a0..886224ab 100644 --- a/src/main/java/com/first/flash/climbing/problem/application/ProblemsService.java +++ b/src/main/java/com/first/flash/climbing/problem/application/ProblemsService.java @@ -35,4 +35,10 @@ public void updateProblemSolutionInfo(final UUID problemId) { QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId); queryProblem.addSolutionCount(); } + + @Transactional + public void updateQueryProblemInfo(final Long sectorId, final String sectorName, + final LocalDate settingDate) { + queryProblemRepository.updateQueryProblemInfo(sectorId, sectorName, settingDate); + } } From d1680a33c5cb17918df5f86dd5b3d709f2ab1b23 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Fri, 19 Jul 2024 16:25:58 +0900 Subject: [PATCH 3/7] =?UTF-8?q?FLASH-172=20feat:=20=EB=B0=98=EC=A0=95?= =?UTF-8?q?=EA=B7=9C=ED=99=94=EB=90=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../problem/domain/QueryProblemRepository.java | 3 +++ .../infrastructure/QueryProblemQueryDslRepository.java | 10 ++++++++++ .../infrastructure/QueryProblemRepositoryImpl.java | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/src/main/java/com/first/flash/climbing/problem/domain/QueryProblemRepository.java b/src/main/java/com/first/flash/climbing/problem/domain/QueryProblemRepository.java index b9f7983a..df1b37e0 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/QueryProblemRepository.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/QueryProblemRepository.java @@ -20,4 +20,7 @@ List findAll(final Cursor preCursor, final SortBy sortBy, final in void updateRemovalDateBySectorId(final Long sectorId, final LocalDate removalDate); void expireProblemsBySectorIds(final List expiredSectorsIds); + + void updateQueryProblemInfo(final Long sectorId, final String sectorName, + final LocalDate settingDate); } diff --git a/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemQueryDslRepository.java b/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemQueryDslRepository.java index 9b1dfd1d..7a286e09 100644 --- a/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemQueryDslRepository.java +++ b/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemQueryDslRepository.java @@ -38,6 +38,7 @@ public List findAll(final Cursor prevCursor, final SortBy sortBy, public void updateRemovalDateBySectorId(final Long sectorId, final LocalDate removalDate) { queryFactory.update(queryProblem) .set(queryProblem.removalDate, removalDate) + .set(queryProblem.isFakeRemovalDate, false) .where(queryProblem.sectorId.eq(sectorId)) .execute(); } @@ -49,6 +50,15 @@ public void expireProblemsBySectorIds(final List expiredSectorsIds) { .execute(); } + public void updateQueryProblemInfo(final Long sectorId, final String sectorName, + final LocalDate settingDate) { + queryFactory.update(queryProblem) + .set(queryProblem.sectorName, sectorName) + .set(queryProblem.settingDate, settingDate) + .where(queryProblem.sectorId.eq(sectorId)) + .execute(); + } + private BooleanExpression inGym(final Long gymId) { return queryProblem.gymId.eq(gymId); } diff --git a/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemRepositoryImpl.java b/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemRepositoryImpl.java index 023f8743..dac8b733 100644 --- a/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemRepositoryImpl.java +++ b/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemRepositoryImpl.java @@ -45,4 +45,10 @@ public void updateRemovalDateBySectorId(final Long sectorId, final LocalDate rem public void expireProblemsBySectorIds(final List expiredSectorsIds) { queryProblemQueryDslRepository.expireProblemsBySectorIds(expiredSectorsIds); } + + @Override + public void updateQueryProblemInfo(final Long sectorId, final String sectorName, + final LocalDate settingDate) { + queryProblemQueryDslRepository.updateQueryProblemInfo(sectorId, sectorName, settingDate); + } } From 77386c17c626473526e9e04c09d0db08584f2c70 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Fri, 19 Jul 2024 16:27:52 +0900 Subject: [PATCH 4/7] =?UTF-8?q?FLASH-172=20refactor:=20=EC=84=B9=ED=84=B0?= =?UTF-8?q?=EC=9D=98=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EB=B3=B4=EC=97=AC?= =?UTF-8?q?=EC=A3=BC=EB=8A=94=20=EB=94=94=ED=85=8C=EC=9D=BC=20dto=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../climbing/sector/application/SectorService.java | 14 +++++++------- ...sponseDto.java => SectorDetailResponseDto.java} | 8 ++++---- .../flash/climbing/sector/ui/SectorController.java | 11 ++++++----- .../sector/application/SectorServiceTest.java | 4 ++-- 4 files changed, 19 insertions(+), 18 deletions(-) rename src/main/java/com/first/flash/climbing/sector/application/dto/{SectorWriteDetailResponseDto.java => SectorDetailResponseDto.java} (50%) diff --git a/src/main/java/com/first/flash/climbing/sector/application/SectorService.java b/src/main/java/com/first/flash/climbing/sector/application/SectorService.java index 5203b5ca..2365354f 100644 --- a/src/main/java/com/first/flash/climbing/sector/application/SectorService.java +++ b/src/main/java/com/first/flash/climbing/sector/application/SectorService.java @@ -2,7 +2,7 @@ import com.first.flash.climbing.sector.application.dto.SectorCreateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorUpdateRequestDto; -import com.first.flash.climbing.sector.application.dto.SectorWriteDetailResponseDto; +import com.first.flash.climbing.sector.application.dto.SectorDetailResponseDto; import com.first.flash.climbing.sector.application.dto.SectorUpdateRemovalDateRequestDto; import com.first.flash.climbing.sector.domain.Sector; import com.first.flash.climbing.sector.domain.SectorExpiredEvent; @@ -26,20 +26,20 @@ public class SectorService { private final SectorRepository sectorRepository; @Transactional - public SectorWriteDetailResponseDto saveSector(final Long gymId, + public SectorDetailResponseDto saveSector(final Long gymId, final SectorCreateRequestDto createRequestDto) { Sector sector = createSectorByDto(gymId, createRequestDto); - return SectorWriteDetailResponseDto.toDto(sectorRepository.save(sector)); + return SectorDetailResponseDto.toDto(sectorRepository.save(sector)); } @Transactional - public SectorWriteDetailResponseDto updateSectorRemovalDate(final Long sectorId, + public SectorDetailResponseDto updateSectorRemovalDate(final Long sectorId, final SectorUpdateRemovalDateRequestDto sectorUpdateRemovalDateRequestDto) { Sector sector = findById(sectorId); LocalDate removalDate = sectorUpdateRemovalDateRequestDto.removalDate(); sector.updateRemovalDate(removalDate); Events.raise(SectorRemovalDateUpdatedEvent.of(sectorId, removalDate)); - return SectorWriteDetailResponseDto.toDto(sector); + return SectorDetailResponseDto.toDto(sector); } @Transactional @@ -49,7 +49,7 @@ public void expireSector() { } @Transactional - public SectorWriteDetailResponseDto updateSector( + public SectorDetailResponseDto updateSector( final Long sectorId, final SectorUpdateRequestDto updateRequestDto) { Sector foundSector = findById(sectorId); @@ -58,7 +58,7 @@ public SectorWriteDetailResponseDto updateSector( updateRequestDto.removalDate(), updateRequestDto.gymId()); Events.raise(SectorInfoUpdatedEvent.of(foundSector.getId(), updateRequestDto.sectorName(), updateRequestDto.settingDate())); - return SectorWriteDetailResponseDto.toDto(foundSector); + return SectorDetailResponseDto.toDto(foundSector); } public Sector findById(final Long id) { diff --git a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorWriteDetailResponseDto.java b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorDetailResponseDto.java similarity index 50% rename from src/main/java/com/first/flash/climbing/sector/application/dto/SectorWriteDetailResponseDto.java rename to src/main/java/com/first/flash/climbing/sector/application/dto/SectorDetailResponseDto.java index 0ac0f446..5213c615 100644 --- a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorWriteDetailResponseDto.java +++ b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorDetailResponseDto.java @@ -5,11 +5,11 @@ import com.first.flash.climbing.sector.domain.vo.SectorName; import java.time.LocalDate; -public record SectorWriteDetailResponseDto(Long id, SectorName sectorName, LocalDate settingDate, - RemovalInfo removalInfo, Long gymId) { +public record SectorDetailResponseDto(Long id, SectorName sectorName, LocalDate settingDate, + RemovalInfo removalInfo, Long gymId) { - public static SectorWriteDetailResponseDto toDto(final Sector sector) { - return new SectorWriteDetailResponseDto(sector.getId(), sector.getSectorName(), + public static SectorDetailResponseDto toDto(final Sector sector) { + return new SectorDetailResponseDto(sector.getId(), sector.getSectorName(), sector.getSettingDate(), sector.getRemovalInfo(), sector.getGymId()); } } diff --git a/src/main/java/com/first/flash/climbing/sector/ui/SectorController.java b/src/main/java/com/first/flash/climbing/sector/ui/SectorController.java index 56daae63..abddc8c4 100644 --- a/src/main/java/com/first/flash/climbing/sector/ui/SectorController.java +++ b/src/main/java/com/first/flash/climbing/sector/ui/SectorController.java @@ -4,7 +4,7 @@ import com.first.flash.climbing.sector.application.dto.SectorCreateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorUpdateRemovalDateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorUpdateRequestDto; -import com.first.flash.climbing.sector.application.dto.SectorWriteDetailResponseDto; +import com.first.flash.climbing.sector.application.dto.SectorDetailResponseDto; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; @@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; 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; @@ -34,7 +35,7 @@ public class SectorController { @ApiResponse(responseCode = "400", description = "탈거일이 세팅일보다 빠름") }) @PostMapping("gyms/{gymId}/sectors") - public ResponseEntity createSector(@PathVariable final Long gymId, + public ResponseEntity createSector(@PathVariable final Long gymId, @RequestBody final SectorCreateRequestDto sectorCreateRequestDto) { return ResponseEntity.status(HttpStatus.CREATED) .body(sectorService.saveSector(gymId, sectorCreateRequestDto)); @@ -47,10 +48,10 @@ public ResponseEntity createSector(@PathVariable f @ApiResponse(responseCode = "404", description = "섹터를 찾을 수 없음") }) @PatchMapping("sectors/{sectorId}") - public ResponseEntity updateSectorRemovalDate( + public ResponseEntity updateSectorRemovalDate( @PathVariable final Long sectorId, @RequestBody final SectorUpdateRemovalDateRequestDto sectorUpdateRemovalDateRequestDto) { - SectorWriteDetailResponseDto response = sectorService.updateSectorRemovalDate( + SectorDetailResponseDto response = sectorService.updateSectorRemovalDate( sectorId, sectorUpdateRemovalDateRequestDto); return ResponseEntity.ok(response); } @@ -60,7 +61,7 @@ public ResponseEntity updateSectorRemovalDate( @ApiResponse(responseCode = "200", description = "성공적으로 섹터 탈거일을 수정함"), }) @PutMapping("sectors/{sectorId}") - public ResponseEntity updateSector( + public ResponseEntity updateSector( @PathVariable final Long sectorId, @RequestBody final SectorUpdateRequestDto updateRequestDto) { return ResponseEntity.ok(sectorService.updateSector(sectorId, updateRequestDto)); diff --git a/src/test/java/com/first/flash/climbing/sector/application/SectorServiceTest.java b/src/test/java/com/first/flash/climbing/sector/application/SectorServiceTest.java index e332ef19..b4681fbf 100644 --- a/src/test/java/com/first/flash/climbing/sector/application/SectorServiceTest.java +++ b/src/test/java/com/first/flash/climbing/sector/application/SectorServiceTest.java @@ -6,7 +6,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import com.first.flash.climbing.sector.application.dto.SectorCreateRequestDto; -import com.first.flash.climbing.sector.application.dto.SectorWriteDetailResponseDto; +import com.first.flash.climbing.sector.application.dto.SectorDetailResponseDto; import com.first.flash.climbing.sector.application.dto.SectorUpdateRemovalDateRequestDto; import com.first.flash.climbing.sector.domain.Sector; import com.first.flash.climbing.sector.domain.SectorRepository; @@ -35,7 +35,7 @@ void init() { SectorCreateRequestDto requestDto = createDefaultRequestDto(LocalDate.now()); // when - SectorWriteDetailResponseDto response = sectorService.saveSector(DEFAULT_GYM_ID, requestDto); + SectorDetailResponseDto response = sectorService.saveSector(DEFAULT_GYM_ID, requestDto); Sector foundSector = sectorService.findById(response.id()); // then From 729f103f123fd0d064d61ccbbecff9f07d96a2e1 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Fri, 19 Jul 2024 16:36:56 +0900 Subject: [PATCH 5/7] =?UTF-8?q?FLASH-172=20feat:=20=EC=84=B9=ED=84=B0=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=ED=95=98=EB=8A=94=20=EB=A0=88=ED=8F=AC=EC=A7=80?= =?UTF-8?q?=ED=86=A0=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../climbing/sector/domain/SectorRepository.java | 2 ++ .../sector/infrastructure/SectorJpaRepository.java | 3 +++ .../sector/infrastructure/SectorRepositoryImpl.java | 5 +++++ .../sector/infrastructure/FakeSectorRepository.java | 11 ++++++++--- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/sector/domain/SectorRepository.java b/src/main/java/com/first/flash/climbing/sector/domain/SectorRepository.java index 4b50446a..7b662e4d 100644 --- a/src/main/java/com/first/flash/climbing/sector/domain/SectorRepository.java +++ b/src/main/java/com/first/flash/climbing/sector/domain/SectorRepository.java @@ -10,4 +10,6 @@ public interface SectorRepository { Optional findById(final Long id); List updateExpiredSector(); + + List findAll(); } diff --git a/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorJpaRepository.java b/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorJpaRepository.java index ce84b88b..7ac0a472 100644 --- a/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorJpaRepository.java +++ b/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorJpaRepository.java @@ -1,6 +1,7 @@ package com.first.flash.climbing.sector.infrastructure; import com.first.flash.climbing.sector.domain.Sector; +import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; @@ -9,4 +10,6 @@ public interface SectorJpaRepository extends JpaRepository { Sector save(final Sector sector); Optional findById(final Long id); + + List findAll(); } diff --git a/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorRepositoryImpl.java b/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorRepositoryImpl.java index 18fa1d83..5fc5d5d8 100644 --- a/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorRepositoryImpl.java +++ b/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorRepositoryImpl.java @@ -28,4 +28,9 @@ public Optional findById(final Long id) { public List updateExpiredSector() { return sectorQueryDslRepository.updateExpiredSector(); } + + @Override + public List findAll() { + return sectorJpaRepository.findAll(); + } } diff --git a/src/test/java/com/first/flash/climbing/sector/infrastructure/FakeSectorRepository.java b/src/test/java/com/first/flash/climbing/sector/infrastructure/FakeSectorRepository.java index e9a02c2d..dd215ee6 100644 --- a/src/test/java/com/first/flash/climbing/sector/infrastructure/FakeSectorRepository.java +++ b/src/test/java/com/first/flash/climbing/sector/infrastructure/FakeSectorRepository.java @@ -27,10 +27,15 @@ public Optional findById(final Long id) { @Override public List updateExpiredSector() { List expiredIds = db.keySet().stream() - .filter(key -> db.get(key).getRemovalInfo().getRemovalDate() - .isBefore(db.get(key).getSettingDate())) - .toList(); + .filter(key -> db.get(key).getRemovalInfo().getRemovalDate() + .isBefore(db.get(key).getSettingDate())) + .toList(); expiredIds.forEach(db::remove); return expiredIds; } + + @Override + public List findAll() { + return List.copyOf(db.values()); + } } From 816aed43150135b61ebff8cb26a484bd611bd678 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Fri, 19 Jul 2024 16:37:19 +0900 Subject: [PATCH 6/7] =?UTF-8?q?FLASH-172=20feat:=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=EC=84=B9=ED=84=B0=20=EB=94=94=ED=85=8C=EC=9D=BC=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20dto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sector/application/dto/SectorsDetailResponseDto.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/sector/application/dto/SectorsDetailResponseDto.java diff --git a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorsDetailResponseDto.java b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorsDetailResponseDto.java new file mode 100644 index 00000000..a3c58763 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorsDetailResponseDto.java @@ -0,0 +1,7 @@ +package com.first.flash.climbing.sector.application.dto; + +import java.util.List; + +public record SectorsDetailResponseDto(List sectorsDetailResponseDtos) { + +} From 95dada4f97993e3c912bb00bad4e3d21ef15ee49 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Fri, 19 Jul 2024 16:37:46 +0900 Subject: [PATCH 7/7] =?UTF-8?q?FLASH-172=20feat:=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=EC=84=B9=ED=84=B0=20=EC=A1=B0=ED=9A=8C=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../climbing/sector/application/SectorService.java | 11 +++++++++++ .../flash/climbing/sector/ui/SectorController.java | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/first/flash/climbing/sector/application/SectorService.java b/src/main/java/com/first/flash/climbing/sector/application/SectorService.java index 2365354f..527ff9b5 100644 --- a/src/main/java/com/first/flash/climbing/sector/application/SectorService.java +++ b/src/main/java/com/first/flash/climbing/sector/application/SectorService.java @@ -4,6 +4,7 @@ import com.first.flash.climbing.sector.application.dto.SectorUpdateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorDetailResponseDto; import com.first.flash.climbing.sector.application.dto.SectorUpdateRemovalDateRequestDto; +import com.first.flash.climbing.sector.application.dto.SectorsDetailResponseDto; import com.first.flash.climbing.sector.domain.Sector; import com.first.flash.climbing.sector.domain.SectorExpiredEvent; import com.first.flash.climbing.sector.domain.SectorInfoUpdatedEvent; @@ -66,6 +67,16 @@ public Sector findById(final Long id) { .orElseThrow(() -> new SectorNotFoundException(id)); } + public SectorsDetailResponseDto findAllSectors() { + List sectorsResponse = sectorRepository + .findAll() + .stream() + .map( + SectorDetailResponseDto::toDto) + .toList(); + return new SectorsDetailResponseDto(sectorsResponse); + } + private Sector createSectorByDto(final Long gymId, final SectorCreateRequestDto createRequestDto) { if (hasNoRemovalDate(createRequestDto)) { diff --git a/src/main/java/com/first/flash/climbing/sector/ui/SectorController.java b/src/main/java/com/first/flash/climbing/sector/ui/SectorController.java index abddc8c4..9faef744 100644 --- a/src/main/java/com/first/flash/climbing/sector/ui/SectorController.java +++ b/src/main/java/com/first/flash/climbing/sector/ui/SectorController.java @@ -5,6 +5,7 @@ import com.first.flash.climbing.sector.application.dto.SectorUpdateRemovalDateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorUpdateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorDetailResponseDto; +import com.first.flash.climbing.sector.application.dto.SectorsDetailResponseDto; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; @@ -29,6 +30,15 @@ public class SectorController { private final SectorService sectorService; + @Operation(summary = "섹터 전체 조회", description = "모든 섹터의 정보를 반환") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공적으로 섹터를 조회"), + }) + @GetMapping("sectors") + public ResponseEntity findAllSectors() { + return ResponseEntity.ok(sectorService.findAllSectors()); + } + @Operation(summary = "섹터 갱신(생성)", description = "특정 클라이밍장에 새로운 섹터 생성") @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "성공적으로 섹터를 생성함"), @@ -58,7 +68,7 @@ public ResponseEntity updateSectorRemovalDate( @Operation(summary = "섹터 전체 수정", description = "특정 섹터의 정보 수정") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "성공적으로 섹터 탈거일을 수정함"), + @ApiResponse(responseCode = "200", description = "성공적으로 섹터 정보 수정함"), }) @PutMapping("sectors/{sectorId}") public ResponseEntity updateSector(