From d607a9b5534ce3a77197a092467a19cd93f7d649 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sat, 23 Nov 2024 17:26:30 +0900 Subject: [PATCH 01/65] =?UTF-8?q?feat:=20sector=20info=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../climbing/sector/domain/SectorInfo.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/sector/domain/SectorInfo.java diff --git a/src/main/java/com/first/flash/climbing/sector/domain/SectorInfo.java b/src/main/java/com/first/flash/climbing/sector/domain/SectorInfo.java new file mode 100644 index 00000000..70822d1d --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/domain/SectorInfo.java @@ -0,0 +1,45 @@ +package com.first.flash.climbing.sector.domain; + +import com.first.flash.climbing.sector.domain.vo.SectorName; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Entity +@NoArgsConstructor +@AllArgsConstructor +@Getter +@ToString +public class SectorInfo { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String selectedImageUrl; + private SectorName sectorName; + private Long gymId; + + protected SectorInfo(final String selectedImageUrl, final SectorName sectorName, + final Long gymId) { + this.selectedImageUrl = selectedImageUrl; + this.sectorName = sectorName; + this.gymId = gymId; + } + + public static SectorInfo createDefault(final String sectorName, final String adminSectorName, + final Long gymId, final String selectedImageUrl) { + return new SectorInfo(selectedImageUrl, SectorName.of(sectorName, adminSectorName), gymId); + } + + public void updateSectorInfo(final String sectorName, final String adminSectorName, + final Long gymId, final String selectedImageUrl) { + this.sectorName = SectorName.of(sectorName, adminSectorName); + this.selectedImageUrl = selectedImageUrl; + this.gymId = gymId; + } +} From 9126c27e0c115f6218732c0bef6934274fdc2709 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sat, 23 Nov 2024 17:26:50 +0900 Subject: [PATCH 02/65] =?UTF-8?q?feat:=20sector=EC=97=90=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=EB=90=98=EC=97=88=EC=9D=84=20=EB=95=8C=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20url=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flash/climbing/sector/domain/Sector.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/sector/domain/Sector.java b/src/main/java/com/first/flash/climbing/sector/domain/Sector.java index a40ccd64..0912b2f1 100644 --- a/src/main/java/com/first/flash/climbing/sector/domain/Sector.java +++ b/src/main/java/com/first/flash/climbing/sector/domain/Sector.java @@ -23,30 +23,34 @@ public class Sector { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + private String selectedImageUrl; private SectorName sectorName; private LocalDate settingDate; private RemovalInfo removalInfo; private Long gymId; protected Sector(final SectorName sectorName, final LocalDate settingDate, - final RemovalInfo removalInfo, final Long gymId) { + final RemovalInfo removalInfo, final Long gymId, final String selectedImageUrl) { this.sectorName = sectorName; this.settingDate = settingDate; this.removalInfo = removalInfo; + this.selectedImageUrl = selectedImageUrl; this.gymId = gymId; } public static Sector createExceptRemovalDate(final String sectorName, - final String adminSectorName, final LocalDate settingDate, final Long gymId) { + final String adminSectorName, final LocalDate settingDate, final Long gymId, + final String selectedImageUrl) { return new Sector(SectorName.of(sectorName, adminSectorName), settingDate, - RemovalInfo.createBySettingDate(settingDate), gymId); + RemovalInfo.createBySettingDate(settingDate), gymId, selectedImageUrl); } public static Sector createDefault(final String sectorName, final String adminSectorName, - final LocalDate settingDate, final LocalDate removalDate, final Long gymId) { + final LocalDate settingDate, final LocalDate removalDate, final Long gymId, + final String selectedImageUrl) { validateRemovalDate(settingDate, removalDate); return new Sector(SectorName.of(sectorName, adminSectorName), settingDate, - RemovalInfo.createDefault(removalDate), gymId); + RemovalInfo.createDefault(removalDate), gymId, selectedImageUrl); } public LocalDate getRemovalDate() { @@ -59,11 +63,13 @@ public void updateRemovalDate(final LocalDate removalDate) { } public void updateSector(final String sectorName, final String adminSectorName, - final LocalDate settingDate, final LocalDate removalDate, final Long gymId) { + final LocalDate settingDate, final LocalDate removalDate, final Long gymId, + final String selectedImageUrl) { validateRemovalDate(settingDate, removalDate); this.sectorName = SectorName.of(sectorName, adminSectorName); this.settingDate = settingDate; this.removalInfo = RemovalInfo.createDefault(removalDate); + this.selectedImageUrl = selectedImageUrl; this.gymId = gymId; } From 1d5107224c2a300ce54ebeb102e870b029c17c72 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sat, 23 Nov 2024 17:27:04 +0900 Subject: [PATCH 03/65] =?UTF-8?q?test:=20sector=EC=97=90=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=EB=90=98=EC=97=88=EC=9D=84=20=EB=95=8C=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20url=20=EC=B6=94=EA=B0=80=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B8=ED=95=9C=20=EB=B3=80=EA=B2=BD=20=EC=82=AC=ED=95=AD=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/first/flash/climbing/sector/domain/SectorTest.java | 7 ++++--- .../first/flash/climbing/sector/fixture/SectorFixture.java | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/first/flash/climbing/sector/domain/SectorTest.java b/src/test/java/com/first/flash/climbing/sector/domain/SectorTest.java index c4860bf4..b3921d39 100644 --- a/src/test/java/com/first/flash/climbing/sector/domain/SectorTest.java +++ b/src/test/java/com/first/flash/climbing/sector/domain/SectorTest.java @@ -9,6 +9,7 @@ class SectorTest { + private static final String DEFAULT_SECTOR_IMAGE = "example image url"; private static final Long DEFAULT_GYM_ID = 1L; @Test @@ -18,7 +19,7 @@ class SectorTest { // when & then assertThatThrownBy(() -> Sector.createDefault("test", "test", settingDate, - settingDate.minusDays(1), DEFAULT_GYM_ID)) + settingDate.minusDays(1), DEFAULT_GYM_ID, DEFAULT_SECTOR_IMAGE)) .isInstanceOf(InvalidRemovalDateException.class); } @@ -27,7 +28,7 @@ class SectorTest { // given LocalDate settingDate = LocalDate.now(); Sector sector = Sector.createExceptRemovalDate("test", "test", settingDate, - DEFAULT_GYM_ID); + DEFAULT_GYM_ID, DEFAULT_SECTOR_IMAGE); // when sector.updateRemovalDate(settingDate.plusDays(1)); @@ -42,7 +43,7 @@ class SectorTest { // given LocalDate settingDate = LocalDate.now(); Sector sector = Sector.createExceptRemovalDate("test", "test", settingDate, - DEFAULT_GYM_ID); + DEFAULT_GYM_ID, DEFAULT_SECTOR_IMAGE); // when & then assertThatThrownBy(() -> sector.updateRemovalDate(settingDate.minusDays(1))) diff --git a/src/test/java/com/first/flash/climbing/sector/fixture/SectorFixture.java b/src/test/java/com/first/flash/climbing/sector/fixture/SectorFixture.java index bf0fcd80..0cd9fef7 100644 --- a/src/test/java/com/first/flash/climbing/sector/fixture/SectorFixture.java +++ b/src/test/java/com/first/flash/climbing/sector/fixture/SectorFixture.java @@ -6,17 +6,18 @@ public class SectorFixture { + private static final String DEFAULT_SECTOR_IMAGE = "example image url"; private final static Long DEFAULT_PLUS_DAYS = 30L; public static Sector createDefault(final Long gymId, final LocalDate settingDate) { return Sector.createDefault("sector 1", "admin sector 1", - settingDate, settingDate.plusDays(DEFAULT_PLUS_DAYS), gymId); + settingDate, settingDate.plusDays(DEFAULT_PLUS_DAYS), gymId, DEFAULT_SECTOR_IMAGE); } public static Sector createDefaultExceptRemovalDate(final Long gymId, final LocalDate settingDate) { return Sector.createExceptRemovalDate("sector 1", "admin sector 1", - settingDate, gymId); + settingDate, gymId, DEFAULT_SECTOR_IMAGE); } public static SectorCreateRequestDto createDefaultRequestDtoExceptRemovalDate( From e504ed5162b3db868c0fe32a94bcf5f59a73b7c0 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sat, 23 Nov 2024 17:32:18 +0900 Subject: [PATCH 04/65] =?UTF-8?q?feat:=20sector=20info=EC=9D=98=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=EC=A0=81=EC=9D=B8=20=EB=A6=AC=ED=8F=AC?= =?UTF-8?q?=EC=A7=80=ED=86=A0=EB=A6=AC=20=EA=B8=B0=EB=8A=A5=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 --- .../sector/domain/SectorInfoRepository.java | 13 ++++++++ .../SectorInfoJpaRepository.java | 15 ++++++++++ .../SectorInfoRepositoryImpl.java | 30 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/sector/domain/SectorInfoRepository.java create mode 100644 src/main/java/com/first/flash/climbing/sector/infrastructure/SectorInfoJpaRepository.java create mode 100644 src/main/java/com/first/flash/climbing/sector/infrastructure/SectorInfoRepositoryImpl.java diff --git a/src/main/java/com/first/flash/climbing/sector/domain/SectorInfoRepository.java b/src/main/java/com/first/flash/climbing/sector/domain/SectorInfoRepository.java new file mode 100644 index 00000000..3f538ff6 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/domain/SectorInfoRepository.java @@ -0,0 +1,13 @@ +package com.first.flash.climbing.sector.domain; + +import java.util.List; +import java.util.Optional; + +public interface SectorInfoRepository { + + SectorInfo save(SectorInfo sectorInfo); + + Optional findById(Long id); + + List findAll(); +} diff --git a/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorInfoJpaRepository.java b/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorInfoJpaRepository.java new file mode 100644 index 00000000..616b8942 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorInfoJpaRepository.java @@ -0,0 +1,15 @@ +package com.first.flash.climbing.sector.infrastructure; + +import com.first.flash.climbing.sector.domain.SectorInfo; +import java.util.List; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface SectorInfoJpaRepository extends JpaRepository { + + SectorInfo save(final SectorInfo sector); + + Optional findById(final Long id); + + List findAll(); +} diff --git a/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorInfoRepositoryImpl.java b/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorInfoRepositoryImpl.java new file mode 100644 index 00000000..cf55a1ac --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorInfoRepositoryImpl.java @@ -0,0 +1,30 @@ +package com.first.flash.climbing.sector.infrastructure; + +import com.first.flash.climbing.sector.domain.SectorInfo; +import com.first.flash.climbing.sector.domain.SectorInfoRepository; +import java.util.List; +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; + +@Repository +@RequiredArgsConstructor +public class SectorInfoRepositoryImpl implements SectorInfoRepository { + + private final SectorInfoJpaRepository jpaRepository; + + @Override + public SectorInfo save(final SectorInfo sectorInfo) { + return jpaRepository.save(sectorInfo); + } + + @Override + public Optional findById(final Long id) { + return jpaRepository.findById(id); + } + + @Override + public List findAll() { + return jpaRepository.findAll(); + } +} From 01174832f5c1ba172c9a03191bd09c41621c1d49 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sat, 23 Nov 2024 17:44:57 +0900 Subject: [PATCH 05/65] =?UTF-8?q?feat:=20=ED=8A=B9=EC=A0=95=20gym=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=EC=9C=BC=EB=A1=9C=20=EC=A0=9C=EA=B3=B5?= =?UTF-8?q?=ED=95=A0=20=EC=84=B9=ED=84=B0=20dto=EC=97=90=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=EB=90=98=EC=97=88=EC=9D=84=20=EB=95=8C=20=EC=A7=80?= =?UTF-8?q?=EB=8F=84=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=8F=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=9C=20dto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gym/infrastructure/dto/SectorInfoResponseDto.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/gym/infrastructure/dto/SectorInfoResponseDto.java diff --git a/src/main/java/com/first/flash/climbing/gym/infrastructure/dto/SectorInfoResponseDto.java b/src/main/java/com/first/flash/climbing/gym/infrastructure/dto/SectorInfoResponseDto.java new file mode 100644 index 00000000..16e6cca2 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/gym/infrastructure/dto/SectorInfoResponseDto.java @@ -0,0 +1,5 @@ +package com.first.flash.climbing.gym.infrastructure.dto; + +public record SectorInfoResponseDto(String name, String selectedImageUrl) { + +} From 34a9a34eeb672b2107a11bca6151ccc090789930 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sat, 23 Nov 2024 17:46:37 +0900 Subject: [PATCH 06/65] =?UTF-8?q?feat:=20=EB=B3=80=EA=B2=BD=EB=90=9C=20sec?= =?UTF-8?q?tor=20=EC=A0=95=EB=B3=B4=20dto=EB=A5=BC=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../climbing/gym/application/ClimbingGymService.java | 5 +++-- .../gym/application/dto/ClimbingGymDetailResponseDto.java | 3 ++- .../flash/climbing/gym/domian/ClimbingGymRepository.java | 3 ++- .../gym/infrastructure/ClimbingGymQueryDslRepository.java | 8 ++++++-- .../gym/infrastructure/ClimbingGymRepositoryImpl.java | 3 ++- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java b/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java index 35ef6600..2ebebb94 100644 --- a/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java +++ b/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java @@ -8,6 +8,7 @@ import com.first.flash.climbing.gym.domian.ClimbingGymRepository; import com.first.flash.climbing.gym.domian.vo.Difficulty; import com.first.flash.climbing.gym.exception.exceptions.ClimbingGymNotFoundException; +import com.first.flash.climbing.gym.infrastructure.dto.SectorInfoResponseDto; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -39,14 +40,14 @@ public List findAllClimbingGyms() { public ClimbingGymDetailResponseDto findClimbingGymDetail(final Long id) { ClimbingGym climbingGym = findClimbingGymById(id); - List sectorNames = findSectorNamesById(id); + List sectorNames = findSectorNamesById(id); List difficultyNames = getDifficultyNames(climbingGym); return new ClimbingGymDetailResponseDto(climbingGym.getGymName(), climbingGym.getMapImageUrl(), climbingGym.getCalendarImageUrl(), difficultyNames, sectorNames); } - private List findSectorNamesById(final Long id) { + private List findSectorNamesById(final Long id) { return climbingGymRepository.findGymSectorNamesById(id); } diff --git a/src/main/java/com/first/flash/climbing/gym/application/dto/ClimbingGymDetailResponseDto.java b/src/main/java/com/first/flash/climbing/gym/application/dto/ClimbingGymDetailResponseDto.java index f2f1f822..fb9260ef 100644 --- a/src/main/java/com/first/flash/climbing/gym/application/dto/ClimbingGymDetailResponseDto.java +++ b/src/main/java/com/first/flash/climbing/gym/application/dto/ClimbingGymDetailResponseDto.java @@ -1,10 +1,11 @@ package com.first.flash.climbing.gym.application.dto; +import com.first.flash.climbing.gym.infrastructure.dto.SectorInfoResponseDto; import java.util.List; public record ClimbingGymDetailResponseDto(String gymName, String mapImageUrl, String calendarImageUrl, List difficulties, - List sectors) { + List sectors) { } diff --git a/src/main/java/com/first/flash/climbing/gym/domian/ClimbingGymRepository.java b/src/main/java/com/first/flash/climbing/gym/domian/ClimbingGymRepository.java index e5e665f0..0f25f1ae 100644 --- a/src/main/java/com/first/flash/climbing/gym/domian/ClimbingGymRepository.java +++ b/src/main/java/com/first/flash/climbing/gym/domian/ClimbingGymRepository.java @@ -1,5 +1,6 @@ package com.first.flash.climbing.gym.domian; +import com.first.flash.climbing.gym.infrastructure.dto.SectorInfoResponseDto; import java.util.List; import java.util.Optional; @@ -11,5 +12,5 @@ public interface ClimbingGymRepository { List findAll(); - List findGymSectorNamesById(final Long id); + List findGymSectorNamesById(final Long id); } diff --git a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java index 215c7d32..fd9ed2f8 100644 --- a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java +++ b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java @@ -2,6 +2,8 @@ import static com.first.flash.climbing.sector.domain.QSector.sector; +import com.first.flash.climbing.gym.infrastructure.dto.SectorInfoResponseDto; +import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; import lombok.RequiredArgsConstructor; @@ -13,8 +15,10 @@ public class ClimbingGymQueryDslRepository { private final JPAQueryFactory jpaQueryFactory; - public List findSortedSectorNamesByGymId(final Long gymId) { - return jpaQueryFactory.select(sector.sectorName.name) + public List findSortedSectorNamesByGymId(final Long gymId) { + return jpaQueryFactory.select( + Projections.constructor(SectorInfoResponseDto.class, sector.sectorName.name, + sector.selectedImageUrl)) .from(sector) .where(sector.gymId.eq(gymId), sector.removalInfo.isExpired.isFalse()) .distinct() diff --git a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymRepositoryImpl.java b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymRepositoryImpl.java index ea93b6f0..2f504fb0 100644 --- a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymRepositoryImpl.java +++ b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymRepositoryImpl.java @@ -2,6 +2,7 @@ import com.first.flash.climbing.gym.domian.ClimbingGym; import com.first.flash.climbing.gym.domian.ClimbingGymRepository; +import com.first.flash.climbing.gym.infrastructure.dto.SectorInfoResponseDto; import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; @@ -30,7 +31,7 @@ public List findAll() { } @Override - public List findGymSectorNamesById(final Long id) { + public List findGymSectorNamesById(final Long id) { return climbingGymQueryDslRepository.findSortedSectorNamesByGymId(id); } } From 288d3450b08b817618a6a1b148fb930173a08d73 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sat, 23 Nov 2024 18:34:11 +0900 Subject: [PATCH 07/65] =?UTF-8?q?refactor:=20=ED=94=84=EB=A1=9C=ED=8D=BC?= =?UTF-8?q?=ED=8B=B0=20=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/first/flash/climbing/sector/domain/Sector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/first/flash/climbing/sector/domain/Sector.java b/src/main/java/com/first/flash/climbing/sector/domain/Sector.java index 0912b2f1..ad51ace5 100644 --- a/src/main/java/com/first/flash/climbing/sector/domain/Sector.java +++ b/src/main/java/com/first/flash/climbing/sector/domain/Sector.java @@ -23,10 +23,10 @@ public class Sector { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - private String selectedImageUrl; private SectorName sectorName; private LocalDate settingDate; private RemovalInfo removalInfo; + private String selectedImageUrl; private Long gymId; protected Sector(final SectorName sectorName, final LocalDate settingDate, From c4073649bc8b8fb9c50034f6f5bc18a8c53defa0 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sat, 23 Nov 2024 18:34:41 +0900 Subject: [PATCH 08/65] =?UTF-8?q?feat:=20sector=EC=9D=98=20=EA=B3=A0?= =?UTF-8?q?=EC=A0=95=20=EC=A0=95=EB=B3=B4=20=EC=83=9D=EC=84=B1=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sector/application/SectorService.java | 32 ++++++++++++++----- .../dto/SectorInfoCreateRequestDto.java | 5 +++ .../dto/SectorInfoDetailResponseDto.java | 13 ++++++++ 3 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoCreateRequestDto.java create mode 100644 src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoDetailResponseDto.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 ce7fffc7..116a052e 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 @@ -3,11 +3,15 @@ import com.first.flash.climbing.gym.domian.ClimbingGymIdConfirmRequestedEvent; import com.first.flash.climbing.sector.application.dto.SectorCreateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorDetailResponseDto; +import com.first.flash.climbing.sector.application.dto.SectorInfoCreateRequestDto; +import com.first.flash.climbing.sector.application.dto.SectorInfoDetailResponseDto; 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.SectorsDetailResponseDto; import com.first.flash.climbing.sector.domain.Sector; import com.first.flash.climbing.sector.domain.SectorExpiredEvent; +import com.first.flash.climbing.sector.domain.SectorInfo; +import com.first.flash.climbing.sector.domain.SectorInfoRepository; import com.first.flash.climbing.sector.domain.SectorInfoUpdatedEvent; import com.first.flash.climbing.sector.domain.SectorRemovalDateUpdatedEvent; import com.first.flash.climbing.sector.domain.SectorRepository; @@ -26,6 +30,7 @@ public class SectorService { private final SectorRepository sectorRepository; + private final SectorInfoRepository sectorInfoRepository; @Transactional public SectorDetailResponseDto saveSector(final Long gymId, @@ -36,6 +41,15 @@ public SectorDetailResponseDto saveSector(final Long gymId, return SectorDetailResponseDto.toDto(sectorRepository.save(sector)); } + + @Transactional + public SectorInfoDetailResponseDto saveSectorInfo(final Long gymId, + final SectorInfoCreateRequestDto createRequestDto) { + SectorInfo sectorInfo = SectorInfo.createDefault(createRequestDto.name(), + createRequestDto.adminName(), gymId, createRequestDto.selectedImageUrl()); + Events.raise(ClimbingGymIdConfirmRequestedEvent.of(gymId)); + return SectorInfoDetailResponseDto.toDto(sectorInfoRepository.save(sectorInfo)); + } @Transactional public SectorDetailResponseDto updateSectorRemovalDate(final Long sectorId, @@ -58,9 +72,9 @@ public SectorDetailResponseDto updateSector( final Long sectorId, final SectorUpdateRequestDto updateRequestDto) { Sector foundSector = findById(sectorId); - foundSector.updateSector(updateRequestDto.sectorName(), updateRequestDto.adminSectorName(), - updateRequestDto.settingDate(), - updateRequestDto.removalDate(), updateRequestDto.gymId()); +// foundSector.updateSector(updateRequestDto.sectorName(), updateRequestDto.adminSectorName(), +// updateRequestDto.settingDate(), +// updateRequestDto.removalDate(), updateRequestDto.gymId()); Events.raise(SectorInfoUpdatedEvent.of(foundSector.getId(), updateRequestDto.sectorName(), updateRequestDto.settingDate())); Events.raise(ClimbingGymIdConfirmRequestedEvent.of(updateRequestDto.gymId())); @@ -85,13 +99,15 @@ public SectorsDetailResponseDto findAllSectors() { private Sector createSectorByDto(final Long gymId, final SectorCreateRequestDto createRequestDto) { if (hasNoRemovalDate(createRequestDto)) { - return Sector.createExceptRemovalDate(createRequestDto.name(), - createRequestDto.adminName(), createRequestDto.settingDate(), gymId); +// return Sector.createExceptRemovalDate(createRequestDto.name(), +// createRequestDto.adminName(), createRequestDto.settingDate(), gymId); + return null; } - return Sector.createDefault(createRequestDto.name(), - createRequestDto.adminName(), createRequestDto.settingDate(), - createRequestDto.removalDate(), gymId); +// return Sector.createDefault(createRequestDto.name(), +// createRequestDto.adminName(), createRequestDto.settingDate(), +// createRequestDto.removalDate(), gymId); + return null; } private static boolean hasNoRemovalDate(final SectorCreateRequestDto createRequestDto) { diff --git a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoCreateRequestDto.java b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoCreateRequestDto.java new file mode 100644 index 00000000..edfce6b9 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoCreateRequestDto.java @@ -0,0 +1,5 @@ +package com.first.flash.climbing.sector.application.dto; + +public record SectorInfoCreateRequestDto(String name, String adminName, String selectedImageUrl) { + +} diff --git a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoDetailResponseDto.java b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoDetailResponseDto.java new file mode 100644 index 00000000..efc8f819 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoDetailResponseDto.java @@ -0,0 +1,13 @@ +package com.first.flash.climbing.sector.application.dto; + +import com.first.flash.climbing.sector.domain.SectorInfo; +import com.first.flash.climbing.sector.domain.vo.SectorName; + +public record SectorInfoDetailResponseDto(Long id, SectorName sectorName, String selectedImageUrl, + Long gymId) { + + public static SectorInfoDetailResponseDto toDto(final SectorInfo sectorInfo) { + return new SectorInfoDetailResponseDto(sectorInfo.getId(), sectorInfo.getSectorName(), + sectorInfo.getSelectedImageUrl(), sectorInfo.getGymId()); + } +} From c812641cf9786099b0ad71b2fc650bcaedf719e5 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 11:00:57 +0900 Subject: [PATCH 09/65] =?UTF-8?q?refactor:=20=ED=83=88=EA=B1=B0=EC=9D=BC?= =?UTF-8?q?=20=EC=9C=A0=EB=AC=B4=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=A9=EB=B2=95=20=EB=B6=84=EA=B8=B0=EB=A5=BC=20?= =?UTF-8?q?sector=EC=97=90=EC=84=9C=20=EC=B2=98=EB=A6=AC=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flash/climbing/sector/domain/Sector.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/com/first/flash/climbing/sector/domain/Sector.java b/src/main/java/com/first/flash/climbing/sector/domain/Sector.java index ad51ace5..a6439a02 100644 --- a/src/main/java/com/first/flash/climbing/sector/domain/Sector.java +++ b/src/main/java/com/first/flash/climbing/sector/domain/Sector.java @@ -8,7 +8,9 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import java.time.LocalDate; +import java.util.Objects; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; @@ -17,6 +19,7 @@ @NoArgsConstructor @AllArgsConstructor @Getter +@Builder @ToString public class Sector { @@ -38,6 +41,18 @@ protected Sector(final SectorName sectorName, final LocalDate settingDate, this.gymId = gymId; } + public static Sector of(final SectorName sectorName, final LocalDate settingDate, + final LocalDate removalDate, final Long gymId, + final String selectedImageUrl) { + if (hasNoRemovalDate(removalDate)) { + return createExceptRemovalDate(sectorName.getName(), sectorName.getAdminName(), + settingDate, gymId, selectedImageUrl); + } + + return createDefault(sectorName.getName(), sectorName.getAdminName(), settingDate, + removalDate, gymId, selectedImageUrl); + } + public static Sector createExceptRemovalDate(final String sectorName, final String adminSectorName, final LocalDate settingDate, final Long gymId, final String selectedImageUrl) { @@ -79,4 +94,8 @@ private static void validateRemovalDate(final LocalDate settingDate, throw new InvalidRemovalDateException(); } } + + private static boolean hasNoRemovalDate(final LocalDate removalDate) { + return Objects.isNull(removalDate); + } } From 113636c27abcc9808dc2ee92fe6a3180ae42e1d7 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 11:02:58 +0900 Subject: [PATCH 10/65] =?UTF-8?q?feat:=20=EA=B3=A0=EC=A0=95=20=EC=84=B9?= =?UTF-8?q?=ED=84=B0=20=EC=A0=95=EB=B3=B4=EC=99=80=20=EA=B0=80=EB=B3=80=20?= =?UTF-8?q?=EC=84=B9=ED=84=B0=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=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 --- .../sector/application/SectorService.java | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) 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 116a052e..3e2bb2ab 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 @@ -15,11 +15,11 @@ 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.SectorInfoNotFoundException; import com.first.flash.climbing.sector.exception.exceptions.SectorNotFoundException; import com.first.flash.global.event.Events; import java.time.LocalDate; import java.util.List; -import java.util.Objects; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -33,15 +33,13 @@ public class SectorService { private final SectorInfoRepository sectorInfoRepository; @Transactional - public SectorDetailResponseDto saveSector(final Long gymId, + public SectorDetailResponseDto saveSector(final Long sectorInfoId, final SectorCreateRequestDto createRequestDto) { - - Sector sector = createSectorByDto(gymId, createRequestDto); - Events.raise(ClimbingGymIdConfirmRequestedEvent.of(gymId)); - + SectorInfo sectorInfo = findSectorInfoById(sectorInfoId); + Sector sector = createSector(sectorInfo, createRequestDto); return SectorDetailResponseDto.toDto(sectorRepository.save(sector)); } - + @Transactional public SectorInfoDetailResponseDto saveSectorInfo(final Long gymId, final SectorInfoCreateRequestDto createRequestDto) { @@ -96,21 +94,16 @@ public SectorsDetailResponseDto findAllSectors() { return new SectorsDetailResponseDto(sectorsResponse); } - private Sector createSectorByDto(final Long gymId, + private Sector createSector(final SectorInfo sectorInfo, final SectorCreateRequestDto createRequestDto) { - if (hasNoRemovalDate(createRequestDto)) { -// return Sector.createExceptRemovalDate(createRequestDto.name(), -// createRequestDto.adminName(), createRequestDto.settingDate(), gymId); - return null; - } - -// return Sector.createDefault(createRequestDto.name(), -// createRequestDto.adminName(), createRequestDto.settingDate(), -// createRequestDto.removalDate(), gymId); - return null; + return Sector.of(sectorInfo.getSectorName(), createRequestDto.settingDate(), + createRequestDto.removalDate(), sectorInfo.getGymId(), + sectorInfo.getSelectedImageUrl()); } - private static boolean hasNoRemovalDate(final SectorCreateRequestDto createRequestDto) { - return Objects.isNull(createRequestDto.removalDate()); + private SectorInfo findSectorInfoById(final Long sectorInfoId) { + return sectorInfoRepository.findById(sectorInfoId) + .orElseThrow( + () -> new SectorInfoNotFoundException(sectorInfoId)); } } From 4310dcd0bc8ac3c8db811cbf25f02e8d084e3ac6 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 11:03:20 +0900 Subject: [PATCH 11/65] =?UTF-8?q?feat:=20=EA=B3=A0=EC=A0=95=20=EC=84=B9?= =?UTF-8?q?=ED=84=B0=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=B0=BE=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=20=EC=97=86=EC=9D=84=20=EB=95=8C=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sector/application/dto/SectorInfoCreateRequestDto.java | 6 +++++- .../climbing/sector/exception/SectorExceptionHandler.java | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoCreateRequestDto.java b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoCreateRequestDto.java index edfce6b9..2a76ff3c 100644 --- a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoCreateRequestDto.java +++ b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfoCreateRequestDto.java @@ -1,5 +1,9 @@ package com.first.flash.climbing.sector.application.dto; -public record SectorInfoCreateRequestDto(String name, String adminName, String selectedImageUrl) { +import jakarta.validation.constraints.NotEmpty; + +public record SectorInfoCreateRequestDto(@NotEmpty(message = "섹터 이름은 필수입니다.") String name, + @NotEmpty(message = "섹터 관리 이름은 필수입니다.") String adminName, + String selectedImageUrl) { } diff --git a/src/main/java/com/first/flash/climbing/sector/exception/SectorExceptionHandler.java b/src/main/java/com/first/flash/climbing/sector/exception/SectorExceptionHandler.java index 5f9041ab..e6de5464 100644 --- a/src/main/java/com/first/flash/climbing/sector/exception/SectorExceptionHandler.java +++ b/src/main/java/com/first/flash/climbing/sector/exception/SectorExceptionHandler.java @@ -1,6 +1,7 @@ package com.first.flash.climbing.sector.exception; import com.first.flash.climbing.sector.exception.exceptions.InvalidRemovalDateException; +import com.first.flash.climbing.sector.exception.exceptions.SectorInfoNotFoundException; import com.first.flash.climbing.sector.exception.exceptions.SectorNotFoundException; import com.first.flash.global.dto.ErrorResponseDto; import org.springframework.http.HttpStatus; @@ -17,6 +18,12 @@ public ResponseEntity handleSectorNotFoundException( return getResponseWithStatus(HttpStatus.NOT_FOUND, exception); } + @ExceptionHandler(SectorInfoNotFoundException.class) + public ResponseEntity handleSectorInfoNotFoundException( + final SectorInfoNotFoundException exception) { + return getResponseWithStatus(HttpStatus.NOT_FOUND, exception); + } + @ExceptionHandler(InvalidRemovalDateException.class) public ResponseEntity handleInvalidRemovalDateException( final InvalidRemovalDateException exception) { From 0afb1ebd0631f90088bb1cddf328a2cd7436e8c6 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 11:03:49 +0900 Subject: [PATCH 12/65] =?UTF-8?q?feat:=20=EA=B3=A0=EC=A0=95=20=EC=84=B9?= =?UTF-8?q?=ED=84=B0=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=B0=BE=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=20=EC=97=86=EC=9D=84=20=EB=95=8C=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=ED=95=A0=20=EC=98=88=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/exceptions/SectorInfoNotFoundException.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/sector/exception/exceptions/SectorInfoNotFoundException.java diff --git a/src/main/java/com/first/flash/climbing/sector/exception/exceptions/SectorInfoNotFoundException.java b/src/main/java/com/first/flash/climbing/sector/exception/exceptions/SectorInfoNotFoundException.java new file mode 100644 index 00000000..c216cc31 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/exception/exceptions/SectorInfoNotFoundException.java @@ -0,0 +1,8 @@ +package com.first.flash.climbing.sector.exception.exceptions; + +public class SectorInfoNotFoundException extends RuntimeException { + + public SectorInfoNotFoundException(final Long id) { + super(String.format("아이디가 %s인 섹터 정보를 찾을 수 없습니다.", id)); + } +} From bef83bd2eb02a4a265cf0e5756f094bbaf5131b1 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 11:04:20 +0900 Subject: [PATCH 13/65] =?UTF-8?q?feat:=20=EA=B3=A0=EC=A0=95=20=EC=84=B9?= =?UTF-8?q?=ED=84=B0=20=EC=A0=95=EB=B3=B4=EC=99=80=20=EA=B0=80=EB=B3=80=20?= =?UTF-8?q?=EC=84=B9=ED=84=B0=20=EC=A0=95=EB=B3=B4=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/SectorCreateRequestDto.java | 5 +--- .../climbing/sector/ui/SectorController.java | 29 +++++++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorCreateRequestDto.java b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorCreateRequestDto.java index 7472783c..821eece0 100644 --- a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorCreateRequestDto.java +++ b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorCreateRequestDto.java @@ -1,13 +1,10 @@ package com.first.flash.climbing.sector.application.dto; -import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import java.time.LocalDate; public record SectorCreateRequestDto( - @NotEmpty(message = "섹터 이름은 필수입니다.") String name, - @NotEmpty(message = "섹터 관리 이름은 필수입니다.") String adminName, @NotNull(message = "세팅일 정보는 비어있을 수 없습니다.") LocalDate settingDate, LocalDate removalDate) { -} \ No newline at end of file +} 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 082e11b1..1cff088d 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 @@ -3,6 +3,8 @@ import com.first.flash.climbing.sector.application.SectorService; import com.first.flash.climbing.sector.application.dto.SectorCreateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorDetailResponseDto; +import com.first.flash.climbing.sector.application.dto.SectorInfoCreateRequestDto; +import com.first.flash.climbing.sector.application.dto.SectorInfoDetailResponseDto; 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.SectorsDetailResponseDto; @@ -44,6 +46,27 @@ public ResponseEntity findAllSectors() { return ResponseEntity.ok(sectorService.findAllSectors()); } + @Operation(summary = "섹터 고정 정보 생성", description = "특정 클라이밍장의 새로운 섹터 고정 정보 생성") + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "성공적으로 섹터를 생성함", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = SectorInfoDetailResponseDto.class))), + @ApiResponse(responseCode = "400", description = "유효하지 않은 요청 형식", + content = @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "요청값 누락", value = "{\"name\": \"섹터 이름은 필수입니다.\"}"), + })), + @ApiResponse(responseCode = "404", description = "클라이밍장을 찾을 수 없음", + content = @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "클라이밍장 없음", value = "{\"error\": \"아이디가 1인 클라이밍장을 찾을 수 없습니다.\"}") + })) + }) + @PostMapping("admin/gyms/{gymId}/sectorInfos") + public ResponseEntity createSectorInfo( + @PathVariable final Long gymId, + @Valid @RequestBody final SectorInfoCreateRequestDto sectorInfoCreateRequestDto) { + return ResponseEntity.status(HttpStatus.CREATED) + .body(sectorService.saveSectorInfo(gymId, sectorInfoCreateRequestDto)); + } + @Operation(summary = "섹터 갱신(생성)", description = "특정 클라이밍장에 새로운 섹터 생성") @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "성공적으로 섹터를 생성함", @@ -58,11 +81,11 @@ public ResponseEntity findAllSectors() { @ExampleObject(name = "클라이밍장 없음", value = "{\"error\": \"아이디가 1인 클라이밍장을 찾을 수 없습니다.\"}") })) }) - @PostMapping("admin/gyms/{gymId}/sectors") - public ResponseEntity createSector(@PathVariable final Long gymId, + @PostMapping("admin/sectorInfos/{sectorInfoId}") + public ResponseEntity createSector(@PathVariable final Long sectorInfoId, @Valid @RequestBody final SectorCreateRequestDto sectorCreateRequestDto) { return ResponseEntity.status(HttpStatus.CREATED) - .body(sectorService.saveSector(gymId, sectorCreateRequestDto)); + .body(sectorService.saveSector(sectorInfoId, sectorCreateRequestDto)); } @Operation(summary = "섹터 탈거일 수정", description = "특정 섹터의 탈거일 정보 수정") From 76ecdeb8a18afad48961445464b5e8048f1404f5 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 17:38:27 +0900 Subject: [PATCH 14/65] =?UTF-8?q?feat:=20=EA=B3=A0=EC=A0=95=20=EC=84=B9?= =?UTF-8?q?=ED=84=B0=20=EC=A0=95=EB=B3=B4=20id=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flash/climbing/sector/domain/Sector.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/sector/domain/Sector.java b/src/main/java/com/first/flash/climbing/sector/domain/Sector.java index a6439a02..ff7fe5e6 100644 --- a/src/main/java/com/first/flash/climbing/sector/domain/Sector.java +++ b/src/main/java/com/first/flash/climbing/sector/domain/Sector.java @@ -31,41 +31,44 @@ public class Sector { private RemovalInfo removalInfo; private String selectedImageUrl; private Long gymId; + private Long sectorInfoId; protected Sector(final SectorName sectorName, final LocalDate settingDate, - final RemovalInfo removalInfo, final Long gymId, final String selectedImageUrl) { + final RemovalInfo removalInfo, final Long gymId, final String selectedImageUrl, + final Long sectorInfoId) { this.sectorName = sectorName; this.settingDate = settingDate; this.removalInfo = removalInfo; this.selectedImageUrl = selectedImageUrl; this.gymId = gymId; + this.sectorInfoId = sectorInfoId; } public static Sector of(final SectorName sectorName, final LocalDate settingDate, final LocalDate removalDate, final Long gymId, - final String selectedImageUrl) { + final String selectedImageUrl, final Long sectorInfoId) { if (hasNoRemovalDate(removalDate)) { return createExceptRemovalDate(sectorName.getName(), sectorName.getAdminName(), - settingDate, gymId, selectedImageUrl); + settingDate, gymId, selectedImageUrl, sectorInfoId); } return createDefault(sectorName.getName(), sectorName.getAdminName(), settingDate, - removalDate, gymId, selectedImageUrl); + removalDate, gymId, selectedImageUrl, sectorInfoId); } public static Sector createExceptRemovalDate(final String sectorName, final String adminSectorName, final LocalDate settingDate, final Long gymId, - final String selectedImageUrl) { + final String selectedImageUrl, final Long sectorInfoId) { return new Sector(SectorName.of(sectorName, adminSectorName), settingDate, - RemovalInfo.createBySettingDate(settingDate), gymId, selectedImageUrl); + RemovalInfo.createBySettingDate(settingDate), gymId, selectedImageUrl, sectorInfoId); } public static Sector createDefault(final String sectorName, final String adminSectorName, final LocalDate settingDate, final LocalDate removalDate, final Long gymId, - final String selectedImageUrl) { + final String selectedImageUrl, final Long sectorInfoId) { validateRemovalDate(settingDate, removalDate); return new Sector(SectorName.of(sectorName, adminSectorName), settingDate, - RemovalInfo.createDefault(removalDate), gymId, selectedImageUrl); + RemovalInfo.createDefault(removalDate), gymId, selectedImageUrl, sectorInfoId); } public LocalDate getRemovalDate() { @@ -78,14 +81,16 @@ public void updateRemovalDate(final LocalDate removalDate) { } public void updateSector(final String sectorName, final String adminSectorName, - final LocalDate settingDate, final LocalDate removalDate, final Long gymId, - final String selectedImageUrl) { + final LocalDate settingDate, final LocalDate removalDate, final String selectedImageUrl) { validateRemovalDate(settingDate, removalDate); this.sectorName = SectorName.of(sectorName, adminSectorName); this.settingDate = settingDate; - this.removalInfo = RemovalInfo.createDefault(removalDate); + this.removalInfo = RemovalInfo.createByNewRemovalDate(removalDate); this.selectedImageUrl = selectedImageUrl; - this.gymId = gymId; + } + + public boolean isExpired() { + return removalInfo.getIsExpired(); } private static void validateRemovalDate(final LocalDate settingDate, From 06d3f4ad4a863d543c5b19977b079f3afcb56786 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 17:39:11 +0900 Subject: [PATCH 15/65] =?UTF-8?q?feat:=20=EC=83=88=EB=A1=9C=EC=9A=B4=20rem?= =?UTF-8?q?oval=20date=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EB=A7=8C=EB=A3=8C?= =?UTF-8?q?=20=EC=97=AC=EB=B6=80=20=ED=8C=90=EB=8B=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../first/flash/climbing/sector/domain/vo/RemovalInfo.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/first/flash/climbing/sector/domain/vo/RemovalInfo.java b/src/main/java/com/first/flash/climbing/sector/domain/vo/RemovalInfo.java index 0e308ab0..aa555463 100644 --- a/src/main/java/com/first/flash/climbing/sector/domain/vo/RemovalInfo.java +++ b/src/main/java/com/first/flash/climbing/sector/domain/vo/RemovalInfo.java @@ -35,4 +35,11 @@ public static RemovalInfo createBySettingDate(final LocalDate settingDate) { public static RemovalInfo createDefault(final LocalDate removalDate) { return new RemovalInfo(removalDate, false, false); } + + public static RemovalInfo createByNewRemovalDate(final LocalDate removalDate) { + if (removalDate.isBefore(LocalDate.now())) { + return new RemovalInfo(removalDate, false, true); + } + return new RemovalInfo(removalDate, false, false); + } } From 54d6fa12f7b775642df086db159f0409e15bd72a Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 17:40:05 +0900 Subject: [PATCH 16/65] =?UTF-8?q?feat:=20=ED=95=B4=EB=8B=B9=20=EC=84=B9?= =?UTF-8?q?=ED=84=B0=EC=9D=98=20=ED=81=B4=EB=9D=BC=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=EC=9E=A5=EC=9D=80=20=EC=88=98=EC=A0=95=20=EB=B6=88=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/first/flash/climbing/sector/domain/SectorInfo.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/sector/domain/SectorInfo.java b/src/main/java/com/first/flash/climbing/sector/domain/SectorInfo.java index 70822d1d..36da6bd0 100644 --- a/src/main/java/com/first/flash/climbing/sector/domain/SectorInfo.java +++ b/src/main/java/com/first/flash/climbing/sector/domain/SectorInfo.java @@ -37,9 +37,8 @@ public static SectorInfo createDefault(final String sectorName, final String adm } public void updateSectorInfo(final String sectorName, final String adminSectorName, - final Long gymId, final String selectedImageUrl) { + final String selectedImageUrl) { this.sectorName = SectorName.of(sectorName, adminSectorName); this.selectedImageUrl = selectedImageUrl; - this.gymId = gymId; } } From 1d504521aeefd1632757eaef793347ab1d76ea00 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 17:41:28 +0900 Subject: [PATCH 17/65] =?UTF-8?q?feat:=20=EC=84=B9=ED=84=B0=EC=9D=98=20?= =?UTF-8?q?=EA=B3=A0=EC=A0=95=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=A0=84=EC=9D=B4=EC=99=80=20=EA=B0=80=EB=B3=80=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EC=A0=84=EC=9D=B4=EB=A5=BC=20?= =?UTF-8?q?=EA=B0=81=EA=B0=81=20=EB=8B=A4=EB=A5=B8=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=EB=A1=9C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sector/application/SectorService.java | 25 ++++++++++++++----- .../dto/SectorUpdateRequestDto.java | 9 ++----- .../sector/domain/SectorInfoUpdatedEvent.java | 5 ++-- .../sector/domain/SectorRepository.java | 5 ++++ .../SectorQueryDslRepository.java | 18 +++++++++++++ .../infrastructure/SectorRepositoryImpl.java | 12 +++++++++ 6 files changed, 59 insertions(+), 15 deletions(-) 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 3e2bb2ab..bbbda082 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 @@ -1,6 +1,7 @@ package com.first.flash.climbing.sector.application; import com.first.flash.climbing.gym.domian.ClimbingGymIdConfirmRequestedEvent; +import com.first.flash.climbing.sector.infrastructure.dto.UpdateSectorsDto; import com.first.flash.climbing.sector.application.dto.SectorCreateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorDetailResponseDto; import com.first.flash.climbing.sector.application.dto.SectorInfoCreateRequestDto; @@ -70,15 +71,27 @@ public SectorDetailResponseDto updateSector( final Long sectorId, final SectorUpdateRequestDto updateRequestDto) { Sector foundSector = findById(sectorId); -// foundSector.updateSector(updateRequestDto.sectorName(), updateRequestDto.adminSectorName(), -// updateRequestDto.settingDate(), -// updateRequestDto.removalDate(), updateRequestDto.gymId()); + foundSector.updateSector(updateRequestDto.sectorName(), updateRequestDto.adminSectorName(), + updateRequestDto.settingDate(), updateRequestDto.removalDate(), + updateRequestDto.selectedImageUrl()); Events.raise(SectorInfoUpdatedEvent.of(foundSector.getId(), updateRequestDto.sectorName(), - updateRequestDto.settingDate())); - Events.raise(ClimbingGymIdConfirmRequestedEvent.of(updateRequestDto.gymId())); + updateRequestDto.settingDate(), foundSector.isExpired())); return SectorDetailResponseDto.toDto(foundSector); } + @Transactional + public SectorInfoDetailResponseDto updateSectorInfo(final Long sectorInfoId, + final SectorInfoCreateRequestDto updateRequestDto) { + SectorInfo sectorInfo = findSectorInfoById(sectorInfoId); + sectorInfo.updateSectorInfo(updateRequestDto.name(), updateRequestDto.adminName(), + updateRequestDto.selectedImageUrl()); + UpdateSectorsDto updateSectorsDto = UpdateSectorsDto.toDto(sectorInfo); + sectorRepository.updateSectors(sectorInfoId, updateSectorsDto); + List sectorIds = sectorRepository.findSectorIdsBySectorInfoId(sectorInfoId); + Events.raise(SectorFixedInfoUpdatedEvent.of(sectorIds, sectorInfo)); + return SectorInfoDetailResponseDto.toDto(sectorInfo); + } + public Sector findById(final Long id) { return sectorRepository.findById(id) .orElseThrow(() -> new SectorNotFoundException(id)); @@ -98,7 +111,7 @@ private Sector createSector(final SectorInfo sectorInfo, final SectorCreateRequestDto createRequestDto) { return Sector.of(sectorInfo.getSectorName(), createRequestDto.settingDate(), createRequestDto.removalDate(), sectorInfo.getGymId(), - sectorInfo.getSelectedImageUrl()); + sectorInfo.getSelectedImageUrl(), sectorInfo.getId()); } private SectorInfo findSectorInfoById(final Long sectorInfoId) { diff --git a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorUpdateRequestDto.java b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorUpdateRequestDto.java index ec0a810d..f95265ee 100644 --- a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorUpdateRequestDto.java +++ b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorUpdateRequestDto.java @@ -9,11 +9,6 @@ public record SectorUpdateRequestDto( @NotEmpty(message = "섹터 관리 이름은 필수입니다.") String adminSectorName, @NotNull(message = "세팅일 정보는 비어있을 수 없습니다.") LocalDate settingDate, @NotNull(message = "탈거일 정보는 비어있을 수 없습니다.") LocalDate removalDate, - @NotNull(message = "클라이밍장 ID는 비어있을 수 없습니다.") Long gymId) { + String selectedImageUrl) { - public static SectorUpdateRequestDto of(final String sectorName, final String adminSectorName, - final LocalDate settingDate, final LocalDate removalDate, final Long gymId) { - return new SectorUpdateRequestDto(sectorName, adminSectorName, settingDate, removalDate, - gymId); - } -} \ No newline at end of file +} 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 index cdcf1dc2..da8f8893 100644 --- a/src/main/java/com/first/flash/climbing/sector/domain/SectorInfoUpdatedEvent.java +++ b/src/main/java/com/first/flash/climbing/sector/domain/SectorInfoUpdatedEvent.java @@ -11,9 +11,10 @@ public class SectorInfoUpdatedEvent { private Long id; private String sectorName; private LocalDate settingDate; + private boolean isExpired; public static SectorInfoUpdatedEvent of(final Long id, final String sectorName, - final LocalDate settingDate) { - return new SectorInfoUpdatedEvent(id, sectorName, settingDate); + final LocalDate settingDate, final boolean isExpired) { + return new SectorInfoUpdatedEvent(id, sectorName, settingDate, isExpired); } } 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 7b662e4d..80f0821c 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 @@ -1,5 +1,6 @@ package com.first.flash.climbing.sector.domain; +import com.first.flash.climbing.sector.infrastructure.dto.UpdateSectorsDto; import java.util.List; import java.util.Optional; @@ -12,4 +13,8 @@ public interface SectorRepository { List updateExpiredSector(); List findAll(); + + void updateSectors(final Long sectorInfoId, final UpdateSectorsDto updateSectorsDto); + + List findSectorIdsBySectorInfoId(Long sectorInfoId); } diff --git a/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorQueryDslRepository.java b/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorQueryDslRepository.java index 9700beeb..e6acd233 100644 --- a/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorQueryDslRepository.java +++ b/src/main/java/com/first/flash/climbing/sector/infrastructure/SectorQueryDslRepository.java @@ -2,6 +2,7 @@ import static com.first.flash.climbing.sector.domain.QSector.sector; +import com.first.flash.climbing.sector.infrastructure.dto.UpdateSectorsDto; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; import java.time.LocalDate; @@ -37,4 +38,21 @@ private BooleanExpression isExpired() { sector.removalInfo.removalDate .before(LocalDate.now())); } + + public void updateSectors(final Long sectorInfoId, + final UpdateSectorsDto updateSectorsDto) { + List sectorIds = findSectorIdsBySectorInfoId(sectorInfoId); + jpaQueryFactory.update(sector) + .set(sector.sectorName.name, updateSectorsDto.name()) + .set(sector.sectorName.adminName, updateSectorsDto.adminName()) + .where(sector.id.in(sectorIds)) + .execute(); + } + + public List findSectorIdsBySectorInfoId(final Long sectorInfoId) { + return jpaQueryFactory.select(sector.id) + .from(sector) + .where(sector.sectorInfoId.eq(sectorInfoId)) + .fetch(); + } } 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 5fc5d5d8..995d8c6c 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 @@ -2,6 +2,7 @@ import com.first.flash.climbing.sector.domain.Sector; import com.first.flash.climbing.sector.domain.SectorRepository; +import com.first.flash.climbing.sector.infrastructure.dto.UpdateSectorsDto; import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; @@ -33,4 +34,15 @@ public List updateExpiredSector() { public List findAll() { return sectorJpaRepository.findAll(); } + + @Override + public void updateSectors(final Long sectorInfoId, + final UpdateSectorsDto updateSectorsDto) { + sectorQueryDslRepository.updateSectors(sectorInfoId, updateSectorsDto); + } + + @Override + public List findSectorIdsBySectorInfoId(final Long sectorInfoId) { + return sectorQueryDslRepository.findSectorIdsBySectorInfoId(sectorInfoId); + } } From 7c1ff74261875927f6f5db42fccc6f1e9e2c6885 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 17:45:06 +0900 Subject: [PATCH 18/65] =?UTF-8?q?feat:=20=EA=B3=A0=EC=A0=95=20=EC=84=B9?= =?UTF-8?q?=ED=84=B0=20=EC=A0=95=EB=B3=B4=EC=9D=98=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=9D=84=20=EA=B0=80=EB=B3=80=20=EC=84=B9=ED=84=B0=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EC=97=90=20=EB=B0=98=EC=98=81=ED=95=98=EB=8A=94=20dto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sector/infrastructure/dto/UpdateSectorsDto.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/sector/infrastructure/dto/UpdateSectorsDto.java diff --git a/src/main/java/com/first/flash/climbing/sector/infrastructure/dto/UpdateSectorsDto.java b/src/main/java/com/first/flash/climbing/sector/infrastructure/dto/UpdateSectorsDto.java new file mode 100644 index 00000000..9a42f27c --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/infrastructure/dto/UpdateSectorsDto.java @@ -0,0 +1,11 @@ +package com.first.flash.climbing.sector.infrastructure.dto; + +import com.first.flash.climbing.sector.domain.SectorInfo; + +public record UpdateSectorsDto(String name, String adminName, String selectedImageUrl) { + + public static UpdateSectorsDto toDto(final SectorInfo sectorInfo) { + return new UpdateSectorsDto(sectorInfo.getSectorName().getName(), + sectorInfo.getSectorName().getAdminName(), sectorInfo.getSelectedImageUrl()); + } +} From 34a14cb632437b4439676e8a02c36a4ccd963f91 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 17:45:25 +0900 Subject: [PATCH 19/65] =?UTF-8?q?feat:=20=EA=B3=A0=EC=A0=95=20=EC=84=B9?= =?UTF-8?q?=ED=84=B0=20=EC=A0=95=EB=B3=B4=EC=9D=98=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=9D=84=20=EC=95=8C=EB=A6=AC=EB=8A=94=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SectorFixedInfoUpdatedEvent.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/sector/application/SectorFixedInfoUpdatedEvent.java diff --git a/src/main/java/com/first/flash/climbing/sector/application/SectorFixedInfoUpdatedEvent.java b/src/main/java/com/first/flash/climbing/sector/application/SectorFixedInfoUpdatedEvent.java new file mode 100644 index 00000000..0e8d6758 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/application/SectorFixedInfoUpdatedEvent.java @@ -0,0 +1,19 @@ +package com.first.flash.climbing.sector.application; + +import com.first.flash.climbing.sector.domain.SectorInfo; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class SectorFixedInfoUpdatedEvent { + + private List sectorIds; + private String sectorName; + + public static SectorFixedInfoUpdatedEvent of(final List sectorIds, + final SectorInfo sectorInfo) { + return new SectorFixedInfoUpdatedEvent(sectorIds, sectorInfo.getSectorName().getName()); + } +} From f13e5fc3a835de9abc3c4c2a6b2b2d6f38183f44 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 17:51:15 +0900 Subject: [PATCH 20/65] =?UTF-8?q?feat:=20=EA=B3=A0=EC=A0=95=20=EC=84=B9?= =?UTF-8?q?=ED=84=B0=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../climbing/sector/ui/SectorController.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) 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 1cff088d..424d0643 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 @@ -82,7 +82,8 @@ public ResponseEntity createSectorInfo( })) }) @PostMapping("admin/sectorInfos/{sectorInfoId}") - public ResponseEntity createSector(@PathVariable final Long sectorInfoId, + public ResponseEntity createSector( + @PathVariable final Long sectorInfoId, @Valid @RequestBody final SectorCreateRequestDto sectorCreateRequestDto) { return ResponseEntity.status(HttpStatus.CREATED) .body(sectorService.saveSector(sectorInfoId, sectorCreateRequestDto)); @@ -123,7 +124,6 @@ public ResponseEntity updateSectorRemovalDate( @ApiResponse(responseCode = "404", description = "리소스를 찾을 수 없음", content = @Content(mediaType = "application/json", examples = { @ExampleObject(name = "섹터 없음", value = "{\"error\": \"아이디가 1인 섹터를 찾을 수 없습니다.\"}"), - @ExampleObject(name = "클라이밍장 없음", value = "{\"error\": \"아이디가 1인 클라이밍장을 찾을 수 없습니다.\"}") })) }) @PutMapping("admin/sectors/{sectorId}") @@ -132,4 +132,24 @@ public ResponseEntity updateSector( @Valid @RequestBody final SectorUpdateRequestDto updateRequestDto) { return ResponseEntity.ok(sectorService.updateSector(sectorId, updateRequestDto)); } + + @Operation(summary = "섹터 전체 수정", description = "특정 섹터의 정보 수정") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공적으로 섹터 정보 수정함", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = SectorInfoDetailResponseDto.class))), + @ApiResponse(responseCode = "400", description = "유효하지 않은 요청 형식", + content = @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "요청값 누락", value = "{\"name\": \"섹터 이름은 필수입니다.\"}"), + })), + @ApiResponse(responseCode = "404", description = "리소스를 찾을 수 없음", + content = @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "섹터 없음", value = "{\"error\": \"아이디가 1인 섹터 정보를 찾을 수 없습니다.\"}"), + })) + }) + @PutMapping("admin/sectorInfos/{sectorInfoId}") + public ResponseEntity updateSectorInfo( + @PathVariable final Long sectorInfoId, + @Valid @RequestBody final SectorInfoCreateRequestDto updateRequestDto) { + return ResponseEntity.ok(sectorService.updateSectorInfo(sectorInfoId, updateRequestDto)); + } } From 95befb21df73d883297689af5685865b406ceb36 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 17:59:17 +0900 Subject: [PATCH 21/65] =?UTF-8?q?feat:=20=EC=97=AC=EB=9F=AC=20=EC=84=B9?= =?UTF-8?q?=ED=84=B0=20id=EC=9D=98=20=EC=84=B9=ED=84=B0=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=EC=9D=84=20=EB=B3=80=EA=B2=BD=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../problem/domain/QueryProblemRepository.java | 2 ++ .../QueryProblemQueryDslRepository.java | 13 +++++++++++-- .../infrastructure/QueryProblemRepositoryImpl.java | 5 +++++ 3 files changed, 18 insertions(+), 2 deletions(-) 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 b0aea189..4cefb9e8 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 @@ -23,4 +23,6 @@ List findAll(final ProblemCursor preProblemCursor, final ProblemSo void updateQueryProblemInfo(final Long sectorId, final String sectorName, final LocalDate settingDate); + + void updateSectorNameBySectorIds(final List sectorIds, final String sectorName); } 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 508292e0..1e05e71e 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 @@ -23,12 +23,14 @@ public class QueryProblemQueryDslRepository { private final JPAQueryFactory queryFactory; - public List findAll(final ProblemCursor prevProblemCursor, final ProblemSortBy problemSortBy, final int size, + public List findAll(final ProblemCursor prevProblemCursor, + final ProblemSortBy problemSortBy, final int size, final Long gymId, final List difficulty, final List sector, final Boolean hasSolution, final Boolean isHoney) { return queryFactory .selectFrom(queryProblem) - .where(notExpired(), cursorCondition(prevProblemCursor), inGym(gymId), inSectors(sector), + .where(notExpired(), cursorCondition(prevProblemCursor), inGym(gymId), + inSectors(sector), inDifficulties(difficulty), hasSolution(hasSolution), isHoneyCondition(isHoney)) .orderBy(sortItem(problemSortBy), queryProblem.id.desc()) .limit(size) @@ -133,4 +135,11 @@ private BooleanExpression hasSolution(final Boolean hasSolution) { } return queryProblem.hasSolution.eq(hasSolution); } + + public void updateSectorNameBySectorIds(final List sectorIds, final String sectorName) { + queryFactory.update(queryProblem) + .set(queryProblem.sectorName, sectorName) + .where(queryProblem.sectorId.in(sectorIds)) + .execute(); + } } 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 b804ae28..76f3fe2d 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 @@ -51,4 +51,9 @@ public void updateQueryProblemInfo(final Long sectorId, final String sectorName, final LocalDate settingDate) { queryProblemQueryDslRepository.updateQueryProblemInfo(sectorId, sectorName, settingDate); } + + @Override + public void updateSectorNameBySectorIds(final List sectorIds, final String sectorName) { + queryProblemQueryDslRepository.updateSectorNameBySectorIds(sectorIds, sectorName); + } } From 0f85b65583d96d0f8be926c43ef715f92abb36f5 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 17:59:37 +0900 Subject: [PATCH 22/65] =?UTF-8?q?feat:=20=EA=B3=A0=EC=A0=95=20=EC=84=B9?= =?UTF-8?q?=ED=84=B0=20=EC=A0=95=EB=B3=B4=20=EB=B3=80=EA=B2=BD=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=EC=97=90=20=EB=8C=80=ED=95=9C=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=EB=84=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../climbing/problem/application/ProblemEventHandler.java | 7 +++++++ .../climbing/problem/application/ProblemsService.java | 4 ++++ 2 files changed, 11 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 44c3a089..5b8936ad 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.problem.domain.ProblemIdConfirmRequestedEvent; +import com.first.flash.climbing.sector.application.SectorFixedInfoUpdatedEvent; import com.first.flash.climbing.sector.domain.SectorExpiredEvent; import com.first.flash.climbing.sector.domain.SectorInfoUpdatedEvent; import com.first.flash.climbing.sector.domain.SectorRemovalDateUpdatedEvent; @@ -50,6 +51,12 @@ public void updateQueryProblemInfo(final SectorInfoUpdatedEvent event) { event.getSettingDate()); } + @EventListener + @Transactional + public void updateQueryProblemFixedInfo(final SectorFixedInfoUpdatedEvent event) { + problemsService.updateQueryProblemFixedInfo(event.getSectorIds(), event.getSectorName()); + } + @EventListener @Transactional public void confirmProblemId(final ProblemIdConfirmRequestedEvent event) { 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 0685d7ce..259b4ffb 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 @@ -62,4 +62,8 @@ public ProblemDetailResponseDto setPerceivedDifficulty(final UUID problemId, fin queryProblem.setPerceivedDifficulty(perceivedDifficulty); return ProblemDetailResponseDto.of(queryProblem); } + + public void updateQueryProblemFixedInfo(final List sectorIds, final String sectorName) { + queryProblemRepository.updateSectorNameBySectorIds(sectorIds, sectorName); + } } From 95778367af0daa0c91cbff355dbca2cdcfd2167e Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 18:17:21 +0900 Subject: [PATCH 23/65] =?UTF-8?q?feat:=20=EB=AA=A8=EB=93=A0=20=EA=B3=A0?= =?UTF-8?q?=EC=A0=95=20=EC=84=B9=ED=84=B0=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0?= =?UTF-8?q?=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 +++++++++++ .../dto/SectorInfosDetailResponseDto.java | 11 +++++++++++ .../flash/climbing/sector/ui/SectorController.java | 13 ++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfosDetailResponseDto.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 bbbda082..951090d6 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 @@ -1,6 +1,7 @@ package com.first.flash.climbing.sector.application; import com.first.flash.climbing.gym.domian.ClimbingGymIdConfirmRequestedEvent; +import com.first.flash.climbing.sector.application.dto.SectorInfosDetailResponseDto; import com.first.flash.climbing.sector.infrastructure.dto.UpdateSectorsDto; import com.first.flash.climbing.sector.application.dto.SectorCreateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorDetailResponseDto; @@ -107,6 +108,16 @@ public SectorsDetailResponseDto findAllSectors() { return new SectorsDetailResponseDto(sectorsResponse); } + public SectorInfosDetailResponseDto findAllSectorInfos() { + List sectorInfosResponse = sectorInfoRepository + .findAll() + .stream() + .map( + SectorInfoDetailResponseDto::toDto) + .toList(); + return new SectorInfosDetailResponseDto(sectorInfosResponse); + } + private Sector createSector(final SectorInfo sectorInfo, final SectorCreateRequestDto createRequestDto) { return Sector.of(sectorInfo.getSectorName(), createRequestDto.settingDate(), diff --git a/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfosDetailResponseDto.java b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfosDetailResponseDto.java new file mode 100644 index 00000000..ba8cedf2 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/sector/application/dto/SectorInfosDetailResponseDto.java @@ -0,0 +1,11 @@ +package com.first.flash.climbing.sector.application.dto; + +import java.util.List; + +public record SectorInfosDetailResponseDto(List sectorInfosResponse) { + + public static SectorInfosDetailResponseDto toDto( + final List sectorInfosResponse) { + return new SectorInfosDetailResponseDto(sectorInfosResponse); + } +} 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 424d0643..eadcc324 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.SectorDetailResponseDto; import com.first.flash.climbing.sector.application.dto.SectorInfoCreateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorInfoDetailResponseDto; +import com.first.flash.climbing.sector.application.dto.SectorInfosDetailResponseDto; 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.SectorsDetailResponseDto; @@ -46,6 +47,16 @@ public ResponseEntity findAllSectors() { return ResponseEntity.ok(sectorService.findAllSectors()); } + @Operation(summary = "모든 섹터 고정 정보 조회", description = "모든 섹터 정보를 리스트로 반환") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공적으로 섹터를 조회", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = SectorInfosDetailResponseDto.class))), + }) + @GetMapping("sectors") + public ResponseEntity findAllSectorInfos() { + return ResponseEntity.ok(sectorService.findAllSectorInfos()); + } + @Operation(summary = "섹터 고정 정보 생성", description = "특정 클라이밍장의 새로운 섹터 고정 정보 생성") @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "성공적으로 섹터를 생성함", @@ -81,7 +92,7 @@ public ResponseEntity createSectorInfo( @ExampleObject(name = "클라이밍장 없음", value = "{\"error\": \"아이디가 1인 클라이밍장을 찾을 수 없습니다.\"}") })) }) - @PostMapping("admin/sectorInfos/{sectorInfoId}") + @PostMapping("admin/sectorInfos/{sectorInfoId}/sectors") public ResponseEntity createSector( @PathVariable final Long sectorInfoId, @Valid @RequestBody final SectorCreateRequestDto sectorCreateRequestDto) { From 220561c0ed956f5906bf8b1cc479975022cbeca5 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 24 Nov 2024 18:25:59 +0900 Subject: [PATCH 24/65] =?UTF-8?q?feat:=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20dom?= =?UTF-8?q?ain=EC=9C=BC=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../climbing/problem/application/ProblemEventHandler.java | 2 +- .../first/flash/climbing/sector/application/SectorService.java | 1 + .../{application => domain}/SectorFixedInfoUpdatedEvent.java | 3 +-- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/main/java/com/first/flash/climbing/sector/{application => domain}/SectorFixedInfoUpdatedEvent.java (79%) 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 5b8936ad..82a98c09 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,7 +1,7 @@ package com.first.flash.climbing.problem.application; import com.first.flash.climbing.problem.domain.ProblemIdConfirmRequestedEvent; -import com.first.flash.climbing.sector.application.SectorFixedInfoUpdatedEvent; +import com.first.flash.climbing.sector.domain.SectorFixedInfoUpdatedEvent; import com.first.flash.climbing.sector.domain.SectorExpiredEvent; import com.first.flash.climbing.sector.domain.SectorInfoUpdatedEvent; import com.first.flash.climbing.sector.domain.SectorRemovalDateUpdatedEvent; 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 951090d6..95bc940c 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,6 +2,7 @@ import com.first.flash.climbing.gym.domian.ClimbingGymIdConfirmRequestedEvent; import com.first.flash.climbing.sector.application.dto.SectorInfosDetailResponseDto; +import com.first.flash.climbing.sector.domain.SectorFixedInfoUpdatedEvent; import com.first.flash.climbing.sector.infrastructure.dto.UpdateSectorsDto; import com.first.flash.climbing.sector.application.dto.SectorCreateRequestDto; import com.first.flash.climbing.sector.application.dto.SectorDetailResponseDto; diff --git a/src/main/java/com/first/flash/climbing/sector/application/SectorFixedInfoUpdatedEvent.java b/src/main/java/com/first/flash/climbing/sector/domain/SectorFixedInfoUpdatedEvent.java similarity index 79% rename from src/main/java/com/first/flash/climbing/sector/application/SectorFixedInfoUpdatedEvent.java rename to src/main/java/com/first/flash/climbing/sector/domain/SectorFixedInfoUpdatedEvent.java index 0e8d6758..9aa6eec8 100644 --- a/src/main/java/com/first/flash/climbing/sector/application/SectorFixedInfoUpdatedEvent.java +++ b/src/main/java/com/first/flash/climbing/sector/domain/SectorFixedInfoUpdatedEvent.java @@ -1,6 +1,5 @@ -package com.first.flash.climbing.sector.application; +package com.first.flash.climbing.sector.domain; -import com.first.flash.climbing.sector.domain.SectorInfo; import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; From 900a2188df64511c3fd9ddb1ff13ffda3c4172be Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 26 Nov 2024 19:24:30 +0900 Subject: [PATCH 25/65] =?UTF-8?q?feat:=20=EC=84=B9=ED=84=B0=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EB=B3=80=EA=B2=BD=20=EC=9D=B4=EB=B2=A4=ED=8A=B8?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EB=A7=8C=EB=A3=8C=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=EA=B9=8C=EC=A7=80=20=EB=AC=B8=EC=A0=9C=EC=97=90=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../problem/application/ProblemEventHandler.java | 2 +- .../climbing/problem/application/ProblemsService.java | 10 ++++++---- .../problem/domain/QueryProblemRepository.java | 2 +- .../infrastructure/QueryProblemQueryDslRepository.java | 3 ++- .../infrastructure/QueryProblemRepositoryImpl.java | 8 +++++--- 5 files changed, 15 insertions(+), 10 deletions(-) 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 82a98c09..787b142c 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 @@ -48,7 +48,7 @@ public void updateProblemDeletedSolutionInfo(final SolutionDeletedEvent event) { @Transactional public void updateQueryProblemInfo(final SectorInfoUpdatedEvent event) { problemsService.updateQueryProblemInfo(event.getId(), event.getSectorName(), - event.getSettingDate()); + event.getSettingDate(), event.isExpired()); } @EventListener 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 259b4ffb..910280ec 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 @@ -38,7 +38,8 @@ public void updateProblemSolutionInfo(final UUID problemId) { } @Transactional - public void updateProblemDeletedSolutionInfo(final UUID problemId, final Integer perceivedDifficulty) { + public void updateProblemDeletedSolutionInfo(final UUID problemId, + final Integer perceivedDifficulty) { QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId); queryProblem.decrementSolutionCount(); queryProblem.subtractPerceivedDifficulty(perceivedDifficulty); @@ -46,8 +47,8 @@ public void updateProblemDeletedSolutionInfo(final UUID problemId, final Integer @Transactional public void updateQueryProblemInfo(final Long sectorId, final String sectorName, - final LocalDate settingDate) { - queryProblemRepository.updateQueryProblemInfo(sectorId, sectorName, settingDate); + final LocalDate settingDate, final boolean isExpired) { + queryProblemRepository.updateQueryProblemInfo(sectorId, sectorName, settingDate, isExpired); } @Transactional @@ -57,7 +58,8 @@ public void addPerceivedDifficulty(final UUID problemId, final Integer perceived } @Transactional - public ProblemDetailResponseDto setPerceivedDifficulty(final UUID problemId, final Integer perceivedDifficulty) { + public ProblemDetailResponseDto setPerceivedDifficulty(final UUID problemId, + final Integer perceivedDifficulty) { QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId); queryProblem.setPerceivedDifficulty(perceivedDifficulty); return ProblemDetailResponseDto.of(queryProblem); 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 4cefb9e8..a835bf06 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 @@ -22,7 +22,7 @@ List findAll(final ProblemCursor preProblemCursor, final ProblemSo void expireProblemsBySectorIds(final List expiredSectorsIds); void updateQueryProblemInfo(final Long sectorId, final String sectorName, - final LocalDate settingDate); + final LocalDate settingDate, final boolean isExpired); void updateSectorNameBySectorIds(final List sectorIds, final String sectorName); } 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 1e05e71e..084efc99 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 @@ -53,10 +53,11 @@ public void expireProblemsBySectorIds(final List expiredSectorsIds) { } public void updateQueryProblemInfo(final Long sectorId, final String sectorName, - final LocalDate settingDate) { + final LocalDate settingDate, final boolean isExpired) { queryFactory.update(queryProblem) .set(queryProblem.sectorName, sectorName) .set(queryProblem.settingDate, settingDate) + .set(queryProblem.isExpired, isExpired) .where(queryProblem.sectorId.eq(sectorId)) .execute(); } 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 76f3fe2d..e32173b8 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 @@ -29,7 +29,8 @@ public Optional findById(final UUID id) { } @Override - public List findAll(final ProblemCursor prevProblemCursor, final ProblemSortBy problemSortBy, final int size, + public List findAll(final ProblemCursor prevProblemCursor, + final ProblemSortBy problemSortBy, final int size, final Long gymId, final List difficulty, final List sector, final Boolean hasSolution, final Boolean isHoney) { return queryProblemQueryDslRepository.findAll(prevProblemCursor, problemSortBy, size, @@ -48,8 +49,9 @@ public void expireProblemsBySectorIds(final List expiredSectorsIds) { @Override public void updateQueryProblemInfo(final Long sectorId, final String sectorName, - final LocalDate settingDate) { - queryProblemQueryDslRepository.updateQueryProblemInfo(sectorId, sectorName, settingDate); + final LocalDate settingDate, final boolean isExpired) { + queryProblemQueryDslRepository.updateQueryProblemInfo(sectorId, sectorName, settingDate, + isExpired); } @Override From 2082c6b84294f6a74a9beece5d005ef7e020a67d Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 26 Nov 2024 19:40:59 +0900 Subject: [PATCH 26/65] =?UTF-8?q?fix:=20=EC=84=B9=ED=84=B0=20=EA=B3=A0?= =?UTF-8?q?=EC=A0=95=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20API?= =?UTF-8?q?=EC=9D=98=20URI=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/first/flash/climbing/sector/ui/SectorController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 eadcc324..72836fa3 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 @@ -52,7 +52,7 @@ public ResponseEntity findAllSectors() { @ApiResponse(responseCode = "200", description = "성공적으로 섹터를 조회", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SectorInfosDetailResponseDto.class))), }) - @GetMapping("sectors") + @GetMapping("sectorInfos") public ResponseEntity findAllSectorInfos() { return ResponseEntity.ok(sectorService.findAllSectorInfos()); } From b0dd8a56bf80402391b29e1d0cecfe52d4a1fab2 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 26 Nov 2024 19:56:42 +0900 Subject: [PATCH 27/65] =?UTF-8?q?feat:=20=ED=83=88=EA=B1=B0=EC=9D=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20API=EA=B0=80=20=EB=A7=8C=EB=A3=8C=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EB=8F=84=20=EB=B3=80=EA=B2=BD=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../problem/application/ProblemEventHandler.java | 9 ++++++--- .../climbing/problem/application/ProblemsService.java | 4 ++-- .../climbing/problem/domain/QueryProblemRepository.java | 2 +- .../infrastructure/QueryProblemQueryDslRepository.java | 4 +++- .../infrastructure/QueryProblemRepositoryImpl.java | 4 ++-- 5 files changed, 14 insertions(+), 9 deletions(-) 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 787b142c..8b05b54d 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 @@ -23,7 +23,8 @@ public class ProblemEventHandler { @EventListener @Transactional public void changeRemovalDate(final SectorRemovalDateUpdatedEvent event) { - problemsService.changeRemovalDate(event.getSectorId(), event.getRemovalDate()); + problemsService.changeRemovalDate(event.getSectorId(), event.getRemovalDate(), + event.isExpired()); } @EventListener @@ -41,7 +42,8 @@ public void updateProblemSolutionInfo(final SolutionSavedEvent event) { @EventListener @Transactional public void updateProblemDeletedSolutionInfo(final SolutionDeletedEvent event) { - problemsService.updateProblemDeletedSolutionInfo(event.getProblemId(), event.getPerceivedDifficulty()); + problemsService.updateProblemDeletedSolutionInfo(event.getProblemId(), + event.getPerceivedDifficulty()); } @EventListener @@ -66,6 +68,7 @@ public void confirmProblemId(final ProblemIdConfirmRequestedEvent event) { @EventListener @Transactional public void updatePerceivedDifficulty(final PerceivedDifficultySetEvent event) { - problemsService.addPerceivedDifficulty(event.getProblemId(), event.getPerceivedDifficulty()); + problemsService.addPerceivedDifficulty(event.getProblemId(), + event.getPerceivedDifficulty()); } } 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 910280ec..d904c4b3 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 @@ -21,8 +21,8 @@ public class ProblemsService { private final ProblemReadService problemReadService; @Transactional - public void changeRemovalDate(final Long sectorId, final LocalDate removalDate) { - queryProblemRepository.updateRemovalDateBySectorId(sectorId, removalDate); + public void changeRemovalDate(final Long sectorId, final LocalDate removalDate, final boolean isExpired) { + queryProblemRepository.updateRemovalDateBySectorId(sectorId, removalDate, isExpired); } @Transactional 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 a835bf06..37bb8c25 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 @@ -17,7 +17,7 @@ List findAll(final ProblemCursor preProblemCursor, final ProblemSo final Long gymId, final List difficulty, final List sector, final Boolean hasSolution, final Boolean isHoney); - void updateRemovalDateBySectorId(final Long sectorId, final LocalDate removalDate); + void updateRemovalDateBySectorId(final Long sectorId, final LocalDate removalDate, final boolean isExpired); void expireProblemsBySectorIds(final List expiredSectorsIds); 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 084efc99..351650ef 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 @@ -37,9 +37,11 @@ public List findAll(final ProblemCursor prevProblemCursor, .fetch(); } - public void updateRemovalDateBySectorId(final Long sectorId, final LocalDate removalDate) { + public void updateRemovalDateBySectorId(final Long sectorId, final LocalDate removalDate, + final boolean isExpired) { queryFactory.update(queryProblem) .set(queryProblem.removalDate, removalDate) + .set(queryProblem.isExpired, isExpired) .set(queryProblem.isFakeRemovalDate, false) .where(queryProblem.sectorId.eq(sectorId)) .execute(); 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 e32173b8..c95c3a9a 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 @@ -38,8 +38,8 @@ public List findAll(final ProblemCursor prevProblemCursor, } @Override - public void updateRemovalDateBySectorId(final Long sectorId, final LocalDate removalDate) { - queryProblemQueryDslRepository.updateRemovalDateBySectorId(sectorId, removalDate); + public void updateRemovalDateBySectorId(final Long sectorId, final LocalDate removalDate, final boolean isExpired) { + queryProblemQueryDslRepository.updateRemovalDateBySectorId(sectorId, removalDate, isExpired); } @Override From 79f6348d67a25a8b33ec58bd98f763f2f648f3ee Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 26 Nov 2024 19:57:38 +0900 Subject: [PATCH 28/65] =?UTF-8?q?feat:=20=ED=83=88=EA=B1=B0=EC=9D=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20API=20=ED=98=B8=EC=B6=9C=20=EC=8B=9C=20?= =?UTF-8?q?=EB=A7=8C=EB=A3=8C=20=EC=97=AC=EB=B6=80=EB=A5=BC=20=EB=8B=A4?= =?UTF-8?q?=EC=8B=9C=20=ED=8C=90=EB=8B=A8=ED=95=98=EB=8A=94=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flash/climbing/sector/application/SectorService.java | 2 +- .../java/com/first/flash/climbing/sector/domain/Sector.java | 2 +- .../sector/domain/SectorRemovalDateUpdatedEvent.java | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) 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 95bc940c..63a3106f 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 @@ -58,7 +58,7 @@ public SectorDetailResponseDto updateSectorRemovalDate(final Long sectorId, Sector sector = findById(sectorId); LocalDate removalDate = sectorUpdateRemovalDateRequestDto.removalDate(); sector.updateRemovalDate(removalDate); - Events.raise(SectorRemovalDateUpdatedEvent.of(sectorId, removalDate)); + Events.raise(SectorRemovalDateUpdatedEvent.of(sectorId, removalDate, sector.isExpired())); return SectorDetailResponseDto.toDto(sector); } diff --git a/src/main/java/com/first/flash/climbing/sector/domain/Sector.java b/src/main/java/com/first/flash/climbing/sector/domain/Sector.java index ff7fe5e6..dd05d812 100644 --- a/src/main/java/com/first/flash/climbing/sector/domain/Sector.java +++ b/src/main/java/com/first/flash/climbing/sector/domain/Sector.java @@ -77,7 +77,7 @@ public LocalDate getRemovalDate() { public void updateRemovalDate(final LocalDate removalDate) { validateRemovalDate(settingDate, removalDate); - removalInfo = RemovalInfo.createDefault(removalDate); + removalInfo = RemovalInfo.createByNewRemovalDate(removalDate); } public void updateSector(final String sectorName, final String adminSectorName, diff --git a/src/main/java/com/first/flash/climbing/sector/domain/SectorRemovalDateUpdatedEvent.java b/src/main/java/com/first/flash/climbing/sector/domain/SectorRemovalDateUpdatedEvent.java index a02bdada..62855233 100644 --- a/src/main/java/com/first/flash/climbing/sector/domain/SectorRemovalDateUpdatedEvent.java +++ b/src/main/java/com/first/flash/climbing/sector/domain/SectorRemovalDateUpdatedEvent.java @@ -11,9 +11,10 @@ public class SectorRemovalDateUpdatedEvent extends Event { private Long sectorId; private LocalDate removalDate; + private boolean isExpired; public static SectorRemovalDateUpdatedEvent of( - final Long sectorId, final LocalDate removalDate) { - return new SectorRemovalDateUpdatedEvent(sectorId, removalDate); + final Long sectorId, final LocalDate removalDate, final boolean isExpired) { + return new SectorRemovalDateUpdatedEvent(sectorId, removalDate, isExpired); } } From 7727a68bc4fcde74314b414491b7c367eb354b9e Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 15:59:04 +0900 Subject: [PATCH 29/65] =?UTF-8?q?feat:=20=ED=81=B4=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=EC=9E=A5=20=EC=A6=90=EA=B2=A8=EC=B0=BE=EA=B8=B0=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80,=20=ED=81=B4=EB=9D=BC=EC=9D=B4=EB=B0=8D=20M:N=20?= =?UTF-8?q?=EA=B4=80=EA=B3=84=20=EC=97=94=ED=8B=B0=ED=8B=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../favorite/domain/MemberFavoriteGym.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGym.java diff --git a/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGym.java b/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGym.java new file mode 100644 index 00000000..52d24ef5 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGym.java @@ -0,0 +1,30 @@ +package com.first.flash.climbing.favorite.domain; + +import com.first.flash.global.domain.BaseEntity; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import java.util.UUID; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Entity +@NoArgsConstructor +@Getter +@ToString +public class MemberFavoriteGym extends BaseEntity { + + @Id + private Long id; + private UUID memberId; + private Long gymId; + + protected MemberFavoriteGym(final UUID memberId, final Long gymId) { + this.memberId = memberId; + this.gymId = gymId; + } + + public static MemberFavoriteGym createDefault(final UUID memberId, final Long gymId) { + return new MemberFavoriteGym(memberId, gymId); + } +} From c2198604294c2a801a08eec303d9c01f6373d46a Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 15:59:40 +0900 Subject: [PATCH 30/65] =?UTF-8?q?feat:=20=EA=B8=B0=EB=B3=B8=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=8B=A8=EA=B1=B4=20=EC=A1=B0=ED=9A=8C,=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1,=20=EC=9C=A0=EC=A0=80=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=EB=94=94=EB=A1=9C=20=ED=81=B4=EB=9D=BC=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=EC=9E=A5=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/MemberFavoriteGymRepository.java | 14 +++++++++ .../MemberFavoriteGymJpaRepository.java | 17 ++++++++++ .../MemberFavoriteGymRepositoryImpl.java | 31 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGymRepository.java create mode 100644 src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymJpaRepository.java create mode 100644 src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymRepositoryImpl.java diff --git a/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGymRepository.java b/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGymRepository.java new file mode 100644 index 00000000..d3296aed --- /dev/null +++ b/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGymRepository.java @@ -0,0 +1,14 @@ +package com.first.flash.climbing.favorite.domain; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +public interface MemberFavoriteGymRepository { + + MemberFavoriteGym save(final MemberFavoriteGym memberFavoriteGym); + + Optional findById(final Long id); + + List findByMemberId(final UUID memberId); +} diff --git a/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymJpaRepository.java b/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymJpaRepository.java new file mode 100644 index 00000000..aa5ea0ec --- /dev/null +++ b/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymJpaRepository.java @@ -0,0 +1,17 @@ +package com.first.flash.climbing.favorite.infrastructure; + +import com.first.flash.climbing.favorite.domain.MemberFavoriteGym; +import com.first.flash.climbing.favorite.domain.MemberFavoriteGymRepository; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface MemberFavoriteGymJpaRepository extends JpaRepository { + + MemberFavoriteGym save(final MemberFavoriteGym memberFavoriteGym); + + Optional findById(final Long id); + + List findByMemberId(final UUID memberId); +} diff --git a/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymRepositoryImpl.java b/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymRepositoryImpl.java new file mode 100644 index 00000000..f780e075 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymRepositoryImpl.java @@ -0,0 +1,31 @@ +package com.first.flash.climbing.favorite.infrastructure; + +import com.first.flash.climbing.favorite.domain.MemberFavoriteGym; +import com.first.flash.climbing.favorite.domain.MemberFavoriteGymRepository; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; + +@Repository +@RequiredArgsConstructor +public class MemberFavoriteGymRepositoryImpl implements MemberFavoriteGymRepository { + + private final MemberFavoriteGymJpaRepository memberFavoriteGymJpaRepository; + + @Override + public MemberFavoriteGym save(final MemberFavoriteGym memberFavoriteGym) { + return memberFavoriteGymJpaRepository.save(memberFavoriteGym); + } + + @Override + public Optional findById(final Long id) { + return memberFavoriteGymJpaRepository.findById(id); + } + + @Override + public List findByMemberId(final UUID memberId) { + return memberFavoriteGymJpaRepository.findByMemberId(memberId); + } +} From 8012e0de1d12526bcc5196893a3e27a8f72cfac2 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 16:08:01 +0900 Subject: [PATCH 31/65] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20id=EC=99=80?= =?UTF-8?q?=20gym=20id=EB=A1=9C=20=EA=B4=80=EA=B3=84=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=EB=A5=BC=20=EC=83=9D=EC=84=B1=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=8B=9C=EB=82=98=EB=A6=AC=EC=98=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/MemberFavoriteGymService.java | 21 +++++++++++++++++++ .../dto/MemberFavoriteGymResponseDto.java | 12 +++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java create mode 100644 src/main/java/com/first/flash/climbing/favorite/application/dto/MemberFavoriteGymResponseDto.java diff --git a/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java new file mode 100644 index 00000000..ef69917a --- /dev/null +++ b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java @@ -0,0 +1,21 @@ +package com.first.flash.climbing.favorite.application; + +import com.first.flash.climbing.favorite.application.dto.MemberFavoriteGymResponseDto; +import com.first.flash.climbing.favorite.domain.MemberFavoriteGym; +import com.first.flash.climbing.favorite.domain.MemberFavoriteGymRepository; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class MemberFavoriteGymService { + + private final MemberFavoriteGymRepository memberFavoriteGymRepository; + + public MemberFavoriteGymResponseDto saveMemberFavoriteGym(final UUID memberId, final Long gymId) { + MemberFavoriteGym memberFavoriteGym = MemberFavoriteGym.createDefault(memberId, gymId); + MemberFavoriteGym savedMemberFavoriteGym = memberFavoriteGymRepository.save(memberFavoriteGym); + return MemberFavoriteGymResponseDto.toDto(savedMemberFavoriteGym); + } +} diff --git a/src/main/java/com/first/flash/climbing/favorite/application/dto/MemberFavoriteGymResponseDto.java b/src/main/java/com/first/flash/climbing/favorite/application/dto/MemberFavoriteGymResponseDto.java new file mode 100644 index 00000000..cb2236ee --- /dev/null +++ b/src/main/java/com/first/flash/climbing/favorite/application/dto/MemberFavoriteGymResponseDto.java @@ -0,0 +1,12 @@ +package com.first.flash.climbing.favorite.application.dto; + +import com.first.flash.climbing.favorite.domain.MemberFavoriteGym; +import java.util.UUID; + +public record MemberFavoriteGymResponseDto(Long id, Long gymId, UUID memberId) { + + public static MemberFavoriteGymResponseDto toDto(final MemberFavoriteGym memberFavoriteGym) { + return new MemberFavoriteGymResponseDto(memberFavoriteGym.getId(), + memberFavoriteGym.getGymId(), memberFavoriteGym.getMemberId()); + } +} From 7fb8e45d93246541f8ef5b044806e628481a655f Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 16:09:01 +0900 Subject: [PATCH 32/65] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20id=EB=A1=9C?= =?UTF-8?q?=20=ED=95=B4=EB=8B=B9=20=EB=A9=A4=EB=B2=84=EA=B0=80=20=EC=96=B4?= =?UTF-8?q?=EB=96=A4=20=ED=81=B4=EB=9D=BC=EC=9D=B4=EB=B0=8D=EC=9E=A5?= =?UTF-8?q?=EB=93=A4=EC=9D=84=20=EC=A6=90=EA=B2=A8=EC=B0=BE=EA=B8=B0=20?= =?UTF-8?q?=ED=96=88=EB=8A=94=EC=A7=80=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=8B=9C=EB=82=98=EB=A6=AC=EC=98=A4=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 --- .../favorite/application/MemberFavoriteGymService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java index ef69917a..5b2bb276 100644 --- a/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java +++ b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java @@ -3,6 +3,7 @@ import com.first.flash.climbing.favorite.application.dto.MemberFavoriteGymResponseDto; import com.first.flash.climbing.favorite.domain.MemberFavoriteGym; import com.first.flash.climbing.favorite.domain.MemberFavoriteGymRepository; +import java.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -18,4 +19,10 @@ public MemberFavoriteGymResponseDto saveMemberFavoriteGym(final UUID memberId, f MemberFavoriteGym savedMemberFavoriteGym = memberFavoriteGymRepository.save(memberFavoriteGym); return MemberFavoriteGymResponseDto.toDto(savedMemberFavoriteGym); } + + public List findFavoriteGymIdsByMemberId(final UUID memberId) { + return memberFavoriteGymRepository.findByMemberId(memberId).stream() + .map(MemberFavoriteGym::getGymId) + .toList(); + } } From 9013a1a7effb6c050af628901d57d1eaba164730 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 16:09:57 +0900 Subject: [PATCH 33/65] =?UTF-8?q?feat:=20auth=20util=EB=A1=9C=20=EC=A7=81?= =?UTF-8?q?=EC=A0=91=20member=20id=EB=A5=BC=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../favorite/application/MemberFavoriteGymService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java index 5b2bb276..370e6a75 100644 --- a/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java +++ b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java @@ -3,6 +3,7 @@ import com.first.flash.climbing.favorite.application.dto.MemberFavoriteGymResponseDto; import com.first.flash.climbing.favorite.domain.MemberFavoriteGym; import com.first.flash.climbing.favorite.domain.MemberFavoriteGymRepository; +import com.first.flash.global.util.AuthUtil; import java.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; @@ -14,9 +15,11 @@ public class MemberFavoriteGymService { private final MemberFavoriteGymRepository memberFavoriteGymRepository; - public MemberFavoriteGymResponseDto saveMemberFavoriteGym(final UUID memberId, final Long gymId) { + public MemberFavoriteGymResponseDto saveMemberFavoriteGym(final Long gymId) { + UUID memberId = AuthUtil.getId(); MemberFavoriteGym memberFavoriteGym = MemberFavoriteGym.createDefault(memberId, gymId); - MemberFavoriteGym savedMemberFavoriteGym = memberFavoriteGymRepository.save(memberFavoriteGym); + MemberFavoriteGym savedMemberFavoriteGym = memberFavoriteGymRepository.save( + memberFavoriteGym); return MemberFavoriteGymResponseDto.toDto(savedMemberFavoriteGym); } From 013cbaf6d212381ad26e6bede0baeef0769b05ed Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 16:23:15 +0900 Subject: [PATCH 34/65] =?UTF-8?q?feat:=20=EC=82=AD=EC=A0=9C=EC=99=80=20?= =?UTF-8?q?=EC=9C=A0=EC=A0=80=20id,=20=ED=81=B4=EB=9D=BC=EC=9D=B4=EB=B0=8D?= =?UTF-8?q?=EC=9E=A5=20id=EB=A1=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=A5=BC?= =?UTF-8?q?=20=EC=B0=BE=EB=8A=94=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 --- .../favorite/domain/MemberFavoriteGymRepository.java | 4 ++++ .../MemberFavoriteGymJpaRepository.java | 5 ++++- .../MemberFavoriteGymRepositoryImpl.java | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGymRepository.java b/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGymRepository.java index d3296aed..28205336 100644 --- a/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGymRepository.java +++ b/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGymRepository.java @@ -11,4 +11,8 @@ public interface MemberFavoriteGymRepository { Optional findById(final Long id); List findByMemberId(final UUID memberId); + + Optional findByMemberIdAndGymId(final UUID memberId, final Long gymId); + + void delete(final MemberFavoriteGym memberFavoriteGym); } diff --git a/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymJpaRepository.java b/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymJpaRepository.java index aa5ea0ec..de034077 100644 --- a/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymJpaRepository.java +++ b/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymJpaRepository.java @@ -1,7 +1,6 @@ package com.first.flash.climbing.favorite.infrastructure; import com.first.flash.climbing.favorite.domain.MemberFavoriteGym; -import com.first.flash.climbing.favorite.domain.MemberFavoriteGymRepository; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -14,4 +13,8 @@ public interface MemberFavoriteGymJpaRepository extends JpaRepository findById(final Long id); List findByMemberId(final UUID memberId); + + Optional findByMemberIdAndGymId(final UUID memberId, final Long gymId); + + void delete(final MemberFavoriteGym memberFavoriteGym); } diff --git a/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymRepositoryImpl.java b/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymRepositoryImpl.java index f780e075..8fbddaf2 100644 --- a/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymRepositoryImpl.java +++ b/src/main/java/com/first/flash/climbing/favorite/infrastructure/MemberFavoriteGymRepositoryImpl.java @@ -28,4 +28,15 @@ public Optional findById(final Long id) { public List findByMemberId(final UUID memberId) { return memberFavoriteGymJpaRepository.findByMemberId(memberId); } + + @Override + public Optional findByMemberIdAndGymId(final UUID memberId, + final Long gymId) { + return memberFavoriteGymJpaRepository.findByMemberIdAndGymId(memberId, gymId); + } + + @Override + public void delete(final MemberFavoriteGym memberFavoriteGym) { + memberFavoriteGymJpaRepository.delete(memberFavoriteGym); + } } From 1cc3ee813bf75a515634786ddfc14c103c9de345 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 16:23:38 +0900 Subject: [PATCH 35/65] =?UTF-8?q?feat:=20=EC=A6=90=EA=B2=A8=EC=B0=BE?= =?UTF-8?q?=EA=B8=B0=EA=B0=80=20=ED=86=A0=EA=B8=80=EC=B2=98=EB=9F=BC=20?= =?UTF-8?q?=EB=8F=99=EC=9E=91=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/MemberFavoriteGymService.java | 14 ++++++++++---- .../dto/MemberFavoriteGymResponseDto.java | 13 ++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java index 370e6a75..18687288 100644 --- a/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java +++ b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java @@ -5,6 +5,7 @@ import com.first.flash.climbing.favorite.domain.MemberFavoriteGymRepository; import com.first.flash.global.util.AuthUtil; import java.util.List; +import java.util.Optional; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -17,10 +18,15 @@ public class MemberFavoriteGymService { public MemberFavoriteGymResponseDto saveMemberFavoriteGym(final Long gymId) { UUID memberId = AuthUtil.getId(); - MemberFavoriteGym memberFavoriteGym = MemberFavoriteGym.createDefault(memberId, gymId); - MemberFavoriteGym savedMemberFavoriteGym = memberFavoriteGymRepository.save( - memberFavoriteGym); - return MemberFavoriteGymResponseDto.toDto(savedMemberFavoriteGym); + Optional favoriteGym = memberFavoriteGymRepository.findByMemberIdAndGymId(memberId, gymId); + + if (favoriteGym.isPresent()) { + memberFavoriteGymRepository.delete(favoriteGym.get()); + } else { + MemberFavoriteGym memberFavoriteGym = MemberFavoriteGym.createDefault(memberId, gymId); + memberFavoriteGymRepository.save(memberFavoriteGym); + } + return MemberFavoriteGymResponseDto.toDtoByStatus(favoriteGym.isPresent()); } public List findFavoriteGymIdsByMemberId(final UUID memberId) { diff --git a/src/main/java/com/first/flash/climbing/favorite/application/dto/MemberFavoriteGymResponseDto.java b/src/main/java/com/first/flash/climbing/favorite/application/dto/MemberFavoriteGymResponseDto.java index cb2236ee..ed1e5529 100644 --- a/src/main/java/com/first/flash/climbing/favorite/application/dto/MemberFavoriteGymResponseDto.java +++ b/src/main/java/com/first/flash/climbing/favorite/application/dto/MemberFavoriteGymResponseDto.java @@ -1,12 +1,11 @@ package com.first.flash.climbing.favorite.application.dto; -import com.first.flash.climbing.favorite.domain.MemberFavoriteGym; -import java.util.UUID; +public record MemberFavoriteGymResponseDto(String message) { -public record MemberFavoriteGymResponseDto(Long id, Long gymId, UUID memberId) { - - public static MemberFavoriteGymResponseDto toDto(final MemberFavoriteGym memberFavoriteGym) { - return new MemberFavoriteGymResponseDto(memberFavoriteGym.getId(), - memberFavoriteGym.getGymId(), memberFavoriteGym.getMemberId()); + public static MemberFavoriteGymResponseDto toDtoByStatus(final boolean present) { + if (present) { + return new MemberFavoriteGymResponseDto("즐겨찾기에서 제거되었습니다."); + } + return new MemberFavoriteGymResponseDto("즐겨찾기에 추가되었습니다."); } } From 2f2afc43e4090063559243a7dd2c58a58f77d5af Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 16:47:01 +0900 Subject: [PATCH 36/65] =?UTF-8?q?feat:=20=EC=A6=90=EA=B2=A8=EC=B0=BE?= =?UTF-8?q?=EA=B8=B0=EA=B0=80=20=ED=86=A0=EA=B8=80=EC=B2=98=EB=9F=BC=20?= =?UTF-8?q?=EB=8F=99=EC=9E=91=ED=95=98=EB=8A=94=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/MemberFavoriteGymController.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java diff --git a/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java b/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java new file mode 100644 index 00000000..29c02d64 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java @@ -0,0 +1,34 @@ +package com.first.flash.climbing.favorite.ui; + +import com.first.flash.climbing.favorite.application.MemberFavoriteGymService; +import com.first.flash.climbing.favorite.application.dto.MemberFavoriteGymResponseDto; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +public class MemberFavoriteGymController { + + private final MemberFavoriteGymService memberFavoriteGymService; + + @Operation(summary = "클라이밍장 즐겨찾기 생성/삭제", description = "클라이밍장 id로 즐겨찾기 토글") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "즐겨찾기 생성 및 삭제", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = MemberFavoriteGymResponseDto.class))), + @ApiResponse(responseCode = "400", description = "유효하지 않은 요청 형식", + content = @Content(mediaType = "application/json")) + }) + public ResponseEntity toggleMemberFavoriteGym( + @PathVariable final Long gymId) { + return ResponseEntity.status(HttpStatus.OK) + .body(memberFavoriteGymService.save(gymId)); + } +} From ae27c7b4b71ef902692867e799c9793cbcce8b54 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 16:48:01 +0900 Subject: [PATCH 37/65] =?UTF-8?q?feat:=20=EC=8B=9C=EB=82=98=EB=A6=AC?= =?UTF-8?q?=EC=98=A4=20=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/favorite/application/MemberFavoriteGymService.java | 2 +- .../flash/climbing/favorite/ui/MemberFavoriteGymController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java index 18687288..2478fb84 100644 --- a/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java +++ b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java @@ -16,7 +16,7 @@ public class MemberFavoriteGymService { private final MemberFavoriteGymRepository memberFavoriteGymRepository; - public MemberFavoriteGymResponseDto saveMemberFavoriteGym(final Long gymId) { + public MemberFavoriteGymResponseDto toggleMemberFavoriteGym(final Long gymId) { UUID memberId = AuthUtil.getId(); Optional favoriteGym = memberFavoriteGymRepository.findByMemberIdAndGymId(memberId, gymId); diff --git a/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java b/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java index 29c02d64..144a50f2 100644 --- a/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java +++ b/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java @@ -29,6 +29,6 @@ public class MemberFavoriteGymController { public ResponseEntity toggleMemberFavoriteGym( @PathVariable final Long gymId) { return ResponseEntity.status(HttpStatus.OK) - .body(memberFavoriteGymService.save(gymId)); + .body(memberFavoriteGymService.toggleMemberFavoriteGym(gymId)); } } From 8e8e6a1262c7012879ed02a1e107894d71105331 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 16:58:26 +0900 Subject: [PATCH 38/65] =?UTF-8?q?feat:=20=ED=81=B4=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=EC=9E=A5=20service=EC=97=90=20=EC=A6=90=EA=B2=A8?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0=20service=EB=A5=BC=20=EC=A3=BC=EC=9E=85?= =?UTF-8?q?=ED=95=B4=20=EC=A6=90=EA=B2=A8=EC=B0=BE=EA=B8=B0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../climbing/gym/application/ClimbingGymService.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java b/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java index 2ebebb94..f90d75f0 100644 --- a/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java +++ b/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java @@ -1,5 +1,6 @@ package com.first.flash.climbing.gym.application; +import com.first.flash.climbing.favorite.application.MemberFavoriteGymService; import com.first.flash.climbing.gym.application.dto.ClimbingGymCreateRequestDto; import com.first.flash.climbing.gym.application.dto.ClimbingGymCreateResponseDto; import com.first.flash.climbing.gym.application.dto.ClimbingGymDetailResponseDto; @@ -9,7 +10,9 @@ import com.first.flash.climbing.gym.domian.vo.Difficulty; import com.first.flash.climbing.gym.exception.exceptions.ClimbingGymNotFoundException; import com.first.flash.climbing.gym.infrastructure.dto.SectorInfoResponseDto; +import com.first.flash.global.util.AuthUtil; import java.util.List; +import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -20,6 +23,7 @@ public class ClimbingGymService { private final ClimbingGymRepository climbingGymRepository; + private final MemberFavoriteGymService memberFavoriteGymService; @Transactional public ClimbingGymCreateResponseDto save(final ClimbingGymCreateRequestDto createRequestDto) { @@ -33,8 +37,13 @@ public ClimbingGym findClimbingGymById(final Long id) { } public List findAllClimbingGyms() { + UUID memberId = AuthUtil.getId(); + List favoriteGymIds = memberFavoriteGymService.findFavoriteGymIdsByMemberId(memberId); + climbingGymRepository.findAll(); return climbingGymRepository.findAll().stream() - .map(ClimbingGymResponseDto::toDto) + .map( + gym -> (ClimbingGymResponseDto) + ClimbingGymResponseDto.toDto(gym, favoriteGymIds)) .toList(); } From d2bda4471f98cf4c0d10a1a34f8b1cb4443c42ed Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 16:59:08 +0900 Subject: [PATCH 39/65] =?UTF-8?q?feat:=20=ED=81=B4=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=EC=9E=A5=20=EC=9D=91=EB=8B=B5=EC=97=90=20=EC=A6=90?= =?UTF-8?q?=EA=B2=A8=EC=B0=BE=EA=B8=B0=EB=A5=BC=20=ED=96=88=EB=8A=94?= =?UTF-8?q?=EC=A7=80=20=EC=97=AC=EB=B6=80=20=ED=95=84=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 --- .../gym/application/dto/ClimbingGymResponseDto.java | 7 ++++--- .../first/flash/climbing/gym/ui/ClimbingGymController.java | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/gym/application/dto/ClimbingGymResponseDto.java b/src/main/java/com/first/flash/climbing/gym/application/dto/ClimbingGymResponseDto.java index 5f024d7c..12b40e16 100644 --- a/src/main/java/com/first/flash/climbing/gym/application/dto/ClimbingGymResponseDto.java +++ b/src/main/java/com/first/flash/climbing/gym/application/dto/ClimbingGymResponseDto.java @@ -1,10 +1,11 @@ package com.first.flash.climbing.gym.application.dto; import com.first.flash.climbing.gym.domian.ClimbingGym; +import java.util.List; -public record ClimbingGymResponseDto(Long id, String gymName, String thumbnailUrl) { +public record ClimbingGymResponseDto(Long id, String gymName, String thumbnailUrl, boolean isFavorite) { - public static ClimbingGymResponseDto toDto(final ClimbingGym gym) { - return new ClimbingGymResponseDto(gym.getId(), gym.getGymName(), gym.getThumbnailUrl()); + public static Object toDto(final ClimbingGym gym, final List favoriteGymIds) { + return new ClimbingGymResponseDto(gym.getId(), gym.getGymName(), gym.getThumbnailUrl(), favoriteGymIds.contains(gym.getId())); } } diff --git a/src/main/java/com/first/flash/climbing/gym/ui/ClimbingGymController.java b/src/main/java/com/first/flash/climbing/gym/ui/ClimbingGymController.java index 5c4707a8..8f5eba7f 100644 --- a/src/main/java/com/first/flash/climbing/gym/ui/ClimbingGymController.java +++ b/src/main/java/com/first/flash/climbing/gym/ui/ClimbingGymController.java @@ -27,7 +27,6 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @Tag(name = "gyms", description = "클라이밍장 조회 API") From 09afeee4c5f8afe0cf88e12a37f3c29357fbf6dc Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 20:59:41 +0900 Subject: [PATCH 40/65] =?UTF-8?q?feat:=20=ED=81=B4=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=EC=9E=A5=20=EC=A0=84=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=8B=9C=20=ED=95=B4=EB=8B=B9=20=EC=9C=A0=EC=A0=80=EC=9D=98=20?= =?UTF-8?q?=EC=A6=90=EA=B2=A8=EC=B0=BE=EA=B8=B0=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=9D=84=20=EB=B0=98=EC=98=81=ED=95=B4=20=EC=A0=95=EB=A0=AC?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gym/application/ClimbingGymService.java | 9 ++------- .../gym/domian/ClimbingGymRepository.java | 3 ++- .../ClimbingGymJpaRepository.java | 3 --- .../ClimbingGymQueryDslRepository.java | 18 ++++++++++++++++++ .../ClimbingGymRepositoryImpl.java | 7 ++++--- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java b/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java index f90d75f0..45ea8660 100644 --- a/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java +++ b/src/main/java/com/first/flash/climbing/gym/application/ClimbingGymService.java @@ -4,7 +4,7 @@ import com.first.flash.climbing.gym.application.dto.ClimbingGymCreateRequestDto; import com.first.flash.climbing.gym.application.dto.ClimbingGymCreateResponseDto; import com.first.flash.climbing.gym.application.dto.ClimbingGymDetailResponseDto; -import com.first.flash.climbing.gym.application.dto.ClimbingGymResponseDto; +import com.first.flash.climbing.gym.infrastructure.dto.ClimbingGymResponseDto; import com.first.flash.climbing.gym.domian.ClimbingGym; import com.first.flash.climbing.gym.domian.ClimbingGymRepository; import com.first.flash.climbing.gym.domian.vo.Difficulty; @@ -39,12 +39,7 @@ public ClimbingGym findClimbingGymById(final Long id) { public List findAllClimbingGyms() { UUID memberId = AuthUtil.getId(); List favoriteGymIds = memberFavoriteGymService.findFavoriteGymIdsByMemberId(memberId); - climbingGymRepository.findAll(); - return climbingGymRepository.findAll().stream() - .map( - gym -> (ClimbingGymResponseDto) - ClimbingGymResponseDto.toDto(gym, favoriteGymIds)) - .toList(); + return climbingGymRepository.findAllWithFavorites(favoriteGymIds); } public ClimbingGymDetailResponseDto findClimbingGymDetail(final Long id) { diff --git a/src/main/java/com/first/flash/climbing/gym/domian/ClimbingGymRepository.java b/src/main/java/com/first/flash/climbing/gym/domian/ClimbingGymRepository.java index 0f25f1ae..2367d4ed 100644 --- a/src/main/java/com/first/flash/climbing/gym/domian/ClimbingGymRepository.java +++ b/src/main/java/com/first/flash/climbing/gym/domian/ClimbingGymRepository.java @@ -1,5 +1,6 @@ package com.first.flash.climbing.gym.domian; +import com.first.flash.climbing.gym.infrastructure.dto.ClimbingGymResponseDto; import com.first.flash.climbing.gym.infrastructure.dto.SectorInfoResponseDto; import java.util.List; import java.util.Optional; @@ -10,7 +11,7 @@ public interface ClimbingGymRepository { Optional findById(final Long id); - List findAll(); + List findAllWithFavorites(final List favoriteGymIds); List findGymSectorNamesById(final Long id); } diff --git a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymJpaRepository.java b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymJpaRepository.java index f5a9a619..49749c71 100644 --- a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymJpaRepository.java +++ b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymJpaRepository.java @@ -1,7 +1,6 @@ package com.first.flash.climbing.gym.infrastructure; import com.first.flash.climbing.gym.domian.ClimbingGym; -import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; @@ -10,6 +9,4 @@ public interface ClimbingGymJpaRepository extends JpaRepository findById(final Long id); - - List findAll(); } diff --git a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java index fd9ed2f8..00f9d5bf 100644 --- a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java +++ b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java @@ -1,9 +1,12 @@ package com.first.flash.climbing.gym.infrastructure; +import static com.first.flash.climbing.gym.domian.QClimbingGym.climbingGym; import static com.first.flash.climbing.sector.domain.QSector.sector; +import com.first.flash.climbing.gym.infrastructure.dto.ClimbingGymResponseDto; import com.first.flash.climbing.gym.infrastructure.dto.SectorInfoResponseDto; import com.querydsl.core.types.Projections; +import com.querydsl.core.types.dsl.CaseBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; import lombok.RequiredArgsConstructor; @@ -25,4 +28,19 @@ public List findSortedSectorNamesByGymId(final Long gymId .orderBy(sector.sectorName.name.asc()) .fetch(); } + + public List findAllWithFavorites(final List favoriteGymIds) { + return jpaQueryFactory.select( + Projections.constructor(ClimbingGymResponseDto.class, climbingGym.id, + climbingGym.gymName, climbingGym.thumbnailUrl, climbingGym.id.in(favoriteGymIds)) + ) + .from(climbingGym) + .orderBy( + new CaseBuilder() + .when(climbingGym.id.in(favoriteGymIds)).then(1) + .otherwise(0).desc(), + climbingGym.gymName.asc() + ) + .fetch(); + } } diff --git a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymRepositoryImpl.java b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymRepositoryImpl.java index 2f504fb0..4946d6f1 100644 --- a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymRepositoryImpl.java +++ b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymRepositoryImpl.java @@ -2,6 +2,7 @@ import com.first.flash.climbing.gym.domian.ClimbingGym; import com.first.flash.climbing.gym.domian.ClimbingGymRepository; +import com.first.flash.climbing.gym.infrastructure.dto.ClimbingGymResponseDto; import com.first.flash.climbing.gym.infrastructure.dto.SectorInfoResponseDto; import java.util.List; import java.util.Optional; @@ -26,9 +27,9 @@ public Optional findById(final Long id) { } @Override - public List findAll() { - return climbingGymJpaRepository.findAll(); - } + public List findAllWithFavorites(final List favoriteGymIds){ + return climbingGymQueryDslRepository.findAllWithFavorites(favoriteGymIds); + }; @Override public List findGymSectorNamesById(final Long id) { From 04aa7b1db5f7800ab92f42faf21cdd1f7c4035b1 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 21:00:00 +0900 Subject: [PATCH 41/65] =?UTF-8?q?feat:=20=ED=81=B4=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=EC=9E=A5=20=EC=A0=84=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?dto=EB=A5=BC=20=EC=9D=B8=ED=94=84=EB=9D=BC=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EB=9F=AD=EC=B2=98=20=EB=A0=88=EC=9D=B4=EC=96=B4=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/ClimbingGymResponseDto.java | 2 +- .../com/first/flash/climbing/gym/ui/ClimbingGymController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/main/java/com/first/flash/climbing/gym/{application => infrastructure}/dto/ClimbingGymResponseDto.java (88%) diff --git a/src/main/java/com/first/flash/climbing/gym/application/dto/ClimbingGymResponseDto.java b/src/main/java/com/first/flash/climbing/gym/infrastructure/dto/ClimbingGymResponseDto.java similarity index 88% rename from src/main/java/com/first/flash/climbing/gym/application/dto/ClimbingGymResponseDto.java rename to src/main/java/com/first/flash/climbing/gym/infrastructure/dto/ClimbingGymResponseDto.java index 12b40e16..09c2fbc5 100644 --- a/src/main/java/com/first/flash/climbing/gym/application/dto/ClimbingGymResponseDto.java +++ b/src/main/java/com/first/flash/climbing/gym/infrastructure/dto/ClimbingGymResponseDto.java @@ -1,4 +1,4 @@ -package com.first.flash.climbing.gym.application.dto; +package com.first.flash.climbing.gym.infrastructure.dto; import com.first.flash.climbing.gym.domian.ClimbingGym; import java.util.List; diff --git a/src/main/java/com/first/flash/climbing/gym/ui/ClimbingGymController.java b/src/main/java/com/first/flash/climbing/gym/ui/ClimbingGymController.java index 8f5eba7f..55e34459 100644 --- a/src/main/java/com/first/flash/climbing/gym/ui/ClimbingGymController.java +++ b/src/main/java/com/first/flash/climbing/gym/ui/ClimbingGymController.java @@ -4,7 +4,7 @@ import com.first.flash.climbing.gym.application.dto.ClimbingGymCreateRequestDto; import com.first.flash.climbing.gym.application.dto.ClimbingGymCreateResponseDto; import com.first.flash.climbing.gym.application.dto.ClimbingGymDetailResponseDto; -import com.first.flash.climbing.gym.application.dto.ClimbingGymResponseDto; +import com.first.flash.climbing.gym.infrastructure.dto.ClimbingGymResponseDto; import com.first.flash.climbing.gym.domian.vo.Difficulty; import com.first.flash.climbing.gym.exception.exceptions.DuplicateDifficultyLevelException; import com.first.flash.climbing.gym.exception.exceptions.DuplicateDifficultyNameException; From 4d8c25a8c2407bf706a490d3f8bfde8101d143cb Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 21:00:17 +0900 Subject: [PATCH 42/65] =?UTF-8?q?feat:=20pk=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EC=A0=84=EB=9E=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flash/climbing/favorite/domain/MemberFavoriteGym.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGym.java b/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGym.java index 52d24ef5..a0a7e040 100644 --- a/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGym.java +++ b/src/main/java/com/first/flash/climbing/favorite/domain/MemberFavoriteGym.java @@ -2,6 +2,8 @@ import com.first.flash.global.domain.BaseEntity; import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import java.util.UUID; import lombok.Getter; @@ -15,6 +17,7 @@ public class MemberFavoriteGym extends BaseEntity { @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private UUID memberId; private Long gymId; From 87207231f739a6e249a3b0264ad71fc471ef22a1 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 21:00:33 +0900 Subject: [PATCH 43/65] =?UTF-8?q?feat:=20=EC=A6=90=EA=B2=A8=EC=B0=BE?= =?UTF-8?q?=EA=B8=B0=20=ED=86=A0=EA=B8=80=20API=20uri=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flash/climbing/favorite/ui/MemberFavoriteGymController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java b/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java index 144a50f2..d426b976 100644 --- a/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java +++ b/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java @@ -11,6 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RestController; @RestController @@ -26,6 +27,7 @@ public class MemberFavoriteGymController { @ApiResponse(responseCode = "400", description = "유효하지 않은 요청 형식", content = @Content(mediaType = "application/json")) }) + @PutMapping("/favorites/{gymId}") public ResponseEntity toggleMemberFavoriteGym( @PathVariable final Long gymId) { return ResponseEntity.status(HttpStatus.OK) From 92fdde64036e204d2f5e47b3a984eab130b7bcee Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 27 Nov 2024 21:12:49 +0900 Subject: [PATCH 44/65] =?UTF-8?q?feat:=20=ED=81=B4=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=EC=9E=A5=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20=EA=B2=80?= =?UTF-8?q?=EC=82=AC=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../favorite/application/MemberFavoriteGymService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java index 2478fb84..f736b2c7 100644 --- a/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java +++ b/src/main/java/com/first/flash/climbing/favorite/application/MemberFavoriteGymService.java @@ -3,6 +3,8 @@ import com.first.flash.climbing.favorite.application.dto.MemberFavoriteGymResponseDto; import com.first.flash.climbing.favorite.domain.MemberFavoriteGym; import com.first.flash.climbing.favorite.domain.MemberFavoriteGymRepository; +import com.first.flash.climbing.gym.domian.ClimbingGymIdConfirmRequestedEvent; +import com.first.flash.global.event.Events; import com.first.flash.global.util.AuthUtil; import java.util.List; import java.util.Optional; @@ -17,6 +19,7 @@ public class MemberFavoriteGymService { private final MemberFavoriteGymRepository memberFavoriteGymRepository; public MemberFavoriteGymResponseDto toggleMemberFavoriteGym(final Long gymId) { + Events.raise(ClimbingGymIdConfirmRequestedEvent.of(gymId)); UUID memberId = AuthUtil.getId(); Optional favoriteGym = memberFavoriteGymRepository.findByMemberIdAndGymId(memberId, gymId); From 10e1a0a2f92e2a24464c9717169d0cf7ff4391aa Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Thu, 28 Nov 2024 13:48:24 +0900 Subject: [PATCH 45/65] =?UTF-8?q?feat:=20swagger=EC=97=90=20tag=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flash/climbing/favorite/ui/MemberFavoriteGymController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java b/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java index d426b976..13d5256f 100644 --- a/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java +++ b/src/main/java/com/first/flash/climbing/favorite/ui/MemberFavoriteGymController.java @@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RestController; +@Tag(name = "favorite", description = "즐겨찾기 API") @RestController @RequiredArgsConstructor public class MemberFavoriteGymController { From ca82cc762422291892b9004c2a094ba447a6fb96 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Tue, 3 Dec 2024 17:10:50 +0900 Subject: [PATCH 46/65] =?UTF-8?q?feat:=20=ED=99=80=EB=93=9C=20=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EB=B8=94,=20=ED=99=80=EB=93=9C=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=20=EB=B0=8F=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hold/application/HoldService.java | 50 ++++++++++++++++++ .../application/dto/HoldCreateRequestDto.java | 10 ++++ .../hold/application/dto/HoldResponseDto.java | 10 ++++ .../application/dto/HoldsResponseDto.java | 7 +++ .../flash/climbing/hold/domain/Hold.java | 31 +++++++++++ .../climbing/hold/domain/HoldRepository.java | 14 +++++ .../hold/exception/HoldExceptionHandler.java | 25 +++++++++ .../exceptions/HoldNotFoundException.java | 15 ++++++ .../infrastructure/HoldJpaRepository.java | 15 ++++++ .../infrastructure/HoldRepositoryImpl.java | 30 +++++++++++ .../climbing/hold/ui/HoldController.java | 52 +++++++++++++++++++ 11 files changed, 259 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/hold/application/HoldService.java create mode 100644 src/main/java/com/first/flash/climbing/hold/application/dto/HoldCreateRequestDto.java create mode 100644 src/main/java/com/first/flash/climbing/hold/application/dto/HoldResponseDto.java create mode 100644 src/main/java/com/first/flash/climbing/hold/application/dto/HoldsResponseDto.java create mode 100644 src/main/java/com/first/flash/climbing/hold/domain/Hold.java create mode 100644 src/main/java/com/first/flash/climbing/hold/domain/HoldRepository.java create mode 100644 src/main/java/com/first/flash/climbing/hold/exception/HoldExceptionHandler.java create mode 100644 src/main/java/com/first/flash/climbing/hold/exception/exceptions/HoldNotFoundException.java create mode 100644 src/main/java/com/first/flash/climbing/hold/infrastructure/HoldJpaRepository.java create mode 100644 src/main/java/com/first/flash/climbing/hold/infrastructure/HoldRepositoryImpl.java create mode 100644 src/main/java/com/first/flash/climbing/hold/ui/HoldController.java diff --git a/src/main/java/com/first/flash/climbing/hold/application/HoldService.java b/src/main/java/com/first/flash/climbing/hold/application/HoldService.java new file mode 100644 index 00000000..32150b05 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/hold/application/HoldService.java @@ -0,0 +1,50 @@ +package com.first.flash.climbing.hold.application; + +import com.first.flash.climbing.hold.application.dto.HoldCreateRequestDto; +import com.first.flash.climbing.hold.application.dto.HoldResponseDto; +import com.first.flash.climbing.hold.application.dto.HoldsResponseDto; +import com.first.flash.climbing.hold.domain.Hold; +import com.first.flash.climbing.hold.domain.HoldRepository; +import com.first.flash.climbing.hold.exception.exceptions.HoldNotFoundException; +import com.first.flash.climbing.sector.application.dto.SectorCreateRequestDto; +import com.first.flash.climbing.sector.application.dto.SectorDetailResponseDto; +import com.first.flash.climbing.sector.application.dto.SectorsDetailResponseDto; +import com.first.flash.climbing.sector.domain.Sector; +import com.first.flash.climbing.sector.domain.SectorInfo; +import com.first.flash.climbing.sector.exception.exceptions.SectorNotFoundException; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class HoldService { + + private final HoldRepository holdRepository; + + public Hold findById(final Long id) { + return holdRepository.findById(id) + .orElseThrow(() -> new HoldNotFoundException(id)); + } + + public HoldsResponseDto findAllHolds() { + List holdsResponse = holdRepository.findAll() + .stream() + .map(HoldResponseDto::toDto) + .toList(); + + return new HoldsResponseDto(holdsResponse); + } + + @Transactional + public HoldResponseDto saveHold(final HoldCreateRequestDto createRequestDto) { + Hold hold = createHold(createRequestDto); + return HoldResponseDto.toDto(holdRepository.save(hold)); + } + + private Hold createHold(final HoldCreateRequestDto createRequestDto) { + return Hold.of(createRequestDto.colorName(), createRequestDto.colorCode()); + } +} diff --git a/src/main/java/com/first/flash/climbing/hold/application/dto/HoldCreateRequestDto.java b/src/main/java/com/first/flash/climbing/hold/application/dto/HoldCreateRequestDto.java new file mode 100644 index 00000000..8eb98f1c --- /dev/null +++ b/src/main/java/com/first/flash/climbing/hold/application/dto/HoldCreateRequestDto.java @@ -0,0 +1,10 @@ +package com.first.flash.climbing.hold.application.dto; + +import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; + +public record HoldCreateRequestDto( + @NotNull(message = "홀드 색상 이름 정보는 비어있을 수 없습니다.") String colorName, + @NotNull(message = "홀드 색상 코드 정보는 비어있을 수 없습니다.") String colorCode) { + +} diff --git a/src/main/java/com/first/flash/climbing/hold/application/dto/HoldResponseDto.java b/src/main/java/com/first/flash/climbing/hold/application/dto/HoldResponseDto.java new file mode 100644 index 00000000..2b6c5732 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/hold/application/dto/HoldResponseDto.java @@ -0,0 +1,10 @@ +package com.first.flash.climbing.hold.application.dto; + +import com.first.flash.climbing.hold.domain.Hold; + +public record HoldResponseDto(Long id, String colorName, String colorCode) { + + public static HoldResponseDto toDto(final Hold hold) { + return new HoldResponseDto(hold.getId(), hold.getColorName(), hold.getColorCode()); + } +} diff --git a/src/main/java/com/first/flash/climbing/hold/application/dto/HoldsResponseDto.java b/src/main/java/com/first/flash/climbing/hold/application/dto/HoldsResponseDto.java new file mode 100644 index 00000000..1f6d215f --- /dev/null +++ b/src/main/java/com/first/flash/climbing/hold/application/dto/HoldsResponseDto.java @@ -0,0 +1,7 @@ +package com.first.flash.climbing.hold.application.dto; + +import java.util.List; + +public record HoldsResponseDto(List holdList) { + +} diff --git a/src/main/java/com/first/flash/climbing/hold/domain/Hold.java b/src/main/java/com/first/flash/climbing/hold/domain/Hold.java new file mode 100644 index 00000000..0644f76c --- /dev/null +++ b/src/main/java/com/first/flash/climbing/hold/domain/Hold.java @@ -0,0 +1,31 @@ +package com.first.flash.climbing.hold.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Entity +@NoArgsConstructor +@Getter +@ToString +public class Hold { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String colorName; + private String colorCode; + + protected Hold(final String colorName, final String colorCode) { + this.colorName = colorName; + this.colorCode = colorCode; + } + + public static Hold of(final String colorName, final String colorCode) { + return new Hold(colorName, colorCode); + } +} diff --git a/src/main/java/com/first/flash/climbing/hold/domain/HoldRepository.java b/src/main/java/com/first/flash/climbing/hold/domain/HoldRepository.java new file mode 100644 index 00000000..2bb02724 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/hold/domain/HoldRepository.java @@ -0,0 +1,14 @@ +package com.first.flash.climbing.hold.domain; + +import com.first.flash.climbing.sector.domain.Sector; +import java.util.List; +import java.util.Optional; + +public interface HoldRepository { + + Hold save(final Hold hold); + + Optional findById(final Long id); + + List findAll(); +} diff --git a/src/main/java/com/first/flash/climbing/hold/exception/HoldExceptionHandler.java b/src/main/java/com/first/flash/climbing/hold/exception/HoldExceptionHandler.java new file mode 100644 index 00000000..73054ba1 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/hold/exception/HoldExceptionHandler.java @@ -0,0 +1,25 @@ +package com.first.flash.climbing.hold.exception; + +import com.first.flash.climbing.hold.exception.exceptions.HoldNotFoundException; +import com.first.flash.global.dto.ErrorResponseDto; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; + +@ControllerAdvice +public class HoldExceptionHandler { + + @ExceptionHandler(HoldNotFoundException.class) + public ResponseEntity handleHoldNotFoundException( + final HoldNotFoundException exception) { + return getResponseWithStatus(HttpStatus.NOT_FOUND, exception); + } + + private ResponseEntity getResponseWithStatus(final HttpStatus httpStatus, + final RuntimeException exception) { + ErrorResponseDto errorResponse = new ErrorResponseDto(exception.getMessage()); + return ResponseEntity.status(httpStatus) + .body(errorResponse); + } +} diff --git a/src/main/java/com/first/flash/climbing/hold/exception/exceptions/HoldNotFoundException.java b/src/main/java/com/first/flash/climbing/hold/exception/exceptions/HoldNotFoundException.java new file mode 100644 index 00000000..c5485321 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/hold/exception/exceptions/HoldNotFoundException.java @@ -0,0 +1,15 @@ +package com.first.flash.climbing.hold.exception.exceptions; + +import com.first.flash.climbing.sector.exception.exceptions.SectorNotFoundException; +import com.first.flash.global.dto.ErrorResponseDto; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; + +public class HoldNotFoundException extends RuntimeException { + + public HoldNotFoundException(final Long id) { + super(String.format("아이디가 %s인 홀드를 찾을 수 없습니다.", id)); + } +} diff --git a/src/main/java/com/first/flash/climbing/hold/infrastructure/HoldJpaRepository.java b/src/main/java/com/first/flash/climbing/hold/infrastructure/HoldJpaRepository.java new file mode 100644 index 00000000..a78cedcb --- /dev/null +++ b/src/main/java/com/first/flash/climbing/hold/infrastructure/HoldJpaRepository.java @@ -0,0 +1,15 @@ +package com.first.flash.climbing.hold.infrastructure; + +import com.first.flash.climbing.hold.domain.Hold; +import java.util.List; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface HoldJpaRepository extends JpaRepository { + + Hold save(final Hold hold); + + Optional findById(final Long id); + + List findAll(); +} diff --git a/src/main/java/com/first/flash/climbing/hold/infrastructure/HoldRepositoryImpl.java b/src/main/java/com/first/flash/climbing/hold/infrastructure/HoldRepositoryImpl.java new file mode 100644 index 00000000..177ca752 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/hold/infrastructure/HoldRepositoryImpl.java @@ -0,0 +1,30 @@ +package com.first.flash.climbing.hold.infrastructure; + +import com.first.flash.climbing.hold.domain.Hold; +import com.first.flash.climbing.hold.domain.HoldRepository; +import java.util.List; +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; + +@Repository +@RequiredArgsConstructor +public class HoldRepositoryImpl implements HoldRepository { + + private final HoldJpaRepository holdJpaRepository; + + @Override + public Hold save(Hold hold) { + return holdJpaRepository.save(hold); + } + + @Override + public Optional findById(Long id) { + return holdJpaRepository.findById(id); + } + + @Override + public List findAll() { + return holdJpaRepository.findAll(); + } +} diff --git a/src/main/java/com/first/flash/climbing/hold/ui/HoldController.java b/src/main/java/com/first/flash/climbing/hold/ui/HoldController.java new file mode 100644 index 00000000..01d9a3d9 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/hold/ui/HoldController.java @@ -0,0 +1,52 @@ +package com.first.flash.climbing.hold.ui; + +import com.first.flash.climbing.hold.application.HoldService; +import com.first.flash.climbing.hold.application.dto.HoldCreateRequestDto; +import com.first.flash.climbing.hold.application.dto.HoldResponseDto; +import com.first.flash.climbing.hold.application.dto.HoldsResponseDto; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +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.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "holds", description = "홀드 정보 관리 API") +@RestController +@RequestMapping +@RequiredArgsConstructor +public class HoldController { + + private final HoldService holdService; + + @Operation(summary = "모든 홀드 정보 조회", description = "모든 홀드 정보를 리스트로 반환") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공적으로 홀드를 조회", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = HoldsResponseDto.class))), + }) + @GetMapping("holds") + public ResponseEntity findAllHolds() { + return ResponseEntity.ok(holdService.findAllHolds()); + } + + @Operation(summary = "홀드 정보 생성", description = "홀드 정보를 생성") + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "홀드 정보를 생성", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = HoldResponseDto.class))), + }) + @PostMapping("holds") + public ResponseEntity createHold( + @Valid @RequestBody final HoldCreateRequestDto createRequestDto) { + return ResponseEntity.status(HttpStatus.CREATED) + .body(holdService.saveHold(createRequestDto)); + } +} \ No newline at end of file From b307d6fdfdb2fe8b6162d7ce99ebfbfdb58df819 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Wed, 4 Dec 2024 13:09:09 +0900 Subject: [PATCH 47/65] =?UTF-8?q?feat:=20=ED=81=B4=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=EC=9E=A5=20=EC=83=81=EC=84=B8=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20sectorId=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=20=EC=A0=9C=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gym/infrastructure/ClimbingGymQueryDslRepository.java | 4 ++-- .../gym/infrastructure/dto/SectorInfoResponseDto.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java index 00f9d5bf..010fdda1 100644 --- a/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java +++ b/src/main/java/com/first/flash/climbing/gym/infrastructure/ClimbingGymQueryDslRepository.java @@ -20,8 +20,8 @@ public class ClimbingGymQueryDslRepository { public List findSortedSectorNamesByGymId(final Long gymId) { return jpaQueryFactory.select( - Projections.constructor(SectorInfoResponseDto.class, sector.sectorName.name, - sector.selectedImageUrl)) + Projections.constructor(SectorInfoResponseDto.class, sector.id, + sector.sectorName.name, sector.selectedImageUrl)) .from(sector) .where(sector.gymId.eq(gymId), sector.removalInfo.isExpired.isFalse()) .distinct() diff --git a/src/main/java/com/first/flash/climbing/gym/infrastructure/dto/SectorInfoResponseDto.java b/src/main/java/com/first/flash/climbing/gym/infrastructure/dto/SectorInfoResponseDto.java index 16e6cca2..3d2540d5 100644 --- a/src/main/java/com/first/flash/climbing/gym/infrastructure/dto/SectorInfoResponseDto.java +++ b/src/main/java/com/first/flash/climbing/gym/infrastructure/dto/SectorInfoResponseDto.java @@ -1,5 +1,5 @@ package com.first.flash.climbing.gym.infrastructure.dto; -public record SectorInfoResponseDto(String name, String selectedImageUrl) { +public record SectorInfoResponseDto(Long id, String name, String selectedImageUrl) { } From 6108615065369008222f4d1d928995745bba9b4f Mon Sep 17 00:00:00 2001 From: wonyangs Date: Wed, 4 Dec 2024 14:42:06 +0900 Subject: [PATCH 48/65] =?UTF-8?q?feat:=20Solution=EC=97=90=20=ED=92=80?= =?UTF-8?q?=EC=9D=B4=20=EC=9D=BC=EC=9E=90,=20=EC=8D=B8=EB=84=A4=EC=9D=BC?= =?UTF-8?q?=20url=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/SolutionSaveService.java | 6 ++++-- .../solution/application/SolutionService.java | 3 ++- .../dto/SolutionUpdateRequestDto.java | 3 +++ .../dto/SolutionWriteResponseDto.java | 7 +++++-- ...registeredMemberSolutionCreateRequest.java | 3 +++ .../climbing/solution/domain/Solution.java | 19 +++++++++++++------ .../domain/dto/SolutionCreateRequestDto.java | 9 ++++++++- .../solution/domain/vo/SolutionDetail.java | 13 ++++++++++--- 8 files changed, 48 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/solution/application/SolutionSaveService.java b/src/main/java/com/first/flash/climbing/solution/application/SolutionSaveService.java index 3d3e89ce..1d9feada 100644 --- a/src/main/java/com/first/flash/climbing/solution/application/SolutionSaveService.java +++ b/src/main/java/com/first/flash/climbing/solution/application/SolutionSaveService.java @@ -34,7 +34,8 @@ public SolutionWriteResponseDto saveSolution(final UUID problemId, PerceivedDifficulty perceivedDifficulty = createRequestDto.perceivedDifficulty(); Solution solution = Solution.of(member.getNickName(), createRequestDto.review(), - member.getInstagramId(), createRequestDto.videoUrl(), problemId, member.getId(), + member.getInstagramId(), createRequestDto.thumbnailImageUrl(), createRequestDto.solvedDate(), + createRequestDto.videoUrl(), problemId, member.getId(), member.getProfileImageUrl(), perceivedDifficulty, member.getHeight(), member.getReach(), member.getGender()); Events.raise(PerceivedDifficultySetEvent.of(solution.getProblemId(), @@ -61,7 +62,8 @@ public SolutionWriteResponseDto saveUnregisteredMemberSolution(final UUID proble PerceivedDifficulty perceivedDifficulty = requestDto.perceivedDifficulty(); Solution solution = Solution.of(requestDto.nickName(), requestDto.review(), - requestDto.instagramId(), requestDto.videoUrl(), problemId, member.getId(), + requestDto.instagramId(), requestDto.thumbnailImageUrl(), requestDto.solvedDate(), + requestDto.videoUrl(), problemId, member.getId(), requestDto.profileImageUrl(), perceivedDifficulty, member.getHeight(), member.getReach(), member.getGender()); diff --git a/src/main/java/com/first/flash/climbing/solution/application/SolutionService.java b/src/main/java/com/first/flash/climbing/solution/application/SolutionService.java index 630afc0e..825749bf 100644 --- a/src/main/java/com/first/flash/climbing/solution/application/SolutionService.java +++ b/src/main/java/com/first/flash/climbing/solution/application/SolutionService.java @@ -79,7 +79,8 @@ public SolutionWriteResponseDto updateContent(final Long id, PerceivedDifficulty oldPerceivedDifficulty = solution.getSolutionDetail().getPerceivedDifficulty(); int difficultyDifference = newPerceivedDifficulty.calculateDifferenceFrom(oldPerceivedDifficulty); - solution.updateContentInfo(requestDto.review(), requestDto.videoUrl(), newPerceivedDifficulty); + solution.updateContentInfo(requestDto.review(), requestDto.thumbnailImageUrl(), + requestDto.videoUrl(), requestDto.solvedDate(), newPerceivedDifficulty); Events.raise(PerceivedDifficultySetEvent.of( solution.getProblemId(), diff --git a/src/main/java/com/first/flash/climbing/solution/application/dto/SolutionUpdateRequestDto.java b/src/main/java/com/first/flash/climbing/solution/application/dto/SolutionUpdateRequestDto.java index 427c2c5e..d24b9108 100644 --- a/src/main/java/com/first/flash/climbing/solution/application/dto/SolutionUpdateRequestDto.java +++ b/src/main/java/com/first/flash/climbing/solution/application/dto/SolutionUpdateRequestDto.java @@ -5,10 +5,13 @@ import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; +import java.time.LocalDate; public record SolutionUpdateRequestDto( + @NotEmpty(message = "썸네일 URL은 필수입니다.") String thumbnailImageUrl, @NotEmpty(message = "비디오 URL은 필수입니다.") String videoUrl, @Size(max = 500, message = "리뷰는 최대 500자까지 가능합니다.") String review, + @NotNull(message = "풀이 일자 정보는 필수입니다.") LocalDate solvedDate, @NotNull(message = "체감 난이도는 필수입니다.") @ValidEnum(enumClass = PerceivedDifficulty.class) PerceivedDifficulty perceivedDifficulty) { diff --git a/src/main/java/com/first/flash/climbing/solution/application/dto/SolutionWriteResponseDto.java b/src/main/java/com/first/flash/climbing/solution/application/dto/SolutionWriteResponseDto.java index b6c7360d..0049a22d 100644 --- a/src/main/java/com/first/flash/climbing/solution/application/dto/SolutionWriteResponseDto.java +++ b/src/main/java/com/first/flash/climbing/solution/application/dto/SolutionWriteResponseDto.java @@ -4,10 +4,12 @@ import com.first.flash.climbing.solution.domain.vo.SolutionDetail; import com.first.flash.climbing.solution.domain.vo.UploaderDetail; import com.first.flash.global.util.AuthUtil; +import java.time.LocalDate; import java.util.UUID; public record SolutionWriteResponseDto(Long id, String uploader, String review, String instagramId, - String videoUrl, UUID uploaderId, Boolean isUploader, + String thumbnailImageUrl, String videoUrl, LocalDate solvedDate, + UUID uploaderId, Boolean isUploader, String profileImageUrl) { public static SolutionWriteResponseDto toDto(final Solution solution) { @@ -18,7 +20,8 @@ public static SolutionWriteResponseDto toDto(final Solution solution) { return new SolutionWriteResponseDto(solution.getId(), uploaderDetail.getUploader(), solutionDetail.getReview(), uploaderDetail.getInstagramId(), - solutionDetail.getVideoUrl(), uploaderDetail.getUploaderId(), isUploader, + solutionDetail.getThumbnailImageUrl(), solutionDetail.getVideoUrl(), + solutionDetail.getSolvedDate(), uploaderDetail.getUploaderId(), isUploader, uploaderDetail.getProfileImageUrl()); } } diff --git a/src/main/java/com/first/flash/climbing/solution/application/dto/UnregisteredMemberSolutionCreateRequest.java b/src/main/java/com/first/flash/climbing/solution/application/dto/UnregisteredMemberSolutionCreateRequest.java index ead35334..e4a133fa 100644 --- a/src/main/java/com/first/flash/climbing/solution/application/dto/UnregisteredMemberSolutionCreateRequest.java +++ b/src/main/java/com/first/flash/climbing/solution/application/dto/UnregisteredMemberSolutionCreateRequest.java @@ -4,12 +4,15 @@ import com.first.flash.global.annotation.ValidEnum; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; public record UnregisteredMemberSolutionCreateRequest( @NotEmpty(message = "닉네임은 필수입니다.") String nickName, @NotEmpty(message = "인스타그램 아이디는 필수입니다.") String instagramId, String review, String profileImageUrl, + @NotEmpty(message = "썸네일 URL은 필수입니다.") String thumbnailImageUrl, @NotEmpty(message = "비디오 URL은 필수입니다.") String videoUrl, + @NotNull(message = "풀이 일자 정보는 필수입니다.") LocalDate solvedDate, @NotNull(message = "체감 난이도는 필수입니다.") @ValidEnum(enumClass = PerceivedDifficulty.class) PerceivedDifficulty perceivedDifficulty) { diff --git a/src/main/java/com/first/flash/climbing/solution/domain/Solution.java b/src/main/java/com/first/flash/climbing/solution/domain/Solution.java index 0049a0f8..23051f4c 100644 --- a/src/main/java/com/first/flash/climbing/solution/domain/Solution.java +++ b/src/main/java/com/first/flash/climbing/solution/domain/Solution.java @@ -11,6 +11,7 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.OneToMany; +import java.time.LocalDate; import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -41,12 +42,14 @@ public class Solution extends BaseEntity { private List comments = new ArrayList<>(); protected Solution(final String uploader, final String review, final String instagramId, + final String thumbnailImageUrl, final LocalDate solvedDate, final String videoUrl, final UUID problemId, final UUID uploaderId, final String profileImageUrl, final PerceivedDifficulty perceivedDifficulty, final Double uploaderHeight, final Double uploaderReach, final Gender uploaderGender) { - this.solutionDetail = SolutionDetail.of(review, videoUrl, perceivedDifficulty); + this.solutionDetail = SolutionDetail.of(review, thumbnailImageUrl, videoUrl, + solvedDate, perceivedDifficulty); this.uploaderDetail = UploaderDetail.of(uploaderId, uploader, instagramId, profileImageUrl, uploaderHeight, uploaderReach, uploaderGender); this.optionalWeight = DEFAULT_OPTIONAL_WEIGHT; @@ -54,16 +57,20 @@ protected Solution(final String uploader, final String review, final String inst } public static Solution of(final String uploader, final String review, final String instagramId, + final String thumbnailImageUrl, final LocalDate solvedDate, final String videoUrl, final UUID problemId, final UUID uploaderId, final String profileImageUrl, final PerceivedDifficulty perceivedDifficulty, - final Double uploaderHeight, final Double uploaderReach, final Gender uploaderGender) { + final Double uploaderHeight, + final Double uploaderReach, final Gender uploaderGender) { - return new Solution(uploader, review, instagramId, videoUrl, problemId, uploaderId, + return new Solution(uploader, review, instagramId, thumbnailImageUrl, solvedDate, videoUrl, + problemId, uploaderId, profileImageUrl, perceivedDifficulty, uploaderHeight, uploaderReach, uploaderGender); } - public void updateContentInfo(final String review, final String videoUrl, - final PerceivedDifficulty perceivedDifficulty) { - this.solutionDetail = SolutionDetail.of(review, videoUrl, perceivedDifficulty); + public void updateContentInfo(final String review, final String videoUrl, final String thumbnailImageUrl, + final LocalDate solvedDate, final PerceivedDifficulty perceivedDifficulty) { + this.solutionDetail = SolutionDetail.of(review, thumbnailImageUrl, videoUrl, + solvedDate, perceivedDifficulty); } } diff --git a/src/main/java/com/first/flash/climbing/solution/domain/dto/SolutionCreateRequestDto.java b/src/main/java/com/first/flash/climbing/solution/domain/dto/SolutionCreateRequestDto.java index 621ea90b..56ddef22 100644 --- a/src/main/java/com/first/flash/climbing/solution/domain/dto/SolutionCreateRequestDto.java +++ b/src/main/java/com/first/flash/climbing/solution/domain/dto/SolutionCreateRequestDto.java @@ -3,16 +3,23 @@ import com.first.flash.climbing.solution.domain.PerceivedDifficulty; import com.first.flash.global.annotation.ValidEnum; import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; +import java.time.LocalDate; public record SolutionCreateRequestDto( + @NotEmpty(message = "썸네일 URL은 필수입니다.") String thumbnailImageUrl, @NotEmpty(message = "비디오 URL은 필수입니다.") String videoUrl, @Size(max = 500, message = "리뷰는 최대 500자까지 가능합니다.") String review, + @NotNull(message = "풀이 일자 정보는 필수입니다.") LocalDate solvedDate, @ValidEnum(enumClass = PerceivedDifficulty.class) PerceivedDifficulty perceivedDifficulty) { - public SolutionCreateRequestDto(final String videoUrl, final String review, final PerceivedDifficulty perceivedDifficulty) { + public SolutionCreateRequestDto(final String thumbnailImageUrl, final String videoUrl, + final String review, final LocalDate solvedDate, final PerceivedDifficulty perceivedDifficulty) { + this.thumbnailImageUrl = thumbnailImageUrl; this.videoUrl = videoUrl; this.review = review; + this.solvedDate = solvedDate; this.perceivedDifficulty = perceivedDifficulty != null ? perceivedDifficulty : PerceivedDifficulty.NORMAL; } } diff --git a/src/main/java/com/first/flash/climbing/solution/domain/vo/SolutionDetail.java b/src/main/java/com/first/flash/climbing/solution/domain/vo/SolutionDetail.java index 6fba659d..2206bc5d 100644 --- a/src/main/java/com/first/flash/climbing/solution/domain/vo/SolutionDetail.java +++ b/src/main/java/com/first/flash/climbing/solution/domain/vo/SolutionDetail.java @@ -4,6 +4,7 @@ import com.first.flash.climbing.solution.domain.PerceivedDifficultyConverter; import jakarta.persistence.Convert; import jakarta.persistence.Embeddable; +import java.time.LocalDate; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -17,17 +18,23 @@ public class SolutionDetail { private String review; + private String thumbnailImageUrl; private String videoUrl; + private LocalDate solvedDate; @Convert(converter = PerceivedDifficultyConverter.class) private PerceivedDifficulty perceivedDifficulty; - protected SolutionDetail(final String review, final String videoUrl, final PerceivedDifficulty perceivedDifficulty) { + protected SolutionDetail(final String review, final String thumbnailImageUrl, final String videoUrl, + final LocalDate solvedDate, final PerceivedDifficulty perceivedDifficulty) { this.review = review; + this.thumbnailImageUrl = thumbnailImageUrl; this.videoUrl = videoUrl; + this.solvedDate = solvedDate; this.perceivedDifficulty = perceivedDifficulty; } - public static SolutionDetail of(final String review, final String videoUrl, final PerceivedDifficulty perceivedDifficulty) { - return new SolutionDetail(review, videoUrl, perceivedDifficulty); + public static SolutionDetail of(final String review, final String thumbnailImageUrl, final String videoUrl, + final LocalDate solvedDate, final PerceivedDifficulty perceivedDifficulty) { + return new SolutionDetail(review, thumbnailImageUrl, videoUrl, solvedDate, perceivedDifficulty); } } From 1b2e478bb7679099585bad98c5e5aaaa7031aec7 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Wed, 4 Dec 2024 15:23:53 +0900 Subject: [PATCH 49/65] =?UTF-8?q?feat:=20Problem=EC=97=90=20=ED=99=80?= =?UTF-8?q?=EB=93=9C=20=EC=A0=95=EB=B3=B4,=20=EC=8D=B8=EB=84=A4=EC=9D=BC?= =?UTF-8?q?=20=ED=95=B4=EC=84=A4=20=EC=A0=95=EB=B3=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 해설 및 홀드 id 검증 로직은 추후 구현 --- .../problem/application/ProblemsSaveService.java | 6 +++++- .../application/dto/ProblemCreateResponseDto.java | 5 ++++- .../first/flash/climbing/problem/domain/Problem.java | 6 +++++- .../climbing/problem/domain/ProblemsCreateService.java | 10 ++++++++-- .../flash/climbing/problem/domain/QueryProblem.java | 4 ++++ .../problem/domain/dto/ProblemCreateRequestDto.java | 5 ++++- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/problem/application/ProblemsSaveService.java b/src/main/java/com/first/flash/climbing/problem/application/ProblemsSaveService.java index d8a09380..346767e2 100644 --- a/src/main/java/com/first/flash/climbing/problem/application/ProblemsSaveService.java +++ b/src/main/java/com/first/flash/climbing/problem/application/ProblemsSaveService.java @@ -2,6 +2,8 @@ import com.first.flash.climbing.gym.application.ClimbingGymService; import com.first.flash.climbing.gym.domian.ClimbingGym; +import com.first.flash.climbing.hold.application.HoldService; +import com.first.flash.climbing.hold.domain.Hold; import com.first.flash.climbing.problem.application.dto.ProblemCreateResponseDto; import com.first.flash.climbing.problem.domain.Problem; import com.first.flash.climbing.problem.domain.ProblemRepository; @@ -24,6 +26,7 @@ public class ProblemsSaveService { private final QueryProblemRepository queryProblemRepository; private final ClimbingGymService climbingGymService; private final SectorService sectorService; + private final HoldService holdService; private final ProblemsCreateService problemsCreateService; @Transactional @@ -31,10 +34,11 @@ public ProblemCreateResponseDto saveProblems(final Long gymId, final Long sector final ProblemCreateRequestDto createRequestDto) { ClimbingGym climbingGym = climbingGymService.findClimbingGymById(gymId); Sector sector = sectorService.findById(sectorId); + Hold hold = holdService.findById(createRequestDto.holdId()); Problem problem = problemsCreateService.createProblem(climbingGym, sector, createRequestDto); QueryProblem queryProblem = problemsCreateService.createQueryProblem(climbingGym, - sector, problem); + sector, problem, hold); problemRepository.save(problem); queryProblemRepository.save(queryProblem); return ProblemCreateResponseDto.toDto(problem); diff --git a/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemCreateResponseDto.java b/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemCreateResponseDto.java index eace0f4d..99e59dae 100644 --- a/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemCreateResponseDto.java +++ b/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemCreateResponseDto.java @@ -8,7 +8,8 @@ @Builder public record ProblemCreateResponseDto(UUID id, String imageUrl, Integer views, Boolean isExpired, DifficultyInfo difficultyInfo, Long optionalWeight, - Long gymId, Long sectorId, String imageSource + Long gymId, Long sectorId, String imageSource, + Long thumbnailSolutionId, Long holdId ) { public static ProblemCreateResponseDto toDto(final Problem problem) { @@ -22,6 +23,8 @@ public static ProblemCreateResponseDto toDto(final Problem problem) { .gymId(problem.getGymId()) .sectorId(problem.getSectorId()) .imageSource(problem.getImageSource()) + .thumbnailSolutionId(problem.getThumbnailSolutionId()) + .holdId(problem.getHoldId()) .build(); } } diff --git a/src/main/java/com/first/flash/climbing/problem/domain/Problem.java b/src/main/java/com/first/flash/climbing/problem/domain/Problem.java index f01cff00..e325f08d 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/Problem.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/Problem.java @@ -35,10 +35,12 @@ public class Problem { private Long gymId; private Long sectorId; private String imageSource; + private Long thumbnailSolutionId; + private Long holdId; public static Problem createDefault(final UUID id, final String imageUrl, final String difficultyName, final Integer difficultyLevel, final Long gymId, - final Long sectorId, final String imageSource) { + final Long sectorId, final String imageSource, final Long thumbnailSolutionId, final Long holdId) { return Problem.builder() .id(id) .imageUrl(imageUrl) @@ -49,6 +51,8 @@ public static Problem createDefault(final UUID id, final String imageUrl, .gymId(gymId) .sectorId(sectorId) .imageSource(imageSource) + .thumbnailSolutionId(thumbnailSolutionId) + .holdId(holdId) .build(); } diff --git a/src/main/java/com/first/flash/climbing/problem/domain/ProblemsCreateService.java b/src/main/java/com/first/flash/climbing/problem/domain/ProblemsCreateService.java index 650529fc..6f85b972 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/ProblemsCreateService.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/ProblemsCreateService.java @@ -2,6 +2,7 @@ import com.first.flash.climbing.gym.domian.ClimbingGym; import com.first.flash.climbing.gym.domian.vo.Difficulty; +import com.first.flash.climbing.hold.domain.Hold; import com.first.flash.climbing.problem.domain.dto.ProblemCreateRequestDto; import com.first.flash.climbing.problem.util.UUIDGenerator; import com.first.flash.climbing.sector.domain.Sector; @@ -26,11 +27,12 @@ public Problem createProblem(final ClimbingGym climbingGym, final Sector sector, UUID generatedUUID = uuidGenerator.generate(); return Problem.createDefault(generatedUUID, createRequestDto.imageUrl(), - difficulty.getName(), difficulty.getLevel(), climbingGym.getId(), sector.getId(), createRequestDto.imageSource()); + difficulty.getName(), difficulty.getLevel(), climbingGym.getId(), sector.getId(), + createRequestDto.imageSource(), createRequestDto.thumbnailSolutionId(), createRequestDto.holdId()); } public QueryProblem createQueryProblem(final ClimbingGym climbingGym, final Sector sector, - final Problem problem) { + final Problem problem, final Hold hold) { return QueryProblem.builder() .id(problem.getId()) .imageUrl(problem.getImageUrl()) @@ -51,6 +53,10 @@ public QueryProblem createQueryProblem(final ClimbingGym climbingGym, final Sect .sectorName(sector.getSectorName().getName()) .settingDate(sector.getSettingDate()) .removalDate(sector.getRemovalDate()) + .thumbnailSolutionId(problem.getThumbnailSolutionId()) + .holdId(hold.getId()) + .holdColorName(hold.getColorName()) + .holdColorCode(hold.getColorCode()) .build(); } } diff --git a/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java b/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java index 65583af8..ebe1eb46 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java @@ -58,6 +58,10 @@ public class QueryProblem { private String sectorName; private LocalDate settingDate; private LocalDate removalDate; + private Long thumbnailSolutionId; + private Long holdId; + private String holdColorName; + private String holdColorCode; public boolean isExpired() { return isExpired; diff --git a/src/main/java/com/first/flash/climbing/problem/domain/dto/ProblemCreateRequestDto.java b/src/main/java/com/first/flash/climbing/problem/domain/dto/ProblemCreateRequestDto.java index 61b2b033..f9c172a2 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/dto/ProblemCreateRequestDto.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/dto/ProblemCreateRequestDto.java @@ -1,10 +1,13 @@ package com.first.flash.climbing.problem.domain.dto; import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; public record ProblemCreateRequestDto( @NotEmpty(message = "이미지 URL은 필수입니다.") String imageUrl, @NotEmpty(message = "난이도는 필수입니다.") String difficulty, - @NotEmpty(message = "이미지 출처는 필수입니다.") String imageSource) { + @NotEmpty(message = "이미지 출처는 필수입니다.") String imageSource, + @NotNull(message = "썸네일 해설 아이디는 필수입니다.") Long thumbnailSolutionId, + @NotNull(message = "홀드 아이디는 필수입니다.") Long holdId) { } From 8ebd9c5e35b128a84d6d0bcf8326ad644d687ba2 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Wed, 4 Dec 2024 16:43:27 +0900 Subject: [PATCH 50/65] =?UTF-8?q?feat:=20=EB=AC=B8=EC=A0=9C=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EC=9D=84=20=EC=9D=BC=EB=B0=98=20=EC=9C=A0=EC=A0=80?= =?UTF-8?q?=EB=8F=84=20=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D?= =?UTF-8?q?=20Url=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../problem/domain/dto/ProblemCreateRequestDto.java | 6 +++--- .../first/flash/climbing/problem/ui/ProblemController.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/problem/domain/dto/ProblemCreateRequestDto.java b/src/main/java/com/first/flash/climbing/problem/domain/dto/ProblemCreateRequestDto.java index f9c172a2..e966ad9b 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/dto/ProblemCreateRequestDto.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/dto/ProblemCreateRequestDto.java @@ -4,10 +4,10 @@ import jakarta.validation.constraints.NotNull; public record ProblemCreateRequestDto( - @NotEmpty(message = "이미지 URL은 필수입니다.") String imageUrl, + String imageUrl, + String imageSource, + Long thumbnailSolutionId, @NotEmpty(message = "난이도는 필수입니다.") String difficulty, - @NotEmpty(message = "이미지 출처는 필수입니다.") String imageSource, - @NotNull(message = "썸네일 해설 아이디는 필수입니다.") Long thumbnailSolutionId, @NotNull(message = "홀드 아이디는 필수입니다.") Long holdId) { } diff --git a/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java b/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java index fd4a6ce5..4a97c464 100644 --- a/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java +++ b/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java @@ -56,7 +56,7 @@ public class ProblemController { @ExampleObject(name = "난이도 없음", value = "{\"error\": \"이름이 핑크인 난이도를 찾을 수 없습니다.\"}") })) }) - @PostMapping("/admin/gyms/{gymId}/sectors/{sectorId}/problems") + @PostMapping("/gyms/{gymId}/sectors/{sectorId}/problems") public ResponseEntity saveProblems( @PathVariable("gymId") final Long gymId, @PathVariable("sectorId") final Long sectorId, From fdd769b1f3fff4cedb59b6ee2f8058ba8c857d64 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Wed, 4 Dec 2024 17:15:33 +0900 Subject: [PATCH 51/65] =?UTF-8?q?feat:=20=EC=97=85=EB=A1=9C=EB=93=9C?= =?UTF-8?q?=EB=90=9C=20=ED=95=B4=EC=84=A4=EC=9D=B4=20=EC=B2=AB=20=EB=B2=88?= =?UTF-8?q?=EC=A7=B8=20=ED=95=B4=EC=84=A4=EC=9D=B8=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=EC=9D=98=20=EC=8D=B8=EB=84=A4=EC=9D=BC,=20?= =?UTF-8?q?=EC=B6=9C=EC=B2=98=EC=9E=90=20=EC=9D=B8=EC=8A=A4=ED=83=80?= =?UTF-8?q?=EA=B7=B8=EB=9E=A8id,=20=EC=8D=B8=EB=84=A4=EC=9D=BC=20=ED=95=B4?= =?UTF-8?q?=EC=84=A4=20id=EB=A5=BC=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../problem/application/ProblemEventHandler.java | 2 ++ .../climbing/problem/application/ProblemsService.java | 11 +++++++++++ .../first/flash/climbing/problem/domain/Problem.java | 7 +++++++ .../flash/climbing/problem/domain/QueryProblem.java | 8 ++++++++ .../problem/domain/QueryProblemRepository.java | 1 + .../solution/application/SolutionSaveService.java | 9 +++++++-- .../climbing/solution/domain/SolutionSavedEvent.java | 8 ++++++-- 7 files changed, 42 insertions(+), 4 deletions(-) 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 8b05b54d..d6ceae5d 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 @@ -36,6 +36,8 @@ public void expireProblem(final SectorExpiredEvent event) { @EventListener @Transactional public void updateProblemSolutionInfo(final SolutionSavedEvent event) { + problemsService.changeThumbnailInfo(event.getProblemId(), event.getSolutionId(), + event.getThumbnailImageUrl(), event.getUploader()); problemsService.updateProblemSolutionInfo(event.getProblemId()); } 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 d904c4b3..a8cd55c6 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 @@ -1,6 +1,7 @@ package com.first.flash.climbing.problem.application; import com.first.flash.climbing.problem.application.dto.ProblemDetailResponseDto; +import com.first.flash.climbing.problem.domain.Problem; import com.first.flash.climbing.problem.domain.ProblemRepository; import com.first.flash.climbing.problem.domain.QueryProblem; import com.first.flash.climbing.problem.domain.QueryProblemRepository; @@ -30,6 +31,16 @@ public void expireProblems(final List expiredSectorsIds) { queryProblemRepository.expireProblemsBySectorIds(expiredSectorsIds); problemRepository.expireProblemsBySectorIds(expiredSectorsIds); } + + @Transactional + public void changeThumbnailInfo(final UUID problemId, final Long solutionId, + final String thumbnailImageUrl, final String uploader) { + Problem problem = problemReadService.findProblemById(problemId); + QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId); + + problem.setThumbnailInfo(solutionId, thumbnailImageUrl, uploader); + queryProblem.setThumbnailInfo(solutionId, thumbnailImageUrl, uploader); + } @Transactional public void updateProblemSolutionInfo(final UUID problemId) { diff --git a/src/main/java/com/first/flash/climbing/problem/domain/Problem.java b/src/main/java/com/first/flash/climbing/problem/domain/Problem.java index e325f08d..fdd54423 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/Problem.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/Problem.java @@ -63,4 +63,11 @@ public void view() { public boolean isExpired() { return isExpired; } + + public void setThumbnailInfo(final Long thumbnailSolutionId, final String imageUrl, + final String imageSource) { + this.thumbnailSolutionId = thumbnailSolutionId; + this.imageUrl = imageUrl; + this.imageSource = imageSource; + } } diff --git a/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java b/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java index ebe1eb46..177515f0 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java @@ -98,6 +98,13 @@ public Boolean isHoney() { return perceivedDifficulty < 0; } + public void setThumbnailInfo(final Long thumbnailSolutionId, final String imageUrl, + final String imageSource) { + this.thumbnailSolutionId = thumbnailSolutionId; + this.imageUrl = imageUrl; + this.imageSource = imageSource; + } + private void enableSolution() { if (!hasSolution) { hasSolution = true; @@ -113,4 +120,5 @@ private void calculateRecommendationValue() { (STANDARD_VIEW_COUNT + difficultyLevel * DIFFICULTY_LEVEL_WEIGHT) * solutionCount + optionalWeight; } + } 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 37bb8c25..2f486559 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 @@ -25,4 +25,5 @@ void updateQueryProblemInfo(final Long sectorId, final String sectorName, final LocalDate settingDate, final boolean isExpired); void updateSectorNameBySectorIds(final List sectorIds, final String sectorName); + } diff --git a/src/main/java/com/first/flash/climbing/solution/application/SolutionSaveService.java b/src/main/java/com/first/flash/climbing/solution/application/SolutionSaveService.java index 1d9feada..f1ea5eca 100644 --- a/src/main/java/com/first/flash/climbing/solution/application/SolutionSaveService.java +++ b/src/main/java/com/first/flash/climbing/solution/application/SolutionSaveService.java @@ -42,7 +42,10 @@ public SolutionWriteResponseDto saveSolution(final UUID problemId, perceivedDifficulty.getValue())); Solution savedSolution = solutionRepository.save(solution); - Events.raise(SolutionSavedEvent.of(savedSolution.getProblemId())); + Events.raise(SolutionSavedEvent.of(savedSolution.getProblemId(), savedSolution.getId(), + savedSolution.getSolutionDetail().getThumbnailImageUrl(), + savedSolution.getUploaderDetail().getInstagramId())); + return SolutionWriteResponseDto.toDto(savedSolution); } @@ -70,7 +73,9 @@ public SolutionWriteResponseDto saveUnregisteredMemberSolution(final UUID proble Solution savedSolution = solutionRepository.save(solution); Events.raise(PerceivedDifficultySetEvent.of(solution.getProblemId(), perceivedDifficulty.getValue())); - Events.raise(SolutionSavedEvent.of(savedSolution.getProblemId())); + Events.raise(SolutionSavedEvent.of(savedSolution.getProblemId(), savedSolution.getId(), + savedSolution.getSolutionDetail().getThumbnailImageUrl(), + savedSolution.getUploaderDetail().getInstagramId())); return SolutionWriteResponseDto.toDto(savedSolution); } } diff --git a/src/main/java/com/first/flash/climbing/solution/domain/SolutionSavedEvent.java b/src/main/java/com/first/flash/climbing/solution/domain/SolutionSavedEvent.java index 789244cd..46978903 100644 --- a/src/main/java/com/first/flash/climbing/solution/domain/SolutionSavedEvent.java +++ b/src/main/java/com/first/flash/climbing/solution/domain/SolutionSavedEvent.java @@ -10,8 +10,12 @@ public class SolutionSavedEvent extends Event { private UUID problemId; + private Long solutionId; + private String thumbnailImageUrl; + private String uploader; - public static SolutionSavedEvent of(final UUID problemId) { - return new SolutionSavedEvent(problemId); + public static SolutionSavedEvent of(final UUID problemId, Long solutionId, + String thumbnailImageUrl, String uploader) { + return new SolutionSavedEvent(problemId, solutionId, thumbnailImageUrl, uploader); } } From 87788bff69da539609498e6a58c6a6e89163e637 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Thu, 5 Dec 2024 12:45:06 +0900 Subject: [PATCH 52/65] =?UTF-8?q?fix:=20=EC=9D=B4=EB=AF=B8=20=EC=8D=B8?= =?UTF-8?q?=EB=84=A4=EC=9D=BC=EC=9D=B4=20=EC=9E=88=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=EC=9D=98=20=EA=B2=BD=EC=9A=B0=20=ED=95=B4=EC=84=A4=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=EB=A5=BC=20=ED=95=98=EB=8D=94?= =?UTF-8?q?=EB=9D=BC=EB=8F=84=20=EC=8D=B8=EB=84=A4=EC=9D=BC=EC=9D=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flash/climbing/problem/application/ProblemsService.java | 4 ++++ 1 file changed, 4 insertions(+) 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 a8cd55c6..e6f12628 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 @@ -38,6 +38,10 @@ public void changeThumbnailInfo(final UUID problemId, final Long solutionId, Problem problem = problemReadService.findProblemById(problemId); QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId); + if (queryProblem.getHasSolution()) { + return; + } + problem.setThumbnailInfo(solutionId, thumbnailImageUrl, uploader); queryProblem.setThumbnailInfo(solutionId, thumbnailImageUrl, uploader); } From 185de1e07d7d717b5bf3e6cfdcb13e18c501ba2b Mon Sep 17 00:00:00 2001 From: wonyangs Date: Thu, 5 Dec 2024 13:49:53 +0900 Subject: [PATCH 53/65] =?UTF-8?q?feat:=20=ED=95=B4=EC=84=A4=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EC=8B=9C=20=EB=8B=A4=EC=9D=8C=20=ED=95=B4=EC=84=A4?= =?UTF-8?q?=EC=9D=B4=20=EC=8D=B8=EB=84=A4=EC=9D=BC,=20=EB=82=A8=EC=9D=80?= =?UTF-8?q?=20=ED=95=B4=EC=84=A4=EC=9D=B4=20=EC=97=86=EC=9D=84=20=EC=8B=9C?= =?UTF-8?q?=20=EB=AC=B8=EC=A0=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../problem/application/ProblemsService.java | 13 +++++++++++++ .../problem/domain/ProblemRepository.java | 6 ++++++ .../problem/domain/QueryProblemRepository.java | 1 + .../infrastructure/ProblemJpaRepository.java | 2 ++ .../ProblemQueryDslRepository.java | 18 ++++++++++++++++++ .../infrastructure/ProblemRepositoryImpl.java | 12 ++++++++++++ .../QueryProblemJpaRepository.java | 2 ++ .../QueryProblemRepositoryImpl.java | 5 +++++ .../dto/ThumbnailSolutionDto.java | 7 +++++++ 9 files changed, 66 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/problem/infrastructure/dto/ThumbnailSolutionDto.java 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 e6f12628..9bdb08a9 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 @@ -5,6 +5,7 @@ import com.first.flash.climbing.problem.domain.ProblemRepository; import com.first.flash.climbing.problem.domain.QueryProblem; import com.first.flash.climbing.problem.domain.QueryProblemRepository; +import com.first.flash.climbing.problem.infrastructure.dto.ThumbnailSolutionDto; import java.time.LocalDate; import java.util.List; import java.util.UUID; @@ -55,8 +56,20 @@ public void updateProblemSolutionInfo(final UUID problemId) { @Transactional public void updateProblemDeletedSolutionInfo(final UUID problemId, final Integer perceivedDifficulty) { + Problem problem = problemReadService.findProblemById(problemId); QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId); + queryProblem.decrementSolutionCount(); + if (!queryProblem.getHasSolution()) { + problemRepository.deleteByProblemId(problemId); + queryProblemRepository.deleteByProblemId(problemId); + return; + } + + ThumbnailSolutionDto dto = problemRepository.findNextSolution(problemId); + problem.setThumbnailInfo(dto.solutionId(), dto.thumbnailImageUrl(), dto.uploader()); + queryProblem.setThumbnailInfo(dto.solutionId(), dto.thumbnailImageUrl(), dto.uploader()); + queryProblem.subtractPerceivedDifficulty(perceivedDifficulty); } diff --git a/src/main/java/com/first/flash/climbing/problem/domain/ProblemRepository.java b/src/main/java/com/first/flash/climbing/problem/domain/ProblemRepository.java index 4ec5e862..17a9eaa6 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/ProblemRepository.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/ProblemRepository.java @@ -1,5 +1,7 @@ package com.first.flash.climbing.problem.domain; +import com.first.flash.climbing.problem.infrastructure.dto.ThumbnailSolutionDto; +import com.first.flash.climbing.solution.domain.Solution; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -11,4 +13,8 @@ public interface ProblemRepository { Optional findById(final UUID id); void expireProblemsBySectorIds(final List expiredSectorsIds); + + void deleteByProblemId(final UUID problemId); + + ThumbnailSolutionDto findNextSolution(final UUID problemId); } 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 2f486559..f4eaf263 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 @@ -26,4 +26,5 @@ void updateQueryProblemInfo(final Long sectorId, final String sectorName, void updateSectorNameBySectorIds(final List sectorIds, final String sectorName); + void deleteByProblemId(final UUID problemId); } diff --git a/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemJpaRepository.java b/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemJpaRepository.java index 1df977ce..2e57c803 100644 --- a/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemJpaRepository.java +++ b/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemJpaRepository.java @@ -10,4 +10,6 @@ public interface ProblemJpaRepository extends JpaRepository { Problem save(final Problem problem); Optional findById(final UUID id); + + void deleteById(final UUID id); } diff --git a/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemQueryDslRepository.java b/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemQueryDslRepository.java index 3a48e71a..29962971 100644 --- a/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemQueryDslRepository.java +++ b/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemQueryDslRepository.java @@ -2,8 +2,12 @@ import static com.first.flash.climbing.problem.domain.QProblem.problem; +import com.first.flash.climbing.problem.infrastructure.dto.ThumbnailSolutionDto; +import com.first.flash.climbing.solution.domain.QSolution; +import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; +import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; @@ -19,4 +23,18 @@ public void expireProblemsBySectorIds(final List expiredSectorsIds) { .where(problem.sectorId.in(expiredSectorsIds)) .execute(); } + + public ThumbnailSolutionDto findNextSolution(UUID problemId) { + QSolution solution = QSolution.solution; + + return queryFactory.select(Projections.constructor(ThumbnailSolutionDto.class, + solution.id, + solution.uploaderDetail.uploader, + solution.solutionDetail.thumbnailImageUrl)) + .from(solution) + .where(solution.problemId.eq(problemId)) + .orderBy(solution.createdAt.asc()) + .limit(1) + .fetchOne(); + } } diff --git a/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemRepositoryImpl.java b/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemRepositoryImpl.java index 1412aed0..6b27e170 100644 --- a/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemRepositoryImpl.java +++ b/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemRepositoryImpl.java @@ -2,6 +2,8 @@ import com.first.flash.climbing.problem.domain.Problem; import com.first.flash.climbing.problem.domain.ProblemRepository; +import com.first.flash.climbing.problem.infrastructure.dto.ThumbnailSolutionDto; +import com.first.flash.climbing.solution.domain.Solution; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -29,4 +31,14 @@ public Optional findById(final UUID id) { public void expireProblemsBySectorIds(final List expiredSectorsIds) { queryDslRepository.expireProblemsBySectorIds(expiredSectorsIds); } + + @Override + public void deleteByProblemId(UUID problemId) { + jpaRepository.deleteById(problemId); + } + + @Override + public ThumbnailSolutionDto findNextSolution(UUID problemId) { + return queryDslRepository.findNextSolution(problemId); + } } diff --git a/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java b/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java index ca0b0637..96eb8549 100644 --- a/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java +++ b/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java @@ -10,4 +10,6 @@ public interface QueryProblemJpaRepository extends JpaRepository findById(final UUID id); + + void deleteById(final UUID id); } 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 c95c3a9a..978742d4 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 @@ -58,4 +58,9 @@ public void updateQueryProblemInfo(final Long sectorId, final String sectorName, public void updateSectorNameBySectorIds(final List sectorIds, final String sectorName) { queryProblemQueryDslRepository.updateSectorNameBySectorIds(sectorIds, sectorName); } + + @Override + public void deleteByProblemId(UUID problemId) { + jpaRepository.deleteById(problemId); + } } diff --git a/src/main/java/com/first/flash/climbing/problem/infrastructure/dto/ThumbnailSolutionDto.java b/src/main/java/com/first/flash/climbing/problem/infrastructure/dto/ThumbnailSolutionDto.java new file mode 100644 index 00000000..38b1b612 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/problem/infrastructure/dto/ThumbnailSolutionDto.java @@ -0,0 +1,7 @@ +package com.first.flash.climbing.problem.infrastructure.dto; + +import java.util.UUID; + +public record ThumbnailSolutionDto(Long solutionId, String uploader, String thumbnailImageUrl) { + +} From 994608bec2286d6c8d51261697e01f84b8717f75 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Thu, 5 Dec 2024 14:40:34 +0900 Subject: [PATCH 54/65] =?UTF-8?q?feat:=20=EB=82=B4=EA=B0=80=20=EC=98=AC?= =?UTF-8?q?=EB=A6=B0=20=ED=95=B4=EC=84=A4=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C?= =?UTF-8?q?=20=EC=8D=B8=EB=84=A4=EC=9D=BC=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=EC=99=80=20=ED=92=80=EC=9D=B4=20=EB=82=A0=EC=A7=9C=EB=A5=BC=20?= =?UTF-8?q?=ED=95=A8=EA=BB=98=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solution/infrastructure/SolutionQueryDslRepository.java | 4 ++-- .../climbing/solution/infrastructure/dto/MySolutionDto.java | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java b/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java index 620b6e28..0c7d6307 100644 --- a/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java +++ b/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java @@ -48,8 +48,8 @@ public List findByUploaderId(final UUID uploaderId, final List difficulty) { return jpaQueryFactory.select(Projections.constructor(MySolutionDto.class, solution.id, queryProblem.gymName, queryProblem.sectorName, - queryProblem.difficultyName, queryProblem.imageUrl, solutionComment.count(), - solution.createdAt + queryProblem.difficultyName, solution.solutionDetail.thumbnailImageUrl, + solutionComment.count(), solution.solutionDetail.solvedDate, solution.updatedAt )) .from(solution) .innerJoin(queryProblem) diff --git a/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/MySolutionDto.java b/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/MySolutionDto.java index 91aed245..6cbe6bd0 100644 --- a/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/MySolutionDto.java +++ b/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/MySolutionDto.java @@ -1,9 +1,10 @@ package com.first.flash.climbing.solution.infrastructure.dto; +import java.time.LocalDate; import java.time.LocalDateTime; public record MySolutionDto(Long solutionId, String gymName, String sectorName, - String difficultyName, String problemImageUrl, Long commentsCount, - LocalDateTime uploadedAt) { + String difficultyName, String thumbnailImageUrl, Long commentsCount, + LocalDate solvedDate, LocalDateTime uploadedAt) { } From e43905c614f0fc13bbc4a57cdc70b015dafb1a25 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Thu, 5 Dec 2024 15:32:44 +0900 Subject: [PATCH 55/65] =?UTF-8?q?feat:=20=EC=A4=91=EB=B3=B5=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../problem/application/ProblemReadService.java | 9 +++++++++ .../problem/application/ProblemsService.java | 3 +++ .../dto/DuplicateProblemsResponseDto.java | 14 ++++++++++++++ .../application/dto/ProblemResponseDto.java | 5 +++-- .../problem/domain/QueryProblemRepository.java | 2 ++ .../QueryProblemJpaRepository.java | 3 +++ .../QueryProblemRepositoryImpl.java | 6 ++++++ .../climbing/problem/ui/ProblemController.java | 17 +++++++++++++++++ 8 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/first/flash/climbing/problem/application/dto/DuplicateProblemsResponseDto.java diff --git a/src/main/java/com/first/flash/climbing/problem/application/ProblemReadService.java b/src/main/java/com/first/flash/climbing/problem/application/ProblemReadService.java index 1dac8299..0e3a18e2 100644 --- a/src/main/java/com/first/flash/climbing/problem/application/ProblemReadService.java +++ b/src/main/java/com/first/flash/climbing/problem/application/ProblemReadService.java @@ -4,7 +4,9 @@ import static com.first.flash.climbing.problem.infrastructure.paging.ProblemSortBy.VIEWS; import com.first.flash.climbing.gym.domian.ClimbingGymIdConfirmRequestedEvent; +import com.first.flash.climbing.problem.application.dto.DuplicateProblemsResponseDto; import com.first.flash.climbing.problem.application.dto.ProblemDetailResponseDto; +import com.first.flash.climbing.problem.application.dto.ProblemResponseDto; import com.first.flash.climbing.problem.application.dto.ProblemsResponseDto; import com.first.flash.climbing.problem.domain.Problem; import com.first.flash.climbing.problem.domain.ProblemRepository; @@ -66,6 +68,13 @@ public QueryProblem findQueryProblemById(final UUID problemId) { () -> new QueryProblemNotFoundException(problemId)); } + public DuplicateProblemsResponseDto findDuplicateProblems(final Long sectorId, final Long holdId, + final String difficulty) { + List duplicateProblems = queryProblemRepository.findBySectorIdAndHoldIdAndDifficulty(sectorId, holdId, difficulty); + + return DuplicateProblemsResponseDto.of(duplicateProblems); + } + private void validateExpiration(final Problem problem, final QueryProblem queryProblem) { if (problem.isExpired() || queryProblem.isExpired()) { throw new QueryProblemExpiredException(problem.getId()); 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 9bdb08a9..e0cbf4c4 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 @@ -1,6 +1,8 @@ package com.first.flash.climbing.problem.application; import com.first.flash.climbing.problem.application.dto.ProblemDetailResponseDto; +import com.first.flash.climbing.problem.application.dto.ProblemResponseDto; +import com.first.flash.climbing.problem.application.dto.ProblemsResponseDto; import com.first.flash.climbing.problem.domain.Problem; import com.first.flash.climbing.problem.domain.ProblemRepository; import com.first.flash.climbing.problem.domain.QueryProblem; @@ -96,4 +98,5 @@ public ProblemDetailResponseDto setPerceivedDifficulty(final UUID problemId, public void updateQueryProblemFixedInfo(final List sectorIds, final String sectorName) { queryProblemRepository.updateSectorNameBySectorIds(sectorIds, sectorName); } + } diff --git a/src/main/java/com/first/flash/climbing/problem/application/dto/DuplicateProblemsResponseDto.java b/src/main/java/com/first/flash/climbing/problem/application/dto/DuplicateProblemsResponseDto.java new file mode 100644 index 00000000..b4646e57 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/problem/application/dto/DuplicateProblemsResponseDto.java @@ -0,0 +1,14 @@ +package com.first.flash.climbing.problem.application.dto; + +import com.first.flash.climbing.problem.domain.QueryProblem; +import com.first.flash.global.paging.Meta; +import java.util.List; + +public record DuplicateProblemsResponseDto(List problems) { + + public static DuplicateProblemsResponseDto of(final List queryProblems) { + return new DuplicateProblemsResponseDto(queryProblems.stream() + .map(ProblemResponseDto::toDto) + .toList()); + } +} diff --git a/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemResponseDto.java b/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemResponseDto.java index fa0659ae..f74b4780 100644 --- a/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemResponseDto.java +++ b/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemResponseDto.java @@ -6,12 +6,13 @@ public record ProblemResponseDto(UUID id, String sector, String difficulty, LocalDate settingDate, LocalDate removalDate, boolean hasSolution, String imageUrl, - Boolean isHoney, Integer solutionCount) { + String holdColorCode, Boolean isHoney, Integer solutionCount) { public static ProblemResponseDto toDto(QueryProblem queryProblem) { return new ProblemResponseDto(queryProblem.getId(), queryProblem.getSectorName(), queryProblem.getDifficultyName(), queryProblem.getSettingDate(), queryProblem.getRemovalDate(), queryProblem.getHasSolution(), - queryProblem.getImageUrl(), queryProblem.isHoney(), queryProblem.getSolutionCount()); + queryProblem.getImageUrl(), queryProblem.getHoldColorCode(), + queryProblem.isHoney(), queryProblem.getSolutionCount()); } } 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 f4eaf263..b084822e 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 @@ -27,4 +27,6 @@ void updateQueryProblemInfo(final Long sectorId, final String sectorName, void updateSectorNameBySectorIds(final List sectorIds, final String sectorName); void deleteByProblemId(final UUID problemId); + + List findBySectorIdAndHoldIdAndDifficulty(Long sectorId, Long holdId, String difficulty); } diff --git a/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java b/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java index 96eb8549..91cd890f 100644 --- a/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java +++ b/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java @@ -1,6 +1,7 @@ package com.first.flash.climbing.problem.infrastructure; import com.first.flash.climbing.problem.domain.QueryProblem; +import java.util.List; import java.util.Optional; import java.util.UUID; import org.springframework.data.jpa.repository.JpaRepository; @@ -12,4 +13,6 @@ public interface QueryProblemJpaRepository extends JpaRepository findById(final UUID id); void deleteById(final UUID id); + + List findBySectorIdAndHoldIdAndDifficultyName(Long sectorId, Long holdId, String difficulty); } 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 978742d4..c90afe33 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 @@ -63,4 +63,10 @@ public void updateSectorNameBySectorIds(final List sectorIds, final String public void deleteByProblemId(UUID problemId) { jpaRepository.deleteById(problemId); } + + @Override + public List findBySectorIdAndHoldIdAndDifficulty(Long sectorId, Long holdId, + String difficulty) { + return jpaRepository.findBySectorIdAndHoldIdAndDifficultyName(sectorId, holdId, difficulty); + } } diff --git a/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java b/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java index 4a97c464..90c76305 100644 --- a/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java +++ b/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java @@ -3,6 +3,7 @@ import com.first.flash.climbing.problem.application.ProblemReadService; import com.first.flash.climbing.problem.application.ProblemsSaveService; import com.first.flash.climbing.problem.application.ProblemsService; +import com.first.flash.climbing.problem.application.dto.DuplicateProblemsResponseDto; import com.first.flash.climbing.problem.application.dto.ProblemCreateResponseDto; import com.first.flash.climbing.problem.application.dto.ProblemDetailResponseDto; import com.first.flash.climbing.problem.application.dto.ProblemPerceivedDifficultyRequestDto; @@ -123,4 +124,20 @@ public ResponseEntity changePerceivedDifficulty( @Valid @RequestBody final ProblemPerceivedDifficultyRequestDto requestDto) { return ResponseEntity.ok(problemsService.setPerceivedDifficulty(problemId, requestDto.perceivedDifficulty())); } + + @Operation(summary = "중복된 문제 조회", description = "sectorId, holdColorId, difficulty로 중복된 문제를 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공적으로 중복된 문제 조회", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = DuplicateProblemsResponseDto.class))) + }) + @GetMapping("/problems/duplicate") + public ResponseEntity findDuplicateProblems( + @RequestParam("sectorId") final Long sectorId, + @RequestParam("holdColorId") final Long holdId, + @RequestParam("difficulty") final String difficulty) { + + DuplicateProblemsResponseDto response = problemReadService.findDuplicateProblems(sectorId, holdId, difficulty); + + return ResponseEntity.ok(response); + } } From fe7862748ae20c1ccaaf83b92cffb6a1a1d6cf11 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Thu, 5 Dec 2024 15:41:20 +0900 Subject: [PATCH 56/65] =?UTF-8?q?feat:=20=EB=AC=B8=EC=A0=9C=20=EB=8B=A8?= =?UTF-8?q?=EA=B1=B4=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=ED=99=80=EB=93=9C?= =?UTF-8?q?=EC=83=89=20=EC=A0=95=EB=B3=B4=20=EC=A0=9C=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../problem/application/dto/ProblemDetailResponseDto.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemDetailResponseDto.java b/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemDetailResponseDto.java index b3d8a606..175cf9c5 100644 --- a/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemDetailResponseDto.java +++ b/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemDetailResponseDto.java @@ -7,13 +7,14 @@ public record ProblemDetailResponseDto(UUID id, String sector, String difficulty, LocalDate settingDate, LocalDate removalDate, boolean isFakeRemovalDate, boolean hasSolution, + String holdColorCode, String imageUrl, String gymName, String imageSource, Boolean isHoney) { public static ProblemDetailResponseDto of(final QueryProblem queryProblem) { return new ProblemDetailResponseDto(queryProblem.getId(), queryProblem.getSectorName(), queryProblem.getDifficultyName(), queryProblem.getSettingDate(), queryProblem.getRemovalDate(), queryProblem.getIsFakeRemovalDate(), - queryProblem.getHasSolution(), queryProblem.getImageUrl(), queryProblem.getGymName(), - queryProblem.getImageSource(), queryProblem.isHoney()); + queryProblem.getHasSolution(), queryProblem.getHoldColorCode(), queryProblem.getImageUrl(), + queryProblem.getGymName(), queryProblem.getImageSource(), queryProblem.isHoney()); } } From 3569c5472ac9674d8ce09edd5b8c823a3745cff5 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Fri, 6 Dec 2024 12:04:58 +0900 Subject: [PATCH 57/65] =?UTF-8?q?feat:=20=EC=8D=B8=EB=84=A4=EC=9D=BC=20id?= =?UTF-8?q?=EC=97=90=20=ED=95=B4=EB=8B=B9=ED=95=98=EB=8A=94=20=ED=95=B4?= =?UTF-8?q?=EC=84=A4=20=EC=8D=B8=EB=84=A4=EC=9D=BC=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=8B=9C=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/ProblemEventHandler.java | 10 ++++++++++ .../problem/application/ProblemsService.java | 10 ++++++++++ .../problem/domain/ProblemRepository.java | 2 ++ .../domain/QueryProblemRepository.java | 2 ++ .../infrastructure/ProblemJpaRepository.java | 3 +++ .../infrastructure/ProblemRepositoryImpl.java | 9 +++++++-- .../QueryProblemJpaRepository.java | 4 +++- .../QueryProblemRepositoryImpl.java | 5 +++++ .../solution/application/SolutionService.java | 7 +++++-- .../solution/domain/SolutionUpdatedEvent.java | 20 +++++++++++++++++++ 10 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/first/flash/climbing/solution/domain/SolutionUpdatedEvent.java 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 d6ceae5d..83e5add5 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 @@ -8,6 +8,7 @@ import com.first.flash.climbing.solution.domain.PerceivedDifficultySetEvent; import com.first.flash.climbing.solution.domain.SolutionDeletedEvent; import com.first.flash.climbing.solution.domain.SolutionSavedEvent; +import com.first.flash.climbing.solution.domain.SolutionUpdatedEvent; import lombok.RequiredArgsConstructor; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; @@ -41,6 +42,13 @@ public void updateProblemSolutionInfo(final SolutionSavedEvent event) { problemsService.updateProblemSolutionInfo(event.getProblemId()); } + @EventListener + @Transactional + public void updateThumbnailInfo(final SolutionUpdatedEvent event) { + problemsService.changeAllThumbnailInfo(event.getSolutionId(), event.getThumbnailImageUrl(), + event.getUploader()); + } + @EventListener @Transactional public void updateProblemDeletedSolutionInfo(final SolutionDeletedEvent event) { @@ -73,4 +81,6 @@ public void updatePerceivedDifficulty(final PerceivedDifficultySetEvent event) { problemsService.addPerceivedDifficulty(event.getProblemId(), event.getPerceivedDifficulty()); } + + } 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 e0cbf4c4..f6b92015 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 @@ -49,6 +49,16 @@ public void changeThumbnailInfo(final UUID problemId, final Long solutionId, queryProblem.setThumbnailInfo(solutionId, thumbnailImageUrl, uploader); } + @Transactional + public void changeAllThumbnailInfo(final Long solutionId, final String thumbnailImageUrl, final String uploader) { + List problems = problemRepository.findProblemsByThumbnailSolutionId(solutionId); + List queryProblems = queryProblemRepository.findProblemsByThumbnailSolutionId( + solutionId); + + problems.forEach(problem -> problem.setThumbnailInfo(solutionId, thumbnailImageUrl, uploader)); + queryProblems.forEach(queryProblem -> queryProblem.setThumbnailInfo(solutionId, thumbnailImageUrl, uploader)); + } + @Transactional public void updateProblemSolutionInfo(final UUID problemId) { QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId); diff --git a/src/main/java/com/first/flash/climbing/problem/domain/ProblemRepository.java b/src/main/java/com/first/flash/climbing/problem/domain/ProblemRepository.java index 17a9eaa6..36ae7b41 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/ProblemRepository.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/ProblemRepository.java @@ -17,4 +17,6 @@ public interface ProblemRepository { void deleteByProblemId(final UUID problemId); ThumbnailSolutionDto findNextSolution(final UUID problemId); + + List findProblemsByThumbnailSolutionId(final Long solutionId); } 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 b084822e..e4782f2b 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 @@ -29,4 +29,6 @@ void updateQueryProblemInfo(final Long sectorId, final String sectorName, void deleteByProblemId(final UUID problemId); List findBySectorIdAndHoldIdAndDifficulty(Long sectorId, Long holdId, String difficulty); + + List findProblemsByThumbnailSolutionId(Long solutionId); } diff --git a/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemJpaRepository.java b/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemJpaRepository.java index 2e57c803..2ee70f56 100644 --- a/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemJpaRepository.java +++ b/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemJpaRepository.java @@ -1,6 +1,7 @@ package com.first.flash.climbing.problem.infrastructure; import com.first.flash.climbing.problem.domain.Problem; +import java.util.List; import java.util.Optional; import java.util.UUID; import org.springframework.data.jpa.repository.JpaRepository; @@ -12,4 +13,6 @@ public interface ProblemJpaRepository extends JpaRepository { Optional findById(final UUID id); void deleteById(final UUID id); + + List findProblemsByThumbnailSolutionId(final Long solutionId); } diff --git a/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemRepositoryImpl.java b/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemRepositoryImpl.java index 6b27e170..6e176191 100644 --- a/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemRepositoryImpl.java +++ b/src/main/java/com/first/flash/climbing/problem/infrastructure/ProblemRepositoryImpl.java @@ -33,12 +33,17 @@ public void expireProblemsBySectorIds(final List expiredSectorsIds) { } @Override - public void deleteByProblemId(UUID problemId) { + public void deleteByProblemId(final UUID problemId) { jpaRepository.deleteById(problemId); } @Override - public ThumbnailSolutionDto findNextSolution(UUID problemId) { + public ThumbnailSolutionDto findNextSolution(final UUID problemId) { return queryDslRepository.findNextSolution(problemId); } + + @Override + public List findProblemsByThumbnailSolutionId(final Long solutionId) { + return jpaRepository.findProblemsByThumbnailSolutionId(solutionId); + } } diff --git a/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java b/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java index 91cd890f..29e7da6f 100644 --- a/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java +++ b/src/main/java/com/first/flash/climbing/problem/infrastructure/QueryProblemJpaRepository.java @@ -14,5 +14,7 @@ public interface QueryProblemJpaRepository extends JpaRepository findBySectorIdAndHoldIdAndDifficultyName(Long sectorId, Long holdId, String difficulty); + List findBySectorIdAndHoldIdAndDifficultyName(final Long sectorId, final Long holdId, final String difficulty); + + List findProblemsByThumbnailSolutionId(final Long solutionId); } 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 c90afe33..33be9dca 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 @@ -69,4 +69,9 @@ public List findBySectorIdAndHoldIdAndDifficulty(Long sectorId, Lo String difficulty) { return jpaRepository.findBySectorIdAndHoldIdAndDifficultyName(sectorId, holdId, difficulty); } + + @Override + public List findProblemsByThumbnailSolutionId(Long solutionId) { + return jpaRepository.findProblemsByThumbnailSolutionId(solutionId); + } } diff --git a/src/main/java/com/first/flash/climbing/solution/application/SolutionService.java b/src/main/java/com/first/flash/climbing/solution/application/SolutionService.java index 825749bf..61cb0481 100644 --- a/src/main/java/com/first/flash/climbing/solution/application/SolutionService.java +++ b/src/main/java/com/first/flash/climbing/solution/application/SolutionService.java @@ -12,6 +12,7 @@ import com.first.flash.climbing.solution.domain.Solution; import com.first.flash.climbing.solution.domain.SolutionDeletedEvent; import com.first.flash.climbing.solution.domain.SolutionRepository; +import com.first.flash.climbing.solution.domain.SolutionUpdatedEvent; import com.first.flash.climbing.solution.domain.dto.SolutionResponseDto; import com.first.flash.climbing.solution.exception.exceptions.SolutionAccessDeniedException; import com.first.flash.climbing.solution.exception.exceptions.SolutionNotFoundException; @@ -79,9 +80,11 @@ public SolutionWriteResponseDto updateContent(final Long id, PerceivedDifficulty oldPerceivedDifficulty = solution.getSolutionDetail().getPerceivedDifficulty(); int difficultyDifference = newPerceivedDifficulty.calculateDifferenceFrom(oldPerceivedDifficulty); - solution.updateContentInfo(requestDto.review(), requestDto.thumbnailImageUrl(), - requestDto.videoUrl(), requestDto.solvedDate(), newPerceivedDifficulty); + solution.updateContentInfo(requestDto.review(), requestDto.videoUrl(), + requestDto.thumbnailImageUrl(), requestDto.solvedDate(), newPerceivedDifficulty); + Events.raise(SolutionUpdatedEvent.of(solution.getId(), requestDto.thumbnailImageUrl(), + solution.getUploaderDetail().getUploader())); Events.raise(PerceivedDifficultySetEvent.of( solution.getProblemId(), difficultyDifference diff --git a/src/main/java/com/first/flash/climbing/solution/domain/SolutionUpdatedEvent.java b/src/main/java/com/first/flash/climbing/solution/domain/SolutionUpdatedEvent.java new file mode 100644 index 00000000..cc4423e6 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/solution/domain/SolutionUpdatedEvent.java @@ -0,0 +1,20 @@ +package com.first.flash.climbing.solution.domain; + +import com.first.flash.global.event.Event; +import java.util.UUID; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class SolutionUpdatedEvent extends Event { + + private Long solutionId; + private String thumbnailImageUrl; + private String uploader; + + public static SolutionUpdatedEvent of(final Long solutionId, final String thumbnailImageUrl, + final String uploader) { + return new SolutionUpdatedEvent(solutionId, thumbnailImageUrl, uploader); + } +} From 5ac390ce73ef2bd610660169d1cdb9f6aa5df54f Mon Sep 17 00:00:00 2001 From: wonyangs Date: Tue, 10 Dec 2024 12:33:52 +0900 Subject: [PATCH 58/65] =?UTF-8?q?feat:=20=ED=95=B4=EC=84=A4=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20API=EC=97=90=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solution/infrastructure/SolutionQueryDslRepository.java | 1 + .../climbing/solution/infrastructure/dto/DetailSolutionDto.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java b/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java index 0c7d6307..55d5bc66 100644 --- a/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java +++ b/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java @@ -85,6 +85,7 @@ public DetailSolutionDto findDetailSolutionById(final Long solutionId) { queryProblem.sectorName, solution.solutionDetail.review, queryProblem.difficultyName, solutionComment.count(), solution.solutionDetail.perceivedDifficulty, + solution.solutionDetail.thumbnailImageUrl, queryProblem.holdColorCode, queryProblem.removalDate, queryProblem.settingDate, solution.createdAt )) .from(solution) diff --git a/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/DetailSolutionDto.java b/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/DetailSolutionDto.java index cd20c0e7..f030bfe1 100644 --- a/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/DetailSolutionDto.java +++ b/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/DetailSolutionDto.java @@ -6,5 +6,6 @@ public record DetailSolutionDto(Long solutionId, String videoUrl, String gymName, String sectorName, String review, String difficultyName, Long commentsCount, PerceivedDifficulty perceivedDifficulty, + String thumbnailImageUrl, String holdColorCode, LocalDate removalDate, LocalDate settingDate, LocalDateTime uploadedAt) { } From bd42cbe11f37d9948dbfe0fab35bb70ef7a51dd9 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Tue, 10 Dec 2024 14:09:22 +0900 Subject: [PATCH 59/65] =?UTF-8?q?feat:=20=ED=95=B4=EC=84=A4=20=EB=94=94?= =?UTF-8?q?=ED=85=8C=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20API=EC=97=90=20?= =?UTF-8?q?=ED=92=80=EC=9D=B4=20=EB=82=A0=EC=A7=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solution/infrastructure/SolutionQueryDslRepository.java | 1 + .../climbing/solution/infrastructure/dto/DetailSolutionDto.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java b/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java index 55d5bc66..3774c7a8 100644 --- a/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java +++ b/src/main/java/com/first/flash/climbing/solution/infrastructure/SolutionQueryDslRepository.java @@ -86,6 +86,7 @@ public DetailSolutionDto findDetailSolutionById(final Long solutionId) { queryProblem.difficultyName, solutionComment.count(), solution.solutionDetail.perceivedDifficulty, solution.solutionDetail.thumbnailImageUrl, queryProblem.holdColorCode, + solution.solutionDetail.solvedDate, queryProblem.removalDate, queryProblem.settingDate, solution.createdAt )) .from(solution) diff --git a/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/DetailSolutionDto.java b/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/DetailSolutionDto.java index f030bfe1..0351cb6b 100644 --- a/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/DetailSolutionDto.java +++ b/src/main/java/com/first/flash/climbing/solution/infrastructure/dto/DetailSolutionDto.java @@ -6,6 +6,6 @@ public record DetailSolutionDto(Long solutionId, String videoUrl, String gymName, String sectorName, String review, String difficultyName, Long commentsCount, PerceivedDifficulty perceivedDifficulty, - String thumbnailImageUrl, String holdColorCode, + String thumbnailImageUrl, String holdColorCode, LocalDate solvedDate, LocalDate removalDate, LocalDate settingDate, LocalDateTime uploadedAt) { } From 79d4f89923a1738fc9b103250a9627b1599ce445 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Fri, 13 Dec 2024 15:49:39 +0900 Subject: [PATCH 60/65] =?UTF-8?q?feat:=20=EB=AC=B8=EC=A0=9C=EC=9D=98=20?= =?UTF-8?q?=ED=99=80=EB=93=9C=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../problem/application/ProblemsService.java | 12 +++++++++++ .../dto/ProblemHoldRequestDto.java | 8 +++++++ .../climbing/problem/domain/Problem.java | 3 +++ .../domain/QueryProblemRepository.java | 2 ++ .../QueryProblemQueryDslRepository.java | 15 +++++++++++++ .../QueryProblemRepositoryImpl.java | 5 +++++ .../problem/ui/ProblemController.java | 21 +++++++++++++++++++ 7 files changed, 66 insertions(+) create mode 100644 src/main/java/com/first/flash/climbing/problem/application/dto/ProblemHoldRequestDto.java 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 f6b92015..ca4bdfa0 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 @@ -105,6 +105,18 @@ public ProblemDetailResponseDto setPerceivedDifficulty(final UUID problemId, return ProblemDetailResponseDto.of(queryProblem); } + @Transactional + public ProblemDetailResponseDto updateHold(final UUID problemId, + final Long holdId) { + Problem problem = problemReadService.findProblemById(problemId); + + problem.setHoldId(holdId); + queryProblemRepository.updateHoldInfoByHoldId(problemId, holdId); + + QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId); + return ProblemDetailResponseDto.of(queryProblem); + } + public void updateQueryProblemFixedInfo(final List sectorIds, final String sectorName) { queryProblemRepository.updateSectorNameBySectorIds(sectorIds, sectorName); } diff --git a/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemHoldRequestDto.java b/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemHoldRequestDto.java new file mode 100644 index 00000000..82407017 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/problem/application/dto/ProblemHoldRequestDto.java @@ -0,0 +1,8 @@ +package com.first.flash.climbing.problem.application.dto; + +import jakarta.validation.constraints.NotNull; + +public record ProblemHoldRequestDto( + @NotNull(message = "변경할 홀드 id는 필수입니다.") Long holdId) { + +} diff --git a/src/main/java/com/first/flash/climbing/problem/domain/Problem.java b/src/main/java/com/first/flash/climbing/problem/domain/Problem.java index fdd54423..308a668a 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/Problem.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/Problem.java @@ -10,6 +10,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import lombok.ToString; @Entity @@ -36,6 +37,7 @@ public class Problem { private Long sectorId; private String imageSource; private Long thumbnailSolutionId; + @Setter private Long holdId; public static Problem createDefault(final UUID id, final String imageUrl, @@ -70,4 +72,5 @@ public void setThumbnailInfo(final Long thumbnailSolutionId, final String imageU this.imageUrl = imageUrl; this.imageSource = imageSource; } + } 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 e4782f2b..223d7a62 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 @@ -26,6 +26,8 @@ void updateQueryProblemInfo(final Long sectorId, final String sectorName, void updateSectorNameBySectorIds(final List sectorIds, final String sectorName); + void updateHoldInfoByHoldId(UUID id, final Long holdId); + void deleteByProblemId(final UUID problemId); List findBySectorIdAndHoldIdAndDifficulty(Long sectorId, Long holdId, String difficulty); 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 351650ef..e7eda580 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 @@ -1,9 +1,11 @@ package com.first.flash.climbing.problem.infrastructure; +import static com.first.flash.climbing.hold.domain.QHold.hold; import static com.first.flash.climbing.problem.domain.QQueryProblem.queryProblem; import static com.first.flash.climbing.problem.infrastructure.paging.ProblemSortBy.DIFFICULTY; import static com.first.flash.climbing.problem.infrastructure.paging.ProblemSortBy.VIEWS; +import com.first.flash.climbing.hold.domain.Hold; import com.first.flash.climbing.problem.domain.QueryProblem; import com.first.flash.climbing.problem.infrastructure.paging.ProblemCursor; import com.first.flash.climbing.problem.infrastructure.paging.ProblemSortBy; @@ -64,6 +66,19 @@ public void updateQueryProblemInfo(final Long sectorId, final String sectorName, .execute(); } + public void updateHoldInfoByHoldId(final UUID id, final Long holdId) { + Hold holdData = queryFactory.selectFrom(hold) + .where(hold.id.eq(holdId)) + .fetchOne(); + + queryFactory.update(queryProblem) + .set(queryProblem.holdId, holdId) + .set(queryProblem.holdColorName, holdData.getColorName()) + .set(queryProblem.holdColorCode, holdData.getColorCode()) + .where(queryProblem.id.eq(id)) + .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 33be9dca..7976dcd8 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 @@ -59,6 +59,11 @@ public void updateSectorNameBySectorIds(final List sectorIds, final String queryProblemQueryDslRepository.updateSectorNameBySectorIds(sectorIds, sectorName); } + @Override + public void updateHoldInfoByHoldId(UUID id, Long holdId) { + queryProblemQueryDslRepository.updateHoldInfoByHoldId(id, holdId); + } + @Override public void deleteByProblemId(UUID problemId) { jpaRepository.deleteById(problemId); diff --git a/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java b/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java index 90c76305..9564c2f7 100644 --- a/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java +++ b/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java @@ -6,6 +6,7 @@ import com.first.flash.climbing.problem.application.dto.DuplicateProblemsResponseDto; import com.first.flash.climbing.problem.application.dto.ProblemCreateResponseDto; import com.first.flash.climbing.problem.application.dto.ProblemDetailResponseDto; +import com.first.flash.climbing.problem.application.dto.ProblemHoldRequestDto; import com.first.flash.climbing.problem.application.dto.ProblemPerceivedDifficultyRequestDto; import com.first.flash.climbing.problem.application.dto.ProblemsResponseDto; import com.first.flash.climbing.problem.domain.dto.ProblemCreateRequestDto; @@ -125,6 +126,26 @@ public ResponseEntity changePerceivedDifficulty( return ResponseEntity.ok(problemsService.setPerceivedDifficulty(problemId, requestDto.perceivedDifficulty())); } + @Operation(summary = "문제 홀드색 수정", description = "특정 문제의 홀드색 수정") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공적으로 문제 정보 수정함", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = ProblemDetailResponseDto.class))), + @ApiResponse(responseCode = "400", description = "유효하지 않은 요청 형식", + content = @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "요청값 누락", value = "{\"perceivedDifficulty\": \"변경할 홀드 id는 필수입니다.\"}") + })), + @ApiResponse(responseCode = "404", description = "리소스를 찾을 수 없음", + content = @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "문제 없음", value = "{\"error\": \"아이디가 0190c558-9063-7050-b4fc-eb421e3236b3인 문제를 찾을 수 없습니다.\"}") + })) + }) + @PatchMapping("/admin/problems/{problemId}/hold") + public ResponseEntity changeHold( + @PathVariable final UUID problemId, + @Valid @RequestBody final ProblemHoldRequestDto requestDto) { + return ResponseEntity.ok(problemsService.updateHold(problemId, requestDto.holdId())); + } + @Operation(summary = "중복된 문제 조회", description = "sectorId, holdColorId, difficulty로 중복된 문제를 조회") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공적으로 중복된 문제 조회", From 95561ab17cb0b518248506808ec51d44fefab838 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Fri, 13 Dec 2024 16:57:50 +0900 Subject: [PATCH 61/65] =?UTF-8?q?chore:=20final=20=ED=82=A4=EC=9B=8C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flash/climbing/problem/domain/QueryProblemRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 223d7a62..9f1e95ea 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 @@ -26,7 +26,7 @@ void updateQueryProblemInfo(final Long sectorId, final String sectorName, void updateSectorNameBySectorIds(final List sectorIds, final String sectorName); - void updateHoldInfoByHoldId(UUID id, final Long holdId); + void updateHoldInfoByHoldId(final UUID id, final Long holdId); void deleteByProblemId(final UUID problemId); From 41908e98a4ab47f3263e22c22dfe316e2ef7cb45 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Fri, 13 Dec 2024 16:58:54 +0900 Subject: [PATCH 62/65] =?UTF-8?q?chore:=20setter=20=EC=A0=9C=EA=B1=B0=20?= =?UTF-8?q?=EB=B0=8F=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/first/flash/climbing/problem/domain/Problem.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/first/flash/climbing/problem/domain/Problem.java b/src/main/java/com/first/flash/climbing/problem/domain/Problem.java index 308a668a..92bb8998 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/Problem.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/Problem.java @@ -37,7 +37,6 @@ public class Problem { private Long sectorId; private String imageSource; private Long thumbnailSolutionId; - @Setter private Long holdId; public static Problem createDefault(final UUID id, final String imageUrl, @@ -73,4 +72,8 @@ public void setThumbnailInfo(final Long thumbnailSolutionId, final String imageU this.imageSource = imageSource; } + public void setHoldInfo(final Long holdId) { + this.holdId = holdId; + } + } From c14f045fbeef54d511ca8de6ab9bb1e2188b5865 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Fri, 13 Dec 2024 16:59:20 +0900 Subject: [PATCH 63/65] =?UTF-8?q?chore:=20url=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/first/flash/climbing/problem/ui/ProblemController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java b/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java index 9564c2f7..4f1957be 100644 --- a/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java +++ b/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java @@ -139,7 +139,7 @@ public ResponseEntity changePerceivedDifficulty( @ExampleObject(name = "문제 없음", value = "{\"error\": \"아이디가 0190c558-9063-7050-b4fc-eb421e3236b3인 문제를 찾을 수 없습니다.\"}") })) }) - @PatchMapping("/admin/problems/{problemId}/hold") + @PatchMapping("/admin/problems/{problemId}/holds") public ResponseEntity changeHold( @PathVariable final UUID problemId, @Valid @RequestBody final ProblemHoldRequestDto requestDto) { From acd35a4e1d56147ad193417ee64f33adc5ef83d5 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Fri, 13 Dec 2024 17:06:35 +0900 Subject: [PATCH 64/65] =?UTF-8?q?refactor:=20problem=20=EC=95=A0=EA=B7=B8?= =?UTF-8?q?=EB=A6=AC=EA=B1=B0=ED=8A=B8=EC=97=90=EC=84=9C=20hold=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=9E=91=EC=97=85=EC=9D=84=20=EB=8B=B4?= =?UTF-8?q?=EB=8B=B9=ED=95=98=EB=8A=94=20service=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=A1=9C=EC=A7=81=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/ProblemsHoldService.java | 35 +++++++++++++++++++ .../problem/application/ProblemsService.java | 12 ------- .../climbing/problem/domain/QueryProblem.java | 6 ++++ .../domain/QueryProblemRepository.java | 2 -- .../QueryProblemQueryDslRepository.java | 13 ------- .../QueryProblemRepositoryImpl.java | 5 --- .../problem/ui/ProblemController.java | 4 ++- 7 files changed, 44 insertions(+), 33 deletions(-) create mode 100644 src/main/java/com/first/flash/climbing/problem/application/ProblemsHoldService.java diff --git a/src/main/java/com/first/flash/climbing/problem/application/ProblemsHoldService.java b/src/main/java/com/first/flash/climbing/problem/application/ProblemsHoldService.java new file mode 100644 index 00000000..f64303d2 --- /dev/null +++ b/src/main/java/com/first/flash/climbing/problem/application/ProblemsHoldService.java @@ -0,0 +1,35 @@ +package com.first.flash.climbing.problem.application; + +import com.first.flash.climbing.hold.application.HoldService; +import com.first.flash.climbing.hold.domain.Hold; +import com.first.flash.climbing.problem.application.dto.ProblemDetailResponseDto; +import com.first.flash.climbing.problem.domain.Problem; +import com.first.flash.climbing.problem.domain.QueryProblem; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class ProblemsHoldService { + + private final ProblemReadService problemReadService; + private final HoldService holdService; + + @Transactional + public ProblemDetailResponseDto updateHold(final UUID problemId, + final Long holdId) { + Hold hold = holdService.findById(holdId); + + Problem problem = problemReadService.findProblemById(problemId); + QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId); + + problem.setHoldInfo(hold.getId()); + queryProblem.setHoldInfo(hold.getId(), hold.getColorName(), hold.getColorCode()); + + return ProblemDetailResponseDto.of(queryProblem); + } + +} 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 ca4bdfa0..f6b92015 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 @@ -105,18 +105,6 @@ public ProblemDetailResponseDto setPerceivedDifficulty(final UUID problemId, return ProblemDetailResponseDto.of(queryProblem); } - @Transactional - public ProblemDetailResponseDto updateHold(final UUID problemId, - final Long holdId) { - Problem problem = problemReadService.findProblemById(problemId); - - problem.setHoldId(holdId); - queryProblemRepository.updateHoldInfoByHoldId(problemId, holdId); - - QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId); - return ProblemDetailResponseDto.of(queryProblem); - } - public void updateQueryProblemFixedInfo(final List sectorIds, final String sectorName) { queryProblemRepository.updateSectorNameBySectorIds(sectorIds, sectorName); } diff --git a/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java b/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java index 177515f0..82b94c82 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java @@ -105,6 +105,12 @@ public void setThumbnailInfo(final Long thumbnailSolutionId, final String imageU this.imageSource = imageSource; } + public void setHoldInfo(final Long holdId, final String holdColorName, final String holdColorCode) { + this.holdId = holdId; + this.holdColorName = holdColorName; + this.holdColorCode = holdColorCode; + } + private void enableSolution() { if (!hasSolution) { hasSolution = true; 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 9f1e95ea..e4782f2b 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 @@ -26,8 +26,6 @@ void updateQueryProblemInfo(final Long sectorId, final String sectorName, void updateSectorNameBySectorIds(final List sectorIds, final String sectorName); - void updateHoldInfoByHoldId(final UUID id, final Long holdId); - void deleteByProblemId(final UUID problemId); List findBySectorIdAndHoldIdAndDifficulty(Long sectorId, Long holdId, String difficulty); 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 e7eda580..e40ec488 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 @@ -66,19 +66,6 @@ public void updateQueryProblemInfo(final Long sectorId, final String sectorName, .execute(); } - public void updateHoldInfoByHoldId(final UUID id, final Long holdId) { - Hold holdData = queryFactory.selectFrom(hold) - .where(hold.id.eq(holdId)) - .fetchOne(); - - queryFactory.update(queryProblem) - .set(queryProblem.holdId, holdId) - .set(queryProblem.holdColorName, holdData.getColorName()) - .set(queryProblem.holdColorCode, holdData.getColorCode()) - .where(queryProblem.id.eq(id)) - .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 7976dcd8..33be9dca 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 @@ -59,11 +59,6 @@ public void updateSectorNameBySectorIds(final List sectorIds, final String queryProblemQueryDslRepository.updateSectorNameBySectorIds(sectorIds, sectorName); } - @Override - public void updateHoldInfoByHoldId(UUID id, Long holdId) { - queryProblemQueryDslRepository.updateHoldInfoByHoldId(id, holdId); - } - @Override public void deleteByProblemId(UUID problemId) { jpaRepository.deleteById(problemId); diff --git a/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java b/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java index 4f1957be..0e63598c 100644 --- a/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java +++ b/src/main/java/com/first/flash/climbing/problem/ui/ProblemController.java @@ -1,6 +1,7 @@ package com.first.flash.climbing.problem.ui; import com.first.flash.climbing.problem.application.ProblemReadService; +import com.first.flash.climbing.problem.application.ProblemsHoldService; import com.first.flash.climbing.problem.application.ProblemsSaveService; import com.first.flash.climbing.problem.application.ProblemsService; import com.first.flash.climbing.problem.application.dto.DuplicateProblemsResponseDto; @@ -42,6 +43,7 @@ public class ProblemController { private final ProblemsSaveService problemsSaveService; private final ProblemReadService problemReadService; private final ProblemsService problemsService; + private final ProblemsHoldService problemsHoldService; @Operation(summary = "문제 생성", description = "특정 섹터에 문제 생성") @ApiResponses(value = { @@ -143,7 +145,7 @@ public ResponseEntity changePerceivedDifficulty( public ResponseEntity changeHold( @PathVariable final UUID problemId, @Valid @RequestBody final ProblemHoldRequestDto requestDto) { - return ResponseEntity.ok(problemsService.updateHold(problemId, requestDto.holdId())); + return ResponseEntity.ok(problemsHoldService.updateHold(problemId, requestDto.holdId())); } @Operation(summary = "중복된 문제 조회", description = "sectorId, holdColorId, difficulty로 중복된 문제를 조회") From 1e12e7e8bc35ddee9431ab27777044eed2553028 Mon Sep 17 00:00:00 2001 From: wonyangs Date: Mon, 16 Dec 2024 10:58:51 +0900 Subject: [PATCH 65/65] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=EB=AA=85=EC=9D=84=20updateXXX=EB=A1=9C=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/ProblemsHoldService.java | 4 ++-- .../java/com/first/flash/climbing/problem/domain/Problem.java | 2 +- .../com/first/flash/climbing/problem/domain/QueryProblem.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/first/flash/climbing/problem/application/ProblemsHoldService.java b/src/main/java/com/first/flash/climbing/problem/application/ProblemsHoldService.java index f64303d2..9abb42d3 100644 --- a/src/main/java/com/first/flash/climbing/problem/application/ProblemsHoldService.java +++ b/src/main/java/com/first/flash/climbing/problem/application/ProblemsHoldService.java @@ -26,8 +26,8 @@ public ProblemDetailResponseDto updateHold(final UUID problemId, Problem problem = problemReadService.findProblemById(problemId); QueryProblem queryProblem = problemReadService.findQueryProblemById(problemId); - problem.setHoldInfo(hold.getId()); - queryProblem.setHoldInfo(hold.getId(), hold.getColorName(), hold.getColorCode()); + problem.updateHoldInfo(hold.getId()); + queryProblem.updateHoldInfo(hold.getId(), hold.getColorName(), hold.getColorCode()); return ProblemDetailResponseDto.of(queryProblem); } diff --git a/src/main/java/com/first/flash/climbing/problem/domain/Problem.java b/src/main/java/com/first/flash/climbing/problem/domain/Problem.java index 92bb8998..b5d24701 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/Problem.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/Problem.java @@ -72,7 +72,7 @@ public void setThumbnailInfo(final Long thumbnailSolutionId, final String imageU this.imageSource = imageSource; } - public void setHoldInfo(final Long holdId) { + public void updateHoldInfo(final Long holdId) { this.holdId = holdId; } diff --git a/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java b/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java index 82b94c82..51b39fb7 100644 --- a/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java +++ b/src/main/java/com/first/flash/climbing/problem/domain/QueryProblem.java @@ -105,7 +105,7 @@ public void setThumbnailInfo(final Long thumbnailSolutionId, final String imageU this.imageSource = imageSource; } - public void setHoldInfo(final Long holdId, final String holdColorName, final String holdColorCode) { + public void updateHoldInfo(final Long holdId, final String holdColorName, final String holdColorCode) { this.holdId = holdId; this.holdColorName = holdColorName; this.holdColorCode = holdColorCode;