-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/26 봉사 모집글 수정 기능 #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
d7624cf
refactor(recruit-board): RecruitBoard 객체 분리
leebs0521 fea3800
test(recruit-board): RecruitBoard 객체 분리에 따른 테스트
leebs0521 fa85194
feat(location): Location 생성, 조회, 수정 기능 추가
leebs0521 9973e1c
test(location): Location 생성, 조회, 수정 기능 테스트
leebs0521 ac3c60a
feat(recruit-board): RecruitBoard 수정
leebs0521 a32242a
test(recruit-board): RecruitBoard 수정 기능 테스트
leebs0521 219d00c
refactor(recruit-board): RecruitBoard 레포지토리 리팩토링
leebs0521 22d5091
feat(recruit-board): RecruitBoard 조회 기능
leebs0521 2a021ec
test(recruit-board): RecruitBoard 조회 기능 테스트
leebs0521 950ca5d
feat(recruit-board): RecruitBoard 수정 기능
leebs0521 7bb562b
test(recruit-board): RecruitBoard 수정 기능 테스트
leebs0521 b00b3c5
feat: QueryDsl queryFactory 추가
leebs0521 0ced1c9
chore: 불필요한 import 제거
leebs0521 78622a9
feat: 테스트 수정
leebs0521 0e5e3bf
fix: 테스트 수정
leebs0521 4601f0e
feat: 논리 삭제 반영
leebs0521 4f1a9a1
feat: 논리 삭제 테스트
leebs0521 de47b58
test: 고정된 LocalDateTime 반환 클래스 작성
leebs0521 921e210
test: LocalDateTimeFixture 으로 변경
leebs0521 06102da
fix: sonarqube issue fix
leebs0521 ad45c72
chore: 파일 끝 개행 문자 추가
leebs0521 4cc9412
fix: region 고정된 값이 들어가는 문제 수정
leebs0521 e4b30b8
refactor: findByIdOrThrow() -> findById() 대체
leebs0521 d0747cc
test: findByIdOrThrow() -> findById() 따른 테스트
leebs0521 4d30604
refactor: isNotWriter 메서드 제거
leebs0521 7f3d31b
test: isNotWriter 메서드 제거에 따른 테스트
leebs0521 d6992bc
refactor: VolunteerInfo -> RecruitmentInfo 객체명 변경
leebs0521 c58f0c2
test: VolunteerInfo -> RecruitmentInfo 변경에 따른 테스트
leebs0521 c02bd42
chore: 불필요한 import 제거
leebs0521 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,4 +33,8 @@ public void prePersist() { | |
| this.deleted = false; | ||
| } | ||
| } | ||
|
|
||
| public void markAsDeleted() { | ||
| this.deleted = true; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/com/somemore/location/dto/request/LocationUpdateRequestDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package com.somemore.location.dto.request; | ||
|
|
||
| import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.DecimalMax; | ||
| import jakarta.validation.constraints.DecimalMin; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import java.math.BigDecimal; | ||
| import lombok.Builder; | ||
|
|
||
| @JsonNaming(SnakeCaseStrategy.class) | ||
| @Builder | ||
| public record LocationUpdateRequestDto( | ||
| @Schema(description = "도로명 주소", example = "서울특별시 서초구 반포대로 45, 4층(서초동, 명정빌딩)") | ||
| @NotBlank(message = "주소는 필수 입력 값입니다.") | ||
| String address, | ||
| @Schema(description = "주소에 해당하는 위도 정보", example = "37.4845373748015") | ||
| @NotNull(message = "위도는 필수 입력 값입니다.") | ||
| @DecimalMin(value = "33", message = "위도는 33도 이상이어야 합니다.") | ||
| @DecimalMax(value = "39", message = "위도는 38도 이하이어야 합니다.") | ||
| BigDecimal latitude, | ||
| @Schema(description = "주소에 해당하는 경도 정보", example = "127.010842267696") | ||
| @NotNull(message = "경도는 필수 입력 값입니다.") | ||
| @DecimalMin(value = "124", message = "경도는 124도 이상이어야 합니다.") | ||
| @DecimalMax(value = "132", message = "경도는 132도 이하이어야 합니다.") | ||
| BigDecimal longitude | ||
| ) { | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/com/somemore/location/service/command/UpdateLocationService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.somemore.location.service.command; | ||
|
|
||
| import com.somemore.location.domain.Location; | ||
| import com.somemore.location.dto.request.LocationUpdateRequestDto; | ||
| import com.somemore.location.repository.LocationRepository; | ||
| import com.somemore.location.usecase.command.UpdateLocationUseCase; | ||
| import com.somemore.location.usecase.query.LocationQueryUseCase; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Transactional | ||
| @Service | ||
| public class UpdateLocationService implements UpdateLocationUseCase { | ||
|
|
||
| private final LocationQueryUseCase locationQueryUseCase; | ||
| private final LocationRepository locationRepository; | ||
|
|
||
| @Override | ||
| public void updateLocation(LocationUpdateRequestDto requestDto, Long locationId) { | ||
| Location location = locationQueryUseCase.findByIdOrThrow(locationId); | ||
leebs0521 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| location.updateWith(requestDto); | ||
| locationRepository.save(location); | ||
| } | ||
| } | ||
30 changes: 30 additions & 0 deletions
30
src/main/java/com/somemore/location/service/query/LocationQueryService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.somemore.location.service.query; | ||
|
|
||
| import com.somemore.global.exception.BadRequestException; | ||
| import com.somemore.location.domain.Location; | ||
| import com.somemore.location.repository.LocationRepository; | ||
| import com.somemore.location.usecase.query.LocationQueryUseCase; | ||
| import java.util.Optional; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| @Service | ||
| public class LocationQueryService implements LocationQueryUseCase { | ||
|
|
||
| private final LocationRepository locationRepository; | ||
|
|
||
| @Override | ||
| public Optional<Location> findById(Long id) { | ||
| return locationRepository.findById(id); | ||
| } | ||
|
|
||
| @Override | ||
| public Location findByIdOrThrow(Long id) { | ||
| return locationRepository.findById(id).orElseThrow( | ||
| () -> new BadRequestException("존재하지 않는 위치입니다.") | ||
| ); | ||
| } | ||
| } | ||
leebs0521 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
8 changes: 8 additions & 0 deletions
8
src/main/java/com/somemore/location/usecase/command/UpdateLocationUseCase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.somemore.location.usecase.command; | ||
|
|
||
| import com.somemore.location.dto.request.LocationUpdateRequestDto; | ||
|
|
||
| public interface UpdateLocationUseCase { | ||
|
|
||
| void updateLocation(LocationUpdateRequestDto requestDto, Long locationId); | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/somemore/location/usecase/query/LocationQueryUseCase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.somemore.location.usecase.query; | ||
|
|
||
| import com.somemore.location.domain.Location; | ||
| import java.util.Optional; | ||
|
|
||
| public interface LocationQueryUseCase { | ||
|
|
||
| Optional<Location> findById(Long id); | ||
|
|
||
| Location findByIdOrThrow(Long id); | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/main/java/com/somemore/recruitboard/domain/VolunteerInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| package com.somemore.recruitboard.domain; | ||
|
|
||
| import static jakarta.persistence.EnumType.STRING; | ||
| import static java.time.temporal.ChronoUnit.MINUTES; | ||
| import static lombok.AccessLevel.PROTECTED; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Embeddable; | ||
| import jakarta.persistence.Enumerated; | ||
| import java.time.Duration; | ||
| import java.time.LocalDateTime; | ||
| import java.time.LocalTime; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = PROTECTED) | ||
| @Embeddable | ||
| public class VolunteerInfo { | ||
|
|
||
| @Column(name = "region", nullable = false) | ||
| private String region; | ||
|
|
||
| @Column(name = "recruitment_count", nullable = false) | ||
| private Integer recruitmentCount; | ||
|
|
||
| @Column(name = "volunteer_start_date_time", nullable = false) | ||
| private LocalDateTime volunteerStartDateTime; | ||
|
|
||
| @Column(name = "volunteer_end_date_time", nullable = false) | ||
| private LocalDateTime volunteerEndDateTime; | ||
|
|
||
| @Enumerated(value = STRING) | ||
| @Column(name = "volunteer_type", nullable = false, length = 30) | ||
| private VolunteerType volunteerType; | ||
|
|
||
| @Column(name = "admitted", nullable = false) | ||
| private Boolean admitted; | ||
|
|
||
| @Builder | ||
| public VolunteerInfo(String region, Integer recruitmentCount, | ||
| LocalDateTime volunteerStartDateTime, LocalDateTime volunteerEndDateTime, | ||
| VolunteerType volunteerType, Boolean admitted) { | ||
|
|
||
| validateVolunteerDateTime(volunteerStartDateTime, volunteerEndDateTime); | ||
|
|
||
| this.region = region; | ||
| this.recruitmentCount = recruitmentCount; | ||
| this.volunteerStartDateTime = volunteerStartDateTime.truncatedTo(MINUTES); | ||
| this.volunteerEndDateTime = volunteerEndDateTime.truncatedTo(MINUTES); | ||
| this.volunteerType = volunteerType; | ||
| this.admitted = admitted; | ||
| } | ||
|
|
||
| public LocalTime calculateVolunteerTime() { | ||
| Duration duration = Duration.between(volunteerStartDateTime, volunteerEndDateTime); | ||
|
|
||
| long hours = duration.toHours(); | ||
| long minutes = duration.toMinutes() % 60; | ||
|
|
||
| return LocalTime.of((int) hours, (int) minutes); | ||
| } | ||
leebs0521 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public void updateWith(Integer recruitmentCount, VolunteerType volunteerType, | ||
| LocalDateTime volunteerStartDateTime, LocalDateTime volunteerEndDateTime, | ||
| Boolean admitted) { | ||
|
|
||
| validateVolunteerDateTime(volunteerStartDateTime, volunteerEndDateTime); | ||
|
|
||
| this.recruitmentCount = recruitmentCount; | ||
| this.volunteerType = volunteerType; | ||
| this.volunteerStartDateTime = volunteerStartDateTime.truncatedTo(MINUTES); | ||
| this.volunteerEndDateTime = volunteerEndDateTime.truncatedTo(MINUTES); | ||
| this.admitted = admitted; | ||
| } | ||
|
|
||
| public void updateWith(String region) { | ||
| this.region = region; | ||
| } | ||
|
|
||
| private void validateVolunteerDateTime(LocalDateTime startDateTime, LocalDateTime endDateTime) { | ||
| if (endDateTime.isEqual(startDateTime) || endDateTime.isBefore(startDateTime)) { | ||
| throw new IllegalArgumentException("종료 시간은 시작 시간보다 이후여야 합니다."); | ||
leebs0521 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.