From 5b41bb50834700b0936eed61eff6584f845b8079 Mon Sep 17 00:00:00 2001 From: Anna-Jin Date: Wed, 20 Jul 2022 23:25:15 +0900 Subject: [PATCH] =?UTF-8?q?#26=20[Update]=20=EA=B4=80=EB=A6=AC=EC=9E=90?= =?UTF-8?q?=EC=9A=A9=20=EC=9C=A0=EC=A0=80=20=EB=93=B1=EB=A1=9D=20=EC=97=85?= =?UTF-8?q?=EC=9E=A5=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 이미지 리스트를 빼고, responseDto의 id 필드 이름 변경 및 생성자에 추가 - 페이징 추가 --- .../baechelin/admin/controller/AdminController.java | 2 ++ .../mpnp/baechelin/admin/dto/AdminResponseDto.java | 10 ++-------- .../mpnp/baechelin/admin/service/AdminService.java | 11 ++++++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/mpnp/baechelin/admin/controller/AdminController.java b/src/main/java/com/mpnp/baechelin/admin/controller/AdminController.java index 969c676..25ed452 100644 --- a/src/main/java/com/mpnp/baechelin/admin/controller/AdminController.java +++ b/src/main/java/com/mpnp/baechelin/admin/controller/AdminController.java @@ -2,6 +2,7 @@ import com.mpnp.baechelin.admin.dto.AdminResponseDto; import com.mpnp.baechelin.admin.service.AdminService; +import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.userdetails.User; @@ -18,6 +19,7 @@ public class AdminController { private final AdminService adminService; + @ApiOperation(value = "유저가 등록한 업장을 관리자 페이지에서 조회하는 메소드") @GetMapping("/approval") public List getUserRegisterStore() { return adminService.getUserRegisterStore(); diff --git a/src/main/java/com/mpnp/baechelin/admin/dto/AdminResponseDto.java b/src/main/java/com/mpnp/baechelin/admin/dto/AdminResponseDto.java index 0d841c3..33ecf70 100644 --- a/src/main/java/com/mpnp/baechelin/admin/dto/AdminResponseDto.java +++ b/src/main/java/com/mpnp/baechelin/admin/dto/AdminResponseDto.java @@ -1,37 +1,31 @@ package com.mpnp.baechelin.admin.dto; import com.mpnp.baechelin.store.domain.UserRegisterStore; -import com.mpnp.baechelin.store.dto.userRegisterStore.UserRegisterStoreImgDto; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; -import java.util.stream.Collectors; - @Getter @NoArgsConstructor public class AdminResponseDto { - private int id; + private int registerStoreId; private String name; private String address; private String elevator; private String toilet; private String heightDifferent; private String approach; - private List userRegisterStoreImageList; @Builder public AdminResponseDto( UserRegisterStore userRegisterStore ) { + this.registerStoreId = userRegisterStore.getId(); this.name = userRegisterStore.getName(); this.address = userRegisterStore.getAddress(); this.elevator = userRegisterStore.getElevator(); this.toilet = userRegisterStore.getToilet(); this.heightDifferent = userRegisterStore.getHeightDifferent(); this.approach = userRegisterStore.getApproach(); - this.userRegisterStoreImageList = userRegisterStore.getUserRegisterStoreImgList().parallelStream() - .map(UserRegisterStoreImgDto::new).collect(Collectors.toList()); } } diff --git a/src/main/java/com/mpnp/baechelin/admin/service/AdminService.java b/src/main/java/com/mpnp/baechelin/admin/service/AdminService.java index c2efdd7..505198a 100644 --- a/src/main/java/com/mpnp/baechelin/admin/service/AdminService.java +++ b/src/main/java/com/mpnp/baechelin/admin/service/AdminService.java @@ -4,6 +4,8 @@ import com.mpnp.baechelin.store.domain.UserRegisterStore; import com.mpnp.baechelin.store.repository.UserRegisterStoreRepository; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import javax.transaction.Transactional; @@ -17,13 +19,16 @@ public class AdminService { private final UserRegisterStoreRepository userRegisterStoreRepository; + /** + * 유저가 등록한 업장 조회 + * @return + */ public List getUserRegisterStore() { -// Page foundUserRegisterStores = userRegisterStoreRepository.findAll(Pageable.ofSize(5)); + Page foundUserRegisterStores = userRegisterStoreRepository.findAll(Pageable.ofSize(5)); - List foundUserRegisterStores = userRegisterStoreRepository.findAll(); List result = new ArrayList<>(); - for (UserRegisterStore foundUserRegisterStore : foundUserRegisterStores) { + for (UserRegisterStore foundUserRegisterStore : foundUserRegisterStores.getContent()) { AdminResponseDto adminResponseDto = new AdminResponseDto(foundUserRegisterStore); result.add(adminResponseDto); }