From 59d5efcbd778a22ab66a684276c023f2a3c76f2b Mon Sep 17 00:00:00 2001 From: kho903 Date: Sun, 13 Feb 2022 23:45:40 +0900 Subject: [PATCH] refactor: json change createDate to create_date [#341] --- .../domain/manager/controller/ManagerController.java | 6 +++--- .../dto/{ManagerRequestDto.java => ManagerResponseDto.java} | 5 ++++- .../bancowback/domain/manager/mapper/ManagerMapper.java | 6 +++--- .../bancowback/domain/manager/service/ManagerService.java | 4 ++-- .../domain/manager/controller/ManagerControllerTest.java | 4 ++-- 5 files changed, 14 insertions(+), 11 deletions(-) rename spring/src/main/java/com/bancow/bancowback/domain/manager/dto/{ManagerRequestDto.java => ManagerResponseDto.java} (80%) diff --git a/spring/src/main/java/com/bancow/bancowback/domain/manager/controller/ManagerController.java b/spring/src/main/java/com/bancow/bancowback/domain/manager/controller/ManagerController.java index 768a6e3b..ceb5b2ff 100644 --- a/spring/src/main/java/com/bancow/bancowback/domain/manager/controller/ManagerController.java +++ b/spring/src/main/java/com/bancow/bancowback/domain/manager/controller/ManagerController.java @@ -16,7 +16,7 @@ import com.bancow.bancowback.domain.common.dto.Response; import com.bancow.bancowback.domain.common.dto.ServiceResult; -import com.bancow.bancowback.domain.manager.dto.ManagerRequestDto; +import com.bancow.bancowback.domain.manager.dto.ManagerResponseDto; import com.bancow.bancowback.domain.manager.dto.ManagerFindDto; import com.bancow.bancowback.domain.manager.dto.ManagerLoginDto; import com.bancow.bancowback.domain.manager.dto.ManagerLoginResultDto; @@ -64,8 +64,8 @@ public Response statusToAdmin(@RequestHeader("TOKEN") String toke } @GetMapping("/allmanager") - public Response> findPagingManager(@RequestParam int page, @RequestHeader("TOKEN") String token) { - Page pagingManager = managerService.findPagingManager(page, token); + public Response> findPagingManager(@RequestParam int page, @RequestHeader("TOKEN") String token) { + Page pagingManager = managerService.findPagingManager(page, token); return new Response<>(pagingManager, HttpStatus.OK); } diff --git a/spring/src/main/java/com/bancow/bancowback/domain/manager/dto/ManagerRequestDto.java b/spring/src/main/java/com/bancow/bancowback/domain/manager/dto/ManagerResponseDto.java similarity index 80% rename from spring/src/main/java/com/bancow/bancowback/domain/manager/dto/ManagerRequestDto.java rename to spring/src/main/java/com/bancow/bancowback/domain/manager/dto/ManagerResponseDto.java index a6f6e39b..467ae246 100644 --- a/spring/src/main/java/com/bancow/bancowback/domain/manager/dto/ManagerRequestDto.java +++ b/spring/src/main/java/com/bancow/bancowback/domain/manager/dto/ManagerResponseDto.java @@ -6,6 +6,7 @@ import javax.persistence.Enumerated; import com.bancow.bancowback.domain.manager.entity.ManagerStatus; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; @@ -16,7 +17,7 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class ManagerRequestDto { +public class ManagerResponseDto { private Long id; @@ -27,7 +28,9 @@ public class ManagerRequestDto { @Enumerated(EnumType.STRING) private ManagerStatus managerStatus; + @JsonProperty("create_date") private LocalDateTime createDate; + @JsonProperty("update_date") private LocalDateTime updateDate; } diff --git a/spring/src/main/java/com/bancow/bancowback/domain/manager/mapper/ManagerMapper.java b/spring/src/main/java/com/bancow/bancowback/domain/manager/mapper/ManagerMapper.java index 1f7361cb..0459be78 100644 --- a/spring/src/main/java/com/bancow/bancowback/domain/manager/mapper/ManagerMapper.java +++ b/spring/src/main/java/com/bancow/bancowback/domain/manager/mapper/ManagerMapper.java @@ -7,7 +7,7 @@ import com.bancow.bancowback.domain.common.util.PasswordUtils; import com.bancow.bancowback.domain.manager.dto.ManagerRegisterDto; -import com.bancow.bancowback.domain.manager.dto.ManagerRequestDto; +import com.bancow.bancowback.domain.manager.dto.ManagerResponseDto; import com.bancow.bancowback.domain.manager.entity.Manager; import com.bancow.bancowback.domain.manager.entity.ManagerStatus; @@ -28,8 +28,8 @@ default public Manager registerToEntity(ManagerRegisterDto dto) { .build(); } - default public ManagerRequestDto toRequest(Manager manager) { - return ManagerRequestDto.builder() + default public ManagerResponseDto toRequest(Manager manager) { + return ManagerResponseDto.builder() .id(manager.getId()) .email(manager.getEmail()) .username(manager.getUsername()) diff --git a/spring/src/main/java/com/bancow/bancowback/domain/manager/service/ManagerService.java b/spring/src/main/java/com/bancow/bancowback/domain/manager/service/ManagerService.java index c51b4f62..f7207ba9 100644 --- a/spring/src/main/java/com/bancow/bancowback/domain/manager/service/ManagerService.java +++ b/spring/src/main/java/com/bancow/bancowback/domain/manager/service/ManagerService.java @@ -25,7 +25,7 @@ import com.bancow.bancowback.domain.manager.dto.ManagerLoginResultDto; import com.bancow.bancowback.domain.manager.dto.ManagerPasswordDto; import com.bancow.bancowback.domain.manager.dto.ManagerRegisterDto; -import com.bancow.bancowback.domain.manager.dto.ManagerRequestDto; +import com.bancow.bancowback.domain.manager.dto.ManagerResponseDto; import com.bancow.bancowback.domain.manager.entity.Manager; import com.bancow.bancowback.domain.manager.entity.ManagerStatus; import com.bancow.bancowback.domain.manager.mapper.ManagerMapper; @@ -111,7 +111,7 @@ public ServiceResult statusToAdmin(String token, Long id) { return ServiceResult.success(manager.getUsername() + " 님의 상태를 ADMIN으로 변경하였습니다."); } - public Page findPagingManager(int page, String token) { + public Page findPagingManager(int page, String token) { tokenService.validTokenSuper(token); Page allManager = managerRepository.findAll( diff --git a/spring/src/test/java/com/bancow/bancowback/domain/manager/controller/ManagerControllerTest.java b/spring/src/test/java/com/bancow/bancowback/domain/manager/controller/ManagerControllerTest.java index f3266ace..34c81438 100644 --- a/spring/src/test/java/com/bancow/bancowback/domain/manager/controller/ManagerControllerTest.java +++ b/spring/src/test/java/com/bancow/bancowback/domain/manager/controller/ManagerControllerTest.java @@ -212,8 +212,8 @@ void findAllManager() throws Exception { fieldWithPath("data.content[0].email").description("이메일"), fieldWithPath("data.content[0].username").description("이름"), fieldWithPath("data.content[0].managerStatus").description("Manager 상태"), - fieldWithPath("data.content[0].createDate").description("Manager 생성일"), - fieldWithPath("data.content[0].updateDate").description("Manager 수정일"), + fieldWithPath("data.content[0].create_date").description("Manager 생성일"), + fieldWithPath("data.content[0].update_date").description("Manager 수정일"), fieldWithPath("data.pageable").description("Pageable 설명"), fieldWithPath("data.pageable.sort").description("페이지 정렬 설명"), fieldWithPath("data.pageable.sort.empty").description("비어있는 지 여부"),