diff --git a/src/docs/asciidoc/api/wedding.adoc b/src/docs/asciidoc/api/wedding.adoc index 2d1ff700..4acb84b3 100644 --- a/src/docs/asciidoc/api/wedding.adoc +++ b/src/docs/asciidoc/api/wedding.adoc @@ -26,14 +26,14 @@ operation::wedding/get-wedding-day[snippets='http-request,http-response,response operation::wedding/modify-wedding-day[snippets='http-request,request-fields,http-response,response-fields'] -=== 총 예산 조회 +=== 결혼 예산 조회 -사용자의 총 예산을 조회합니다. +사용자의 결혼 예산을 조회합니다. operation::wedding/get-budget[snippets='http-request,http-response,response-fields'] -=== 총 예산 수정 +=== 결혼 예산 수정 -사용자의 총 예산을 수정합니다. +사용자의 결혼 예산을 수정합니다. operation::wedding/modify-budget[snippets='http-request,request-fields,http-response,response-fields'] diff --git a/src/main/java/com/dnd/weddingmap/domain/wedding/Wedding.java b/src/main/java/com/dnd/weddingmap/domain/wedding/Wedding.java index 73bdc2d8..eccf3b36 100644 --- a/src/main/java/com/dnd/weddingmap/domain/wedding/Wedding.java +++ b/src/main/java/com/dnd/weddingmap/domain/wedding/Wedding.java @@ -31,20 +31,20 @@ public class Wedding extends BaseTimeEntity { private LocalDate weddingDay; @Column(nullable = false) - private Long totalBudget; + private Long budget; public Wedding(Member member, LocalDate weddingDay) { this.weddingMembers.add(member); this.weddingDay = weddingDay; - this.totalBudget = 0L; + this.budget = 0L; } @Builder - public Wedding(Long id, Member member, LocalDate weddingDay, Long totalBudget) { + public Wedding(Long id, Member member, LocalDate weddingDay, Long budget) { this.id = id; this.weddingMembers.add(member); this.weddingDay = weddingDay; - this.totalBudget = totalBudget; + this.budget = budget; } public void removeMember(Member member) { @@ -55,7 +55,7 @@ public void setWeddingDay(LocalDate weddingDay) { this.weddingDay = weddingDay; } - public void setTotalBudget(Long totalBudget) { - this.totalBudget = totalBudget; + public void setBudget(Long budget) { + this.budget = budget; } } diff --git a/src/main/java/com/dnd/weddingmap/domain/wedding/controller/WeddingController.java b/src/main/java/com/dnd/weddingmap/domain/wedding/controller/WeddingController.java index 16cbbb9a..da470c1c 100644 --- a/src/main/java/com/dnd/weddingmap/domain/wedding/controller/WeddingController.java +++ b/src/main/java/com/dnd/weddingmap/domain/wedding/controller/WeddingController.java @@ -1,7 +1,7 @@ package com.dnd.weddingmap.domain.wedding.controller; import com.dnd.weddingmap.domain.oauth.CustomUserDetails; -import com.dnd.weddingmap.domain.wedding.dto.TotalBudgetDto; +import com.dnd.weddingmap.domain.wedding.dto.BudgetDto; import com.dnd.weddingmap.domain.wedding.dto.WeddingDayDto; import com.dnd.weddingmap.domain.wedding.service.WeddingService; import com.dnd.weddingmap.global.response.SuccessResponse; @@ -50,18 +50,18 @@ public ResponseEntity modifyWeddingDay( } @GetMapping("/budget") - public ResponseEntity getTotalBudget( + public ResponseEntity getBudget( @AuthenticationPrincipal CustomUserDetails user) { - TotalBudgetDto totalBudgetDto = weddingService.getTotalBudget(user.getId()); + BudgetDto budgetDto = weddingService.getBudget(user.getId()); return ResponseEntity.ok() - .body(SuccessResponse.builder().message("총 예산 조회 성공").data(totalBudgetDto).build()); + .body(SuccessResponse.builder().message("총 예산 조회 성공").data(budgetDto).build()); } @PutMapping("/budget") - public ResponseEntity modifyTotalBudget( + public ResponseEntity modifyBudget( @AuthenticationPrincipal CustomUserDetails user, - @RequestBody @Valid TotalBudgetDto totalBudgetDto) { - weddingService.modifyTotalBudget(user.getId(), totalBudgetDto); + @RequestBody @Valid BudgetDto budgetDto) { + weddingService.modifyBudget(user.getId(), budgetDto); return ResponseEntity.ok().body(SuccessResponse.builder().message("총 예산 수정 성공").build()); } } diff --git a/src/main/java/com/dnd/weddingmap/domain/wedding/dto/TotalBudgetDto.java b/src/main/java/com/dnd/weddingmap/domain/wedding/dto/BudgetDto.java similarity index 60% rename from src/main/java/com/dnd/weddingmap/domain/wedding/dto/TotalBudgetDto.java rename to src/main/java/com/dnd/weddingmap/domain/wedding/dto/BudgetDto.java index f1609ab1..d5df39f7 100644 --- a/src/main/java/com/dnd/weddingmap/domain/wedding/dto/TotalBudgetDto.java +++ b/src/main/java/com/dnd/weddingmap/domain/wedding/dto/BudgetDto.java @@ -8,12 +8,12 @@ @Getter @Setter @NoArgsConstructor -public class TotalBudgetDto { +public class BudgetDto { - Long totalBudget; + Long budget; @Builder - public TotalBudgetDto(Long totalBudget) { - this.totalBudget = totalBudget; + public BudgetDto(Long budget) { + this.budget = budget; } } diff --git a/src/main/java/com/dnd/weddingmap/domain/wedding/service/WeddingService.java b/src/main/java/com/dnd/weddingmap/domain/wedding/service/WeddingService.java index fc49ef0d..529f15b2 100644 --- a/src/main/java/com/dnd/weddingmap/domain/wedding/service/WeddingService.java +++ b/src/main/java/com/dnd/weddingmap/domain/wedding/service/WeddingService.java @@ -1,6 +1,6 @@ package com.dnd.weddingmap.domain.wedding.service; -import com.dnd.weddingmap.domain.wedding.dto.TotalBudgetDto; +import com.dnd.weddingmap.domain.wedding.dto.BudgetDto; import com.dnd.weddingmap.domain.wedding.dto.WeddingDayDto; public interface WeddingService { @@ -35,20 +35,20 @@ public interface WeddingService { WeddingDayDto getWeddingDay(Long memberId); /** - * 회원의 총예산을 수정한다. + * 회원의 결혼 예산을 수정한다. * - * @param memberId 총예산을 수정할 회원 ID - * @param totalBudgetDto 총예산 정보를 담은 DTO + * @param memberId 결혼 예산을 수정할 회원 ID + * @param budgetDto 결혼 예산 정보를 담은 DTO * @Exception IllegalStateException 결혼이 존재하지 않는 경우 발생 */ - void modifyTotalBudget(Long memberId, TotalBudgetDto totalBudgetDto); + void modifyBudget(Long memberId, BudgetDto budgetDto); /** - * 회원의 총예산을 조회한다. + * 회원의 결혼 예산을 조회한다. * - * @param memberId 총예산을 조회할 회원 ID - * @return 회원의 총예산 정보를 담은 DTO + * @param memberId 결혼 예산을 조회할 회원 ID + * @return 회원의 결혼 예산 정보를 담은 DTO * @Exception IllegalStateException 결혼이 존재하지 않는 경우 발생 */ - TotalBudgetDto getTotalBudget(Long memberId); + BudgetDto getBudget(Long memberId); } diff --git a/src/main/java/com/dnd/weddingmap/domain/wedding/service/impl/WeddingServiceImpl.java b/src/main/java/com/dnd/weddingmap/domain/wedding/service/impl/WeddingServiceImpl.java index 007a5c3b..40963e80 100644 --- a/src/main/java/com/dnd/weddingmap/domain/wedding/service/impl/WeddingServiceImpl.java +++ b/src/main/java/com/dnd/weddingmap/domain/wedding/service/impl/WeddingServiceImpl.java @@ -3,7 +3,7 @@ import com.dnd.weddingmap.domain.member.Member; import com.dnd.weddingmap.domain.member.MemberRepository; import com.dnd.weddingmap.domain.wedding.Wedding; -import com.dnd.weddingmap.domain.wedding.dto.TotalBudgetDto; +import com.dnd.weddingmap.domain.wedding.dto.BudgetDto; import com.dnd.weddingmap.domain.wedding.dto.WeddingDayDto; import com.dnd.weddingmap.domain.wedding.repository.WeddingRepository; import com.dnd.weddingmap.domain.wedding.service.WeddingService; @@ -70,7 +70,7 @@ public WeddingDayDto getWeddingDay(Long memberId) { @Override @Transactional - public void modifyTotalBudget(Long memberId, TotalBudgetDto totalBudgetDto) { + public void modifyBudget(Long memberId, BudgetDto budgetDto) { Member member = memberRepository.findById(memberId) .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 회원입니다.")); @@ -80,13 +80,13 @@ public void modifyTotalBudget(Long memberId, TotalBudgetDto totalBudgetDto) { } Wedding wedding = member.getWedding(); - wedding.setTotalBudget(totalBudgetDto.getTotalBudget()); + wedding.setBudget(budgetDto.getBudget()); weddingRepository.save(wedding); } @Override @Transactional - public TotalBudgetDto getTotalBudget(Long memberId) { + public BudgetDto getBudget(Long memberId) { Member member = memberRepository.findById(memberId) .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 회원입니다.")); @@ -95,8 +95,8 @@ public TotalBudgetDto getTotalBudget(Long memberId) { throw new IllegalStateException("결혼이 등록되어 있지 않습니다."); } - return TotalBudgetDto.builder() - .totalBudget(member.getWedding().getTotalBudget()) + return BudgetDto.builder() + .budget(member.getWedding().getBudget()) .build(); } } diff --git a/src/main/resources/db/migration/V202302281047__Rename_column_for_wedding_budget.sql b/src/main/resources/db/migration/V202302281047__Rename_column_for_wedding_budget.sql new file mode 100644 index 00000000..4e5370cb --- /dev/null +++ b/src/main/resources/db/migration/V202302281047__Rename_column_for_wedding_budget.sql @@ -0,0 +1 @@ +ALTER TABLE `wedding` RENAME COLUMN `total_budget` TO `budget`; \ No newline at end of file diff --git a/src/test/java/com/dnd/weddingmap/domain/wedding/controller/WeddingControllerTest.java b/src/test/java/com/dnd/weddingmap/domain/wedding/controller/WeddingControllerTest.java index f678db72..7814a0f7 100644 --- a/src/test/java/com/dnd/weddingmap/domain/wedding/controller/WeddingControllerTest.java +++ b/src/test/java/com/dnd/weddingmap/domain/wedding/controller/WeddingControllerTest.java @@ -16,7 +16,7 @@ import com.dnd.weddingmap.docs.springrestdocs.AbstractRestDocsTests; import com.dnd.weddingmap.domain.jwt.JwtTokenProvider; -import com.dnd.weddingmap.domain.wedding.dto.TotalBudgetDto; +import com.dnd.weddingmap.domain.wedding.dto.BudgetDto; import com.dnd.weddingmap.domain.wedding.dto.WeddingDayDto; import com.dnd.weddingmap.domain.wedding.service.WeddingService; import com.dnd.weddingmap.global.WithMockOAuth2User; @@ -114,11 +114,11 @@ void modifyWeddingDay() throws Exception { } @Test - @DisplayName("총 예산 조회 테스트") + @DisplayName("결혼 예산 조회 테스트") @WithMockOAuth2User - void getTotalBudget() throws Exception { + void getBudget() throws Exception { // given - given(weddingService.getTotalBudget(any())).willReturn(new TotalBudgetDto(1000000L)); + given(weddingService.getBudget(any())).willReturn(new BudgetDto(1000000L)); // when ResultActions result = mockMvc.perform( @@ -130,26 +130,26 @@ void getTotalBudget() throws Exception { requestHeaders(headerWithName(HttpHeaders.AUTHORIZATION).description("액세스 토큰")), responseFields(fieldWithPath("status").description("응답 상태 코드"), fieldWithPath("message").description("응답 메시지"), - fieldWithPath("data.totalBudget").description("총 예산")))); + fieldWithPath("data.budget").description("결혼 예산")))); } @Test - @DisplayName("총 예산 수정 테스트") + @DisplayName("결혼 예산 수정 테스트") @WithMockOAuth2User - void modifyTotalBudget() throws Exception { + void modifyBudget() throws Exception { // given - TotalBudgetDto totalBudgetDto = new TotalBudgetDto(1000000L); + BudgetDto budgetDto = new BudgetDto(1000000L); // when ResultActions result = mockMvc.perform( put("/api/v1/wedding/budget").contentType(MediaType.APPLICATION_JSON) .header(HttpHeaders.AUTHORIZATION, ACCESS_TOKEN_PREFIX + "ACCESS_TOKEN") - .content(objectMapper.writeValueAsString(totalBudgetDto))); + .content(objectMapper.writeValueAsString(budgetDto))); // then result.andExpect(status().isOk()).andDo(document("wedding/modify-budget", requestHeaders(headerWithName(HttpHeaders.AUTHORIZATION).description("액세스 토큰")), - requestFields(fieldWithPath("totalBudget").description("총 예산")), + requestFields(fieldWithPath("budget").description("총 예산")), responseFields(fieldWithPath("status").description("응답 상태 코드"), fieldWithPath("message").description("응답 메시지"), fieldWithPath("data").description("데이터").ignored()))); diff --git a/src/test/java/com/dnd/weddingmap/domain/wedding/service/WeddingServiceTest.java b/src/test/java/com/dnd/weddingmap/domain/wedding/service/WeddingServiceTest.java index b7f587ac..ed64570d 100644 --- a/src/test/java/com/dnd/weddingmap/domain/wedding/service/WeddingServiceTest.java +++ b/src/test/java/com/dnd/weddingmap/domain/wedding/service/WeddingServiceTest.java @@ -8,7 +8,7 @@ import com.dnd.weddingmap.domain.member.Member; import com.dnd.weddingmap.domain.member.MemberRepository; import com.dnd.weddingmap.domain.wedding.Wedding; -import com.dnd.weddingmap.domain.wedding.dto.TotalBudgetDto; +import com.dnd.weddingmap.domain.wedding.dto.BudgetDto; import com.dnd.weddingmap.domain.wedding.dto.WeddingDayDto; import com.dnd.weddingmap.domain.wedding.repository.WeddingRepository; import com.dnd.weddingmap.domain.wedding.service.impl.WeddingServiceImpl; @@ -126,11 +126,11 @@ void getWeddingDay() { } @Test - @DisplayName("총예산을 수정한다.") - void modifyTotalBudget() { + @DisplayName("결혼 예산을 수정한다.") + void modifyBudget() { // given - TotalBudgetDto totalBudgetDto = TotalBudgetDto.builder() - .totalBudget(1000000L) + BudgetDto budgetDto = BudgetDto.builder() + .budget(1000000L) .build(); given(memberRepository.findById(memberId)) @@ -139,30 +139,30 @@ void modifyTotalBudget() { .willReturn(Optional.ofNullable(wedding)); // when - weddingService.modifyTotalBudget(memberId, totalBudgetDto); + weddingService.modifyBudget(memberId, budgetDto); // then Wedding savedWedding = weddingRepository.findById(1L).get(); - assertEquals(savedWedding.getTotalBudget(), totalBudgetDto.getTotalBudget()); + assertEquals(savedWedding.getBudget(), budgetDto.getBudget()); } @Test - @DisplayName("총예산을 조회한다.") - void getTotalBudget() { + @DisplayName("결혼 예산을 조회한다.") + void getBudget() { // given given(memberRepository.findById(memberId)) .willReturn(Optional.ofNullable(registeredMember)); - TotalBudgetDto requestDto = TotalBudgetDto.builder() - .totalBudget(1000000L) + BudgetDto requestDto = BudgetDto.builder() + .budget(1000000L) .build(); - weddingService.modifyTotalBudget(memberId, requestDto); + weddingService.modifyBudget(memberId, requestDto); // when - TotalBudgetDto responseDto = weddingService.getTotalBudget(memberId); + BudgetDto responseDto = weddingService.getBudget(memberId); // then - assertEquals(responseDto.getTotalBudget(), requestDto.getTotalBudget()); + assertEquals(responseDto.getBudget(), requestDto.getBudget()); } } \ No newline at end of file