Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
set -e
cd /home/ubuntu/stack/docker/app

sudo docker compose down || true
sudo docker compose -f docker-compose-dev.yml down || true

# 기존 kindergarten 이미지 전부 삭제
sudo docker images "juhoonlee/kindergarten" -q | xargs -r sudo docker rmi -f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.onebyone.kindergarten.domain.communityComments.dto.response.PageCommunityCommentsResponseDTO;
import com.onebyone.kindergarten.domain.userBlock.repository.UserBlockRepository;
import com.onebyone.kindergarten.global.exception.BusinessException;
import com.onebyone.kindergarten.global.exception.ErrorCodes;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
Expand Down Expand Up @@ -42,28 +44,28 @@ public CommentResponseDTO createComment(Long postId, CreateCommentRequestDTO dto

// 게시글 조회 (작성자 정보를 포함)
CommunityPost post = postRepository.findByIdWithUser(postId)
.orElseThrow(() -> new IllegalArgumentException("게시글을 찾을 수 없습니다."));
.orElseThrow(() -> new BusinessException(ErrorCodes.NOT_FOUND_POST));

CommunityComment parent = null;

// 대댓글인 경우 부모 댓글 조회
if (dto.getParentId() != null) {
parent = commentRepository.findByIdWithUser(dto.getParentId())
.orElseThrow(() -> new IllegalArgumentException("원댓글을 찾을 수 없습니다."));
.orElseThrow(() -> new BusinessException(ErrorCodes.NOT_FOUND_PARENT_COMMENT));

// 부모 댓글의 게시글과 요청된 게시글이 일치하는지 확인
if (!parent.getPost().getId().equals(postId)) {
throw new IllegalArgumentException("원댓글의 게시글이 일치하지 않습니다.");
throw new BusinessException(ErrorCodes.PARENT_POST_MISMATCH);
}

// 이미 대댓글인 경우 대댓글에 대댓글 작성 방지
if (parent.isReply()) {
throw new IllegalArgumentException("대댓글에는 답글을 작성할 수 없습니다.");
throw new BusinessException(ErrorCodes.REPLY_TO_REPLY_NOT_ALLOWED);
}

// 삭제된 댓글에는 대댓글 작성 불가
if (parent.getDeletedAt() != null) {
throw new IllegalArgumentException("삭제된 댓글에는 답글을 작성할 수 없습니다.");
throw new BusinessException(ErrorCodes.REPLY_TO_DELETED_COMMENT_NOT_ALLOWED);
}
}

Expand Down Expand Up @@ -143,11 +145,11 @@ public PageCommunityCommentsResponseDTO getWroteMyCommunityComments(Long userId,
public void deleteComment(Long commentId, String email) {
// 댓글 조회 (작성자 정보 포함)
CommunityComment comment = commentRepository.findByIdWithUser(commentId)
.orElseThrow(() -> new IllegalArgumentException("댓글을 찾을 수 없습니다."));
.orElseThrow(() -> new BusinessException(ErrorCodes.NOT_FOUND_COMMENT));

// 작성자 확인
if (!comment.getUser().getEmail().equals(email)) {
throw new com.onebyone.kindergarten.domain.kindergartenWorkHistories.exception.UnauthorizedDeleteException();
throw new BusinessException(ErrorCodes.UNAUTHORIZED_DELETE);
}

Long postId = comment.getPost().getId();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import com.onebyone.kindergarten.domain.communityPosts.dto.response.CommunityLikeResponseDTO;
import com.onebyone.kindergarten.domain.communityPosts.entity.CommunityLike;
import com.onebyone.kindergarten.domain.communityPosts.entity.CommunityPost;
import com.onebyone.kindergarten.domain.communityPosts.exception.PostNotFoundException;
import com.onebyone.kindergarten.domain.communityPosts.repository.CommunityLikeRepository;
import com.onebyone.kindergarten.domain.communityPosts.repository.CommunityRepository;
import com.onebyone.kindergarten.domain.pushNotification.service.NotificationTemplateService;
import com.onebyone.kindergarten.domain.user.entity.User;
import com.onebyone.kindergarten.domain.user.service.UserService;
import com.onebyone.kindergarten.global.exception.BusinessException;
import com.onebyone.kindergarten.global.exception.ErrorCodes;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -51,7 +52,7 @@ public CommunityLikeResponseDTO toggleLike(Long postId, String email) {
.orElseGet(() -> {
// 게시글 존재 여부 확인 및 좋아요 추가
CommunityPost post = communityRepository.findById(postId)
.orElseThrow(() -> new PostNotFoundException("게시글을 찾을 수 없습니다."));
.orElseThrow(() -> new BusinessException(ErrorCodes.NOT_FOUND_POST));

CommunityLike newLike = CommunityLike.builder()
.user(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import com.onebyone.kindergarten.domain.communityPosts.dto.response.CommunityPostResponseDTO;
import com.onebyone.kindergarten.domain.communityPosts.entity.CommunityCategory;
import com.onebyone.kindergarten.domain.communityPosts.entity.CommunityPost;
import com.onebyone.kindergarten.domain.communityPosts.exception.PostNotFoundException;
import com.onebyone.kindergarten.domain.communityPosts.mapper.CommunityPostMapper;
import com.onebyone.kindergarten.domain.communityPosts.repository.CommunityCategoryRepository;
import com.onebyone.kindergarten.domain.communityPosts.repository.CommunityRepository;
import com.onebyone.kindergarten.domain.user.entity.User;
import com.onebyone.kindergarten.domain.user.service.UserService;
import com.onebyone.kindergarten.domain.userBlock.repository.UserBlockRepository;
import com.onebyone.kindergarten.global.config.CacheConfig;
import com.onebyone.kindergarten.global.exception.BusinessException;
import com.onebyone.kindergarten.global.exception.ErrorCodes;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
Expand Down Expand Up @@ -84,7 +85,7 @@ public CommunityPostResponseDTO getPost(Long id) {

// 게시글 조회 (User 정보 포함)
CommunityPost post = communityRepository.findByIdWithUser(id)
.orElseThrow(() -> new PostNotFoundException("게시글을 찾을 수 없습니다."));
.orElseThrow(() -> new BusinessException(ErrorCodes.NOT_FOUND_POST));

// 게시글이 존재할 때만 조회수 증가
communityRepository.increaseViewCount(id);
Expand All @@ -111,11 +112,11 @@ public void deletePost(Long postId, String email) {

// 게시글 조회 (작성자 정보 포함)
CommunityPost post = communityRepository.findByIdWithUser(postId)
.orElseThrow(() -> new PostNotFoundException("게시글을 찾을 수 없습니다."));
.orElseThrow(() -> new BusinessException(ErrorCodes.NOT_FOUND_POST));

// 작성자 확인
if (!post.getUser().getEmail().equals(email)) {
throw new com.onebyone.kindergarten.domain.kindergartenWorkHistories.exception.UnauthorizedDeleteException();
throw new BusinessException(ErrorCodes.UNAUTHORIZED_DELETE);
}

// 게시글 소프트 삭제 (deletedAt 설정)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import com.onebyone.kindergarten.domain.inquires.dto.response.InquiryResponseDTO;
import com.onebyone.kindergarten.domain.inquires.entity.Inquiry;
import com.onebyone.kindergarten.domain.inquires.enums.InquiryStatus;
import com.onebyone.kindergarten.domain.inquires.exception.InquiryNotAdminReadException;
import com.onebyone.kindergarten.domain.inquires.exception.InquiryNotAdminWriteException;
import com.onebyone.kindergarten.domain.inquires.exception.InquiryNotFoundException;
import com.onebyone.kindergarten.domain.inquires.repository.InquiryRepository;
import com.onebyone.kindergarten.domain.pushNotification.service.NotificationTemplateService;
import com.onebyone.kindergarten.domain.user.entity.User;
import com.onebyone.kindergarten.domain.user.enums.UserRole;
import com.onebyone.kindergarten.domain.user.service.UserService;
import com.onebyone.kindergarten.global.exception.BusinessException;
import com.onebyone.kindergarten.global.exception.ErrorCodes;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -54,11 +53,11 @@ public InquiryResponseDTO getInquiry(Long id, String email) {

// 문의 조회
Inquiry inquiry = inquiryRepository.findByIdWithUser(id)
.orElseThrow(() -> new InquiryNotFoundException("문의를 찾을 수 없습니다."));
.orElseThrow(() -> new BusinessException(ErrorCodes.NOT_FOUND_INQUIRY));

// 본인 및 관리자 권한 체크
if (!inquiry.getUser().getId().equals(user.getId()) && !user.getRole().equals(UserRole.ADMIN)) {
throw new InquiryNotAdminReadException("본인 문의만 조회할 수 있습니다.");
throw new BusinessException(ErrorCodes.INQUIRY_NOT_ADMIN_CANNOT_READ);
}

return InquiryResponseDTO.fromEntity(inquiry);
Expand All @@ -82,7 +81,7 @@ public Page<InquiryResponseDTO> getAllInquiries(String email, Pageable pageable)

// 관리자 권한 체크
if (!user.getRole().equals(UserRole.ADMIN)) {
throw new InquiryNotAdminReadException("관리자만 모든 문의를 조회할 수 있습니다.");
throw new BusinessException(ErrorCodes.INQUIRY_NOT_ADMIN_CANNOT_READ);
}

return inquiryRepository.findAllDtosOrderByStatusAndCreatedAt(pageable);
Expand All @@ -96,7 +95,7 @@ public Page<InquiryResponseDTO> getInquiriesByStatus(InquiryStatus status, Strin

// 관리자 권한 체크
if (!user.getRole().equals(UserRole.ADMIN)) {
throw new InquiryNotAdminReadException("관리자만 상태별 문의를 조회할 수 있습니다.");
throw new BusinessException(ErrorCodes.INQUIRY_NOT_ADMIN_CANNOT_READ);
}

return inquiryRepository.findDtosByStatus(status, pageable);
Expand All @@ -111,12 +110,12 @@ public InquiryResponseDTO answerInquiry(Long id, AnswerInquiryRequestDTO dto, St

// 관리자 권한 체크
if (!user.getRole().equals(UserRole.ADMIN)) {
throw new InquiryNotAdminWriteException("관리자만 문의에 답변할 수 있습니다.");
throw new BusinessException(ErrorCodes.INQUIRY_NOT_ADMIN_CANNOT_WRITE);
}

// 문의 조회
Inquiry inquiry = inquiryRepository.findByIdWithUser(id)
.orElseThrow(() -> new InquiryNotFoundException("문의를 찾을 수 없습니다."));
.orElseThrow(() -> new BusinessException(ErrorCodes.NOT_FOUND_INQUIRY));

// 답변 등록
inquiry.answerInquiry(dto.getAnswer());
Expand All @@ -140,12 +139,12 @@ public InquiryResponseDTO closeInquiry(Long id, String email) {

// 관리자 권한 체크
if (!user.getRole().equals(UserRole.ADMIN)) {
throw new InquiryNotAdminWriteException("관리자만 문의를 마감할 수 있습니다.");
throw new BusinessException(ErrorCodes.INQUIRY_NOT_ADMIN_CANNOT_READ);
}

// 문의 조회
Inquiry inquiry = inquiryRepository.findById(id)
.orElseThrow(() -> new InquiryNotFoundException("문의를 찾을 수 없습니다."));
.orElseThrow(() -> new BusinessException(ErrorCodes.NOT_FOUND_INQUIRY));

// 문의 마감
inquiry.closeInquiry();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
import com.onebyone.kindergarten.domain.kindergartenInternshipReview.entity.KindergartenInternshipReview;
import com.onebyone.kindergarten.domain.kindergartenInternshipReview.entity.KindergartenInternshipReviewLikeHistory;
import com.onebyone.kindergarten.domain.kindergartenInternshipReview.enums.InternshipReviewStarRatingType;
import com.onebyone.kindergarten.domain.kindergartenInternshipReview.exception.AlreadyExistInternshipReviewException;
import com.onebyone.kindergarten.domain.kindergartenInternshipReview.exception.NotFoundInternshipReviewException;
import com.onebyone.kindergarten.domain.kindergartenInternshipReview.repository.KindergartenInternshipReviewLikeHistoryRepository;
import com.onebyone.kindergarten.domain.kindergartenInternshipReview.repository.KindergartenInternshipReviewRepository;
import com.onebyone.kindergarten.domain.kindergatens.entity.Kindergarten;
import com.onebyone.kindergarten.domain.kindergatens.service.KindergartenService;
import com.onebyone.kindergarten.domain.user.entity.User;
import com.onebyone.kindergarten.domain.user.service.UserService;
import com.onebyone.kindergarten.global.enums.ReviewStatus;
import com.onebyone.kindergarten.global.exception.IllegalArgumentStarRatingException;
import com.onebyone.kindergarten.global.exception.IncorrectUserException;
import com.onebyone.kindergarten.global.exception.BusinessException;
import com.onebyone.kindergarten.global.exception.ErrorCodes;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
import org.springframework.data.domain.Page;
Expand Down Expand Up @@ -45,7 +43,7 @@ public Kindergarten createInternshipReview(CreateInternshipReviewRequestDTO requ

boolean exists = kindergartenInternshipReviewRepository.existsByUserAndKindergarten(user, kindergarten);
if (exists) {
throw new AlreadyExistInternshipReviewException("이미 등록된 실습 리뷰가 존재합니다.");
throw new BusinessException(ErrorCodes.ALREADY_EXIST_INTERNSHIP_REVIEW);
}

KindergartenInternshipReview review = KindergartenInternshipReview.builder()
Expand Down Expand Up @@ -76,10 +74,10 @@ public Kindergarten modifyInternshipReview(ModifyInternshipReviewRequestDTO requ

KindergartenInternshipReview review = kindergartenInternshipReviewRepository
.findById(request.getInternshipReviewId())
.orElseThrow(() -> new NotFoundInternshipReviewException("존재하지 않는 실습 리뷰입니다."));
.orElseThrow(() -> new BusinessException(ErrorCodes.NOT_FOUND_INTERNSHIP_REVIEW));

if (!review.getUser().equals(user)) {
throw new IncorrectUserException("작성자가 일치하지 않습니다.");
throw new BusinessException(ErrorCodes.INCORRECT_USER_EXCEPTION);
}

review.updateReview(request);
Expand All @@ -92,7 +90,7 @@ public void likeInternshipReview(long reviewId, String email) {
User user = userService.getUserByEmail(email);

KindergartenInternshipReview review = kindergartenInternshipReviewRepository.findById(reviewId)
.orElseThrow(() -> new NotFoundInternshipReviewException("존재하지 않는 실습 리뷰입니다."));
.orElseThrow(() -> new BusinessException(ErrorCodes.NOT_FOUND_INTERNSHIP_REVIEW));

Optional<KindergartenInternshipReviewLikeHistory> existingLike = kindergartenInternshipReviewLikeHistoryRepository.findByUserAndInternshipReview(user, review);

Expand All @@ -114,7 +112,7 @@ public void likeInternshipReview(long reviewId, String email) {

public InternshipReviewPagedResponseDTO getReviews(Long kindergartenId, int page, int size, InternshipReviewPagedResponseDTO.SortType sortType, InternshipReviewStarRatingType internshipReviewStarRatingType, int starRating) {
if (internshipReviewStarRatingType != InternshipReviewStarRatingType.ALL && starRating < 1 || starRating > 5) {
throw new IllegalArgumentStarRatingException("starRating은 1부터 5 사이의 값이어야 합니다.");
throw new BusinessException(ErrorCodes.ILLEGAL_ARGUMENT_STAR_RATING_EXCEPTION);
}

Pageable pageable;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading