Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.2.1 #481

Merged
merged 3 commits into from
Nov 11, 2024
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 @@ -7,56 +7,57 @@
@Getter
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
public enum ErrorStatus {
/**
* 204 NO_CONTENT
*/
NO_CONTENT_EXCEPTION("μ°Έμ—¬ν•œ λͺ¨μž„이 μ—†μŠ΅λ‹ˆλ‹€."),

/**
* 400 BAD_REQUEST
*/
VALIDATION_EXCEPTION("CF-001"),
VALIDATION_REQUEST_MISSING_EXCEPTION("μš”μ²­κ°’μ΄ μž…λ ₯λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€."),
INVALID_INPUT_VALUE("μš”μ²­κ°’μ΄ μ˜¬λ°”λ₯΄μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."),
INVALID_INPUT_VALUE_FILTER("μš”μ²­κ°’ λ˜λŠ” 토큰이 μ˜¬λ°”λ₯΄μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."),
NOT_FOUND_MEETING("λͺ¨μž„이 μ—†μŠ΅λ‹ˆλ‹€."),
NOT_FOUND_POST("μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” κ²Œμ‹œκΈ€μž…λ‹ˆλ‹€."),
NOT_FOUND_USER("μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” μœ μ €μž…λ‹ˆλ‹€."),
NOT_FOUND_COMMENT("μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” λŒ“κΈ€μž…λ‹ˆλ‹€."),
FULL_MEETING_CAPACITY("정원이 꽉 μ°ΌμŠ΅λ‹ˆλ‹€."),
ALREADY_APPLIED_MEETING("이미 μ§€μ›ν•œ λͺ¨μž„μž…λ‹ˆλ‹€."),
ALREADY_REPORTED_COMMENT("이미 μ‹ κ³ ν•œ λŒ“κΈ€μž…λ‹ˆλ‹€."),
ALREADY_REPORTED_POST("이미 μ‹ κ³ ν•œ κ²Œμ‹œκΈ€μž…λ‹ˆλ‹€."),
NOT_IN_APPLY_PERIOD("λͺ¨μž„ 지원 기간이 μ•„λ‹™λ‹ˆλ‹€."),
MISSING_GENERATION_PART("λ‚΄ ν”„λ‘œν•„μ—μ„œ 기수/파트 정보λ₯Ό μž…λ ₯ν•΄μ£Όμ„Έμš”."),
NOT_ACTIVE_GENERATION("ν™œλ™ κΈ°μˆ˜κ°€ μ•„λ‹™λ‹ˆλ‹€."),
NOT_TARGET_PART("지원 κ°€λŠ₯ν•œ νŒŒνŠΈκ°€ μ•„λ‹™λ‹ˆλ‹€."),
NOT_FOUND_APPLY("μ‹ μ²­μƒνƒœκ°€ μ•„λ‹Œ λͺ¨μž„μž…λ‹ˆλ‹€."),
ALREADY_PROCESSED_APPLY("이미 ν•΄λ‹Ή μƒνƒœλ‘œ 처리된 μ‹ μ²­ μ •λ³΄μž…λ‹ˆλ‹€."),
MAX_IMAGE_UPLOAD_EXCEEDED("μ΄λ―Έμ§€λŠ” μ΅œλŒ€ 10κ°œκΉŒμ§€λ§Œ μ—…λ‘œλ“œ κ°€λŠ₯ν•©λ‹ˆλ‹€."),
LEADER_CANNOT_APPLY("λͺ¨μž„μž₯은 μ‹ μ²­ν•  수 μ—†μŠ΅λ‹ˆλ‹€."),
CO_LEADER_CANNOT_APPLY("곡동 λͺ¨μž„μž₯은 μ‹ μ²­ν•  수 μ—†μŠ΅λ‹ˆλ‹€."),
LEADER_CANNOT_BE_CO_LEADER_APPLY("λͺ¨μž„μž₯은 곡동 λͺ¨μž„μž₯이 될 수 μ—†μŠ΅λ‹ˆλ‹€."),

/**
* 401 UNAUTHORIZED
*/
UNAUTHORIZED_TOKEN("μœ νš¨ν•˜μ§€ μ•Šμ€ ν† ν°μž…λ‹ˆλ‹€."),
UNAUTHORIZED_USER("μ‘΄μž¬ν•˜μ§€ μ•Šκ±°λ‚˜ μœ νš¨ν•˜μ§€ μ•Šμ€ μœ μ €μž…λ‹ˆλ‹€."),

/**
* 403 FORBIDDEN
*/
FORBIDDEN_EXCEPTION("κΆŒν•œμ΄ μ—†μŠ΅λ‹ˆλ‹€."),

/**
* 500 SERVER_ERROR
*/
NOTIFICATION_SERVER_ERROR("μ•Œλ¦Ό μ„œλ²„μ— μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."),
CSV_ERROR("csv 처리 과정에 μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."),
S3_STORAGE_ERROR("s3 μŠ€ν† λ¦¬μ§€μ— μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."),
INTERNAL_SERVER_ERROR("μ˜ˆμƒμΉ˜ λͺ»ν•œ μ„œλ²„ μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.");

private final String errorCode;

}
/**
* 204 NO_CONTENT
*/
NO_CONTENT_EXCEPTION("μ°Έμ—¬ν•œ λͺ¨μž„이 μ—†μŠ΅λ‹ˆλ‹€."),

