Skip to content

Commit

Permalink
chore : SettlementController return 값을 SuccessResponse 로 wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
mingj7235 committed May 22, 2023
1 parent b830f50 commit 5cf87b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import webling.coffee.backend.domain.order.dto.request.SettlementRequestDto;
import webling.coffee.backend.domain.order.dto.response.SettlementResponseDto;
import webling.coffee.backend.domain.order.service.SettlementFacade;
import webling.coffee.backend.global.annotation.AuthRequired;
import webling.coffee.backend.global.annotation.AuthUser;
import webling.coffee.backend.global.context.UserAuthentication;

import java.util.List;
import webling.coffee.backend.global.responses.success.codes.OrderSuccessCode;
import webling.coffee.backend.global.responses.success.response.SuccessResponse;

import static webling.coffee.backend.global.enums.UserRole.*;

Expand Down Expand Up @@ -46,9 +45,11 @@ public class SettlementController {
)
@AuthRequired (roles = {MANAGER, BARISTA, DEVELOPER})
@PostMapping("")
public ResponseEntity<List<SettlementResponseDto.User>> settlementAllBySearchOptions(final @NotNull @RequestBody SettlementRequestDto.Search request) {
return ResponseEntity.ok()
.body(settlementFacade.settlementAllBySearchOptions(request));
public ResponseEntity<SuccessResponse> settlementAllBySearchOptions(final @NotNull @RequestBody SettlementRequestDto.Search request) {
return SuccessResponse.toResponseEntity(
OrderSuccessCode.SETTLEMENT,
settlementFacade.settlementAllBySearchOptions(request)
);
}

@Operation(
Expand All @@ -71,10 +72,12 @@ public ResponseEntity<List<SettlementResponseDto.User>> settlementAllBySearchOpt
)
@AuthRequired
@PostMapping("/me")
public ResponseEntity<SettlementResponseDto.User> settlementMeBySearchOptions (final @NotNull @Parameter(hidden = true) @AuthUser UserAuthentication authentication,
public ResponseEntity<SuccessResponse> settlementMeBySearchOptions (final @NotNull @Parameter(hidden = true) @AuthUser UserAuthentication authentication,
final @NotNull @RequestBody SettlementRequestDto.RegDate request) {

return ResponseEntity.ok()
.body(settlementFacade.settlementMeBySearchOptions(authentication.getUserId(), request));
return SuccessResponse.toResponseEntity(
OrderSuccessCode.SETTLEMENT,
settlementFacade.settlementMeBySearchOptions(authentication.getUserId(), request)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum OrderSuccessCode implements SuccessCode{
ORDERED_ORDER_ME_FIND(HttpStatus.OK, "OS003", "로그인한 회원의 주문된 주문 리스트 조회에 성공했습니다."),
CANCEL(HttpStatus.OK, "OS004", "주문 취소에 성공했습니다."),
COMPLETED(HttpStatus.OK, "OS005", "주문을 완성하여 주문자 호출에 성공했습니다."),
SETTLEMENT(HttpStatus.OK, "OS006", "정산 조회에 성공했습니다."),

;

Expand Down

0 comments on commit 5cf87b8

Please sign in to comment.