Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import com.somemore.domains.recruitboard.dto.response.RecruitBoardWithCenterResponseDto;
import com.somemore.domains.recruitboard.dto.response.RecruitBoardWithLocationResponseDto;
import com.somemore.domains.recruitboard.usecase.RecruitBoardQueryUseCase;
import com.somemore.global.auth.annotation.RoleId;
import com.somemore.global.common.response.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -135,6 +137,34 @@ public ApiResponse<Page<RecruitBoardResponseDto>> getRecruitBoardsByCenterId(
.pageable(pageable)
.build();

return ApiResponse.ok(
200,
recruitBoardQueryUseCase.getRecruitBoardsByCenterId(centerId, condition),
"특정 기관 봉사 활동 모집글 조회 성공"
);
}

@Secured("ROLE_CENTER")
@GetMapping("/recruit-boards/me")
@Operation(summary = "기관이 작성한 모집글 조회", description = "기관의 봉사 모집글을 조회합니다.")
public ApiResponse<Page<RecruitBoardResponseDto>> getMyRecruitBoards(
@RoleId UUID centerId,
@PageableDefault(sort = "created_at", direction = DESC) Pageable pageable,
@RequestParam(required = false) String keyword,
@RequestParam(required = false) VolunteerCategory category,
@RequestParam(required = false) String region,
@RequestParam(required = false) Boolean admitted,
@RequestParam(required = false) RecruitStatus status
) {
RecruitBoardSearchCondition condition = RecruitBoardSearchCondition.builder()
.keyword(keyword)
.category(category)
.region(region)
.admitted(admitted)
.status(status)
.pageable(pageable)
.build();

return ApiResponse.ok(
200,
recruitBoardQueryUseCase.getRecruitBoardsByCenterId(centerId, condition),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static RecruitBoardResponseDto from(RecruitBoard board) {
return RecruitBoardResponseDto.builder()
.id(board.getId())
.centerId(board.getCenterId())
.locationId(board.getLocationId())
.createdAt(board.getCreatedAt())
.updatedAt(board.getUpdatedAt())
.title(board.getTitle())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.somemore.domains.recruitboard.dto.response.RecruitBoardWithLocationResponseDto;
import com.somemore.domains.recruitboard.usecase.RecruitBoardQueryUseCase;
import com.somemore.support.ControllerTestSupport;
import com.somemore.support.annotation.MockUser;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
Expand Down Expand Up @@ -141,9 +142,34 @@ void getRecruitBoardsByCenterId() throws Exception {
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.data").exists())
.andExpect(jsonPath("$.message").value("기관 봉사 활동 모집글 조회 성공"));
.andExpect(jsonPath("$.message").value("특정 기관 봉사 활동 모집글 조회 성공"));

verify(recruitBoardQueryUseCase, times(1)).getRecruitBoardsByCenterId(eq(centerId),
any(RecruitBoardSearchCondition.class));
}

@MockUser(role = "ROLE_CENTER")
@DisplayName("본인(기관)이 작성한 게시글 리스트를 조회할 수 있다.")
@Test
void getMyRecruitBoards() throws Exception {
// given
Page<RecruitBoardResponseDto> page = new PageImpl<>(Collections.emptyList());

given(recruitBoardQueryUseCase.getRecruitBoardsByCenterId(any(),
any(RecruitBoardSearchCondition.class)))
.willReturn(page);

// when
// then
mockMvc.perform(get("/api/recruit-boards/me")
.param("keyword", "volunteer")
.param("category", ADMINISTRATIVE_SUPPORT.name())
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.data").exists())
.andExpect(jsonPath("$.message").value("기관 봉사 활동 모집글 조회 성공"));

verify(recruitBoardQueryUseCase, times(1))
.getRecruitBoardsByCenterId(any(), any(RecruitBoardSearchCondition.class));
}
}
Loading