diff --git a/src/main/java/com/pickple/server/api/submitter/controller/SubmitterController.java b/src/main/java/com/pickple/server/api/submitter/controller/SubmitterController.java index 691597ed..d36d43ab 100644 --- a/src/main/java/com/pickple/server/api/submitter/controller/SubmitterController.java +++ b/src/main/java/com/pickple/server/api/submitter/controller/SubmitterController.java @@ -1,11 +1,15 @@ package com.pickple.server.api.submitter.controller; import com.pickple.server.api.submitter.dto.request.SubmitterCreateRequest; +import com.pickple.server.api.submitter.dto.response.SubmitterListGetResponse; import com.pickple.server.api.submitter.service.SubmitterCommandService; +import com.pickple.server.api.submitter.service.SubmitterQueryService; import com.pickple.server.global.common.annotation.GuestId; import com.pickple.server.global.response.ApiResponseDto; import com.pickple.server.global.response.enums.SuccessCode; +import java.util.List; import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -17,6 +21,7 @@ public class SubmitterController implements SubmitterControllerDocs { private final SubmitterCommandService submitterCommandService; + private final SubmitterQueryService submitterQueryService; @PostMapping("/v1/submitter") public ApiResponseDto postSubmitter(@GuestId final Long guestId, @@ -24,4 +29,9 @@ public ApiResponseDto postSubmitter(@GuestId final Long guestId, submitterCommandService.createSubmitter(guestId, submitterCreateRequest); return ApiResponseDto.success(SuccessCode.SUBMITTER_POST_SUCCESS); } + + @GetMapping("v1/submitter-list") + public ApiResponseDto> getSubmitterList() { + return ApiResponseDto.success(SuccessCode.SUBMITTER_LIST_GET_SUCCESS, submitterQueryService.getSubmitterList()); + } } \ No newline at end of file diff --git a/src/main/java/com/pickple/server/api/submitter/dto/response/SubmitterListGetResponse.java b/src/main/java/com/pickple/server/api/submitter/dto/response/SubmitterListGetResponse.java new file mode 100644 index 00000000..47b4029e --- /dev/null +++ b/src/main/java/com/pickple/server/api/submitter/dto/response/SubmitterListGetResponse.java @@ -0,0 +1,29 @@ +package com.pickple.server.api.submitter.dto.response; + +import com.pickple.server.api.submitter.domain.SubmitterCategoryInfo; +import lombok.Builder; + +@Builder +public record SubmitterListGetResponse( + String guestNickname, + Long guestId, + + Long submitterId, + + String intro, + + String goal, + + String link, + + String nickname, + + SubmitterCategoryInfo categoryList, + + String plan, + + String email, + + String submitterState +) { +} diff --git a/src/main/java/com/pickple/server/api/submitter/service/SubmitterQueryService.java b/src/main/java/com/pickple/server/api/submitter/service/SubmitterQueryService.java new file mode 100644 index 00000000..b16c54f5 --- /dev/null +++ b/src/main/java/com/pickple/server/api/submitter/service/SubmitterQueryService.java @@ -0,0 +1,39 @@ +package com.pickple.server.api.submitter.service; + + +import com.pickple.server.api.submitter.domain.Submitter; +import com.pickple.server.api.submitter.dto.response.SubmitterListGetResponse; +import com.pickple.server.api.submitter.repository.SubmitterRepository; +import java.util.List; +import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class SubmitterQueryService { + + private final SubmitterRepository submitterRepository; + + public List getSubmitterList() { + List submitterList = submitterRepository.findAll(); + + return submitterList.stream() + .map(submitter -> SubmitterListGetResponse.builder() + .guestNickname(submitter.getGuest().getNickname()) + .guestId(submitter.getGuest().getId()) + .submitterId(submitter.getId()) + .intro(submitter.getIntro()) + .goal(submitter.getGoal()) + .link(submitter.getLink()) + .nickname(submitter.getNickname()) + .categoryList(submitter.getCategoryList()) + .plan(submitter.getPlan()) + .email(submitter.getEmail()) + .submitterState(submitter.getSubmitterState()) + .build()) + .collect(Collectors.toList()); + } +} diff --git a/src/main/java/com/pickple/server/global/response/enums/SuccessCode.java b/src/main/java/com/pickple/server/global/response/enums/SuccessCode.java index 73c6c635..46df8afa 100644 --- a/src/main/java/com/pickple/server/global/response/enums/SuccessCode.java +++ b/src/main/java/com/pickple/server/global/response/enums/SuccessCode.java @@ -33,6 +33,7 @@ public enum SuccessCode { SUBMITTER_LIST_BY_MOIM_GET_SUCCESS(20021, HttpStatus.OK, "모임에 해당하는 신청자 전체 조회 성공"), SUBMITTER_APPROVE_SUCCESS(20022, HttpStatus.OK, "신청자 승인 성공"), MOIM_LIST_BY_HOST(20023, HttpStatus.OK, "호스트에 해당하는 모임 조회 성공"), + SUBMITTER_LIST_GET_SUCCESS(20024, HttpStatus.OK, "호스트 승인 신청 내역 조회 성공"), // 201 Created MOIM_CREATE_SUCCESS(20100, HttpStatus.CREATED, "모임 개설 성공");