/**
* 400 BAD_REQUEST
*/
VALIDATION_EXCEPTION("CF-001"),
VALIDATION_REQUEST_MISSING_EXCEPTION("μš”μ²­κ°’μ΄ μž…λ ₯λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€."),
INVALID_INPUT_VALUE("μš”μ²­κ°’μ΄ μ˜¬λ°”λ₯΄μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."),
INVALID_INPUT_VALUE_FILTER("μš”μ²­κ°’ λ˜λŠ” 토큰이 μ˜¬λ°”λ₯΄μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."),
NOT_FOUND_MEETING("λͺ¨μž„이 μ—†μŠ΅λ‹ˆλ‹€."),
NOT_FOUND_POST("μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” κ²Œμ‹œκΈ€μž…λ‹ˆλ‹€."),
NOT_FOUND_USER("μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” μœ μ €μž…λ‹ˆλ‹€."),
NOT_FOUND_COMMENT("μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” λŒ“κΈ€μž…λ‹ˆλ‹€."),
FULL_MEETING_CAPACITY("정원이 꽉 μ°ΌμŠ΅λ‹ˆλ‹€."),
ALREADY_APPLIED_MEETING("이미 μ§€μ›ν•œ λͺ¨μž„μž…λ‹ˆλ‹€."),
ALREADY_REPORTED_COMMENT("이미 μ‹ κ³ ν•œ λŒ“κΈ€μž…λ‹ˆλ‹€."),
ALREADY_REPORTED_POST("이미 μ‹ κ³ ν•œ κ²Œμ‹œκΈ€μž…λ‹ˆλ‹€."),
NOT_IN_APPLY_PERIOD("λͺ¨μž„ 지원 기간이 μ•„λ‹™λ‹ˆλ‹€."),
MISSING_GENERATION_PART("λ‚΄ ν”„λ‘œν•„μ—μ„œ 기수/파트 정보λ₯Ό μž…λ ₯ν•΄μ£Όμ„Έμš”."),
NOT_ACTIVE_GENERATION("ν™œλ™ κΈ°μˆ˜κ°€ μ•„λ‹™λ‹ˆλ‹€."),
NOT_TARGET_PART("지원 κ°€λŠ₯ν•œ νŒŒνŠΈκ°€ μ•„λ‹™λ‹ˆλ‹€."),
NOT_FOUND_APPLY("μ‹ μ²­μƒνƒœκ°€ μ•„λ‹Œ λͺ¨μž„μž…λ‹ˆλ‹€."),
ALREADY_PROCESSED_APPLY("이미 ν•΄λ‹Ή μƒνƒœλ‘œ 처리된 μ‹ μ²­ μ •λ³΄μž…λ‹ˆλ‹€."),
MAX_IMAGE_UPLOAD_EXCEEDED("μ΄λ―Έμ§€λŠ” μ΅œλŒ€ 10κ°œκΉŒμ§€λ§Œ μ—…λ‘œλ“œ κ°€λŠ₯ν•©λ‹ˆλ‹€."),
LEADER_CANNOT_APPLY("λͺ¨μž„μž₯은 μ‹ μ²­ν•  수 μ—†μŠ΅λ‹ˆλ‹€."),
CO_LEADER_CANNOT_APPLY("곡동 λͺ¨μž„μž₯은 μ‹ μ²­ν•  수 μ—†μŠ΅λ‹ˆλ‹€."),
LEADER_CANNOT_BE_CO_LEADER_APPLY("λͺ¨μž„μž₯은 곡동 λͺ¨μž„μž₯이 될 수 μ—†μŠ΅λ‹ˆλ‹€."),
NOT_ALLOW_MEETING_APPLY("ν—ˆμš©λ˜μ§€ μ•ŠλŠ” λͺ¨μž„ μ‹ μ²­μž…λ‹ˆλ‹€."),

