-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
111 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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
28 changes: 28 additions & 0 deletions
28
src/main/java/umc/haruchi/converter/MonthBudgetConverter.java
This file contains 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,28 @@ | ||
package umc.haruchi.converter; | ||
|
||
import umc.haruchi.domain.MonthBudget; | ||
import umc.haruchi.web.dto.MonthBudgetRequestDTO; | ||
import umc.haruchi.web.dto.MonthBudgetResponseDTO; | ||
|
||
import java.time.LocalDate; | ||
|
||
public class MonthBudgetConverter { | ||
public static MonthBudgetResponseDTO.CreateMonthResultDTO toCreateMonthResultDTO(MonthBudget monthBudget) { | ||
return MonthBudgetResponseDTO.CreateMonthResultDTO.builder() | ||
.id(monthBudget.getId()) | ||
.build(); | ||
} | ||
|
||
public static MonthBudgetResponseDTO.UpdateMonthResultDTO toUpdateMonthResultDTO(MonthBudget monthBudget) { | ||
return MonthBudgetResponseDTO.UpdateMonthResultDTO.builder() | ||
.id(monthBudget.getId()) | ||
.updatedAt(monthBudget.getUpdatedAt()) | ||
.build(); | ||
} | ||
|
||
public static MonthBudget toMonthBudget(Long monthBudget) { | ||
return MonthBudget.builder() | ||
.monthBudget(monthBudget) | ||
.build(); | ||
} | ||
} |
This file contains 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 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 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 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/umc/haruchi/web/controller/MonthBudgetController.java
This file contains 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 umc.haruchi.web.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
import umc.haruchi.apiPayload.ApiResponse; | ||
import umc.haruchi.config.login.auth.MemberDetail; | ||
import umc.haruchi.converter.MonthBudgetConverter; | ||
import umc.haruchi.domain.MonthBudget; | ||
import umc.haruchi.service.MonthBudgetService; | ||
import umc.haruchi.web.dto.MonthBudgetRequestDTO; | ||
import umc.haruchi.web.dto.MonthBudgetResponseDTO; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/monthly-budget") | ||
public class MonthBudgetController { | ||
private final MonthBudgetService monthBudgetService; | ||
|
||
//한달 예산 수정 | ||
@Operation(summary = "한달 예산 수정 API", description = "본인의 한달 예산을 수정하는 API 입니다.") | ||
@PatchMapping("/") | ||
public ApiResponse<MonthBudgetResponseDTO.UpdateMonthResultDTO> updateMonthBudget(@AuthenticationPrincipal MemberDetail memberDetail, @RequestBody @Valid MonthBudgetRequestDTO.UpdateMonthDTO request) { | ||
MonthBudget monthBudget = monthBudgetService.updateMonthBudget(memberDetail.getMember().getId(), request); | ||
return ApiResponse.onSuccess(MonthBudgetConverter.toUpdateMonthResultDTO(monthBudget)); | ||
} | ||
} |
This file contains 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
29 changes: 29 additions & 0 deletions
29
src/main/java/umc/haruchi/web/dto/MonthBudgetResponseDTO.java
This file contains 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,29 @@ | ||
package umc.haruchi.web.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
|
||
public class MonthBudgetResponseDTO { | ||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class CreateMonthResultDTO { | ||
Long id; | ||
LocalDateTime createdAt; | ||
} | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class UpdateMonthResultDTO { | ||
Long id; | ||
LocalDateTime updatedAt; | ||
} | ||
} |