diff --git a/backend/src/main/java/moim_today/application/admin/member/AdminMemberService.java b/backend/src/main/java/moim_today/application/admin/member/AdminMemberService.java index bbb104df..f72639b2 100644 --- a/backend/src/main/java/moim_today/application/admin/member/AdminMemberService.java +++ b/backend/src/main/java/moim_today/application/admin/member/AdminMemberService.java @@ -3,8 +3,9 @@ import moim_today.dto.member.MemberResponse; import moim_today.global.error.ForbiddenException; import moim_today.persistence.entity.member.MemberJpaEntity; -import moim_today.persistence.repository.meeting.joined_meeting.JoinedMeetingRepository; import moim_today.persistence.repository.member.MemberRepository; +import moim_today.global.spring_event.event.AdminMemberDeleteEvent; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -16,13 +17,13 @@ public class AdminMemberService { private final MemberRepository memberRepository; - private final JoinedMeetingRepository joinedMeetingRepository; + private final ApplicationEventPublisher applicationEventPublisher; public AdminMemberService(final MemberRepository memberRepository, - final JoinedMeetingRepository joinedMeetingRepository + final ApplicationEventPublisher applicationEventPublisher ) { this.memberRepository = memberRepository; - this.joinedMeetingRepository = joinedMeetingRepository; + this.applicationEventPublisher = applicationEventPublisher; } @Transactional(readOnly = true) @@ -38,7 +39,8 @@ public void deleteMember(final long universityId, final long memberId) { throw new ForbiddenException(ADMIN_FORBIDDEN_ERROR.message()); } - joinedMeetingRepository.deleteAllByMemberId(memberId); + AdminMemberDeleteEvent adminMemberDeleteEvent = new AdminMemberDeleteEvent(memberId); + applicationEventPublisher.publishEvent(adminMemberDeleteEvent); member.changeToUnknownMember(); } } diff --git a/backend/src/main/java/moim_today/domain/member/Member.java b/backend/src/main/java/moim_today/domain/member/Member.java index 68b11b92..41798e9f 100644 --- a/backend/src/main/java/moim_today/domain/member/Member.java +++ b/backend/src/main/java/moim_today/domain/member/Member.java @@ -5,11 +5,9 @@ import java.time.LocalDateTime; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import static java.util.stream.Collectors.toList; -import static moim_today.global.constant.NumberConstant.MOIM_SCHEDULE_FIRST_IDX; +import static java.util.stream.Collectors.*; + @Builder public record Member( @@ -18,24 +16,11 @@ public record Member( String memberProfileImageUrl ) { - public static Map> groupSchedulesByMember(final List moimScheduleResponses) { - - return moimScheduleResponses.stream() - .collect(Collectors.groupingBy(MoimScheduleResponse::memberId)); - } - - public static List filterByDateTime(final Map> schedulesByMember, + public static List filterByDateTime(final List moimScheduleResponses, final LocalDateTime startDateTime, final LocalDateTime endDateTime) { - return schedulesByMember.values().stream() - .filter( - moimScheduleResponses -> moimScheduleResponses.stream() - .noneMatch( - moimScheduleResponse -> isScheduleConflicting(moimScheduleResponse, startDateTime, endDateTime)) - ) - .map(moimScheduleResponses -> { - MoimScheduleResponse moimScheduleResponse = moimScheduleResponses.get(MOIM_SCHEDULE_FIRST_IDX.value()); - return moimScheduleResponse.toDomain(); - }) + return moimScheduleResponses.stream() + .filter(schedule -> !isScheduleConflicting(schedule, startDateTime, endDateTime)) + .map(MoimScheduleResponse::toDomain) .collect(toList()); } diff --git a/backend/src/main/java/moim_today/domain/moim/DisplayStatus.java b/backend/src/main/java/moim_today/domain/moim/DisplayStatus.java deleted file mode 100644 index 1ed31ba1..00000000 --- a/backend/src/main/java/moim_today/domain/moim/DisplayStatus.java +++ /dev/null @@ -1,6 +0,0 @@ -package moim_today.domain.moim; - -public enum DisplayStatus { - - PUBLIC, PRIVATE -} diff --git a/backend/src/main/java/moim_today/domain/schedule/AvailableTime.java b/backend/src/main/java/moim_today/domain/schedule/AvailableTime.java index c88bc778..4804c916 100644 --- a/backend/src/main/java/moim_today/domain/schedule/AvailableTime.java +++ b/backend/src/main/java/moim_today/domain/schedule/AvailableTime.java @@ -7,9 +7,9 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.stream.Stream; +import static moim_today.global.constant.NumberConstant.AVAILABLE_TIME_OFFSET; import static moim_today.global.constant.NumberConstant.SCHEDULE_TIME_START_IDX; @@ -27,35 +27,16 @@ public static AvailableTime toDomain(final List members, final LocalDate public static List calculateAvailableTimes(final List moimScheduleResponses, final LocalDate startDate) { ScheduleLocalDate scheduleLocalDate = ScheduleLocalDate.from(startDate); - LocalDateTime start = scheduleLocalDate.atWeeklyStartDateTime(); - LocalDateTime end = scheduleLocalDate.atWeeklyEndDateTime(); - - Map> schedulesByMember = Member.groupSchedulesByMember(moimScheduleResponses); - - List allTimes = getAllTimes(moimScheduleResponses, start, end); - List availableTimes = new ArrayList<>(); - - for (int i = 0; i < allTimes.size() - 1; i++) { - LocalDateTime startDateTime = allTimes.get(i); - LocalDateTime endDateTime = allTimes.get(i + 1); - - List availableMembers = Member.filterByDateTime(schedulesByMember, startDateTime, endDateTime); - - if (!availableMembers.isEmpty()) { - availableTimes.add(AvailableTime.toDomain(availableMembers, startDateTime, endDateTime)); - } - } - - return availableTimes; + List allTimes = getAllTimes(moimScheduleResponses, scheduleLocalDate); + return getAvailableTimes(allTimes, moimScheduleResponses); } private static List getAllTimes(final List moimScheduleResponses, - final LocalDateTime startTime, - final LocalDateTime endTime) { + final ScheduleLocalDate scheduleLocalDate) { List times = getTimesFromSchedules(moimScheduleResponses); List allTimes = new ArrayList<>(times); - allTimes.add(SCHEDULE_TIME_START_IDX.value(), startTime); - allTimes.add(endTime); + allTimes.add(SCHEDULE_TIME_START_IDX.value(), scheduleLocalDate.atWeeklyStartDateTime()); + allTimes.add(scheduleLocalDate.atWeeklyEndDateTime()); return allTimes; } @@ -67,4 +48,21 @@ private static List getTimesFromSchedules(final List getAvailableTimes(final List allTimes, + final List moimScheduleResponses) { + List availableTimes = new ArrayList<>(); + + for (int i = 0; i < allTimes.size() - AVAILABLE_TIME_OFFSET.value(); i++) { + LocalDateTime startDateTime = allTimes.get(i); + LocalDateTime endDateTime = allTimes.get(i + AVAILABLE_TIME_OFFSET.value()); + List availableMembers = Member.filterByDateTime(moimScheduleResponses, startDateTime, endDateTime); + + if (!availableMembers.isEmpty()) { + availableTimes.add(AvailableTime.toDomain(availableMembers, startDateTime, endDateTime)); + } + } + + return availableTimes; + } } diff --git a/backend/src/main/java/moim_today/dto/admin/auth/AdminLoginRequest.java b/backend/src/main/java/moim_today/dto/admin/auth/AdminLoginRequest.java index 4c4cbd15..462119b4 100644 --- a/backend/src/main/java/moim_today/dto/admin/auth/AdminLoginRequest.java +++ b/backend/src/main/java/moim_today/dto/admin/auth/AdminLoginRequest.java @@ -1,7 +1,15 @@ package moim_today.dto.admin.auth; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; + +import static moim_today.global.constant.exception.ValidationExceptionConstant.ADMIN_PASSWORD_BLANK_ERROR; +import static moim_today.global.constant.exception.ValidationExceptionConstant.UNIVERSITY_ID_MIN_ERROR; + + public record AdminLoginRequest( - long universityId, - String adminPassword + @Min(value = 0, message = UNIVERSITY_ID_MIN_ERROR) long universityId, + @NotBlank(message = ADMIN_PASSWORD_BLANK_ERROR) String adminPassword ) { + } diff --git a/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryAnswerRequest.java b/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryAnswerRequest.java index 6eb7c565..c7767470 100644 --- a/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryAnswerRequest.java +++ b/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryAnswerRequest.java @@ -1,10 +1,14 @@ package moim_today.dto.admin.user_inquiry; +import jakarta.validation.constraints.Min; import lombok.Builder; +import static moim_today.global.constant.exception.ValidationExceptionConstant.USER_INQUIRY_ID_MIN_ERROR; + @Builder public record UserInquiryAnswerRequest( - long userInquiryId, + @Min(value = 0, message = USER_INQUIRY_ID_MIN_ERROR) long userInquiryId, boolean answerComplete ) { + } diff --git a/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryRequest.java b/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryRequest.java index 226577e4..f24bb5ae 100644 --- a/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryRequest.java +++ b/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryRequest.java @@ -1,10 +1,14 @@ package moim_today.dto.admin.user_inquiry; +import jakarta.validation.constraints.NotBlank; import moim_today.persistence.entity.admin.UserInquiryJpaEntity; +import static moim_today.global.constant.exception.ValidationExceptionConstant.INQUIRY_CONTENT_BLANK_ERROR; +import static moim_today.global.constant.exception.ValidationExceptionConstant.INQUIRY_TITLE_BLANK_ERROR; + public record UserInquiryRequest ( - String inquiryTitle, - String inquiryContent + @NotBlank(message = INQUIRY_TITLE_BLANK_ERROR) String inquiryTitle, + @NotBlank(message = INQUIRY_CONTENT_BLANK_ERROR) String inquiryContent ){ public UserInquiryJpaEntity toEntity(final long memberId, final long universityId, final long departmentId){ diff --git a/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryRespondRequest.java b/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryRespondRequest.java index 0287ffef..1d8a5188 100644 --- a/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryRespondRequest.java +++ b/backend/src/main/java/moim_today/dto/admin/user_inquiry/UserInquiryRespondRequest.java @@ -1,14 +1,17 @@ package moim_today.dto.admin.user_inquiry; -import lombok.ToString; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; import moim_today.dto.mail.MailSendRequest; import java.util.List; +import static moim_today.global.constant.exception.ValidationExceptionConstant.*; + public record UserInquiryRespondRequest( - long userInquiryId, - long memberId, - String responseContent + @Min(value = 0, message = USER_INQUIRY_ID_MIN_ERROR) long userInquiryId, + @Min(value = 0, message = MEMBER_ID_MIN_ERROR) long memberId, + @NotBlank(message = USER_INQUIRY_RESPONSE_CONTENT_BLANK_ERROR) String responseContent ) { public MailSendRequest toMailSendRequest(final String subject, final String userEmail){ diff --git a/backend/src/main/java/moim_today/dto/auth/MemberLoginRequest.java b/backend/src/main/java/moim_today/dto/auth/MemberLoginRequest.java index 11280de7..ff785dd4 100644 --- a/backend/src/main/java/moim_today/dto/auth/MemberLoginRequest.java +++ b/backend/src/main/java/moim_today/dto/auth/MemberLoginRequest.java @@ -1,8 +1,14 @@ package moim_today.dto.auth; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; + +import static moim_today.global.constant.exception.ValidationExceptionConstant.*; + public record MemberLoginRequest( - String email, - String password, + @Email(message = EMAIL_INVALID_ERROR) @NotBlank(message = EMAIL_BLANK_ERROR) String email, + @NotBlank(message = MEMBER_PASSWORD_BLANK_ERROR) String password, boolean isKeepLogin ) { + } diff --git a/backend/src/main/java/moim_today/dto/auth/MemberSignUpRequest.java b/backend/src/main/java/moim_today/dto/auth/MemberSignUpRequest.java index d19a22f2..b6439648 100644 --- a/backend/src/main/java/moim_today/dto/auth/MemberSignUpRequest.java +++ b/backend/src/main/java/moim_today/dto/auth/MemberSignUpRequest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Builder; @@ -11,26 +12,21 @@ import java.time.LocalDate; import static moim_today.global.constant.MemberConstant.DEFAULT_PROFILE_URL; +import static moim_today.global.constant.exception.ValidationExceptionConstant.*; @Builder public record MemberSignUpRequest( - long universityId, - long departmentId, - @Email(message = INVALID_EMAIL_FORMAT) @NotBlank(message = NO_EMAIL) String email, - @NotBlank(message = NO_PASSWORD) String password, - @NotBlank(message = NO_USERNAME) String username, - @NotBlank String studentId, + @Min(value = 0, message = UNIVERSITY_ID_MIN_ERROR) long universityId, + @Min(value = 0, message = DEPARTMENT_ID_MIN_ERROR) long departmentId, + @Email(message = EMAIL_INVALID_ERROR) @NotBlank(message = EMAIL_BLANK_ERROR) String email, + @NotBlank(message = MEMBER_PASSWORD_BLANK_ERROR) String password, + @NotBlank(message = USERNAME_BLANK_ERROR) String username, + @NotBlank(message = STUDENT_ID_BLANK_ERROR) String studentId, @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-M-d", timezone = "Asia/Seoul") - @NotNull(message = NO_BIRTH_DATE_ERROR) LocalDate birthDate, - @NotNull(message = NO_GENDER_ENUM_ERROR) Gender gender + @NotNull(message = BIRTH_DATE_NULL_ERROR) LocalDate birthDate, + @NotNull(message = GENDER_NULL_ERROR) Gender gender ) { - public static final String NO_PASSWORD = "패스워드가 없습니다."; - public static final String NO_USERNAME = "사용자 이름이 없습니다."; - public static final String NO_EMAIL = "이메일이 없습니다."; - public static final String INVALID_EMAIL_FORMAT = "이메일 형식이 올바르지 않습니다."; - public static final String NO_BIRTH_DATE_ERROR = "birthDate 값이 없습니다."; - public static final String NO_GENDER_ENUM_ERROR = "GENDER 값이 없습니다."; public MemberJpaEntity toEntity(final String encodedPassword) { return MemberJpaEntity.builder() diff --git a/backend/src/main/java/moim_today/dto/certification/CompleteEmailCertificationRequest.java b/backend/src/main/java/moim_today/dto/certification/CompleteEmailCertificationRequest.java index 64603b64..ed6fb3a2 100644 --- a/backend/src/main/java/moim_today/dto/certification/CompleteEmailCertificationRequest.java +++ b/backend/src/main/java/moim_today/dto/certification/CompleteEmailCertificationRequest.java @@ -1,6 +1,13 @@ package moim_today.dto.certification; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; + +import static moim_today.global.constant.exception.ValidationExceptionConstant.EMAIL_BLANK_ERROR; +import static moim_today.global.constant.exception.ValidationExceptionConstant.EMAIL_INVALID_ERROR; + public record CompleteEmailCertificationRequest( - String email + @Email(message = EMAIL_INVALID_ERROR) @NotBlank(message = EMAIL_BLANK_ERROR) String email ) { + } diff --git a/backend/src/main/java/moim_today/dto/certification/EmailCertificationRequest.java b/backend/src/main/java/moim_today/dto/certification/EmailCertificationRequest.java index 5f537b64..f38358b5 100644 --- a/backend/src/main/java/moim_today/dto/certification/EmailCertificationRequest.java +++ b/backend/src/main/java/moim_today/dto/certification/EmailCertificationRequest.java @@ -1,6 +1,13 @@ package moim_today.dto.certification; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; + +import static moim_today.global.constant.exception.ValidationExceptionConstant.EMAIL_BLANK_ERROR; +import static moim_today.global.constant.exception.ValidationExceptionConstant.EMAIL_INVALID_ERROR; + public record EmailCertificationRequest( - String email + @Email(message = EMAIL_INVALID_ERROR) @NotBlank(message = EMAIL_BLANK_ERROR) String email ) { + } diff --git a/backend/src/main/java/moim_today/dto/certification/PasswordFindRequest.java b/backend/src/main/java/moim_today/dto/certification/PasswordFindRequest.java index 68655b6d..e911d11d 100644 --- a/backend/src/main/java/moim_today/dto/certification/PasswordFindRequest.java +++ b/backend/src/main/java/moim_today/dto/certification/PasswordFindRequest.java @@ -1,6 +1,13 @@ package moim_today.dto.certification; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; + +import static moim_today.global.constant.exception.ValidationExceptionConstant.EMAIL_BLANK_ERROR; +import static moim_today.global.constant.exception.ValidationExceptionConstant.EMAIL_INVALID_ERROR; + public record PasswordFindRequest( - String email + @Email(message = EMAIL_INVALID_ERROR) @NotBlank(message = EMAIL_BLANK_ERROR) String email ) { + } diff --git a/backend/src/main/java/moim_today/dto/department/AddDepartmentRequest.java b/backend/src/main/java/moim_today/dto/department/AddDepartmentRequest.java index e9debb70..b0b2c899 100644 --- a/backend/src/main/java/moim_today/dto/department/AddDepartmentRequest.java +++ b/backend/src/main/java/moim_today/dto/department/AddDepartmentRequest.java @@ -1,12 +1,17 @@ package moim_today.dto.department; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; import lombok.Builder; import moim_today.persistence.entity.department.request_deparment.RequestDepartmentJpaEntity; +import static moim_today.global.constant.exception.ValidationExceptionConstant.DEPARTMENT_NAME_BLANK_ERROR; +import static moim_today.global.constant.exception.ValidationExceptionConstant.UNIVERSITY_ID_MIN_ERROR; + @Builder public record AddDepartmentRequest( - long universityId, - String departmentName + @Min(value = 0, message = UNIVERSITY_ID_MIN_ERROR) long universityId, + @NotBlank(message = DEPARTMENT_NAME_BLANK_ERROR) String departmentName ) { public RequestDepartmentJpaEntity toEntity() { diff --git a/backend/src/main/java/moim_today/dto/department/ApproveRequestDepartmentRequest.java b/backend/src/main/java/moim_today/dto/department/ApproveRequestDepartmentRequest.java index c2fb5362..452f5a26 100644 --- a/backend/src/main/java/moim_today/dto/department/ApproveRequestDepartmentRequest.java +++ b/backend/src/main/java/moim_today/dto/department/ApproveRequestDepartmentRequest.java @@ -1,11 +1,16 @@ package moim_today.dto.department; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; import lombok.Builder; +import static moim_today.global.constant.exception.ValidationExceptionConstant.*; + @Builder public record ApproveRequestDepartmentRequest( - long requestDepartmentId, - long universityId, - String requestDepartmentName + @Min(value = 0, message = DEPARTMENT_ID_MIN_ERROR) long requestDepartmentId, + @Min(value = 0, message = UNIVERSITY_ID_MIN_ERROR) long universityId, + @NotBlank(message = DEPARTMENT_NAME_BLANK_ERROR) String requestDepartmentName ) { + } diff --git a/backend/src/main/java/moim_today/dto/file/FileDeleteRequest.java b/backend/src/main/java/moim_today/dto/file/FileDeleteRequest.java index ed3db320..67b3e06f 100644 --- a/backend/src/main/java/moim_today/dto/file/FileDeleteRequest.java +++ b/backend/src/main/java/moim_today/dto/file/FileDeleteRequest.java @@ -1,7 +1,13 @@ package moim_today.dto.file; +import jakarta.validation.constraints.NotBlank; + +import static moim_today.global.constant.exception.ValidationExceptionConstant.FILENAME_BLANK_ERROR; +import static moim_today.global.constant.exception.ValidationExceptionConstant.UPLOAD_FILE_PATH_BLANK_ERROR; + public record FileDeleteRequest( - String uploadFilePath, - String fileName + @NotBlank(message = UPLOAD_FILE_PATH_BLANK_ERROR) String uploadFilePath, + @NotBlank(message = FILENAME_BLANK_ERROR) String fileName ) { + } diff --git a/backend/src/main/java/moim_today/dto/meeting/meeting/JoinedMeetingDao.java b/backend/src/main/java/moim_today/dto/meeting/meeting/JoinedMeetingDao.java index 947be3bd..11b0c41e 100644 --- a/backend/src/main/java/moim_today/dto/meeting/meeting/JoinedMeetingDao.java +++ b/backend/src/main/java/moim_today/dto/meeting/meeting/JoinedMeetingDao.java @@ -6,7 +6,9 @@ import java.time.LocalDateTime; public record JoinedMeetingDao( + long moimId, long meetingId, + String moimTitle, String agenda, @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul") diff --git a/backend/src/main/java/moim_today/dto/meeting/meeting/JoinedMeetingResponse.java b/backend/src/main/java/moim_today/dto/meeting/meeting/JoinedMeetingResponse.java index 50f1eddd..f08af611 100644 --- a/backend/src/main/java/moim_today/dto/meeting/meeting/JoinedMeetingResponse.java +++ b/backend/src/main/java/moim_today/dto/meeting/meeting/JoinedMeetingResponse.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Builder; +import moim_today.domain.meeting.Meeting; import java.time.LocalDate; import java.util.List; @@ -9,8 +10,11 @@ @Builder public record JoinedMeetingResponse( + long moimId, long meetingId, + String moimTitle, String agenda, + long dDay, @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") LocalDate startDate @@ -23,9 +27,15 @@ public static List toResponses(final List error.getField() + ": " + error.getDefaultMessage()) + .map(error -> error.getDefaultMessage()) .findFirst() .orElse(e.getMessage()); return ErrorResponse.of(BAD_REQUEST.statusCode(), errorMessage); @@ -102,7 +103,12 @@ public ErrorResponse handleValidationExceptions(final MethodArgumentNotValidExce @ExceptionHandler(MethodArgumentTypeMismatchException.class) public ErrorResponse handleException(final MethodArgumentTypeMismatchException e) { log.error("MethodArgumentTypeMismatchException={}", e.getMessage()); - BadRequestException exception = new BadRequestException(METHOD_ARGUMENT_TYPE_MISMATCH.message()); + String errorMessage = String.join(ERROR_MESSAGE_DELIMITER.value(), + METHOD_ARGUMENT_TYPE_MISMATCH.message(), + MISSING_PARAMETER.message() + e.getParameter().getParameterName(), + MISMATCH_TYPE.message() + e.getParameter().getParameterType()); + + BadRequestException exception = new BadRequestException(errorMessage); return ErrorResponse.of(exception.getStatusCode(), exception.getMessage()); } @@ -111,7 +117,12 @@ public ErrorResponse handleException(final MethodArgumentTypeMismatchException e @ExceptionHandler(MissingServletRequestParameterException.class) public ErrorResponse handleException(final MissingServletRequestParameterException e) { log.error("MissingServletRequestParameterException={}", e.getMessage()); - BadRequestException exception = new BadRequestException(MISSING_SERVLET_REQUEST_PARAMETER.message()); + String errorMessage = String.join(ERROR_MESSAGE_DELIMITER.value(), + MISSING_SERVLET_REQUEST_PARAMETER.message(), + MISSING_PARAMETER.message() + e.getParameterName(), + MISMATCH_TYPE.message() + e.getParameterType()); + + BadRequestException exception = new BadRequestException(errorMessage); return ErrorResponse.of(exception.getStatusCode(), exception.getMessage()); } diff --git a/backend/src/main/java/moim_today/global/spring_event/event/AdminMemberDeleteEvent.java b/backend/src/main/java/moim_today/global/spring_event/event/AdminMemberDeleteEvent.java new file mode 100644 index 00000000..adbc8b85 --- /dev/null +++ b/backend/src/main/java/moim_today/global/spring_event/event/AdminMemberDeleteEvent.java @@ -0,0 +1,6 @@ +package moim_today.global.spring_event.event; + +public record AdminMemberDeleteEvent( + long memberId +) { +} diff --git a/backend/src/main/java/moim_today/global/spring_event/event_listener/AdminMemberEventListener.java b/backend/src/main/java/moim_today/global/spring_event/event_listener/AdminMemberEventListener.java new file mode 100644 index 00000000..4b52e80f --- /dev/null +++ b/backend/src/main/java/moim_today/global/spring_event/event_listener/AdminMemberEventListener.java @@ -0,0 +1,44 @@ +package moim_today.global.spring_event.event_listener; + +import moim_today.global.spring_event.event.AdminMemberDeleteEvent; +import moim_today.implement.moim.joined_moim.JoinedMoimComposition; +import moim_today.implement.moim.moim.MoimComposition; +import moim_today.implement.schedule.schedule.ScheduleComposition; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.event.TransactionPhase; +import org.springframework.transaction.event.TransactionalEventListener; + +import java.util.List; + +@Component +public class AdminMemberEventListener { + + private final MoimComposition moimComposition; + private final JoinedMoimComposition joinedMoimComposition; + private final ScheduleComposition scheduleComposition; + + public AdminMemberEventListener(final MoimComposition moimComposition, + final JoinedMoimComposition joinedMoimComposition, + final ScheduleComposition scheduleComposition) { + this.moimComposition = moimComposition; + this.joinedMoimComposition = joinedMoimComposition; + this.scheduleComposition = scheduleComposition; + } + + @TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void memberDeleteFromMoim(final AdminMemberDeleteEvent adminMemberDeleteEvent){ + long memberId = adminMemberDeleteEvent.memberId(); + List joinedMoimIds = joinedMoimComposition.findMoimIdsByMemberId(memberId); + joinedMoimIds.forEach(moimId -> moimComposition.deleteMemberFromMoim(memberId, moimId)); + } + + @TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void deleteMemberSchedules(final AdminMemberDeleteEvent adminMemberDeleteEvent){ + long memberId = adminMemberDeleteEvent.memberId(); + scheduleComposition.deleteAllByMemberId(memberId); + } +} diff --git a/backend/src/main/java/moim_today/implement/schedule/schedule/ScheduleComposition.java b/backend/src/main/java/moim_today/implement/schedule/schedule/ScheduleComposition.java index 7ded8f58..0e5b8746 100644 --- a/backend/src/main/java/moim_today/implement/schedule/schedule/ScheduleComposition.java +++ b/backend/src/main/java/moim_today/implement/schedule/schedule/ScheduleComposition.java @@ -75,6 +75,10 @@ public void deleteAllByMeetingId(final long meetingId) { scheduleRemover.deleteAllByMeetingId(meetingId); } + public void deleteAllByMemberId(final long memberId){ + scheduleRemover.deleteAllByMemberId(memberId); + } + public void deleteByMemberIdAndMeetingId(final long memberId, final long meetingId) { scheduleRemover.deleteByMemberIdAndMeetingId(memberId, meetingId); } diff --git a/backend/src/main/java/moim_today/implement/schedule/schedule/ScheduleRemover.java b/backend/src/main/java/moim_today/implement/schedule/schedule/ScheduleRemover.java index d91b2ac9..e1f14992 100644 --- a/backend/src/main/java/moim_today/implement/schedule/schedule/ScheduleRemover.java +++ b/backend/src/main/java/moim_today/implement/schedule/schedule/ScheduleRemover.java @@ -46,4 +46,9 @@ public void deleteAllByMemberInMeeting(final long memberId, final List mee public void deleteByMemberIdAndMeetingId(final long memberId, final long meetingId) { scheduleRepository.deleteByMemberIdAndMeetingId(memberId, meetingId); } + + @Transactional + public void deleteAllByMemberId(final long memberId) { + scheduleRepository.deleteAllByMemberId(memberId); + } } diff --git a/backend/src/main/java/moim_today/persistence/entity/moim/moim/MoimJpaEntity.java b/backend/src/main/java/moim_today/persistence/entity/moim/moim/MoimJpaEntity.java index 1878eee5..6b5bbf7a 100644 --- a/backend/src/main/java/moim_today/persistence/entity/moim/moim/MoimJpaEntity.java +++ b/backend/src/main/java/moim_today/persistence/entity/moim/moim/MoimJpaEntity.java @@ -3,7 +3,6 @@ import jakarta.persistence.*; import lombok.Builder; import lombok.Getter; -import moim_today.domain.moim.DisplayStatus; import moim_today.domain.moim.enums.MoimCategory; import moim_today.dto.moim.moim.MoimUpdateRequest; import moim_today.global.annotation.Association; @@ -15,10 +14,8 @@ import java.time.LocalDateTime; import static moim_today.global.constant.MoimConstant.DEFAULT_MOIM_IMAGE_URL; -import static moim_today.global.constant.MoimConstant.DEFAULT_MOIM_PASSWORD; -import static moim_today.global.constant.exception.MeetingExceptionConstant.MEETING_DATE_TIME_BAD_REQUEST_ERROR; -import static moim_today.global.constant.exception.MoimExceptionConstant.MOIM_HOST_ERROR; import static moim_today.global.constant.NumberConstant.VIEW_COUNT_OF_ONE; +import static moim_today.global.constant.exception.MeetingExceptionConstant.MEETING_DATE_TIME_BAD_REQUEST_ERROR; import static moim_today.global.constant.exception.MoimExceptionConstant.*; @Getter @@ -47,14 +44,9 @@ public class MoimJpaEntity extends BaseTimeEntity { private String imageUrl; - private String password; - @Enumerated(EnumType.STRING) private MoimCategory moimCategory; - @Enumerated(EnumType.STRING) - private DisplayStatus displayStatus; - private int views; private LocalDate startDate; @@ -67,9 +59,8 @@ protected MoimJpaEntity() { @Builder private MoimJpaEntity(final long universityId, final long memberId, final String title, final String contents, final int capacity, final int currentCount, - final String imageUrl, final String password, final MoimCategory moimCategory, - final DisplayStatus displayStatus, final int views, - final LocalDate startDate, final LocalDate endDate) { + final String imageUrl, final MoimCategory moimCategory, + final int views, final LocalDate startDate, final LocalDate endDate) { this.universityId = universityId; this.memberId = memberId; this.title = title; @@ -77,9 +68,7 @@ private MoimJpaEntity(final long universityId, final long memberId, final String this.capacity = capacity; this.currentCount = currentCount; this.imageUrl = imageUrl; - this.password = password; this.moimCategory = moimCategory; - this.displayStatus = displayStatus; this.views = views; this.startDate = startDate; this.endDate = endDate; @@ -119,9 +108,7 @@ public void updateMoim(final MoimUpdateRequest moimUpdateRequest) { this.moimCategory = moimUpdateRequest.moimCategory(); this.startDate = moimUpdateRequest.startDate(); this.endDate = moimUpdateRequest.endDate(); - this.displayStatus = moimUpdateRequest.displayStatus(); - updatePasswordByDisplayStatus(moimUpdateRequest.password()); updateImageUrl(moimUpdateRequest.imageUrl()); } @@ -130,23 +117,13 @@ public void addToCurrentCount(final int plusCount){ } private void updateImageUrl(final String updateImageUrl) { - if (updateImageUrl == null) { + if (updateImageUrl == null || updateImageUrl.isBlank()) { this.imageUrl = DEFAULT_MOIM_IMAGE_URL.value(); } else { this.imageUrl = updateImageUrl; } } - private void updatePasswordByDisplayStatus(final String updatePassword) { - if (displayStatus.equals(DisplayStatus.PUBLIC)) { - this.password = DEFAULT_MOIM_PASSWORD.value(); - } else { - if (updatePassword != null) { - this.password = updatePassword; - } - } - } - public void updateMoimViews() { this.views += VIEW_COUNT_OF_ONE.value(); } diff --git a/backend/src/main/java/moim_today/persistence/repository/meeting/meeting/MeetingRepositoryImpl.java b/backend/src/main/java/moim_today/persistence/repository/meeting/meeting/MeetingRepositoryImpl.java index ddfce62f..56134f46 100644 --- a/backend/src/main/java/moim_today/persistence/repository/meeting/meeting/MeetingRepositoryImpl.java +++ b/backend/src/main/java/moim_today/persistence/repository/meeting/meeting/MeetingRepositoryImpl.java @@ -11,6 +11,8 @@ import moim_today.dto.meeting.meeting.QMeetingSimpleDao; import moim_today.global.error.NotFoundException; import moim_today.persistence.entity.meeting.meeting.MeetingJpaEntity; +import moim_today.persistence.entity.meeting.meeting.QMeetingJpaEntity; +import moim_today.persistence.entity.moim.moim.QMoimJpaEntity; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; @@ -123,13 +125,17 @@ public List findAllPastByMoimId(final long moimId, final long public List findAllByMeetingIds(final List meetingIds) { return queryFactory.select( new QJoinedMeetingDao( + moimJpaEntity.id, meetingJpaEntity.id, + moimJpaEntity.title, meetingJpaEntity.agenda, meetingJpaEntity.startDateTime ) ) .from(meetingJpaEntity) + .join(moimJpaEntity).on(meetingJpaEntity.moimId.eq(moimJpaEntity.id)) .where(meetingJpaEntity.id.in(meetingIds)) + .orderBy(meetingJpaEntity.startDateTime.asc()) .fetch(); } @@ -138,14 +144,18 @@ public List findAllUpcomingByMeetingIds(final List meeti final LocalDateTime currentDateTime) { return queryFactory.select( new QJoinedMeetingDao( + moimJpaEntity.id, meetingJpaEntity.id, + moimJpaEntity.title, meetingJpaEntity.agenda, meetingJpaEntity.startDateTime ) ) .from(meetingJpaEntity) + .join(moimJpaEntity).on(meetingJpaEntity.moimId.eq(moimJpaEntity.id)) .where(meetingJpaEntity.id.in(meetingIds) .and(meetingJpaEntity.startDateTime.after(currentDateTime))) + .orderBy(meetingJpaEntity.startDateTime.asc()) .fetch(); } @@ -154,14 +164,18 @@ public List findAllPastByMeetingIds(final List meetingId final LocalDateTime currentDateTime) { return queryFactory.select( new QJoinedMeetingDao( + moimJpaEntity.id, meetingJpaEntity.id, + moimJpaEntity.title, meetingJpaEntity.agenda, meetingJpaEntity.startDateTime ) ) .from(meetingJpaEntity) + .join(moimJpaEntity).on(meetingJpaEntity.moimId.eq(moimJpaEntity.id)) .where(meetingJpaEntity.id.in(meetingIds) .and(meetingJpaEntity.startDateTime.before(currentDateTime))) + .orderBy(meetingJpaEntity.startDateTime.asc()) .fetch(); } diff --git a/backend/src/main/java/moim_today/persistence/repository/member/MemberRepositoryImpl.java b/backend/src/main/java/moim_today/persistence/repository/member/MemberRepositoryImpl.java index 2838c990..0722b25c 100644 --- a/backend/src/main/java/moim_today/persistence/repository/member/MemberRepositoryImpl.java +++ b/backend/src/main/java/moim_today/persistence/repository/member/MemberRepositoryImpl.java @@ -135,7 +135,7 @@ public List findByUniversityIdAndDepartmentId(final long univers .join(universityJpaEntity).on(memberJpaEntity.universityId.eq(universityJpaEntity.id)) .join(departmentJpaEntity).on(memberJpaEntity.departmentId.eq(departmentJpaEntity.id)) .where( - universityFilter(universityId), + memberJpaEntity.universityId.eq(universityId), departmentFilter(departmentId), memberJpaEntity.studentId.ne(DELETED_MEMBER_STUDENT_ID.value()) ) @@ -147,13 +147,6 @@ public void deleteById(final long memberId) { memberJpaRepository.deleteById(memberId); } - private BooleanExpression universityFilter(final long universityId) { - if(universityId == 0) { - return null; - } - return memberJpaEntity.universityId.eq(universityId); - } - private BooleanExpression departmentFilter(final long departmentId) { if(departmentId == 0) { return null; diff --git a/backend/src/main/java/moim_today/persistence/repository/moim/moim/MoimRepositoryImpl.java b/backend/src/main/java/moim_today/persistence/repository/moim/moim/MoimRepositoryImpl.java index 9d7af32c..0368cfa4 100644 --- a/backend/src/main/java/moim_today/persistence/repository/moim/moim/MoimRepositoryImpl.java +++ b/backend/src/main/java/moim_today/persistence/repository/moim/moim/MoimRepositoryImpl.java @@ -58,8 +58,7 @@ public List findAllByUniversityId(final long universityId) { moimJpaEntity.capacity, moimJpaEntity.currentCount, moimJpaEntity.imageUrl, - moimJpaEntity.moimCategory, - moimJpaEntity.displayStatus + moimJpaEntity.moimCategory )) .from(moimJpaEntity) .where(moimJpaEntity.universityId.eq(universityId)) @@ -110,8 +109,7 @@ public List searchMoimBySearchParam(final long universityId, moimJpaEntity.capacity, moimJpaEntity.currentCount, moimJpaEntity.imageUrl, - moimJpaEntity.moimCategory, - moimJpaEntity.displayStatus + moimJpaEntity.moimCategory )) .from(moimJpaEntity) .where( @@ -130,8 +128,7 @@ public List findEndedMoimSimpleResponsesByMoimIds(final List moimJpaEntity.capacity, moimJpaEntity.currentCount, moimJpaEntity.imageUrl, - moimJpaEntity.moimCategory, - moimJpaEntity.displayStatus + moimJpaEntity.moimCategory )) .from(moimJpaEntity) .where(moimJpaEntity.id.in(moimIds).and(moimJpaEntity.endDate.before(now))) @@ -146,8 +143,7 @@ public List findInProgressMoimSimpleResponsesByMoimIds(final moimJpaEntity.capacity, moimJpaEntity.currentCount, moimJpaEntity.imageUrl, - moimJpaEntity.moimCategory, - moimJpaEntity.displayStatus + moimJpaEntity.moimCategory )) .from(moimJpaEntity) .where(moimJpaEntity.id.in(moimIds).and(moimJpaEntity.endDate.goe(now))) @@ -165,8 +161,7 @@ public List findAllMoimResponses(final long universityId, moimJpaEntity.capacity, moimJpaEntity.currentCount, moimJpaEntity.imageUrl, - moimJpaEntity.moimCategory, - moimJpaEntity.displayStatus + moimJpaEntity.moimCategory )) .from(moimJpaEntity) .where( diff --git a/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleJpaRepository.java b/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleJpaRepository.java index 79d9c1a2..84068797 100644 --- a/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleJpaRepository.java +++ b/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleJpaRepository.java @@ -13,5 +13,7 @@ public interface ScheduleJpaRepository extends JpaRepository findAllByMemberId(final long memberId); } diff --git a/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleRepository.java b/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleRepository.java index 4e386ffd..e58edb0f 100644 --- a/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleRepository.java +++ b/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleRepository.java @@ -39,4 +39,6 @@ public interface ScheduleRepository { void deleteAllByMeetingId(final long meetingId); void deleteByMemberIdAndMeetingId(final long memberId, final long meetingId); + + void deleteAllByMemberId(final long memberId); } diff --git a/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleRepositoryImpl.java b/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleRepositoryImpl.java index 3e5573b7..db46d995 100644 --- a/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleRepositoryImpl.java +++ b/backend/src/main/java/moim_today/persistence/repository/schedule/schedule/ScheduleRepositoryImpl.java @@ -191,4 +191,9 @@ public void deleteAllByMeetingId(final long meetingId) { public void deleteByMemberIdAndMeetingId(final long memberId, final long meetingId) { scheduleJpaRepository.deleteByMemberIdAndMeetingId(memberId, meetingId); } + + @Override + public void deleteAllByMemberId(final long memberId) { + scheduleJpaRepository.deleteAllByMemberId(memberId); + } } diff --git a/backend/src/main/java/moim_today/presentation/admin/auth/AdminAuthController.java b/backend/src/main/java/moim_today/presentation/admin/auth/AdminAuthController.java index 88b960e9..8b7e5081 100644 --- a/backend/src/main/java/moim_today/presentation/admin/auth/AdminAuthController.java +++ b/backend/src/main/java/moim_today/presentation/admin/auth/AdminAuthController.java @@ -1,6 +1,7 @@ package moim_today.presentation.admin.auth; import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; import moim_today.application.admin.auth.AdminAuthService; import moim_today.domain.university.AdminSession; import moim_today.dto.admin.auth.AdminLoginRequest; @@ -21,7 +22,7 @@ public AdminAuthController(final AdminAuthService adminAuthService) { } @PostMapping("/login") - public void adminLogin(@RequestBody final AdminLoginRequest adminLoginRequest, + public void adminLogin(@RequestBody @Valid final AdminLoginRequest adminLoginRequest, final HttpServletRequest request) { adminAuthService.login(adminLoginRequest, request); } diff --git a/backend/src/main/java/moim_today/presentation/admin/department/AdminDepartmentController.java b/backend/src/main/java/moim_today/presentation/admin/department/AdminDepartmentController.java index 8cdcf33c..47660b14 100644 --- a/backend/src/main/java/moim_today/presentation/admin/department/AdminDepartmentController.java +++ b/backend/src/main/java/moim_today/presentation/admin/department/AdminDepartmentController.java @@ -1,5 +1,6 @@ package moim_today.presentation.admin.department; +import jakarta.validation.Valid; import moim_today.application.admin.department.AdminDepartmentService; import moim_today.domain.university.AdminSession; import moim_today.dto.department.ApproveRequestDepartmentRequest; @@ -29,7 +30,7 @@ public CollectionResponse> findAllByUniversityId } @PostMapping("/request-departments") - public void approveRequest(@RequestBody final ApproveRequestDepartmentRequest approveRequestDepartmentRequest) { + public void approveRequest(@RequestBody @Valid final ApproveRequestDepartmentRequest approveRequestDepartmentRequest) { adminDepartmentService.approveRequest(approveRequestDepartmentRequest); } } diff --git a/backend/src/main/java/moim_today/presentation/admin/user_inquiry/UserInquiryController.java b/backend/src/main/java/moim_today/presentation/admin/user_inquiry/UserInquiryController.java index 96296d06..23acbb1c 100644 --- a/backend/src/main/java/moim_today/presentation/admin/user_inquiry/UserInquiryController.java +++ b/backend/src/main/java/moim_today/presentation/admin/user_inquiry/UserInquiryController.java @@ -1,5 +1,6 @@ package moim_today.presentation.admin.user_inquiry; +import jakarta.validation.Valid; import moim_today.application.admin.user_inquiry.UserInquiryService; import moim_today.domain.university.AdminSession; import moim_today.dto.admin.user_inquiry.UserInquiryAnswerRequest; @@ -32,12 +33,12 @@ public CollectionResponse> getNotAnsweredUserInquiries } @PatchMapping("/answer-complete") - public void updateUserInquiryAnswer(@RequestBody final UserInquiryAnswerRequest userInquiryAnswerRequest){ + public void updateUserInquiryAnswer(@RequestBody @Valid final UserInquiryAnswerRequest userInquiryAnswerRequest){ userInquiryService.updateUserInquiryAnswer(userInquiryAnswerRequest); } @PostMapping("/response") - public void respondUserInquiry(@RequestBody final UserInquiryRespondRequest userInquiryRespondRequest){ + public void respondUserInquiry(@RequestBody @Valid final UserInquiryRespondRequest userInquiryRespondRequest){ userInquiryService.respondUserInquiry(userInquiryRespondRequest); } } diff --git a/backend/src/main/java/moim_today/presentation/auth/AuthController.java b/backend/src/main/java/moim_today/presentation/auth/AuthController.java index a20e978c..ae76c706 100644 --- a/backend/src/main/java/moim_today/presentation/auth/AuthController.java +++ b/backend/src/main/java/moim_today/presentation/auth/AuthController.java @@ -19,7 +19,7 @@ public AuthController(final AuthService authService) { } @PostMapping("/login") - public void login(@RequestBody final MemberLoginRequest memberLoginRequest, + public void login(@RequestBody @Valid final MemberLoginRequest memberLoginRequest, final HttpServletRequest request) { authService.login(memberLoginRequest, request); } @@ -30,7 +30,7 @@ public void logout(final HttpServletRequest request) { } @PostMapping("/sign-up") - public void signUp(@Valid @RequestBody final MemberSignUpRequest memberSignUpRequest, + public void signUp(@RequestBody @Valid final MemberSignUpRequest memberSignUpRequest, final HttpServletRequest request) { authService.signUp(memberSignUpRequest, request); } diff --git a/backend/src/main/java/moim_today/presentation/certification/CertificationController.java b/backend/src/main/java/moim_today/presentation/certification/CertificationController.java index 5cd42937..900defd9 100644 --- a/backend/src/main/java/moim_today/presentation/certification/CertificationController.java +++ b/backend/src/main/java/moim_today/presentation/certification/CertificationController.java @@ -1,5 +1,6 @@ package moim_today.presentation.certification; +import jakarta.validation.Valid; import moim_today.application.certification.email.EmailCertificationService; import moim_today.application.certification.password.PasswordCertificationService; import moim_today.dto.certification.CompleteEmailCertificationRequest; @@ -29,20 +30,20 @@ public CertificationController(final PasswordCertificationService passwordCertif @ResponseBody @PostMapping("/password") - public void sendPasswordToken(@RequestBody final PasswordFindRequest passwordFindRequest) { + public void sendPasswordToken(@RequestBody @Valid final PasswordFindRequest passwordFindRequest) { passwordCertificationService.sendPasswordToken(passwordFindRequest.email()); } @ResponseBody @PostMapping("/email") - public void sendCertificationEmail(@RequestBody final EmailCertificationRequest emailCertificationRequest) { + public void sendCertificationEmail(@RequestBody @Valid final EmailCertificationRequest emailCertificationRequest) { emailCertificationService.sendCertificationEmail(emailCertificationRequest.email()); } @ResponseBody @PostMapping("/email/complete") public CompleteEmailCertificationResponse completeCertification( - @RequestBody final CompleteEmailCertificationRequest completeEmailCertificationRequest + @RequestBody @Valid final CompleteEmailCertificationRequest completeEmailCertificationRequest ) { return emailCertificationService.completeCertification(completeEmailCertificationRequest.email()); } diff --git a/backend/src/main/java/moim_today/presentation/department/request_department/RequestDepartmentController.java b/backend/src/main/java/moim_today/presentation/department/request_department/RequestDepartmentController.java index 3ad34e7c..30012aa6 100644 --- a/backend/src/main/java/moim_today/presentation/department/request_department/RequestDepartmentController.java +++ b/backend/src/main/java/moim_today/presentation/department/request_department/RequestDepartmentController.java @@ -1,5 +1,6 @@ package moim_today.presentation.department.request_department; +import jakarta.validation.Valid; import moim_today.application.department.request_department.RequestDepartmentService; import moim_today.dto.department.AddDepartmentRequest; import org.springframework.web.bind.annotation.*; @@ -16,7 +17,7 @@ public RequestDepartmentController(final RequestDepartmentService requestDepartm } @PostMapping("/request-departments") - public void requestAddDepartment(@RequestBody final AddDepartmentRequest addDepartmentRequest) { + public void requestAddDepartment(@RequestBody @Valid final AddDepartmentRequest addDepartmentRequest) { requestDepartmentService.addDepartment(addDepartmentRequest); } } diff --git a/backend/src/main/java/moim_today/presentation/file/FileController.java b/backend/src/main/java/moim_today/presentation/file/FileController.java index e0dbf654..e033b07c 100644 --- a/backend/src/main/java/moim_today/presentation/file/FileController.java +++ b/backend/src/main/java/moim_today/presentation/file/FileController.java @@ -1,5 +1,6 @@ package moim_today.presentation.file; +import jakarta.validation.Valid; import moim_today.application.file.FileService; import moim_today.domain.member.MemberSession; import moim_today.dto.file.FileDeleteRequest; @@ -28,7 +29,7 @@ public FileResponse uploadFile(@Login final MemberSession memberSession, @DeleteMapping public void deleteFile(@Login final MemberSession memberSession, - @RequestBody final FileDeleteRequest fileDeleteRequest){ + @RequestBody @Valid final FileDeleteRequest fileDeleteRequest){ fileService.deleteFile(memberSession, fileDeleteRequest); } } diff --git a/backend/src/main/java/moim_today/presentation/meeting/meeting/MeetingController.java b/backend/src/main/java/moim_today/presentation/meeting/meeting/MeetingController.java index cec0c523..52d3433d 100644 --- a/backend/src/main/java/moim_today/presentation/meeting/meeting/MeetingController.java +++ b/backend/src/main/java/moim_today/presentation/meeting/meeting/MeetingController.java @@ -1,5 +1,6 @@ package moim_today.presentation.meeting.meeting; +import jakarta.validation.Valid; import moim_today.application.meeting.meeting.MeetingService; import moim_today.domain.meeting.enums.MeetingStatus; import moim_today.domain.member.MemberSession; @@ -33,7 +34,7 @@ public CollectionResponse> findMeetingsByMemberId( @PostMapping public MeetingCreateResponse createMeeting( @Login final MemberSession memberSession, - @RequestBody final MeetingCreateRequest meetingCreateRequest) { + @RequestBody @Valid final MeetingCreateRequest meetingCreateRequest) { return meetingService.createMeeting(memberSession.id(), meetingCreateRequest); } @@ -54,7 +55,7 @@ public MeetingDetailResponse findDetailsByMoimId(@PathVariable final long meetin @PatchMapping public void updateMeeting(@Login final MemberSession memberSession, - @RequestBody final MeetingUpdateRequest meetingUpdateRequest) { + @RequestBody @Valid final MeetingUpdateRequest meetingUpdateRequest) { meetingService.updateMeeting(memberSession.id(), meetingUpdateRequest); } diff --git a/backend/src/main/java/moim_today/presentation/meeting/meeting_comment/MeetingCommentController.java b/backend/src/main/java/moim_today/presentation/meeting/meeting_comment/MeetingCommentController.java index df3c60f5..323474a2 100644 --- a/backend/src/main/java/moim_today/presentation/meeting/meeting_comment/MeetingCommentController.java +++ b/backend/src/main/java/moim_today/presentation/meeting/meeting_comment/MeetingCommentController.java @@ -1,5 +1,6 @@ package moim_today.presentation.meeting.meeting_comment; +import jakarta.validation.Valid; import moim_today.application.meeting.meeting_comment.MeetingCommentService; import moim_today.domain.member.MemberSession; import moim_today.dto.meeting.meeting_comment.*; @@ -20,7 +21,7 @@ public MeetingCommentController(final MeetingCommentService meetingCommentServic @PostMapping public void createMeetingComment(@Login final MemberSession memberSession, - @RequestBody final MeetingCommentCreateRequest meetingCommentCreateRequest) { + @RequestBody @Valid final MeetingCommentCreateRequest meetingCommentCreateRequest) { meetingCommentService.createMeetingComment(memberSession.id(), meetingCommentCreateRequest); } @@ -35,13 +36,13 @@ public MeetingCommentCollectionResponse findAllByMeetingId(@Login final MemberSe @PatchMapping public void updateMeetingComment(@Login final MemberSession memberSession, - @RequestBody final MeetingCommentUpdateRequest meetingCommentUpdateRequest) { + @RequestBody @Valid final MeetingCommentUpdateRequest meetingCommentUpdateRequest) { meetingCommentService.updateMeetingComment(memberSession.id(), meetingCommentUpdateRequest); } @DeleteMapping public void deleteMeetingComment(@Login final MemberSession memberSession, - @RequestBody final MeetingCommentDeleteRequest deleteMeetingCommentRequest) { + @RequestBody @Valid final MeetingCommentDeleteRequest deleteMeetingCommentRequest) { meetingCommentService.deleteMeetingComment(memberSession.id(), deleteMeetingCommentRequest.meetingCommentId()); } } diff --git a/backend/src/main/java/moim_today/presentation/member/MemberController.java b/backend/src/main/java/moim_today/presentation/member/MemberController.java index 9c41e5af..7d8df180 100644 --- a/backend/src/main/java/moim_today/presentation/member/MemberController.java +++ b/backend/src/main/java/moim_today/presentation/member/MemberController.java @@ -1,5 +1,6 @@ package moim_today.presentation.member; +import jakarta.validation.Valid; import moim_today.application.member.MemberService; import moim_today.domain.member.MemberSession; import moim_today.dto.admin.user_inquiry.UserInquiryRequest; @@ -19,13 +20,13 @@ public MemberController(final MemberService memberService) { } @PostMapping("/password-recovery") - public void recoverPassword(@RequestBody final PasswordRecoverRequest passwordRecoverRequest) { + public void recoverPassword(@RequestBody @Valid final PasswordRecoverRequest passwordRecoverRequest) { memberService.recoverPassword(passwordRecoverRequest); } @PatchMapping("/password") public void updatePassword(@Login final MemberSession memberSession, - @RequestBody final PasswordUpdateRequest passwordUpdateRequest) { + @RequestBody @Valid final PasswordUpdateRequest passwordUpdateRequest) { memberService.updatePassword(memberSession, passwordUpdateRequest); } @@ -36,7 +37,7 @@ public MemberProfileResponse getMemberProfile(@Login final MemberSession memberS @PatchMapping("/profile") public void updateProfile(@Login final MemberSession memberSession, - @RequestBody final ProfileUpdateRequest profileUpdateRequest) { + @RequestBody @Valid final ProfileUpdateRequest profileUpdateRequest) { memberService.updateProfile(memberSession.id(), profileUpdateRequest); } @@ -65,7 +66,7 @@ public MemberSimpleResponse getHostProfileByMoimId(@PathVariable final long moim @PostMapping("/user-inquiry") public void createUserInquiry(@Login final MemberSession memberSession, - @RequestBody final UserInquiryRequest userInquiryRequest){ + @RequestBody @Valid final UserInquiryRequest userInquiryRequest){ memberService.createUserInquiry(memberSession, userInquiryRequest); } } diff --git a/backend/src/main/java/moim_today/presentation/moim/MoimController.java b/backend/src/main/java/moim_today/presentation/moim/MoimController.java index 7006cb12..ae889c05 100644 --- a/backend/src/main/java/moim_today/presentation/moim/MoimController.java +++ b/backend/src/main/java/moim_today/presentation/moim/MoimController.java @@ -1,6 +1,7 @@ package moim_today.presentation.moim; import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; import moim_today.application.moim.moim.MoimService; import moim_today.application.moim.moim_notice.MoimNoticeService; import moim_today.domain.member.MemberSession; @@ -51,7 +52,7 @@ public CollectionResponse> findAllMyJoinedMoimSimpleRes @PostMapping public MoimIdResponse createMoim(@Login final MemberSession memberSession, - @RequestBody final MoimCreateRequest moimCreateRequest) { + @RequestBody @Valid final MoimCreateRequest moimCreateRequest) { return moimService.createMoim(memberSession.id(), memberSession.universityId(), moimCreateRequest); } @@ -77,7 +78,7 @@ public CollectionResponse> findAllMoimResponses( @PatchMapping public void updateMoim(@Login final MemberSession memberSession, - @RequestBody final MoimUpdateRequest moimUpdateRequest) { + @RequestBody @Valid final MoimUpdateRequest moimUpdateRequest) { moimService.updateMoim(memberSession.id(), moimUpdateRequest); } @@ -89,31 +90,31 @@ public MoimMemberTabResponse findMoimMembers(@Login final MemberSession memberSe @DeleteMapping public void deleteMoim(@Login final MemberSession memberSession, - @RequestBody final MoimDeleteRequest moimDeleteRequest) { + @RequestBody @Valid final MoimDeleteRequest moimDeleteRequest) { moimService.deleteMoim(memberSession.id(), moimDeleteRequest.moimId()); } @DeleteMapping("/members/kick") public void forceDeleteMember(@Login final MemberSession memberSession, - @RequestBody final MoimMemberKickRequest moimMemberKickRequest) { + @RequestBody @Valid final MoimMemberKickRequest moimMemberKickRequest) { moimService.kickMember(memberSession.id(), moimMemberKickRequest); } @PostMapping("/notices") public void createMoimNotice(@Login final MemberSession memberSession, - @RequestBody final MoimNoticeCreateRequest moimNoticeCreateRequest) { + @RequestBody @Valid final MoimNoticeCreateRequest moimNoticeCreateRequest) { moimNoticeService.createMoimNotice(memberSession.id(), moimNoticeCreateRequest); } @DeleteMapping("/members") public void deleteMember(@Login final MemberSession memberSession, - @RequestBody final MoimMemberDeleteRequest moimMemberDeleteRequest) { + @RequestBody @Valid final MoimMemberDeleteRequest moimMemberDeleteRequest) { moimService.deleteMember(memberSession.id(), moimMemberDeleteRequest); } @PostMapping("/members") public void joinMoim(@Login final MemberSession memberSession, - @RequestBody final MoimJoinRequest moimJoinRequest) { + @RequestBody @Valid final MoimJoinRequest moimJoinRequest) { moimService.appendMemberToMoim(memberSession.id(), moimJoinRequest); } @@ -131,13 +132,13 @@ public MoimNoticeDetailResponse getMoimNoticeDetail(@Login final MemberSession m @PatchMapping("/notices") public void updateMoimNotice(@Login final MemberSession memberSession, - @RequestBody final MoimNoticeUpdateRequest moimNoticeUpdateRequest) { + @RequestBody @Valid final MoimNoticeUpdateRequest moimNoticeUpdateRequest) { moimNoticeService.updateMoimNotice(memberSession.id(), moimNoticeUpdateRequest); } @DeleteMapping("/notices") public void deleteMoimNotice(@Login final MemberSession memberSession, - @RequestBody final MoimNoticeDeleteRequest moimNoticeDeleteRequest) { + @RequestBody @Valid final MoimNoticeDeleteRequest moimNoticeDeleteRequest) { moimNoticeService.deleteMoimNotice(memberSession.id(), moimNoticeDeleteRequest); } diff --git a/backend/src/main/java/moim_today/presentation/schedule/ScheduleController.java b/backend/src/main/java/moim_today/presentation/schedule/ScheduleController.java index 3432e8a6..37eff73f 100644 --- a/backend/src/main/java/moim_today/presentation/schedule/ScheduleController.java +++ b/backend/src/main/java/moim_today/presentation/schedule/ScheduleController.java @@ -1,5 +1,6 @@ package moim_today.presentation.schedule; +import jakarta.validation.Valid; import moim_today.application.schedule.ScheduleService; import moim_today.domain.member.MemberSession; import moim_today.dto.schedule.*; @@ -56,25 +57,25 @@ public CollectionResponse> findAllByMonthly(@Login final @PostMapping("/timetable") public void fetchTimeTable(@Login final MemberSession memberSession, - @RequestBody final TimeTableRequest timeTableRequest) { + @RequestBody @Valid final TimeTableRequest timeTableRequest) { scheduleService.fetchTimeTable(memberSession.id(), timeTableRequest); } @PostMapping public void createSchedule(@Login final MemberSession memberSession, - @RequestBody final ScheduleCreateRequest scheduleCreateRequest) { + @RequestBody @Valid final ScheduleCreateRequest scheduleCreateRequest) { scheduleService.createSchedule(memberSession.id(), scheduleCreateRequest); } @PatchMapping public void updateSchedule(@Login final MemberSession memberSession, - @RequestBody final ScheduleUpdateRequest scheduleUpdateRequest) { + @RequestBody @Valid final ScheduleUpdateRequest scheduleUpdateRequest) { scheduleService.updateSchedule(memberSession.id(), scheduleUpdateRequest); } @DeleteMapping public void deleteSchedule(@Login final MemberSession memberSession, - @RequestBody final ScheduleDeleteRequest scheduleDeleteRequest) { + @RequestBody @Valid final ScheduleDeleteRequest scheduleDeleteRequest) { scheduleService.deleteSchedule(memberSession.id(), scheduleDeleteRequest.scheduleId()); } } \ No newline at end of file diff --git a/backend/src/main/java/moim_today/presentation/todo/TodoController.java b/backend/src/main/java/moim_today/presentation/todo/TodoController.java index 6c4f027f..e3bf8aaa 100644 --- a/backend/src/main/java/moim_today/presentation/todo/TodoController.java +++ b/backend/src/main/java/moim_today/presentation/todo/TodoController.java @@ -52,19 +52,19 @@ public TodoResponse findTodoById(@PathVariable final long todoId) { @PatchMapping public TodoUpdateResponse updateTodo(@Login final MemberSession memberSession, - @RequestBody final TodoUpdateRequest todoUpdateRequest) { + @RequestBody @Valid final TodoUpdateRequest todoUpdateRequest) { return todoService.updateTodo(memberSession.id(), todoUpdateRequest); } @PatchMapping("/todo-progress") public TodoUpdateResponse updateTodoProgress(@Login final MemberSession memberSession, - @RequestBody final TodoProgressUpdateRequest todoProgressUpdateRequest){ + @RequestBody @Valid final TodoProgressUpdateRequest todoProgressUpdateRequest){ return todoService.updateTodoProgress(memberSession.id(), todoProgressUpdateRequest); } @DeleteMapping public void deleteTodo(@Login final MemberSession memberSession, - @RequestBody final TodoRemoveRequest todoRemoveRequest) { + @RequestBody @Valid final TodoRemoveRequest todoRemoveRequest) { todoService.deleteTodo(memberSession.id(), todoRemoveRequest); } } diff --git a/backend/src/main/resources/static/js/get-moims.js b/backend/src/main/resources/static/js/get-moims.js index ce92a9db..71da92bf 100644 --- a/backend/src/main/resources/static/js/get-moims.js +++ b/backend/src/main/resources/static/js/get-moims.js @@ -17,7 +17,7 @@ $(document).ready(function() { var imgElement = $('').attr('src', moim.imageUrl).css('width', '100px'); row.append($('').append(imgElement)); // 이미지 요소를 td에 추가합니다. row.append($('').text(moim.moimCategory)); - row.append($('').text(moim.displayStatus)); + // row.append($('').text(moim.displayStatus)); var deleteButton = $('