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

사용자 정보 조회 api 추가 #256

Merged
merged 12 commits into from
Aug 10, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.ddang.ddang.auction.application.exception.UserNotAuthorizationException;
import com.ddang.ddang.auction.domain.Auction;
import com.ddang.ddang.auction.infrastructure.persistence.JpaAuctionRepository;
import com.ddang.ddang.bid.application.exception.UserNotFoundException;
import com.ddang.ddang.category.application.exception.CategoryNotFoundException;
import com.ddang.ddang.category.domain.Category;
import com.ddang.ddang.category.infrastructure.persistence.JpaCategoryRepository;
Expand All @@ -19,15 +18,17 @@
import com.ddang.ddang.region.domain.AuctionRegion;
import com.ddang.ddang.region.domain.Region;
import com.ddang.ddang.region.infrastructure.persistence.JpaRegionRepository;
import com.ddang.ddang.user.application.exception.UserNotFoundException;
import com.ddang.ddang.user.domain.User;
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository;
import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거는 왜 정렬만 변경되었을까요..? 인텔리제이 설정은 참 어려운 것 같습니다

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import 관련 정렬이 안 된 곳이 있었나 봐요... 허허
혹은 각각 intellij 설정이 약간씩 다른 것일 수도..?!

@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.ddang.ddang.bid.application.exception.InvalidAuctionToBidException;
import com.ddang.ddang.bid.application.exception.InvalidBidPriceException;
import com.ddang.ddang.bid.application.exception.InvalidBidderException;
import com.ddang.ddang.bid.application.exception.UserNotFoundException;
import com.ddang.ddang.user.application.exception.UserNotFoundException;
import com.ddang.ddang.bid.domain.Bid;
import com.ddang.ddang.bid.domain.BidPrice;
import com.ddang.ddang.bid.infrastructure.persistence.JpaBidRepository;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.ddang.ddang.chat.application.dto.ReadParticipatingChatRoomDto;
import com.ddang.ddang.chat.application.exception.ChatRoomNotFoundException;
import com.ddang.ddang.chat.application.exception.UserNotAccessibleException;
import com.ddang.ddang.chat.application.exception.UserNotFoundException;
import com.ddang.ddang.chat.domain.ChatRoom;
import com.ddang.ddang.chat.infrastructure.persistence.JpaChatRoomRepository;
import com.ddang.ddang.user.application.exception.UserNotFoundException;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

예외 통일 좋습니다 👍

import com.ddang.ddang.user.domain.User;
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.ddang.ddang.chat.application.dto.CreateMessageDto;
import com.ddang.ddang.chat.application.exception.ChatRoomNotFoundException;
import com.ddang.ddang.chat.application.exception.UserNotFoundException;
import com.ddang.ddang.chat.domain.ChatRoom;
import com.ddang.ddang.chat.domain.Message;
import com.ddang.ddang.chat.infrastructure.persistence.JpaChatRoomRepository;
import com.ddang.ddang.chat.infrastructure.persistence.JpaMessageRepository;
import com.ddang.ddang.user.application.exception.UserNotFoundException;
import com.ddang.ddang.user.domain.User;
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository;
import lombok.RequiredArgsConstructor;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.ddang.ddang.category.application.exception.CategoryNotFoundException;
import com.ddang.ddang.chat.application.exception.ChatRoomNotFoundException;
import com.ddang.ddang.chat.application.exception.UserNotAccessibleException;
import com.ddang.ddang.chat.application.exception.UserNotFoundException;
import com.ddang.ddang.user.application.exception.UserNotFoundException;
import com.ddang.ddang.exception.dto.ExceptionResponse;
import com.ddang.ddang.image.application.exception.ImageNotFoundException;
import com.ddang.ddang.image.infrastructure.local.exception.EmptyImageException;
Expand Down Expand Up @@ -81,15 +81,6 @@ public ResponseEntity<ExceptionResponse> handleUserNotFoundException(final UserN
.body(new ExceptionResponse(ex.getMessage()));
}

