diff --git a/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java b/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java index ff7b31b8..f9d024fe 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java +++ b/src/main/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryController.java @@ -44,14 +44,14 @@ public ResponseEntity> volunteerGetIntermedia return ResponseEntity.ok(response); } - @Operation(summary = "중개자 - 중개 프로필 - 이동봉사 공고 목록 조회", description = "중개 프로필에서 이동봉사 공고 목록을 조회합니다.", + @Operation(summary = "모집자 - 중개 프로필 - 이동봉사 공고 목록 조회", description = "중개 프로필에서 이동봉사 공고 목록을 조회합니다.", security = { @SecurityRequirement(name = "bearer-key") }, responses = {@ApiResponse(responseCode = "200", description = "이동봉사 공고 목록 조회 성공") , @ApiResponse(responseCode = "400" , description = "M2, 해당 이동봉사 중개를 찾을 수 없습니다." , content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - @GetMapping(value = "/intermediaries/posts") + @GetMapping(value = "/intermediaries/my/posts") public ResponseEntity> intermediaryGetIntermediaryPosts(@AuthenticationPrincipal UserDetails loginUser, @RequestParam(required = false) String orderCondition, Pageable pageable) { @@ -59,7 +59,7 @@ public ResponseEntity> intermediaryGetInterme return ResponseEntity.ok(response); } - @Operation(summary = "중개 프로필 - 기본 정보 조회", description = "중개 프로필에서 기본 정보를 조회합니다.", + @Operation(summary = "이동봉사자 - 중개 프로필 - 기본 정보 조회", description = "중개 프로필에서 기본 정보를 조회합니다.", security = { @SecurityRequirement(name = "bearer-key") }, responses = {@ApiResponse(responseCode = "200", description = "중개 프로필 기본 정보 조회 성공") , @ApiResponse(responseCode = "400" @@ -67,8 +67,21 @@ public ResponseEntity> intermediaryGetInterme , content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @GetMapping("/volunteers/intermediaries/{intermediaryId}") - public ResponseEntity getIntermediaryInfo(@PathVariable Long intermediaryId) { - IntermediaryGetInfoResponse response = intermediaryService.getIntermediaryInfo(intermediaryId); + public ResponseEntity volunteerGetIntermediaryInfo(@PathVariable Long intermediaryId) { + IntermediaryGetInfoResponse response = intermediaryService.volunteerGetIntermediaryInfo(intermediaryId); + return ResponseEntity.ok(response); + } + + @Operation(summary = "모집자 - 중개 프로필 - 기본 정보 조회", description = "중개 프로필에서 기본 정보를 조회합니다.", + security = { @SecurityRequirement(name = "bearer-key") }, + responses = {@ApiResponse(responseCode = "200", description = "중개 프로필 기본 정보 조회 성공") + , @ApiResponse(responseCode = "400" + , description = "M2, 해당 이동봉사 중개를 찾을 수 없습니다." + , content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @GetMapping("/intermediaries/my/info") + public ResponseEntity intermediaryGetIntermediaryInfo(@AuthenticationPrincipal UserDetails loginUser) { + IntermediaryGetInfoResponse response = intermediaryService.intermediaryGetIntermediaryInfo(loginUser.getUsername()); return ResponseEntity.ok(response); } @@ -92,7 +105,7 @@ public ResponseEntity> volunteerGetIntermed , description = "M2, 해당 이동봉사 중개를 찾을 수 없습니다." , content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - @GetMapping("/intermediaries/reviews") + @GetMapping("/intermediaries/my/reviews") public ResponseEntity> intermediaryGetIntermediaryReviews(@AuthenticationPrincipal UserDetails loginUser, Pageable pageable) { List response = intermediaryService.intermediaryGetIntermediaryReviews(loginUser.getUsername(), pageable); return ResponseEntity.ok(response); diff --git a/src/main/java/com/pawwithu/connectdog/domain/intermediary/service/IntermediaryService.java b/src/main/java/com/pawwithu/connectdog/domain/intermediary/service/IntermediaryService.java index 25c93a40..7a42d289 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/intermediary/service/IntermediaryService.java +++ b/src/main/java/com/pawwithu/connectdog/domain/intermediary/service/IntermediaryService.java @@ -48,12 +48,19 @@ public List volunteerGetIntermediaryPosts(Long int } @Transactional(readOnly = true) - public IntermediaryGetInfoResponse getIntermediaryInfo(Long intermediaryId) { + public IntermediaryGetInfoResponse volunteerGetIntermediaryInfo(Long intermediaryId) { Intermediary intermediary = intermediaryRepository.findById(intermediaryId).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND)); IntermediaryGetInfoResponse intermediaryInfo = IntermediaryGetInfoResponse.from(intermediary); return intermediaryInfo; } + @Transactional(readOnly = true) + public IntermediaryGetInfoResponse intermediaryGetIntermediaryInfo(String username) { + Intermediary intermediary = intermediaryRepository.findByEmail(username).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND)); + IntermediaryGetInfoResponse intermediaryInfo = IntermediaryGetInfoResponse.from(intermediary); + return intermediaryInfo; + } + @Transactional(readOnly = true) public List volunteerGetIntermediaryReviews(Long intermediaryId, Pageable pageable) { // 이동봉사 중개 diff --git a/src/test/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryControllerTest.java b/src/test/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryControllerTest.java index 2fc5a2d7..7756bf4f 100644 --- a/src/test/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryControllerTest.java +++ b/src/test/java/com/pawwithu/connectdog/domain/intermediary/controller/IntermediaryControllerTest.java @@ -100,7 +100,7 @@ void setUp() { //when given(intermediaryService.intermediaryGetIntermediaryPosts(anyString(), anyString(), any())).willReturn(response); ResultActions result = mockMvc.perform( - get("/intermediaries/posts") + get("/intermediaries/my/posts") .param("orderCondition", "최신순") ); @@ -117,16 +117,35 @@ void setUp() { "이동봉사 중개 이름", "안녕하세요. 한 줄 소개 입니다.", "https://connectdog.site", "인스타그램: @hoxjeong", "안내 사항입니다."); // when - given(intermediaryService.getIntermediaryInfo(anyLong())).willReturn(response); + given(intermediaryService.volunteerGetIntermediaryInfo(anyLong())).willReturn(response); ResultActions result = mockMvc.perform( get("/volunteers/intermediaries/{intermediaryId}", intermediaryId) ); // then result.andExpect(status().isOk()); - verify(intermediaryService, times(1)).getIntermediaryInfo(anyLong()); + verify(intermediaryService, times(1)).volunteerGetIntermediaryInfo(anyLong()); } + @Test + void 모집자_중개_프로필_기본_정보_조회() throws Exception { + // given + Long intermediaryId = 1L; + IntermediaryGetInfoResponse response = new IntermediaryGetInfoResponse("profileImage", + "이동봉사 중개 이름", "안녕하세요. 한 줄 소개 입니다.", "https://connectdog.site", "인스타그램: @hoxjeong", "안내 사항입니다."); + + // when + given(intermediaryService.intermediaryGetIntermediaryInfo(anyString())).willReturn(response); + ResultActions result = mockMvc.perform( + get("/intermediaries/my/info") + ); + + // then + result.andExpect(status().isOk()); + verify(intermediaryService, times(1)).intermediaryGetIntermediaryInfo(anyString()); + } + + @Test void 이동봉사자_중개_프로필_후기_조회() throws Exception { // given @@ -187,7 +206,7 @@ void setUp() { // when given(intermediaryService.intermediaryGetIntermediaryReviews(anyString(), any())).willReturn(response); ResultActions result = mockMvc.perform( - get("/intermediaries/reviews", intermediaryId) + get("/intermediaries/my/reviews", intermediaryId) .param("page", "0") .param("size", "2") );