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 13, 2024
2 parents 4ccdf4e + 8295c09 commit 57ee2a8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.pickple.server.global.response.enums.SuccessCode;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down Expand Up @@ -57,4 +58,10 @@ public ApiResponseDto getCompletedMoimListByGuest(
return ApiResponseDto.success(SuccessCode.COMPLETED_MOIM_LIST_BY_GUEST_GET_SUCCESS,
moimSubmissionQueryService.getCompletedMoimListByGuest(guestId));
}

@PatchMapping("/v1/moim/{moimId}/submitter/{submitterId}")
public ApiResponseDto updateSubmitterState(@PathVariable Long moimId, @PathVariable Long submitterId) {
moimSubmissionCommandService.updateSubmissionState(moimId, submitterId);
return ApiResponseDto.success(SuccessCode.SUBMITTER_APPROVE_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ public class MoimSubmission extends BaseTimeEntity {
private AccountInfo accountList;

private String moimSubmissionState;

public void updateMoimSubmissionState(String moimSubmissionState) {
this.moimSubmissionState = moimSubmissionState;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ private void isDuplicatedMoimSubmission(MoimSubmission moimSubmission) {
throw new BadRequestException(ErrorCode.DUPLICATION_MOIM_SUBMISSION);
}
}

public void updateSubmissionState(Long moimId, Long submitterId) {
MoimSubmission moimSubmission = moimSubmissionRepository.findBymoimIdAndGuestId(moimId, submitterId);
moimSubmission.updateMoimSubmissionState(MoimSubmissionState.APPROVED.getMoimSubmissionState());
moimSubmissionRepository.save(moimSubmission);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public enum ErrorCode {
MISSING_REQUIRED_HEADER(40005, HttpStatus.BAD_REQUEST, "필수 헤더가 누락되었습니다."),
MISSING_REQUIRED_PARAMETER(40006, HttpStatus.BAD_REQUEST, "필수 파라미터가 누락되었습니다."),
DUPLICATION_MOIM_SUBMISSION(40007, HttpStatus.BAD_REQUEST, "이미 대기중인 모임입니다."),
MOIM_SUBMISSION_NOT_FOUND(40008, HttpStatus.BAD_REQUEST, "해당 모임에 신청한 내역이 없습니다."),

// 401 Unauthorized
ACCESS_TOKEN_EXPIRED(40100, HttpStatus.UNAUTHORIZED, "액세스 토큰이 만료되었습니다."),
Expand All @@ -32,7 +31,9 @@ public enum ErrorCode {
MOIM_NOT_FOUND(40404, HttpStatus.NOT_FOUND, "존재하지 않는 모임입니다."),
HOST_NOT_FOUND(40405, HttpStatus.NOT_FOUND, "존재하지 않는 호스트입니다"),
MOIM_BY_STATE_NOT_FOUND(40406, HttpStatus.NOT_FOUND, "상태에 맞는 모임이 없습니다"),
// Method Not Allowed Error 405
MOIM_SUBMISSION_NOT_FOUND(40407, HttpStatus.BAD_REQUEST, "해당 모임에 신청한 내역이 없습니다."),

//405 Method Not Allowed Error
METHOD_NOT_ALLOWED(40500, HttpStatus.METHOD_NOT_ALLOWED, "지원하지 않는 메소드입니다."),

// 500 Internal Server Error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum SuccessCode {
SUBMITTED_MOIM_LIST_BY_GUEST_GET_SUCCESS(20018, HttpStatus.OK, "게스트에 해당하는 신청한 모임 리스트 조회 성공"),
SUBMISSION_DETAIL_GET_SUCCESS(20019, HttpStatus.OK, "신청자 해당하는 신청 내역 조회 성공"),
COMPLETED_MOIM_LIST_BY_GUEST_GET_SUCCESS(20019, HttpStatus.OK, "게스트에 해당하는 참가한 모임 리스트 조회 성공"),
SUBMITTER_APPROVE_SUCCESS(20020, HttpStatus.OK, "신청자 승인 성공"),

//201 Created
MOIM_CREATE_SUCCESS(20100, HttpStatus.CREATED, "모임 개설 성공");
Expand Down

0 comments on commit 57ee2a8

Please sign in to comment.