Skip to content

Commit

Permalink
[merge] 호스트 승인 신청 내역 조회 API 구현
Browse files Browse the repository at this point in the history
[feat] 호스트 승인 신청 내역 조회 API 구현
  • Loading branch information
lreowy authored Jul 17, 2024
2 parents 2b0955f + 4aa24ab commit aff6581
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,11 +21,17 @@
public class SubmitterController implements SubmitterControllerDocs {

private final SubmitterCommandService submitterCommandService;
private final SubmitterQueryService submitterQueryService;

@PostMapping("/v1/submitter")
public ApiResponseDto postSubmitter(@GuestId final Long guestId,
@RequestBody SubmitterCreateRequest submitterCreateRequest) {
submitterCommandService.createSubmitter(guestId, submitterCreateRequest);
return ApiResponseDto.success(SuccessCode.SUBMITTER_POST_SUCCESS);
}

@GetMapping("v1/submitter-list")
public ApiResponseDto<List<SubmitterListGetResponse>> getSubmitterList() {
return ApiResponseDto.success(SuccessCode.SUBMITTER_LIST_GET_SUCCESS, submitterQueryService.getSubmitterList());
}
}
Original file line number Diff line number Diff line change
@@ -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
) {
}
Original file line number Diff line number Diff line change
@@ -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<SubmitterListGetResponse> getSubmitterList() {
List<Submitter> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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, "모임 개설 성공");
Expand Down

0 comments on commit aff6581

Please sign in to comment.