/**
* 401 UNAUTHORIZED
*/
UNAUTHORIZED_TOKEN("μœ νš¨ν•˜μ§€ μ•Šμ€ ν† ν°μž…λ‹ˆλ‹€."),
UNAUTHORIZED_USER("μ‘΄μž¬ν•˜μ§€ μ•Šκ±°λ‚˜ μœ νš¨ν•˜μ§€ μ•Šμ€ μœ μ €μž…λ‹ˆλ‹€."),

/**
* 403 FORBIDDEN
*/
FORBIDDEN_EXCEPTION("κΆŒν•œμ΄ μ—†μŠ΅λ‹ˆλ‹€."),

/**
* 500 SERVER_ERROR
*/
NOTIFICATION_SERVER_ERROR("μ•Œλ¦Ό μ„œλ²„μ— μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."),
CSV_ERROR("csv 처리 과정에 μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."),
S3_STORAGE_ERROR("s3 μŠ€ν† λ¦¬μ§€μ— μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."),
INTERNAL_SERVER_ERROR("μ˜ˆμƒμΉ˜ λͺ»ν•œ μ„œλ²„ μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.");

private final String errorCode;

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
package org.sopt.makers.crew.main.meeting.v2;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.websocket.server.PathParam;

import java.security.Principal;
import java.util.List;

Expand All @@ -35,6 +24,17 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.websocket.server.PathParam;