@ExceptionHandler(com.ddang.ddang.bid.application.exception.UserNotFoundException.class)
public ResponseEntity<ExceptionResponse> handleUserNotFoundException(
final com.ddang.ddang.bid.application.exception.UserNotFoundException ex) {
logger.warn(String.format(EXCEPTION_FORMAT, UserNotFoundException.class), ex);

return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new ExceptionResponse(ex.getMessage()));
}

@ExceptionHandler(AuctionNotFoundException.class)
public ResponseEntity<ExceptionResponse> handleAuctionNotFoundException(final AuctionNotFoundException ex) {
logger.warn(String.format(EXCEPTION_FORMAT, AuctionNotFoundException.class), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.ddang.ddang.auction.domain.BidUnit;
import com.ddang.ddang.auction.domain.Price;
import com.ddang.ddang.auction.infrastructure.persistence.JpaAuctionRepository;
import com.ddang.ddang.bid.application.exception.UserNotFoundException;
import com.ddang.ddang.user.application.exception.UserNotFoundException;
import com.ddang.ddang.category.application.exception.CategoryNotFoundException;
import com.ddang.ddang.category.domain.Category;
import com.ddang.ddang.category.infrastructure.persistence.JpaCategoryRepository;
Expand All @@ -27,9 +27,11 @@
import com.ddang.ddang.region.infrastructure.persistence.JpaRegionRepository;
import com.ddang.ddang.user.domain.User;
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.ddang.ddang.auction.application.dto.ReadRegionsDto;
import com.ddang.ddang.auction.application.exception.AuctionNotFoundException;
import com.ddang.ddang.auction.presentation.dto.request.CreateAuctionRequest;
import com.ddang.ddang.bid.application.exception.UserNotFoundException;
import com.ddang.ddang.user.application.exception.UserNotFoundException;
import com.ddang.ddang.category.application.exception.CategoryNotFoundException;
import com.ddang.ddang.configuration.RestDocsConfiguration;
import com.ddang.ddang.exception.GlobalExceptionHandler;
Expand Down Expand Up @@ -150,7 +150,8 @@ void setUp(@Autowired RestDocumentationContextProvider provider) {
fieldWithPath("image").type(JsonFieldType.STRING).description("경매 대표 이미지"),
fieldWithPath("auctionPrice").type(JsonFieldType.NUMBER).description("시작가"),
fieldWithPath("status").type(JsonFieldType.STRING).description("경매 상태"),
fieldWithPath("auctioneerCount").type(JsonFieldType.NUMBER).description("경매 참여자 수")
fieldWithPath("auctioneerCount").type(JsonFieldType.NUMBER)
.description("경매 참여자 수")
)
)
);
Expand Down Expand Up @@ -432,7 +433,8 @@ void setUp(@Autowired RestDocumentationContextProvider provider) {
given(auctionService.readByAuctionId(anyLong())).willReturn(auction);

// when & then
mockMvc.perform(RestDocumentationRequestBuilders.get("/auctions/{auctionId}", auction.id()).contentType(MediaType.APPLICATION_JSON))
mockMvc.perform(RestDocumentationRequestBuilders.get("/auctions/{auctionId}", auction.id())
.contentType(MediaType.APPLICATION_JSON))
.andExpectAll(
status().isOk(),
jsonPath("$.auction.id", is(auction.id()), Long.class),
Expand All @@ -453,27 +455,43 @@ void setUp(@Autowired RestDocumentationContextProvider provider) {
fieldWithPath("auction.id").type(JsonFieldType.NUMBER).description("경매 글 ID"),
fieldWithPath("auction.images").type(JsonFieldType.ARRAY).description("경매 이미지"),
fieldWithPath("auction.title").type(JsonFieldType.STRING).description("경매 글 제목"),
fieldWithPath("auction.category").type(JsonFieldType.OBJECT).description("경매 카테고리"),
fieldWithPath("auction.category.main").type(JsonFieldType.STRING).description("상위 카테고리"),
fieldWithPath("auction.category.sub").type(JsonFieldType.STRING).description("하위 카테고리"),
fieldWithPath("auction.description").type(JsonFieldType.STRING).description("경매 본문"),
fieldWithPath("auction.startPrice").type(JsonFieldType.NUMBER).description("시작가"),
fieldWithPath("auction.category").type(JsonFieldType.OBJECT)
.description("경매 카테고리"),
fieldWithPath("auction.category.main").type(JsonFieldType.STRING)
.description("상위 카테고리"),
fieldWithPath("auction.category.sub").type(JsonFieldType.STRING)
.description("하위 카테고리"),
fieldWithPath("auction.description").type(JsonFieldType.STRING)
.description("경매 본문"),
fieldWithPath("auction.startPrice").type(JsonFieldType.NUMBER)
.description("시작가"),
fieldWithPath("auction.lastBidPrice").description("마지막 입찰가"),
fieldWithPath("auction.status").description("경매 상태"),
fieldWithPath("auction.bidUnit").type(JsonFieldType.NUMBER).description("입찰 단위"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

461번째 줄 부터 470번째 줄 까지도 description() 개행 부탁드립니다!

Copy link
Member Author

@JJ503 JJ503 Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개행을 하지 않기로 했기에 개행은 제거했습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오! 그렇게 결정했었군요! 그렇다면 죄송..함다..

fieldWithPath("auction.registerTime").type(JsonFieldType.STRING).description("경매 등록시간"),
fieldWithPath("auction.closingTime").type(JsonFieldType.STRING).description("경매 마감시간"),
fieldWithPath("auction.directRegions").type(JsonFieldType.ARRAY).description("모든 직거래 지역"),
fieldWithPath("auction.directRegions.[]").type(JsonFieldType.ARRAY).description("단일 직거래 지역"),
fieldWithPath("auction.directRegions.[].first").type(JsonFieldType.STRING).description("첫 번째 직거래 지역"),
fieldWithPath("auction.directRegions.[].second").type(JsonFieldType.STRING).description("두 번째 직거래 지역"),
fieldWithPath("auction.directRegions.[].third").type(JsonFieldType.STRING).description("세 번째 직거래 지역"),
fieldWithPath("auction.auctioneerCount").type(JsonFieldType.NUMBER).description("경매 참여자 수"),
fieldWithPath("auction.registerTime").type(JsonFieldType.STRING)
.description("경매 등록시간"),
fieldWithPath("auction.closingTime").type(JsonFieldType.STRING)
.description("경매 마감시간"),
fieldWithPath("auction.directRegions").type(JsonFieldType.ARRAY)
.description("모든 직거래 지역"),
fieldWithPath("auction.directRegions.[]").type(JsonFieldType.ARRAY)
.description("단일 직거래 지역"),
fieldWithPath("auction.directRegions.[].first").type(JsonFieldType.STRING)
.description("첫 번째 직거래 지역"),
fieldWithPath("auction.directRegions.[].second").type(JsonFieldType.STRING)
.description("두 번째 직거래 지역"),
fieldWithPath("auction.directRegions.[].third").type(JsonFieldType.STRING)
.description("세 번째 직거래 지역"),
fieldWithPath("auction.auctioneerCount").type(JsonFieldType.NUMBER)
.description("경매 참여자 수"),
fieldWithPath("seller").type(JsonFieldType.OBJECT).description("판매자 정보"),
fieldWithPath("seller.id").type(JsonFieldType.NUMBER).description("판매자 ID"),
fieldWithPath("seller.image").type(JsonFieldType.STRING).description("판매자 프로필 이미지 주소"),
fieldWithPath("seller.nickname").type(JsonFieldType.STRING).description("판매자 닉네임"),
fieldWithPath("seller.reliability").type(JsonFieldType.NUMBER).description("판매자 신뢰도")
fieldWithPath("seller.image").type(JsonFieldType.STRING)
.description("판매자 프로필 이미지 주소"),
fieldWithPath("seller.nickname").type(JsonFieldType.STRING)
.description("판매자 닉네임"),
fieldWithPath("seller.reliability").type(JsonFieldType.NUMBER)
.description("판매자 신뢰도")
)
)
);
Expand Down Expand Up @@ -550,7 +568,7 @@ void setUp(@Autowired RestDocumentationContextProvider provider) {

// when & then
mockMvc.perform(get("/auctions").contentType(MediaType.APPLICATION_JSON)
.queryParam("size", "10")
.queryParam("size", "10")
)
.andExpectAll(
status().isOk(),
Expand All @@ -575,13 +593,19 @@ void setUp(@Autowired RestDocumentationContextProvider provider) {
),
responseFields(
fieldWithPath("auctions").type(JsonFieldType.ARRAY).description("조회한 경매 목록"),
fieldWithPath("auctions.[]").type(JsonFieldType.ARRAY).description("조회한 단일 경매 정보"),
fieldWithPath("auctions.[]").type(JsonFieldType.ARRAY)
.description("조회한 단일 경매 정보"),
fieldWithPath("auctions.[].id").type(JsonFieldType.NUMBER).description("경매 ID"),
fieldWithPath("auctions.[].title").type(JsonFieldType.STRING).description("경매 글 제목"),
fieldWithPath("auctions.[].image").type(JsonFieldType.STRING).description("경매 대표 이미지"),
fieldWithPath("auctions.[].auctionPrice").type(JsonFieldType.NUMBER).description("경매가(시작가, 현재가, 낙찰가 중 하나)"),
fieldWithPath("auctions.[].status").type(JsonFieldType.STRING).description("경매 상태"),
fieldWithPath("auctions.[].auctioneerCount").type(JsonFieldType.NUMBER).description("경매 참여자 수"),
fieldWithPath("auctions.[].title").type(JsonFieldType.STRING)
.description("경매 글 제목"),
fieldWithPath("auctions.[].image").type(JsonFieldType.STRING)
.description("경매 대표 이미지"),
fieldWithPath("auctions.[].auctionPrice").type(JsonFieldType.NUMBER)
.description("경매가(시작가, 현재가, 낙찰가 중 하나)"),
fieldWithPath("auctions.[].status").type(JsonFieldType.STRING)
.description("경매 상태"),
fieldWithPath("auctions.[].auctioneerCount").type(JsonFieldType.NUMBER)
.description("경매 참여자 수"),
fieldWithPath("isLast").type(JsonFieldType.BOOLEAN).description("마지막 페이지 여부")
)
)
Expand All @@ -594,7 +618,8 @@ void setUp(@Autowired RestDocumentationContextProvider provider) {
willDoNothing().given(auctionService).deleteByAuctionId(anyLong(), anyLong());

// when & then
mockMvc.perform(RestDocumentationRequestBuilders.delete("/auctions/{auctionId}", 1L).contentType(MediaType.APPLICATION_JSON))
mockMvc.perform(RestDocumentationRequestBuilders.delete("/auctions/{auctionId}", 1L)
.contentType(MediaType.APPLICATION_JSON))
.andExpectAll(status().isNoContent())
.andDo(
restDocs.document(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import com.ddang.ddang.bid.application.exception.InvalidAuctionToBidException;
import com.ddang.ddang.bid.application.exception.InvalidBidPriceException;
import com.ddang.ddang.bid.application.exception.InvalidBidderException;
import com.ddang.ddang.bid.application.exception.UserNotFoundException;
import com.ddang.ddang.user.application.exception.UserNotFoundException;
import com.ddang.ddang.configuration.IsolateDatabase;
import com.ddang.ddang.user.domain.User;
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository;

import java.time.LocalDateTime;
import java.util.List;

import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import com.ddang.ddang.auction.domain.BidUnit;
import com.ddang.ddang.auction.domain.Price;
import com.ddang.ddang.user.domain.User;

import java.time.LocalDateTime;

import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
Expand Down
Loading