diff --git a/src/main/java/shop/cazait/domain/favorites/api/FavoritesApiController.java b/src/main/java/shop/cazait/domain/favorites/api/FavoritesApiController.java index a7007535..c3dbdb07 100644 --- a/src/main/java/shop/cazait/domain/favorites/api/FavoritesApiController.java +++ b/src/main/java/shop/cazait/domain/favorites/api/FavoritesApiController.java @@ -15,8 +15,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import shop.cazait.domain.cafe.exception.CafeException; -import shop.cazait.domain.favorites.dto.GetFavoritesRes; -import shop.cazait.domain.favorites.dto.PostFavoritesRes; +import shop.cazait.domain.favorites.dto.response.FavoritesListOutDTO; +import shop.cazait.domain.favorites.dto.response.FavoritesCreateOutDTO; import shop.cazait.domain.favorites.service.FavoritesService; import shop.cazait.domain.user.exception.UserException; import shop.cazait.global.common.dto.response.SuccessResponse; @@ -36,8 +36,8 @@ public class FavoritesApiController { @Parameter(name = "userId", description = "즐겨찾기를 등록할 유저 ID"), @Parameter(name = "cafeId", description = "즐겨찾기로 등록할 카페 ID") }) - public SuccessResponse addFavorites(@PathVariable Long userId, - @PathVariable Long cafeId) + public SuccessResponse addFavorites(@PathVariable Long userId, + @PathVariable Long cafeId) throws CafeException, UserException { return new SuccessResponse<>(CREATE_FAVORITES, favoritesService.addFavorites(userId, cafeId)); } @@ -45,9 +45,9 @@ public SuccessResponse addFavorites(@PathVariable Long userId, @GetMapping("/user/{userId}") @Operation(summary = "즐겨찾기 조회", description = "유저 ID를 받아 모든 즐겨찾기를 조회한다.") @Parameter(name = "userId", description = "즐겨찾기를 조회할 유저 ID") - public SuccessResponse> getFavorites(@PathVariable Long userId) { + public SuccessResponse> getFavorites(@PathVariable Long userId) { - List result = favoritesService.getFavorites(userId); + List result = favoritesService.getFavorites(userId); SuccessStatus resultStatus = SUCCESS; if (result == null) { diff --git a/src/main/java/shop/cazait/domain/favorites/dto/PostFavoritesRes.java b/src/main/java/shop/cazait/domain/favorites/dto/response/FavoritesCreateOutDTO.java similarity index 52% rename from src/main/java/shop/cazait/domain/favorites/dto/PostFavoritesRes.java rename to src/main/java/shop/cazait/domain/favorites/dto/response/FavoritesCreateOutDTO.java index 3a6c4871..7467b660 100644 --- a/src/main/java/shop/cazait/domain/favorites/dto/PostFavoritesRes.java +++ b/src/main/java/shop/cazait/domain/favorites/dto/response/FavoritesCreateOutDTO.java @@ -1,20 +1,20 @@ -package shop.cazait.domain.favorites.dto; +package shop.cazait.domain.favorites.dto.response; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; -@Schema(description = "즐겨찾기 등록 Response : 등록한 즐겨찾기 정보") +@Schema(name = "즐겨찾기 등록 Response", description = "등록한 즐겨찾기 정보") @Getter @Builder(access = AccessLevel.PRIVATE) -public class PostFavoritesRes { +public class FavoritesCreateOutDTO { @Schema(description = "즐겨찾기 ID", example = "1") private Long id; - public static PostFavoritesRes of(Long favoritesId) { - return PostFavoritesRes.builder() + public static FavoritesCreateOutDTO of(Long favoritesId) { + return FavoritesCreateOutDTO.builder() .id(favoritesId) .build(); } diff --git a/src/main/java/shop/cazait/domain/favorites/dto/GetFavoritesRes.java b/src/main/java/shop/cazait/domain/favorites/dto/response/FavoritesListOutDTO.java similarity index 85% rename from src/main/java/shop/cazait/domain/favorites/dto/GetFavoritesRes.java rename to src/main/java/shop/cazait/domain/favorites/dto/response/FavoritesListOutDTO.java index c828fdfa..d1935dcf 100644 --- a/src/main/java/shop/cazait/domain/favorites/dto/GetFavoritesRes.java +++ b/src/main/java/shop/cazait/domain/favorites/dto/response/FavoritesListOutDTO.java @@ -1,4 +1,4 @@ -package shop.cazait.domain.favorites.dto; +package shop.cazait.domain.favorites.dto.response; import io.swagger.v3.oas.annotations.media.Schema; import java.util.List; @@ -9,10 +9,10 @@ import shop.cazait.domain.cafeimage.entity.CafeImage; import shop.cazait.domain.favorites.entity.Favorites; -@Schema(description = "즐겨찾기 Response : 즐겨찾기로 등록한 모든 카페에 대한 정보") +@Schema(name = "즐겨찾기 Response", description = "즐겨찾기로 등록한 모든 카페에 대한 정보") @Getter @Builder(access = AccessLevel.PROTECTED) -public class GetFavoritesRes { +public class FavoritesListOutDTO { @Schema(description = "즐겨찾기 ID", example = "1") private Long favoritesId; @@ -38,10 +38,10 @@ public class GetFavoritesRes { @Schema(description = "카페 이미지", example = "image.png") private List imageUrl; - public static List of(List findFavorites) { + public static List of(List findFavorites) { return findFavorites.stream() .map(favorites -> { - return GetFavoritesRes.builder() + return FavoritesListOutDTO.builder() .favoritesId(favorites.getId()) .cafeId(favorites.getCafe().getId()) .name(favorites.getCafe().getName()) diff --git a/src/main/java/shop/cazait/domain/favorites/service/FavoritesService.java b/src/main/java/shop/cazait/domain/favorites/service/FavoritesService.java index 18cc281c..6660fd53 100644 --- a/src/main/java/shop/cazait/domain/favorites/service/FavoritesService.java +++ b/src/main/java/shop/cazait/domain/favorites/service/FavoritesService.java @@ -12,8 +12,8 @@ import shop.cazait.domain.cafe.entity.Cafe; import shop.cazait.domain.cafe.exception.CafeException; import shop.cazait.domain.cafe.repository.CafeRepository; -import shop.cazait.domain.favorites.dto.GetFavoritesRes; -import shop.cazait.domain.favorites.dto.PostFavoritesRes; +import shop.cazait.domain.favorites.dto.response.FavoritesListOutDTO; +import shop.cazait.domain.favorites.dto.response.FavoritesCreateOutDTO; import shop.cazait.domain.favorites.entity.Favorites; import shop.cazait.domain.favorites.exception.FavoritesException; import shop.cazait.domain.favorites.repository.FavoritesRepository; @@ -33,7 +33,7 @@ public class FavoritesService { /** * 즐겨찾기 추가 */ - public PostFavoritesRes addFavorites(Long userId, Long cafeId) throws CafeException, UserException { + public FavoritesCreateOutDTO addFavorites(Long userId, Long cafeId) throws CafeException, UserException { User user = getUser(userId); Cafe cafe = getCafe(cafeId); @@ -45,7 +45,7 @@ public PostFavoritesRes addFavorites(Long userId, Long cafeId) throws CafeExcept Long favoritesId = favoritesRepository.save(favorites).getId(); - return PostFavoritesRes.of(favoritesId); + return FavoritesCreateOutDTO.of(favoritesId); } @@ -72,11 +72,11 @@ private Cafe getCafe(Long cafeId) throws CafeException { * 즐겨찾기 조회 */ @Transactional(readOnly = true) - public List getFavorites(Long userId) { + public List getFavorites(Long userId) { List favorites = favoritesRepository.findAllByUserId(userId).orElse(null); - return GetFavoritesRes.of(favorites); + return FavoritesListOutDTO.of(favorites); }