@Tag(name = "λͺ¨μž„")
public interface MeetingV2Api {
@Operation(summary = "ν”Œλ ˆμ΄κ·ΈλΌμš΄λ“œ λ§ˆμ΄νŽ˜μ΄μ§€ λ‚΄ λͺ¨μž„ 정보 쑰회")
Expand All @@ -58,12 +58,22 @@ ResponseEntity<MeetingV2CreateMeetingResponseDto> createMeeting(
@Valid @RequestBody MeetingV2CreateMeetingBodyDto requestBody,
Principal principal);

@Operation(summary = "λͺ¨μž„ 지원")
@Operation(summary = "일반 λͺ¨μž„ 지원")
@ApiResponses(value = {@ApiResponse(responseCode = "201", description = "지원 μ™„λ£Œ"),
@ApiResponse(responseCode = "400", description =
"\"λͺ¨μž„이 μ—†μŠ΅λ‹ˆλ‹€\" or \"기수/파트λ₯Ό μ„€μ •ν•΄μ£Όμ„Έμš”\" or \"정원이 κ½‰μ°ΌμŠ΅λ‹ˆλ‹€\" or \"ν™œλ™ κΈ°μˆ˜κ°€ μ•„λ‹™λ‹ˆλ‹€\" " +
"or \"지원 κ°€λŠ₯ν•œ νŒŒνŠΈκ°€ μ•„λ‹™λ‹ˆλ‹€\" or \"지원 κ°€λŠ₯ν•œ 기간이 μ•„λ‹™λ‹ˆλ‹€\"", content = @Content),})
ResponseEntity<MeetingV2ApplyMeetingResponseDto> applyGeneralMeeting(
@RequestBody MeetingV2ApplyMeetingDto requestBody,
Principal principal);

@Operation(hidden = true, summary = "행사 λͺ¨μž„ 지원")
@ApiResponses(value = {@ApiResponse(responseCode = "201", description = "지원 μ™„λ£Œ"),
@ApiResponse(responseCode = "400", description =
"\"λͺ¨μž„이 μ—†μŠ΅λ‹ˆλ‹€\" or \"기수/파트λ₯Ό μ„€μ •ν•΄μ£Όμ„Έμš”\" or \"정원이 κ½‰μ°ΌμŠ΅λ‹ˆλ‹€\" or \"ν™œλ™ κΈ°μˆ˜κ°€ μ•„λ‹™λ‹ˆλ‹€\" " +
"or \"지원 κ°€λŠ₯ν•œ νŒŒνŠΈκ°€ μ•„λ‹™λ‹ˆλ‹€\" or \"지원 κ°€λŠ₯ν•œ 기간이 μ•„λ‹™λ‹ˆλ‹€\"", content = @Content),})
ResponseEntity<MeetingV2ApplyMeetingResponseDto> applyMeeting(@RequestBody MeetingV2ApplyMeetingDto requestBody,
ResponseEntity<MeetingV2ApplyMeetingResponseDto> applyEventMeeting(
@RequestBody MeetingV2ApplyMeetingDto requestBody,
Principal principal);

@Operation(summary = "λͺ¨μž„ 지원 μ·¨μ†Œ")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package org.sopt.makers.crew.main.meeting.v2;

import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.Valid;

import java.security.Principal;
import java.util.List;

import lombok.RequiredArgsConstructor;

import org.sopt.makers.crew.main.global.util.UserUtil;
import org.sopt.makers.crew.main.external.s3.service.S3Service;
import org.sopt.makers.crew.main.global.util.UserUtil;
import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingGetAppliesCsvQueryDto;
import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingGetAppliesQueryDto;
import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingV2GetAllMeetingByOrgUserQueryDto;
Expand Down Expand Up @@ -41,6 +36,10 @@
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/meeting/v2")
@RequiredArgsConstructor
Expand Down Expand Up @@ -78,11 +77,21 @@ public ResponseEntity<MeetingV2CreateMeetingResponseDto> createMeeting(

@Override
@PostMapping("/apply")
public ResponseEntity<MeetingV2ApplyMeetingResponseDto> applyMeeting(
public ResponseEntity<MeetingV2ApplyMeetingResponseDto> applyGeneralMeeting(
@Valid @RequestBody MeetingV2ApplyMeetingDto requestBody,
Principal principal) {
Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.status(HttpStatus.CREATED)
.body(meetingV2Service.applyGeneralMeeting(requestBody, userId));
}

@PostMapping("${custom.paths.eventApply}")
public ResponseEntity<MeetingV2ApplyMeetingResponseDto> applyEventMeeting(
@Valid @RequestBody MeetingV2ApplyMeetingDto requestBody,
Principal principal) {
Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.status(HttpStatus.CREATED).body(meetingV2Service.applyMeeting(requestBody, userId));
return ResponseEntity.status(HttpStatus.CREATED)
.body(meetingV2Service.applyEventMeeting(requestBody, userId));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ MeetingV2GetAllMeetingByOrgUserDto getAllMeetingByOrgUser(

MeetingV2CreateMeetingResponseDto createMeeting(MeetingV2CreateMeetingBodyDto requestBody, Integer userId);

MeetingV2ApplyMeetingResponseDto applyMeeting(MeetingV2ApplyMeetingDto requestBody, Integer userId);
MeetingV2ApplyMeetingResponseDto applyGeneralMeeting(MeetingV2ApplyMeetingDto requestBody, Integer userId);

MeetingV2ApplyMeetingResponseDto applyEventMeeting(MeetingV2ApplyMeetingDto requestBody, Integer userId);

void applyMeetingCancel(Integer meetingId, Integer userId);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.sopt.makers.crew.main.meeting.v2.service;

import static org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus.*;
import static org.sopt.makers.crew.main.global.constant.CrewConst.*;
import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*;
import static org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus.*;

import java.io.FileOutputStream;
import java.io.IOException;
Expand All @@ -22,19 +22,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import lombok.RequiredArgsConstructor;

import org.sopt.makers.crew.main.entity.meeting.CoLeader;
import org.sopt.makers.crew.main.entity.meeting.CoLeaderRepository;
import org.sopt.makers.crew.main.entity.meeting.CoLeaders;
import org.sopt.makers.crew.main.global.dto.MeetingResponseDto;
import org.sopt.makers.crew.main.global.exception.BadRequestException;
import org.sopt.makers.crew.main.global.exception.ServerException;
import org.sopt.makers.crew.main.global.pagination.dto.PageMetaDto;
import org.sopt.makers.crew.main.global.pagination.dto.PageOptionsDto;
import org.sopt.makers.crew.main.global.util.CustomPageable;
import org.sopt.makers.crew.main.global.util.Time;
import org.sopt.makers.crew.main.global.util.UserPartUtil;
import org.sopt.makers.crew.main.entity.apply.Applies;
import org.sopt.makers.crew.main.entity.apply.Apply;
import org.sopt.makers.crew.main.entity.apply.ApplyRepository;
Expand All @@ -43,8 +30,12 @@
import org.sopt.makers.crew.main.entity.comment.Comment;
import org.sopt.makers.crew.main.entity.comment.CommentRepository;
import org.sopt.makers.crew.main.entity.like.LikeRepository;
import org.sopt.makers.crew.main.entity.meeting.CoLeader;
import org.sopt.makers.crew.main.entity.meeting.CoLeaderRepository;
import org.sopt.makers.crew.main.entity.meeting.CoLeaders;
import org.sopt.makers.crew.main.entity.meeting.Meeting;
import org.sopt.makers.crew.main.entity.meeting.MeetingRepository;
import org.sopt.makers.crew.main.entity.meeting.enums.MeetingCategory;
import org.sopt.makers.crew.main.entity.meeting.enums.MeetingJoinablePart;
import org.sopt.makers.crew.main.entity.post.Post;
import org.sopt.makers.crew.main.entity.post.PostRepository;
Expand All @@ -53,6 +44,14 @@
import org.sopt.makers.crew.main.entity.user.enums.UserPart;
import org.sopt.makers.crew.main.entity.user.vo.UserActivityVO;
import org.sopt.makers.crew.main.external.s3.service.S3Service;
import org.sopt.makers.crew.main.global.dto.MeetingResponseDto;
import org.sopt.makers.crew.main.global.exception.BadRequestException;
import org.sopt.makers.crew.main.global.exception.ServerException;
import org.sopt.makers.crew.main.global.pagination.dto.PageMetaDto;
import org.sopt.makers.crew.main.global.pagination.dto.PageOptionsDto;
import org.sopt.makers.crew.main.global.util.CustomPageable;
import org.sopt.makers.crew.main.global.util.Time;
import org.sopt.makers.crew.main.global.util.UserPartUtil;
import org.sopt.makers.crew.main.meeting.v2.dto.ApplyMapper;
import org.sopt.makers.crew.main.meeting.v2.dto.MeetingMapper;
import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingGetAppliesQueryDto;
Expand Down Expand Up @@ -81,6 +80,8 @@

import com.opencsv.CSVWriter;

import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
Expand Down Expand Up @@ -215,8 +216,36 @@ public MeetingV2CreateMeetingResponseDto createMeeting(MeetingV2CreateMeetingBod

@Override
@Transactional
public MeetingV2ApplyMeetingResponseDto applyMeeting(MeetingV2ApplyMeetingDto requestBody, Integer userId) {
public MeetingV2ApplyMeetingResponseDto applyGeneralMeeting(MeetingV2ApplyMeetingDto requestBody, Integer userId) {
Meeting meeting = meetingRepository.findByIdOrThrow(requestBody.getMeetingId());

validateMeetingCategoryNotEvent(meeting);

User user = userRepository.findByIdOrThrow(userId);
CoLeaders coLeaders = new CoLeaders(coLeaderRepository.findAllByMeetingId(meeting.getId()));

List<Apply> applies = applyRepository.findAllByMeetingId(meeting.getId());

validateMeetingCapacity(meeting, applies);
validateUserAlreadyApplied(userId, applies);
validateApplyPeriod(meeting);
validateUserActivities(user);
validateUserJoinableParts(user, meeting);
coLeaders.validateCoLeader(meeting.getId(), user.getId());
meeting.validateIsNotMeetingLeader(userId);

Apply apply = applyMapper.toApplyEntity(requestBody, EnApplyType.APPLY, meeting, user, userId);
Apply savedApply = applyRepository.save(apply);
return MeetingV2ApplyMeetingResponseDto.of(savedApply.getId());
}

@Override
@Transactional
public MeetingV2ApplyMeetingResponseDto applyEventMeeting(MeetingV2ApplyMeetingDto requestBody, Integer userId) {
Meeting meeting = meetingRepository.findByIdOrThrow(requestBody.getMeetingId());

validateMeetingCategoryEvent(meeting);

User user = userRepository.findByIdOrThrow(userId);
CoLeaders coLeaders = new CoLeaders(coLeaderRepository.findAllByMeetingId(meeting.getId()));

Expand Down Expand Up @@ -477,6 +506,18 @@ private List<UserActivityVO> filterUserActivities(User user, Meeting meeting) {
return user.getActivities();
}

private void validateMeetingCategoryNotEvent(Meeting meeting) {
if (meeting.getCategory() == MeetingCategory.EVENT) {
throw new BadRequestException(NOT_IN_APPLY_PERIOD.getErrorCode());
}
}

private void validateMeetingCategoryEvent(Meeting meeting) {
if (meeting.getCategory() != MeetingCategory.EVENT) {
throw new BadRequestException(NOT_IN_APPLY_PERIOD.getErrorCode());
}
}

private void validateMeetingCapacity(Meeting meeting, List<Apply> applies) {
List<Apply> approvedApplies = applies.stream()
.filter(apply -> EnApplyStatus.APPROVE.equals(apply.getStatus()))
Expand Down
8 changes: 6 additions & 2 deletions main/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ push-notification:
push-server-url: ${DEV_PUSH_SERVER_URL}

notice:
secret-key : ${NOTICE_SECRET_KEY}
secret-key: ${NOTICE_SECRET_KEY}

playground:
server:
Expand Down Expand Up @@ -94,4 +94,8 @@ management:
prometheus:
metrics:
export:
enabled: true
enabled: true

custom:
paths:
eventApply: ${DEV_EVENT_APPLY_PATH}
Loading
Loading