Skip to content
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

[STYLE] DayBudgetService에 스웨거의 ApiResponse 설명 추가 #62

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/main/java/umc/haruchi/service/DayBudgetService.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ public MonthBudget check(Long memberId){

MonthBudget monthBudget = monthBudgetRepository.findByMemberIdAndYearAndMonth(memberId, year, month)
.orElseThrow(() -> new MonthBudgetHandler(ErrorStatus.MONTH_BUDGET_NOT_FOUND));
if(monthBudget == null){
throw new MonthBudgetHandler(ErrorStatus.MONTH_BUDGET_NOT_FOUND);
}

return monthBudget;
}

Expand Down
43 changes: 43 additions & 0 deletions src/main/java/umc/haruchi/web/controller/DayBudgetController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package umc.haruchi.web.controller;

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.ApiResponses;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
Expand All @@ -26,20 +29,38 @@ public class DayBudgetController {


@Operation(summary = "하루 예산을 조회하는 API.", description = "회원의 하루 예산을 조회하는 API 입니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4005", description = "존재하지 않는 회원입니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MONTHBUDGET4001", description = "한달 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "DAYBUDGET4001", description = "하루예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
})
@GetMapping("")
public ApiResponse<DayBudgetResponseDTO.getDayBudget> getDailyBudget(@AuthenticationPrincipal MemberDetail memberDetail){
Integer todayBudget = dayBudgetService.findDayBudget(memberDetail.getMember().getId());
return ApiResponse.onSuccess(DayBudgetConverter.toGetDayBudget(todayBudget));
}

@Operation(summary = "날짜별 예산 금액 조회하는 API.", description = "오늘부터 말일까지의 예산을 조회하는 API 입니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4005", description = "존재하지 않는 회원입니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MONTHBUDGET4001", description = "한달 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "DAYBUDGET4002", description = "특정 날짜의 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
})
@GetMapping("/list")
public ApiResponse<DayBudgetResponseDTO.getBudgetList> getAllBudget(@AuthenticationPrincipal MemberDetail memberDetail){
List<DayBudget> allBudget = dayBudgetService.findAllBudget(memberDetail.getMember().getId());
return ApiResponse.onSuccess(DayBudgetConverter.toGetBudgetList(allBudget));
}

@Operation(summary = "수입 등록 API", description = "하루 수입을 등록하는 API 입니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4005", description = "존재하지 않는 회원입니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MONTHBUDGET4001", description = "한달 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "DAYBUDGET4002", description = "특정 날짜의 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
})
@PostMapping("/income")
public ApiResponse<DayBudgetResponseDTO.incomeReg> createIncome(@Valid @RequestBody DayBudgetRequestDTO.createIncomeDTO request,
@AuthenticationPrincipal MemberDetail memberDetail){
Expand All @@ -49,6 +70,14 @@ public ApiResponse<DayBudgetResponseDTO.incomeReg> createIncome(@Valid @RequestB
}

@Operation(summary = "수입 삭제 API", description = "기록했던 하루 수입을 삭제하는 API 입니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4005", description = "존재하지 않는 회원입니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MONTHBUDGET4001", description = "한달 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "DAYBUDGET4002", description = "특정 날짜의 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MONTHBUDGET4003", description = "오늘 지출은 마감되었습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "INCOME4001", description = "해당 수입이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
})
@DeleteMapping("/income/{incomeId}")
public ApiResponse<?> deleteIncome(@PathVariable Long incomeId,
@AuthenticationPrincipal MemberDetail memberDetail){
Expand All @@ -57,6 +86,12 @@ public ApiResponse<?> deleteIncome(@PathVariable Long incomeId,
}

@Operation(summary = "지출 등록 API", description = "하루 지출을 등록하는 API 입니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4005", description = "존재하지 않는 회원입니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MONTHBUDGET4001", description = "한달 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "DAYBUDGET4002", description = "특정 날짜의 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
})
@PostMapping("/expenditure")
public ApiResponse<DayBudgetResponseDTO.expenditureReg> createExpenditure(@Valid @RequestBody DayBudgetRequestDTO.createExpenditureDTO request,
@AuthenticationPrincipal MemberDetail memberDetail){
Expand All @@ -65,6 +100,14 @@ public ApiResponse<DayBudgetResponseDTO.expenditureReg> createExpenditure(@Valid
}

@Operation(summary = "지출 삭제 API", description = "기록했던 하루 지출을 삭제하는 APi 입니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200",description = "OK, 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MEMBER4005", description = "존재하지 않는 회원입니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MONTHBUDGET4001", description = "한달 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "DAYBUDGET4002", description = "특정 날짜의 예산이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "MONTHBUDGET4003", description = "오늘 지출은 마감되었습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "EXPENDITURE4001", description = "해당 지출이 존재하지 않습니다.",content = @Content(schema = @Schema(implementation = ApiResponse.class))),
})
@DeleteMapping("/expenditure/{expenditureId}")
public ApiResponse<?> deleteExpenditure(@PathVariable Long expenditureId,
@AuthenticationPrincipal MemberDetail memberDetail){
Expand Down
Loading