diff --git a/main/src/main/java/org/sopt/makers/crew/main/advertisement/dto/AdvertisementGetDto.java b/main/src/main/java/org/sopt/makers/crew/main/advertisement/dto/AdvertisementGetDto.java deleted file mode 100644 index c4ef6364..00000000 --- a/main/src/main/java/org/sopt/makers/crew/main/advertisement/dto/AdvertisementGetDto.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.sopt.makers.crew.main.advertisement.dto; - -import java.time.LocalDateTime; - -import org.sopt.makers.crew.main.entity.advertisement.Advertisement; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@RequiredArgsConstructor -@Getter -@Schema(name = "AdvertisementImageDto", description = "광고 구좌 이미지 Dto") -public class AdvertisementGetDto { - - @Schema(description = "광고 id", example = "3") - @NotNull - private final Integer advertisementId; - - @Schema(description = "[Desktop] 광고 구좌 이미지 url", example = "[pc 버전 url 형식]") - @NotNull - private final String desktopImageUrl; - - @Schema(description = "[mobile] 광고 구좌 이미지 url", example = "[mobile 버전 url 형식]") - @NotNull - private final String mobileImageUrl; - - @Schema(description = "광고 구좌 링크", example = "https://www.naver.com") - @NotNull - private final String advertisementLink; - - @Schema(description = "광고 게시 시작일", example = "2024-07-31T00:00:00") - @NotNull - private final LocalDateTime advertisementStartDate; - - public static AdvertisementGetDto of(Advertisement advertisement) { - return new AdvertisementGetDto(advertisement.getId(), advertisement.getAdvertisementDesktopImageUrl(), - advertisement.getAdvertisementMobileImageUrl(), advertisement.getAdvertisementLink(), - advertisement.getAdvertisementStartDate()); - } -} diff --git a/main/src/main/java/org/sopt/makers/crew/main/advertisement/dto/AdvertisementsGetResponseDto.java b/main/src/main/java/org/sopt/makers/crew/main/advertisement/dto/AdvertisementsGetResponseDto.java index aa2e79ff..1c37d4d0 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/advertisement/dto/AdvertisementsGetResponseDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/advertisement/dto/AdvertisementsGetResponseDto.java @@ -1,18 +1,54 @@ package org.sopt.makers.crew.main.advertisement.dto; +import java.time.LocalDateTime; import java.util.List; +import org.sopt.makers.crew.main.entity.advertisement.Advertisement; + import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; -@Schema(name = "AdvertisementGetResponseDto", description = "광고 구좌 조회 응답 Dto") +@Schema(name = "AdvertisementsGetResponseDto", description = "광고 구좌 조회 응답 Dto") public record AdvertisementsGetResponseDto( - @Schema(description = "광고 구좌 이미지 객체", example = "") + @Schema(description = "광고 구좌 이미지 리스트", example = "") @NotNull List advertisements ) { - public static AdvertisementsGetResponseDto of(List advertisements) { + @Schema(name = "AdvertisementGetDto", description = "광고 구좌 이미지 Dto") + public record AdvertisementGetDto( + + @Schema(description = "광고 id", example = "3") + @NotNull + Integer advertisementId, + + @Schema(description = "[Desktop] 광고 구좌 이미지 url", example = "[pc 버전 url 형식]") + @NotNull + String desktopImageUrl, + + @Schema(description = "[mobile] 광고 구좌 이미지 url", example = "[mobile 버전 url 형식]") + @NotNull + String mobileImageUrl, + @Schema(description = "광고 구좌 링크", example = "https://www.naver.com") + @NotNull + String advertisementLink, + + @Schema(description = "광고 게시 시작일", example = "2024-07-31T00:00:00") + @NotNull + LocalDateTime advertisementStartDate + ) { + public static AdvertisementGetDto of(Advertisement advertisement) { + return new AdvertisementGetDto( + advertisement.getId(), + advertisement.getAdvertisementDesktopImageUrl(), + advertisement.getAdvertisementMobileImageUrl(), + advertisement.getAdvertisementLink(), + advertisement.getAdvertisementStartDate() + ); + } + } + + public static AdvertisementsGetResponseDto of(List advertisements) { return new AdvertisementsGetResponseDto(advertisements); } -} +} \ No newline at end of file diff --git a/main/src/main/java/org/sopt/makers/crew/main/advertisement/service/AdvertisementService.java b/main/src/main/java/org/sopt/makers/crew/main/advertisement/service/AdvertisementService.java index 53f6e198..85234460 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/advertisement/service/AdvertisementService.java +++ b/main/src/main/java/org/sopt/makers/crew/main/advertisement/service/AdvertisementService.java @@ -1,13 +1,16 @@ package org.sopt.makers.crew.main.advertisement.service; +import java.time.LocalDateTime; import java.util.List; import org.sopt.makers.crew.main.advertisement.dto.AdvertisementsGetResponseDto; -import org.sopt.makers.crew.main.advertisement.dto.AdvertisementGetDto; -import org.sopt.makers.crew.main.common.util.Time; +import org.sopt.makers.crew.main.advertisement.dto.AdvertisementsGetResponseDto.AdvertisementGetDto; +import org.sopt.makers.crew.main.global.util.Time; import org.sopt.makers.crew.main.entity.advertisement.Advertisement; import org.sopt.makers.crew.main.entity.advertisement.AdvertisementRepository; import org.sopt.makers.crew.main.entity.advertisement.enums.AdvertisementCategory; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -17,21 +20,38 @@ @RequiredArgsConstructor @Transactional(readOnly = true) public class AdvertisementService { - private final AdvertisementRepository advertisementRepository; + private final AdvertisementRepository advertisementRepository; private final Time time; public AdvertisementsGetResponseDto getAdvertisement(AdvertisementCategory advertisementCategory) { - List advertisements = advertisementRepository.findTop6ByAdvertisementCategoryAndAdvertisementEndDateAfterAndAdvertisementStartDateBeforeOrderByPriority( - advertisementCategory, time.now(), time.now()); + LocalDateTime now = time.now(); + + int maxItems = advertisementCategory.getMaxItems(); + Pageable pageable = PageRequest.of(0, maxItems); + + List advertisements = advertisementRepository.findAdvertisementsByDateAndType( + advertisementCategory, + true, + now, + pageable); - if (advertisements.isEmpty()) { - return AdvertisementsGetResponseDto.of(null); + if (!advertisements.isEmpty()) { + return createResponseDto(advertisements); } - List advertisementDtos = advertisements.stream().map(AdvertisementGetDto::of) - .toList(); + advertisements = advertisementRepository.findAdvertisementsByCategory( + advertisementCategory, + false, + pageable); + + return createResponseDto(advertisements); + } + private AdvertisementsGetResponseDto createResponseDto(List advertisements) { + List advertisementDtos = advertisements.stream() + .map(AdvertisementGetDto::of) + .toList(); return AdvertisementsGetResponseDto.of(advertisementDtos); } -} +} \ No newline at end of file diff --git a/main/src/main/java/org/sopt/makers/crew/main/auth/v2/service/AuthV2ServiceImpl.java b/main/src/main/java/org/sopt/makers/crew/main/auth/v2/service/AuthV2ServiceImpl.java index bedba902..e3c27d8a 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/auth/v2/service/AuthV2ServiceImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/auth/v2/service/AuthV2ServiceImpl.java @@ -4,7 +4,7 @@ import org.sopt.makers.crew.main.auth.v2.dto.request.AuthV2RequestDto; import org.sopt.makers.crew.main.auth.v2.dto.response.AuthV2ResponseDto; -import org.sopt.makers.crew.main.common.jwt.JwtTokenProvider; +import org.sopt.makers.crew.main.global.jwt.JwtTokenProvider; import org.sopt.makers.crew.main.entity.user.User; import org.sopt.makers.crew.main.entity.user.UserRepository; import org.sopt.makers.crew.main.external.playground.PlaygroundService; diff --git a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/CommentV2Api.java b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/CommentV2Api.java index 485fbe2f..bbab99a1 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/CommentV2Api.java +++ b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/CommentV2Api.java @@ -21,7 +21,6 @@ import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2ReportCommentResponseDto; import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2SwitchCommentLikeResponseDto; import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2UpdateCommentResponseDto; -import org.sopt.makers.crew.main.common.dto.TempResponseDto; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ModelAttribute; diff --git a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/CommentV2Controller.java b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/CommentV2Controller.java index fd0220ce..4ca017c3 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/CommentV2Controller.java +++ b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/CommentV2Controller.java @@ -1,7 +1,6 @@ package org.sopt.makers.crew.main.comment.v2; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import java.security.Principal; @@ -18,8 +17,7 @@ import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2SwitchCommentLikeResponseDto; import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2UpdateCommentResponseDto; import org.sopt.makers.crew.main.comment.v2.service.CommentV2Service; -import org.sopt.makers.crew.main.common.dto.TempResponseDto; -import org.sopt.makers.crew.main.common.util.UserUtil; +import org.sopt.makers.crew.main.global.util.UserUtil; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; diff --git a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/dto/query/CommentV2GetCommentsQueryDto.java b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/dto/query/CommentV2GetCommentsQueryDto.java index 54a63d6a..9f65b138 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/dto/query/CommentV2GetCommentsQueryDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/dto/query/CommentV2GetCommentsQueryDto.java @@ -1,6 +1,6 @@ package org.sopt.makers.crew.main.comment.v2.dto.query; -import org.sopt.makers.crew.main.common.pagination.dto.PageOptionsDto; +import org.sopt.makers.crew.main.global.pagination.dto.PageOptionsDto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; diff --git a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/dto/response/CommentV2GetCommentsResponseDto.java b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/dto/response/CommentV2GetCommentsResponseDto.java index 945ac676..9cd4da97 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/dto/response/CommentV2GetCommentsResponseDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/dto/response/CommentV2GetCommentsResponseDto.java @@ -2,7 +2,7 @@ import java.util.List; -import org.sopt.makers.crew.main.common.pagination.dto.PageMetaDto; +import org.sopt.makers.crew.main.global.pagination.dto.PageMetaDto; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2Service.java b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2Service.java index 3a917969..1a9254f8 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2Service.java +++ b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2Service.java @@ -7,7 +7,7 @@ import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2ReportCommentResponseDto; import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2SwitchCommentLikeResponseDto; import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2UpdateCommentResponseDto; -import org.sopt.makers.crew.main.common.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.BadRequestException; public interface CommentV2Service { diff --git a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceImpl.java b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceImpl.java index 00fccbac..9d5478b4 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceImpl.java @@ -22,13 +22,13 @@ import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2SwitchCommentLikeResponseDto; import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2UpdateCommentResponseDto; import org.sopt.makers.crew.main.comment.v2.dto.response.ReplyDto; -import org.sopt.makers.crew.main.common.exception.BadRequestException; -import org.sopt.makers.crew.main.common.exception.ErrorStatus; -import org.sopt.makers.crew.main.common.exception.ForbiddenException; -import org.sopt.makers.crew.main.common.pagination.dto.PageMetaDto; -import org.sopt.makers.crew.main.common.pagination.dto.PageOptionsDto; -import org.sopt.makers.crew.main.common.util.MentionSecretStringRemover; -import org.sopt.makers.crew.main.common.util.Time; +import org.sopt.makers.crew.main.global.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.ErrorStatus; +import org.sopt.makers.crew.main.global.exception.ForbiddenException; +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.MentionSecretStringRemover; +import org.sopt.makers.crew.main.global.util.Time; 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.comment.Comments; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/Advertisement.java b/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/Advertisement.java index 3f5183a6..00d9d312 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/Advertisement.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/Advertisement.java @@ -5,6 +5,7 @@ import java.time.LocalDateTime; import org.sopt.makers.crew.main.entity.advertisement.enums.AdvertisementCategory; +import org.sopt.makers.crew.main.entity.common.BaseTimeEntity; import org.springframework.data.jpa.domain.support.AuditingEntityListener; import jakarta.persistence.Entity; @@ -23,9 +24,8 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -@EntityListeners(AuditingEntityListener.class) @Table(name = "advertisement") -public class Advertisement { +public class Advertisement extends BaseTimeEntity { /** * Primary Key */ @@ -55,10 +55,14 @@ public class Advertisement { @NotNull private LocalDateTime advertisementEndDate; + @NotNull + private boolean isSponsoredContent; + @Builder - private Advertisement(String advertisementDesktopImageUrl, String advertisementMobileImageUrl, String advertisementLink, + private Advertisement(String advertisementDesktopImageUrl, String advertisementMobileImageUrl, + String advertisementLink, AdvertisementCategory advertisementCategory, Long priority, LocalDateTime advertisementStartDate, - LocalDateTime advertisementEndDate) { + LocalDateTime advertisementEndDate, boolean isSponsoredContent) { this.advertisementDesktopImageUrl = advertisementDesktopImageUrl; this.advertisementMobileImageUrl = advertisementMobileImageUrl; this.advertisementLink = advertisementLink; @@ -66,5 +70,6 @@ private Advertisement(String advertisementDesktopImageUrl, String advertisementM this.priority = priority; this.advertisementStartDate = advertisementStartDate; this.advertisementEndDate = advertisementEndDate; + this.isSponsoredContent = isSponsoredContent; } -} +} \ No newline at end of file diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/AdvertisementRepository.java b/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/AdvertisementRepository.java index 2d907735..ee1dc347 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/AdvertisementRepository.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/AdvertisementRepository.java @@ -4,9 +4,31 @@ import java.util.List; import org.sopt.makers.crew.main.entity.advertisement.enums.AdvertisementCategory; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; public interface AdvertisementRepository extends JpaRepository { - List findTop6ByAdvertisementCategoryAndAdvertisementEndDateAfterAndAdvertisementStartDateBeforeOrderByPriority( - AdvertisementCategory advertisementCategory, LocalDateTime now1, LocalDateTime now2); -} + + @Query("SELECT a FROM Advertisement a " + + "WHERE a.isSponsoredContent = :isSponsored " + + "AND a.advertisementCategory = :category " + + "AND a.advertisementStartDate <= :now " + + "AND a.advertisementEndDate >= :now " + + "ORDER BY a.priority ASC") + List findAdvertisementsByDateAndType( + @Param("category") AdvertisementCategory category, + @Param("isSponsored") boolean isSponsored, + @Param("now") LocalDateTime now, + Pageable pageable); + + @Query("SELECT a FROM Advertisement a " + + "WHERE a.isSponsoredContent = :isSponsored " + + "AND a.advertisementCategory = :category " + + "ORDER BY a.priority ASC") + List findAdvertisementsByCategory( + @Param("category") AdvertisementCategory category, + @Param("isSponsored") boolean isSponsored, + Pageable pageable); +} \ No newline at end of file diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/enums/AdvertisementCategory.java b/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/enums/AdvertisementCategory.java index 5ae13ded..a79db50b 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/enums/AdvertisementCategory.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/advertisement/enums/AdvertisementCategory.java @@ -1,5 +1,13 @@ package org.sopt.makers.crew.main.entity.advertisement.enums; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter public enum AdvertisementCategory { - POST, MEETING + POST(6), + MEETING(1); + + private final int maxItems; } diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/apply/Apply.java b/main/src/main/java/org/sopt/makers/crew/main/entity/apply/Apply.java index 706ef03a..d0467851 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/apply/Apply.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/apply/Apply.java @@ -1,7 +1,7 @@ package org.sopt.makers.crew.main.entity.apply; import static jakarta.persistence.GenerationType.IDENTITY; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.*; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import jakarta.persistence.Column; import jakarta.persistence.Convert; @@ -21,7 +21,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import org.sopt.makers.crew.main.common.exception.BadRequestException; +import org.sopt.makers.crew.main.entity.common.BaseTimeEntity; +import org.sopt.makers.crew.main.global.exception.BadRequestException; import org.sopt.makers.crew.main.entity.apply.enums.ApplyStatusConverter; import org.sopt.makers.crew.main.entity.apply.enums.ApplyTypeConverter; import org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus; @@ -34,9 +35,8 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -@EntityListeners(AuditingEntityListener.class) @Table(name = "apply") -public class Apply { +public class Apply extends BaseTimeEntity { /** * Primary Key diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/apply/ApplyRepository.java b/main/src/main/java/org/sopt/makers/crew/main/entity/apply/ApplyRepository.java index f9caa7d1..a480a5bd 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/apply/ApplyRepository.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/apply/ApplyRepository.java @@ -1,10 +1,10 @@ package org.sopt.makers.crew.main.entity.apply; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.NOT_FOUND_APPLY; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.NOT_FOUND_APPLY; import java.util.List; -import java.util.Optional; -import org.sopt.makers.crew.main.common.exception.BadRequestException; + +import org.sopt.makers.crew.main.global.exception.BadRequestException; import org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/apply/ApplySearchRepositoryImpl.java b/main/src/main/java/org/sopt/makers/crew/main/entity/apply/ApplySearchRepositoryImpl.java index ea0303de..c40d6621 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/apply/ApplySearchRepositoryImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/apply/ApplySearchRepositoryImpl.java @@ -1,6 +1,6 @@ package org.sopt.makers.crew.main.entity.apply; -import static org.sopt.makers.crew.main.common.constant.CrewConst.*; +import static org.sopt.makers.crew.main.global.constant.CrewConst.*; import static org.sopt.makers.crew.main.entity.apply.QApply.apply; import static org.sopt.makers.crew.main.entity.user.QUser.user; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/apply/enums/EnApplyStatus.java b/main/src/main/java/org/sopt/makers/crew/main/entity/apply/enums/EnApplyStatus.java index 804aa500..6cf1ee48 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/apply/enums/EnApplyStatus.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/apply/enums/EnApplyStatus.java @@ -1,7 +1,7 @@ package org.sopt.makers.crew.main.entity.apply.enums; import java.util.Arrays; -import org.sopt.makers.crew.main.common.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.BadRequestException; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/apply/enums/EnApplyType.java b/main/src/main/java/org/sopt/makers/crew/main/entity/apply/enums/EnApplyType.java index 9e1c0b37..4e810074 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/apply/enums/EnApplyType.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/apply/enums/EnApplyType.java @@ -1,9 +1,7 @@ package org.sopt.makers.crew.main.entity.apply.enums; import java.util.Arrays; -import org.sopt.makers.crew.main.common.exception.BadRequestException; -import org.sopt.makers.crew.main.common.exception.BaseException; -import org.springframework.http.HttpStatus; +import org.sopt.makers.crew.main.global.exception.BadRequestException; /** 지원 구분 */ public enum EnApplyType { diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/comment/Comment.java b/main/src/main/java/org/sopt/makers/crew/main/entity/comment/Comment.java index 039c006b..55d2c618 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/comment/Comment.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/comment/Comment.java @@ -1,6 +1,6 @@ package org.sopt.makers.crew.main.entity.comment; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.*; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -21,7 +21,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import org.sopt.makers.crew.main.common.exception.ForbiddenException; +import org.sopt.makers.crew.main.entity.common.BaseTimeEntity; +import org.sopt.makers.crew.main.global.exception.ForbiddenException; import org.sopt.makers.crew.main.entity.post.Post; import org.sopt.makers.crew.main.entity.user.User; import org.springframework.data.annotation.CreatedDate; @@ -33,7 +34,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @EntityListeners({AuditingEntityListener.class, Comment.CommentListener.class}) @Table(name = "comment") -public class Comment { +public class Comment extends BaseTimeEntity { private static final int PARENT_COMMENT = 0; private static final String DELETE_COMMENT_CONTENT = "삭제된 댓글입니다."; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/comment/CommentRepository.java b/main/src/main/java/org/sopt/makers/crew/main/entity/comment/CommentRepository.java index 6123a033..51583fc4 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/comment/CommentRepository.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/comment/CommentRepository.java @@ -3,8 +3,8 @@ import java.util.List; import java.util.Optional; -import org.sopt.makers.crew.main.common.exception.BadRequestException; -import org.sopt.makers.crew.main.common.exception.ErrorStatus; +import org.sopt.makers.crew.main.global.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.ErrorStatus; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/comment/Comments.java b/main/src/main/java/org/sopt/makers/crew/main/entity/comment/Comments.java index bb5b91b0..7bc98521 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/comment/Comments.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/comment/Comments.java @@ -2,7 +2,7 @@ import java.util.List; -import org.sopt.makers.crew.main.common.util.MentionSecretStringRemover; +import org.sopt.makers.crew.main.global.util.MentionSecretStringRemover; import lombok.RequiredArgsConstructor; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/common/BaseTimeEntity.java b/main/src/main/java/org/sopt/makers/crew/main/entity/common/BaseTimeEntity.java new file mode 100644 index 00000000..5e1d34db --- /dev/null +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/common/BaseTimeEntity.java @@ -0,0 +1,25 @@ +package org.sopt.makers.crew.main.entity.common; + +import java.time.LocalDateTime; + +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; + +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public abstract class BaseTimeEntity { + + @CreatedDate + @Column(name = "createdTimestamp") + public LocalDateTime createdTimestamp; + + @LastModifiedDate + @Column(name = "modifiedTimestamp") + public LocalDateTime modifiedTimestamp; + +} diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/like/Like.java b/main/src/main/java/org/sopt/makers/crew/main/entity/like/Like.java index 019b0c99..a8e99d42 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/like/Like.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/like/Like.java @@ -15,6 +15,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import org.sopt.makers.crew.main.entity.common.BaseTimeEntity; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -22,8 +23,7 @@ @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "like") -@EntityListeners(AuditingEntityListener.class) -public class Like { +public class Like extends BaseTimeEntity { /** * Primary key diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/Meeting.java b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/Meeting.java index fead16d4..8d815dda 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/Meeting.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/Meeting.java @@ -1,6 +1,6 @@ package org.sopt.makers.crew.main.entity.meeting; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.*; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import io.hypersistence.utils.hibernate.type.array.EnumArrayType; import io.hypersistence.utils.hibernate.type.array.internal.AbstractArrayType; @@ -27,8 +27,9 @@ import org.hibernate.annotations.Parameter; import org.hibernate.annotations.Type; -import org.sopt.makers.crew.main.common.exception.BadRequestException; -import org.sopt.makers.crew.main.common.exception.ForbiddenException; +import org.sopt.makers.crew.main.entity.common.BaseTimeEntity; +import org.sopt.makers.crew.main.global.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.ForbiddenException; import org.sopt.makers.crew.main.entity.meeting.converter.MeetingCategoryConverter; import org.sopt.makers.crew.main.entity.meeting.enums.EnMeetingStatus; import org.sopt.makers.crew.main.entity.meeting.enums.MeetingCategory; @@ -40,9 +41,8 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -@EntityListeners(AuditingEntityListener.class) @Table(name = "meeting") -public class Meeting { +public class Meeting extends BaseTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -126,15 +126,9 @@ public class Meeting { /** * 개설자 소개 */ - @Column(name = "leaderDesc", nullable = false) + @Column(name = "leaderDesc") private String leaderDesc; - /** - * 모집 대상 - */ - @Column(name = "targetDesc", nullable = false) - private String targetDesc; - /** * 유의 사항 */ @@ -194,7 +188,6 @@ public Meeting(User user, Integer userId, String title, MeetingCategory category this.mStartDate = mStartDate; this.mEndDate = mEndDate; this.leaderDesc = leaderDesc; - this.targetDesc = targetDesc; this.note = note; this.isMentorNeeded = isMentorNeeded; this.canJoinOnlyActiveGeneration = canJoinOnlyActiveGeneration; @@ -248,7 +241,6 @@ public void updateMeeting(Meeting updateMeeting) { this.mStartDate = updateMeeting.mStartDate; this.mEndDate = updateMeeting.getMEndDate(); this.leaderDesc = updateMeeting.getLeaderDesc(); - this.targetDesc = updateMeeting.getTargetDesc(); this.note = updateMeeting.getNote(); this.isMentorNeeded = updateMeeting.getIsMentorNeeded(); this.canJoinOnlyActiveGeneration = updateMeeting.getCanJoinOnlyActiveGeneration(); diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingRepository.java b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingRepository.java index e8a70abe..6e1fe392 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingRepository.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingRepository.java @@ -1,10 +1,10 @@ package org.sopt.makers.crew.main.entity.meeting; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.NOT_FOUND_MEETING; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.NOT_FOUND_MEETING; import java.util.List; -import org.sopt.makers.crew.main.common.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.BadRequestException; import org.sopt.makers.crew.main.entity.user.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingSearchRepository.java b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingSearchRepository.java index 37757b15..c1d506ef 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingSearchRepository.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingSearchRepository.java @@ -1,6 +1,6 @@ package org.sopt.makers.crew.main.entity.meeting; -import org.sopt.makers.crew.main.common.util.Time; +import org.sopt.makers.crew.main.global.util.Time; import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingV2GetAllMeetingQueryDto; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingSearchRepositoryImpl.java b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingSearchRepositoryImpl.java index ca888976..ed83c9bc 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingSearchRepositoryImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/MeetingSearchRepositoryImpl.java @@ -8,8 +8,8 @@ import java.util.List; import java.util.stream.Collectors; -import org.sopt.makers.crew.main.common.constant.CrewConst; -import org.sopt.makers.crew.main.common.util.Time; +import org.sopt.makers.crew.main.global.constant.CrewConst; +import org.sopt.makers.crew.main.global.util.Time; import org.sopt.makers.crew.main.entity.meeting.enums.EnMeetingStatus; import org.sopt.makers.crew.main.entity.meeting.enums.MeetingCategory; import org.sopt.makers.crew.main.entity.meeting.enums.MeetingJoinablePart; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/enums/EnMeetingStatus.java b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/enums/EnMeetingStatus.java index 45af6a98..1eea7870 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/enums/EnMeetingStatus.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/enums/EnMeetingStatus.java @@ -1,7 +1,7 @@ package org.sopt.makers.crew.main.entity.meeting.enums; import java.util.Arrays; -import org.sopt.makers.crew.main.common.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.BadRequestException; /** 모임 상태 */ public enum EnMeetingStatus { diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/enums/MeetingCategory.java b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/enums/MeetingCategory.java index ab6d6a53..c81c8f65 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/enums/MeetingCategory.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/meeting/enums/MeetingCategory.java @@ -1,7 +1,7 @@ package org.sopt.makers.crew.main.entity.meeting.enums; import java.util.Arrays; -import org.sopt.makers.crew.main.common.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.BadRequestException; public enum MeetingCategory { STUDY("스터디"), diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/notice/Notice.java b/main/src/main/java/org/sopt/makers/crew/main/entity/notice/Notice.java index 43f7b61a..53b92b29 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/notice/Notice.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/notice/Notice.java @@ -12,15 +12,16 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; + +import org.sopt.makers.crew.main.entity.common.BaseTimeEntity; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -@EntityListeners(AuditingEntityListener.class) @Table(name = "notice") -public class Notice { +public class Notice extends BaseTimeEntity { /** * primary key */ diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/post/Post.java b/main/src/main/java/org/sopt/makers/crew/main/entity/post/Post.java index aa8cf1dc..88e2befd 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/post/Post.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/post/Post.java @@ -1,6 +1,6 @@ package org.sopt.makers.crew.main.entity.post; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.FORBIDDEN_EXCEPTION; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.FORBIDDEN_EXCEPTION; import io.hypersistence.utils.hibernate.type.array.StringArrayType; import jakarta.persistence.Column; @@ -22,7 +22,8 @@ import lombok.NoArgsConstructor; import org.hibernate.annotations.Type; -import org.sopt.makers.crew.main.common.exception.ForbiddenException; +import org.sopt.makers.crew.main.entity.common.BaseTimeEntity; +import org.sopt.makers.crew.main.global.exception.ForbiddenException; import org.sopt.makers.crew.main.entity.meeting.Meeting; import org.sopt.makers.crew.main.entity.user.User; import org.springframework.data.annotation.CreatedDate; @@ -32,9 +33,8 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -@EntityListeners(AuditingEntityListener.class) @Table(name = "post") -public class Post { +public class Post extends BaseTimeEntity { /** * 게시글의 고유 식별자 diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/post/PostRepository.java b/main/src/main/java/org/sopt/makers/crew/main/entity/post/PostRepository.java index 71b37fc4..42501463 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/post/PostRepository.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/post/PostRepository.java @@ -1,11 +1,10 @@ package org.sopt.makers.crew.main.entity.post; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.NOT_FOUND_POST; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.NOT_FOUND_POST; import java.util.List; -import java.util.Optional; -import org.sopt.makers.crew.main.common.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.BadRequestException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/post/PostSearchRepositoryImpl.java b/main/src/main/java/org/sopt/makers/crew/main/entity/post/PostSearchRepositoryImpl.java index 63579a49..bb4a2b13 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/post/PostSearchRepositoryImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/post/PostSearchRepositoryImpl.java @@ -1,6 +1,6 @@ package org.sopt.makers.crew.main.entity.post; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.*; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import static org.sopt.makers.crew.main.entity.comment.QComment.*; import static org.sopt.makers.crew.main.entity.like.QLike.*; import static org.sopt.makers.crew.main.entity.meeting.QMeeting.*; @@ -13,7 +13,7 @@ import java.util.Map; import java.util.stream.Collectors; -import org.sopt.makers.crew.main.common.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.BadRequestException; import org.sopt.makers.crew.main.post.v2.dto.query.PostGetPostsCommand; import org.sopt.makers.crew.main.post.v2.dto.response.CommenterThumbnails; import org.sopt.makers.crew.main.post.v2.dto.response.PostDetailBaseDto; diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/report/Report.java b/main/src/main/java/org/sopt/makers/crew/main/entity/report/Report.java index f722a0db..5c9d588a 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/report/Report.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/report/Report.java @@ -19,6 +19,7 @@ import lombok.NoArgsConstructor; import org.sopt.makers.crew.main.entity.comment.Comment; +import org.sopt.makers.crew.main.entity.common.BaseTimeEntity; import org.sopt.makers.crew.main.entity.post.Post; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -27,8 +28,7 @@ @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "report") -@EntityListeners(AuditingEntityListener.class) -public class Report { +public class Report extends BaseTimeEntity { /** * Primary key */ diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/user/User.java b/main/src/main/java/org/sopt/makers/crew/main/entity/user/User.java index edb0bb6f..216c391b 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/user/User.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/user/User.java @@ -1,6 +1,6 @@ package org.sopt.makers.crew.main.entity.user; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.*; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import io.hypersistence.utils.hibernate.type.json.JsonBinaryType; import jakarta.persistence.Column; @@ -16,14 +16,15 @@ import lombok.Getter; import lombok.NoArgsConstructor; import org.hibernate.annotations.Type; -import org.sopt.makers.crew.main.common.exception.ServerException; +import org.sopt.makers.crew.main.entity.common.BaseTimeEntity; +import org.sopt.makers.crew.main.global.exception.ServerException; import org.sopt.makers.crew.main.entity.user.vo.UserActivityVO; @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "user") -public class User { +public class User extends BaseTimeEntity { /** * Primary Key diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/user/UserRepository.java b/main/src/main/java/org/sopt/makers/crew/main/entity/user/UserRepository.java index 1531436c..34123452 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/user/UserRepository.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/user/UserRepository.java @@ -1,10 +1,10 @@ package org.sopt.makers.crew.main.entity.user; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.*; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import java.util.Optional; -import org.sopt.makers.crew.main.common.exception.UnAuthorizedException; +import org.sopt.makers.crew.main.global.exception.UnAuthorizedException; import org.springframework.data.jpa.repository.JpaRepository; public interface UserRepository extends JpaRepository { diff --git a/main/src/main/java/org/sopt/makers/crew/main/entity/user/enums/UserPart.java b/main/src/main/java/org/sopt/makers/crew/main/entity/user/enums/UserPart.java index 7afb2bbe..54ef300f 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/entity/user/enums/UserPart.java +++ b/main/src/main/java/org/sopt/makers/crew/main/entity/user/enums/UserPart.java @@ -2,7 +2,7 @@ import java.util.Arrays; import lombok.extern.slf4j.Slf4j; -import org.sopt.makers.crew.main.common.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.BadRequestException; @Slf4j public enum UserPart { diff --git a/main/src/main/java/org/sopt/makers/crew/main/external/s3/service/S3Service.java b/main/src/main/java/org/sopt/makers/crew/main/external/s3/service/S3Service.java index 762a3604..3268af68 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/external/s3/service/S3Service.java +++ b/main/src/main/java/org/sopt/makers/crew/main/external/s3/service/S3Service.java @@ -1,6 +1,6 @@ package org.sopt.makers.crew.main.external.s3.service; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.*; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import java.io.File; import java.nio.charset.StandardCharsets; @@ -20,7 +20,7 @@ import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; -import org.sopt.makers.crew.main.common.exception.ServerException; +import org.sopt.makers.crew.main.global.exception.ServerException; import org.sopt.makers.crew.main.external.s3.config.AwsProperties; import org.sopt.makers.crew.main.meeting.v2.dto.response.PreSignedUrlFieldResponseDto; import org.sopt.makers.crew.main.meeting.v2.dto.response.PreSignedUrlResponseDto; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/advice/ControllerExceptionAdvice.java b/main/src/main/java/org/sopt/makers/crew/main/global/advice/ControllerExceptionAdvice.java similarity index 95% rename from main/src/main/java/org/sopt/makers/crew/main/common/advice/ControllerExceptionAdvice.java rename to main/src/main/java/org/sopt/makers/crew/main/global/advice/ControllerExceptionAdvice.java index 0afc8a6b..5b361319 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/advice/ControllerExceptionAdvice.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/advice/ControllerExceptionAdvice.java @@ -1,8 +1,8 @@ -package org.sopt.makers.crew.main.common.advice; +package org.sopt.makers.crew.main.global.advice; -import org.sopt.makers.crew.main.common.exception.BaseException; -import org.sopt.makers.crew.main.common.exception.ExceptionResponse; -import org.sopt.makers.crew.main.common.exception.ErrorStatus; +import org.sopt.makers.crew.main.global.exception.BaseException; +import org.sopt.makers.crew.main.global.exception.ExceptionResponse; +import org.sopt.makers.crew.main.global.exception.ErrorStatus; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/aop/ExecutionLoggingAop.java b/main/src/main/java/org/sopt/makers/crew/main/global/aop/ExecutionLoggingAop.java similarity index 95% rename from main/src/main/java/org/sopt/makers/crew/main/common/aop/ExecutionLoggingAop.java rename to main/src/main/java/org/sopt/makers/crew/main/global/aop/ExecutionLoggingAop.java index 189684ac..c3f50f6d 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/aop/ExecutionLoggingAop.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/aop/ExecutionLoggingAop.java @@ -1,13 +1,12 @@ -package org.sopt.makers.crew.main.common.aop; +package org.sopt.makers.crew.main.global.aop; import jakarta.servlet.http.HttpServletRequest; -import java.security.Principal; + import java.util.Objects; import lombok.extern.log4j.Log4j2; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; -import org.sopt.makers.crew.main.common.util.UserUtil; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/config/CamelCaseNamingStrategy.java b/main/src/main/java/org/sopt/makers/crew/main/global/config/CamelCaseNamingStrategy.java similarity index 96% rename from main/src/main/java/org/sopt/makers/crew/main/common/config/CamelCaseNamingStrategy.java rename to main/src/main/java/org/sopt/makers/crew/main/global/config/CamelCaseNamingStrategy.java index 99684108..0dfee755 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/config/CamelCaseNamingStrategy.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/config/CamelCaseNamingStrategy.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.config; +package org.sopt.makers.crew.main.global.config; import org.hibernate.boot.model.naming.Identifier; import org.hibernate.boot.model.naming.PhysicalNamingStrategy; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/config/CrewDatabaseConfig.java b/main/src/main/java/org/sopt/makers/crew/main/global/config/CrewDatabaseConfig.java similarity index 86% rename from main/src/main/java/org/sopt/makers/crew/main/common/config/CrewDatabaseConfig.java rename to main/src/main/java/org/sopt/makers/crew/main/global/config/CrewDatabaseConfig.java index fbfb0886..a2cb32a4 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/config/CrewDatabaseConfig.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/config/CrewDatabaseConfig.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.config; +package org.sopt.makers.crew.main.global.config; import java.util.Arrays; import java.util.HashMap; @@ -60,10 +60,17 @@ public LocalContainerEntityManagerFactoryBean primaryEntityManagerFactory() { Map properties = new HashMap<>(); properties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect"); properties.put("hibernate.format_sql", true); - properties.put("hibernate.physical_naming_strategy", "org.sopt.makers.crew.main.common.config.CamelCaseNamingStrategy"); + properties.put("hibernate.physical_naming_strategy", + "org.sopt.makers.crew.main.global.config.CamelCaseNamingStrategy"); + + /** + * local, dev, prod 환경은 validate 로 한다. + * test 환경일 경우, none(기본값) 으로 한다. schema.sql 을 사용하여 테이블을 생성한다. (하단 코드 참고) + */ String[] activeProfiles = {"local", "dev", "prod"}; - if (Arrays.stream(activeProfiles).anyMatch(profile -> profile.equals(System.getProperty("spring.profiles.active")))) { + if (Arrays.stream(activeProfiles) + .anyMatch(profile -> profile.equals(System.getProperty("spring.profiles.active")))) { properties.put("hibernate.hbm2ddl.auto", "validate"); } em.setJpaPropertyMap(properties); @@ -91,14 +98,14 @@ public CommandLineRunner init(@Qualifier("primaryEntityManagerFactory") EntityMa return args -> executeSchemaSql(); } - private void executeSchemaSql() { + private void executeSchemaSql() throws Exception { Resource resource = resourceLoader.getResource("classpath:schema.sql"); ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator(); databasePopulator.addScript(resource); try { databasePopulator.populate(primaryDatasourceProperties().getConnection()); } catch (Exception e) { - System.out.println(e); + throw e; } } } diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/config/JpaAuditingConfig.java b/main/src/main/java/org/sopt/makers/crew/main/global/config/JpaAuditingConfig.java similarity index 95% rename from main/src/main/java/org/sopt/makers/crew/main/common/config/JpaAuditingConfig.java rename to main/src/main/java/org/sopt/makers/crew/main/global/config/JpaAuditingConfig.java index b4b92297..d4635393 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/config/JpaAuditingConfig.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/config/JpaAuditingConfig.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.config; +package org.sopt.makers.crew.main.global.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/config/PlaygroundDataSourceConfig.java b/main/src/main/java/org/sopt/makers/crew/main/global/config/PlaygroundDataSourceConfig.java similarity index 84% rename from main/src/main/java/org/sopt/makers/crew/main/common/config/PlaygroundDataSourceConfig.java rename to main/src/main/java/org/sopt/makers/crew/main/global/config/PlaygroundDataSourceConfig.java index 5c4c255f..e97bb513 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/config/PlaygroundDataSourceConfig.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/config/PlaygroundDataSourceConfig.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.config; +package org.sopt.makers.crew.main.global.config; import java.util.Arrays; import java.util.HashMap; @@ -50,10 +50,17 @@ public LocalContainerEntityManagerFactoryBean secondEntityManagerFactory() { Map properties = new HashMap<>(); properties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect"); properties.put("hibernate.format_sql", true); - properties.put("hibernate.physical_naming_strategy", "org.sopt.makers.crew.main.common.config.CamelCaseNamingStrategy"); + properties.put("hibernate.physical_naming_strategy", + "org.sopt.makers.crew.main.global.config.CamelCaseNamingStrategy"); + + /** + * local, dev, prod 환경은 validate 로 한다. + * test 환경일 경우, none(기본값) 으로 한다. schema.sql 을 사용하여 테이블을 생성한다. + */ String[] activeProfiles = {"local", "dev", "prod"}; - if (Arrays.stream(activeProfiles).anyMatch(profile -> profile.equals(System.getProperty("spring.profiles.active")))) { + if (Arrays.stream(activeProfiles) + .anyMatch(profile -> profile.equals(System.getProperty("spring.profiles.active")))) { properties.put("hibernate.hbm2ddl.auto", "validate"); } diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/config/SecurityConfig.java b/main/src/main/java/org/sopt/makers/crew/main/global/config/SecurityConfig.java similarity index 93% rename from main/src/main/java/org/sopt/makers/crew/main/common/config/SecurityConfig.java rename to main/src/main/java/org/sopt/makers/crew/main/global/config/SecurityConfig.java index 5e59ed4c..c4c46c51 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/config/SecurityConfig.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/config/SecurityConfig.java @@ -1,13 +1,13 @@ -package org.sopt.makers.crew.main.common.config; +package org.sopt.makers.crew.main.global.config; import java.util.Arrays; import java.util.stream.Stream; import lombok.RequiredArgsConstructor; -import org.sopt.makers.crew.main.common.jwt.JwtAuthenticationEntryPoint; -import org.sopt.makers.crew.main.common.jwt.JwtAuthenticationFilter; -import org.sopt.makers.crew.main.common.jwt.JwtTokenProvider; +import org.sopt.makers.crew.main.global.jwt.JwtAuthenticationEntryPoint; +import org.sopt.makers.crew.main.global.jwt.JwtAuthenticationFilter; +import org.sopt.makers.crew.main.global.jwt.JwtTokenProvider; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/config/SwaggerConfig.java b/main/src/main/java/org/sopt/makers/crew/main/global/config/SwaggerConfig.java similarity index 96% rename from main/src/main/java/org/sopt/makers/crew/main/common/config/SwaggerConfig.java rename to main/src/main/java/org/sopt/makers/crew/main/global/config/SwaggerConfig.java index 998e7842..8f703608 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/config/SwaggerConfig.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/config/SwaggerConfig.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.config; +package org.sopt.makers.crew.main.global.config; import static io.swagger.v3.oas.models.security.SecurityScheme.Type.HTTP; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/constant/CrewConst.java b/main/src/main/java/org/sopt/makers/crew/main/global/constant/CrewConst.java similarity index 92% rename from main/src/main/java/org/sopt/makers/crew/main/common/constant/CrewConst.java rename to main/src/main/java/org/sopt/makers/crew/main/global/constant/CrewConst.java index 2e8e5cc7..40f40b21 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/constant/CrewConst.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/constant/CrewConst.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.constant; +package org.sopt.makers.crew.main.global.constant; import lombok.AccessLevel; import lombok.NoArgsConstructor; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/dto/MeetingCreatorDto.java b/main/src/main/java/org/sopt/makers/crew/main/global/dto/MeetingCreatorDto.java similarity index 96% rename from main/src/main/java/org/sopt/makers/crew/main/common/dto/MeetingCreatorDto.java rename to main/src/main/java/org/sopt/makers/crew/main/global/dto/MeetingCreatorDto.java index d1fcf8b5..6c93efbf 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/dto/MeetingCreatorDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/dto/MeetingCreatorDto.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.dto; +package org.sopt.makers.crew.main.global.dto; import java.util.List; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/dto/MeetingResponseDto.java b/main/src/main/java/org/sopt/makers/crew/main/global/dto/MeetingResponseDto.java similarity index 97% rename from main/src/main/java/org/sopt/makers/crew/main/common/dto/MeetingResponseDto.java rename to main/src/main/java/org/sopt/makers/crew/main/global/dto/MeetingResponseDto.java index 07036fbd..da189093 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/dto/MeetingResponseDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/dto/MeetingResponseDto.java @@ -1,10 +1,10 @@ -package org.sopt.makers.crew.main.common.dto; +package org.sopt.makers.crew.main.global.dto; import java.time.LocalDateTime; import java.util.List; -import org.sopt.makers.crew.main.common.constant.CrewConst; +import org.sopt.makers.crew.main.global.constant.CrewConst; import org.sopt.makers.crew.main.entity.meeting.Meeting; import org.sopt.makers.crew.main.entity.meeting.enums.MeetingCategory; import org.sopt.makers.crew.main.entity.meeting.enums.MeetingJoinablePart; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/dto/TempResponseDto.java b/main/src/main/java/org/sopt/makers/crew/main/global/dto/TempResponseDto.java similarity index 90% rename from main/src/main/java/org/sopt/makers/crew/main/common/dto/TempResponseDto.java rename to main/src/main/java/org/sopt/makers/crew/main/global/dto/TempResponseDto.java index 7f24aa92..ed34e5bb 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/dto/TempResponseDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/dto/TempResponseDto.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.dto; +package org.sopt.makers.crew.main.global.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/exception/BadRequestException.java b/main/src/main/java/org/sopt/makers/crew/main/global/exception/BadRequestException.java similarity index 85% rename from main/src/main/java/org/sopt/makers/crew/main/common/exception/BadRequestException.java rename to main/src/main/java/org/sopt/makers/crew/main/global/exception/BadRequestException.java index 4897048c..63faf324 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/exception/BadRequestException.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/exception/BadRequestException.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.exception; +package org.sopt.makers.crew.main.global.exception; import org.springframework.http.HttpStatus; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/exception/BaseException.java b/main/src/main/java/org/sopt/makers/crew/main/global/exception/BaseException.java similarity index 92% rename from main/src/main/java/org/sopt/makers/crew/main/common/exception/BaseException.java rename to main/src/main/java/org/sopt/makers/crew/main/global/exception/BaseException.java index a80abf29..01d43610 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/exception/BaseException.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/exception/BaseException.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.exception; +package org.sopt.makers.crew.main.global.exception; import lombok.AccessLevel; import lombok.Getter; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/exception/ErrorStatus.java b/main/src/main/java/org/sopt/makers/crew/main/global/exception/ErrorStatus.java similarity index 97% rename from main/src/main/java/org/sopt/makers/crew/main/common/exception/ErrorStatus.java rename to main/src/main/java/org/sopt/makers/crew/main/global/exception/ErrorStatus.java index a7665cee..47d68653 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/exception/ErrorStatus.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/exception/ErrorStatus.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.exception; +package org.sopt.makers.crew.main.global.exception; import lombok.AccessLevel; import lombok.Getter; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/exception/ExceptionResponse.java b/main/src/main/java/org/sopt/makers/crew/main/global/exception/ExceptionResponse.java similarity index 87% rename from main/src/main/java/org/sopt/makers/crew/main/common/exception/ExceptionResponse.java rename to main/src/main/java/org/sopt/makers/crew/main/global/exception/ExceptionResponse.java index 98968b3c..7e59de9d 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/exception/ExceptionResponse.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/exception/ExceptionResponse.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.exception; +package org.sopt.makers.crew.main.global.exception; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Builder; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/exception/ForbiddenException.java b/main/src/main/java/org/sopt/makers/crew/main/global/exception/ForbiddenException.java similarity index 83% rename from main/src/main/java/org/sopt/makers/crew/main/common/exception/ForbiddenException.java rename to main/src/main/java/org/sopt/makers/crew/main/global/exception/ForbiddenException.java index 8350cdb1..d993806e 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/exception/ForbiddenException.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/exception/ForbiddenException.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.exception; +package org.sopt.makers.crew.main.global.exception; import org.springframework.http.HttpStatus; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/exception/NoContentException.java b/main/src/main/java/org/sopt/makers/crew/main/global/exception/NoContentException.java similarity index 83% rename from main/src/main/java/org/sopt/makers/crew/main/common/exception/NoContentException.java rename to main/src/main/java/org/sopt/makers/crew/main/global/exception/NoContentException.java index 6c204e4c..82f27677 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/exception/NoContentException.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/exception/NoContentException.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.exception; +package org.sopt.makers.crew.main.global.exception; import org.springframework.http.HttpStatus; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/exception/NotFoundException.java b/main/src/main/java/org/sopt/makers/crew/main/global/exception/NotFoundException.java similarity index 84% rename from main/src/main/java/org/sopt/makers/crew/main/common/exception/NotFoundException.java rename to main/src/main/java/org/sopt/makers/crew/main/global/exception/NotFoundException.java index 9d3884a6..0c77d616 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/exception/NotFoundException.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/exception/NotFoundException.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.exception; +package org.sopt.makers.crew.main.global.exception; import org.springframework.http.HttpStatus; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/exception/ServerException.java b/main/src/main/java/org/sopt/makers/crew/main/global/exception/ServerException.java similarity index 85% rename from main/src/main/java/org/sopt/makers/crew/main/common/exception/ServerException.java rename to main/src/main/java/org/sopt/makers/crew/main/global/exception/ServerException.java index 2ab8faa2..e1bcf3a1 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/exception/ServerException.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/exception/ServerException.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.exception; +package org.sopt.makers.crew.main.global.exception; import org.springframework.http.HttpStatus; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/exception/UnAuthorizedException.java b/main/src/main/java/org/sopt/makers/crew/main/global/exception/UnAuthorizedException.java similarity index 85% rename from main/src/main/java/org/sopt/makers/crew/main/common/exception/UnAuthorizedException.java rename to main/src/main/java/org/sopt/makers/crew/main/global/exception/UnAuthorizedException.java index d1329240..c3b6a386 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/exception/UnAuthorizedException.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/exception/UnAuthorizedException.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.exception; +package org.sopt.makers.crew.main.global.exception; import org.springframework.http.HttpStatus; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtAuthenticationEntryPoint.java b/main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtAuthenticationEntryPoint.java similarity index 85% rename from main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtAuthenticationEntryPoint.java rename to main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtAuthenticationEntryPoint.java index ec62d7a8..77086924 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtAuthenticationEntryPoint.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtAuthenticationEntryPoint.java @@ -1,13 +1,13 @@ -package org.sopt.makers.crew.main.common.jwt; +package org.sopt.makers.crew.main.global.jwt; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.*; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; -import org.sopt.makers.crew.main.common.exception.ExceptionResponse; +import org.sopt.makers.crew.main.global.exception.ExceptionResponse; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.stereotype.Component; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtAuthenticationFilter.java b/main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtAuthenticationFilter.java similarity index 94% rename from main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtAuthenticationFilter.java rename to main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtAuthenticationFilter.java index 0f1d45a2..33a053ca 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtAuthenticationFilter.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtAuthenticationFilter.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.jwt; +package org.sopt.makers.crew.main.global.jwt; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; @@ -9,7 +9,7 @@ import lombok.RequiredArgsConstructor; -import org.sopt.makers.crew.main.common.exception.ErrorStatus; +import org.sopt.makers.crew.main.global.exception.ErrorStatus; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtExceptionType.java b/main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtExceptionType.java similarity index 88% rename from main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtExceptionType.java rename to main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtExceptionType.java index 3834205a..179016dd 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtExceptionType.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtExceptionType.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.jwt; +package org.sopt.makers.crew.main.global.jwt; public enum JwtExceptionType { VALID_JWT_TOKEN, // 유효한 JWT diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtTokenProvider.java b/main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtTokenProvider.java similarity index 98% rename from main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtTokenProvider.java rename to main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtTokenProvider.java index 1ed5b3d6..7073262d 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/jwt/JwtTokenProvider.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/jwt/JwtTokenProvider.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.jwt; +package org.sopt.makers.crew.main.global.jwt; import io.jsonwebtoken.Claims; import io.jsonwebtoken.ExpiredJwtException; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/jwt/UserAuthentication.java b/main/src/main/java/org/sopt/makers/crew/main/global/jwt/UserAuthentication.java similarity index 92% rename from main/src/main/java/org/sopt/makers/crew/main/common/jwt/UserAuthentication.java rename to main/src/main/java/org/sopt/makers/crew/main/global/jwt/UserAuthentication.java index 9a2dda09..27eb7121 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/jwt/UserAuthentication.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/jwt/UserAuthentication.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.jwt; +package org.sopt.makers.crew.main.global.jwt; import java.util.Collection; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/pagination/dto/PageMetaDto.java b/main/src/main/java/org/sopt/makers/crew/main/global/pagination/dto/PageMetaDto.java similarity index 94% rename from main/src/main/java/org/sopt/makers/crew/main/common/pagination/dto/PageMetaDto.java rename to main/src/main/java/org/sopt/makers/crew/main/global/pagination/dto/PageMetaDto.java index ab8bd34e..2fafebd2 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/pagination/dto/PageMetaDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/pagination/dto/PageMetaDto.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.pagination.dto; +package org.sopt.makers.crew.main.global.pagination.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/pagination/dto/PageOptionsDto.java b/main/src/main/java/org/sopt/makers/crew/main/global/pagination/dto/PageOptionsDto.java similarity index 91% rename from main/src/main/java/org/sopt/makers/crew/main/common/pagination/dto/PageOptionsDto.java rename to main/src/main/java/org/sopt/makers/crew/main/global/pagination/dto/PageOptionsDto.java index a47401d7..d88b95be 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/pagination/dto/PageOptionsDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/pagination/dto/PageOptionsDto.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.pagination.dto; +package org.sopt.makers.crew.main.global.pagination.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Max; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/util/CustomPageable.java b/main/src/main/java/org/sopt/makers/crew/main/global/util/CustomPageable.java similarity index 96% rename from main/src/main/java/org/sopt/makers/crew/main/common/util/CustomPageable.java rename to main/src/main/java/org/sopt/makers/crew/main/global/util/CustomPageable.java index dd61075b..721eaad4 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/util/CustomPageable.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/util/CustomPageable.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.util; +package org.sopt.makers.crew.main.global.util; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/util/MentionSecretStringRemover.java b/main/src/main/java/org/sopt/makers/crew/main/global/util/MentionSecretStringRemover.java similarity index 96% rename from main/src/main/java/org/sopt/makers/crew/main/common/util/MentionSecretStringRemover.java rename to main/src/main/java/org/sopt/makers/crew/main/global/util/MentionSecretStringRemover.java index 55319527..2bb4a489 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/util/MentionSecretStringRemover.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/util/MentionSecretStringRemover.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.util; +package org.sopt.makers.crew.main.global.util; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/util/RealTime.java b/main/src/main/java/org/sopt/makers/crew/main/global/util/RealTime.java similarity index 86% rename from main/src/main/java/org/sopt/makers/crew/main/common/util/RealTime.java rename to main/src/main/java/org/sopt/makers/crew/main/global/util/RealTime.java index e10bac2d..55e846e6 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/util/RealTime.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/util/RealTime.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.util; +package org.sopt.makers.crew.main.global.util; import java.time.LocalDateTime; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/util/Time.java b/main/src/main/java/org/sopt/makers/crew/main/global/util/Time.java similarity index 63% rename from main/src/main/java/org/sopt/makers/crew/main/common/util/Time.java rename to main/src/main/java/org/sopt/makers/crew/main/global/util/Time.java index 115a50b2..19dd1ebd 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/util/Time.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/util/Time.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.util; +package org.sopt.makers.crew.main.global.util; import java.time.LocalDateTime; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/util/UserPartUtil.java b/main/src/main/java/org/sopt/makers/crew/main/global/util/UserPartUtil.java similarity index 95% rename from main/src/main/java/org/sopt/makers/crew/main/common/util/UserPartUtil.java rename to main/src/main/java/org/sopt/makers/crew/main/global/util/UserPartUtil.java index aae6b192..1b63a1e4 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/util/UserPartUtil.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/util/UserPartUtil.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.util; +package org.sopt.makers.crew.main.global.util; import lombok.RequiredArgsConstructor; import org.sopt.makers.crew.main.entity.meeting.enums.MeetingJoinablePart; diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/util/UserUtil.java b/main/src/main/java/org/sopt/makers/crew/main/global/util/UserUtil.java similarity index 85% rename from main/src/main/java/org/sopt/makers/crew/main/common/util/UserUtil.java rename to main/src/main/java/org/sopt/makers/crew/main/global/util/UserUtil.java index 91ce3151..e8b2acb0 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/common/util/UserUtil.java +++ b/main/src/main/java/org/sopt/makers/crew/main/global/util/UserUtil.java @@ -1,10 +1,10 @@ -package org.sopt.makers.crew.main.common.util; +package org.sopt.makers.crew.main.global.util; import java.security.Principal; import java.util.Comparator; import java.util.List; import lombok.RequiredArgsConstructor; -import org.sopt.makers.crew.main.common.exception.UnAuthorizedException; +import org.sopt.makers.crew.main.global.exception.UnAuthorizedException; import org.sopt.makers.crew.main.entity.user.vo.UserActivityVO; @RequiredArgsConstructor diff --git a/main/src/main/java/org/sopt/makers/crew/main/internal/notification/PushNotificationService.java b/main/src/main/java/org/sopt/makers/crew/main/internal/notification/PushNotificationService.java index 830da233..acc4b525 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/internal/notification/PushNotificationService.java +++ b/main/src/main/java/org/sopt/makers/crew/main/internal/notification/PushNotificationService.java @@ -1,6 +1,6 @@ package org.sopt.makers.crew.main.internal.notification; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.*; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import static org.sopt.makers.crew.main.internal.notification.PushNotificationEnums.PUSH_NOTIFICATION_ACTION; import java.util.UUID; diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Api.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Api.java index 480fdd8b..7d383c25 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Api.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Api.java @@ -1,6 +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; @@ -15,7 +14,6 @@ import java.security.Principal; import java.util.List; -import org.sopt.makers.crew.main.common.dto.TempResponseDto; 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; @@ -36,106 +34,94 @@ import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; @Tag(name = "모임") public interface MeetingV2Api { - @Operation(summary = "플레이그라운드 마이페이지 내 모임 정보 조회") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "성공")}) - @Parameters({@Parameter(name = "page", description = "페이지, default = 1", example = "1"), - @Parameter(name = "take", description = "가져올 데이터 개수, default = 12", example = "50"), - @Parameter(name = "orgUserId", description = "플레이그라운드 유저 id", example = "0")}) - ResponseEntity getAllMeetingByOrgUser( - @ModelAttribute @Parameter(hidden = true) MeetingV2GetAllMeetingByOrgUserQueryDto queryDto); - - @Operation(summary = "모임 둘러보기 조회") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "204", description = "모임이 없습니다.", content = @Content),}) - ResponseEntity> getMeetingBanner( - Principal principal); - - @Operation(summary = "모임 생성") - @ApiResponses(value = {@ApiResponse(responseCode = "201", description = "성공"), - @ApiResponse(responseCode = "400", description = "\"이미지 파일이 없습니다.\" or \"한 개 이상의 파트를 입력해주세요\" or \"프로필을 입력해주세요\"", content = @Content),}) - ResponseEntity createMeeting( - @Valid @RequestBody MeetingV2CreateMeetingBodyDto requestBody, - Principal principal); - - @Operation(summary = "모임 지원") - @ApiResponses(value = {@ApiResponse(responseCode = "201", description = "지원 완료"), - @ApiResponse(responseCode = "400", description = - "\"모임이 없습니다\" or \"기수/파트를 설정해주세요\" or \"정원이 꽉찼습니다\" or \"활동 기수가 아닙니다\" " + - "or \"지원 가능한 파트가 아닙니다\" or \"지원 가능한 기간이 아닙니다\"", content = @Content),}) - ResponseEntity applyMeeting(@RequestBody MeetingV2ApplyMeetingDto requestBody, - Principal principal); - - @Operation(summary = "모임 지원 취소") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "지원 취소 완료"), - @ApiResponse(responseCode = "400", description = - "존재하지 않는 모임 신청입니다.", content = @Content),}) - ResponseEntity applyMeetingCancel(@PathVariable Integer meetingId, - Principal principal); - - - @Operation(summary = "모임 지원자/참여자 조회", description = "모임 지원자/참여자 조회 (모임장이면 지원자, 아니면 참여자 조회)") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "모임 지원자/참여자 조회 성공"), - @ApiResponse(responseCode = "400", description = "모임이 없습니다.", content = @Content),}) - ResponseEntity findApplyList(@PathVariable Integer meetingId, - @ModelAttribute MeetingGetAppliesQueryDto queryCommand, - Principal principal); - - @Operation(summary = "모임 전체 조회/검색/필터링", description = "모임 전체 조회/검색/필터링\n") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "모임 지원자/참여자 조회 성공")}) - @Parameters({ - @Parameter(name = "page", description = "페이지, default = 1", example = "1", schema = @Schema(type = "integer", format = "int32")), - @Parameter(name = "take", description = "가져올 데이터 개수, default = 12", example = "50", schema = @Schema(type = "integer", format = "int32")), - @Parameter(name = "category", description = "카테고리", example = "스터디,번개", schema = @Schema(type = "string", format = "string")), - @Parameter(name = "status", description = "모임 모집 상태", example = "0,1", schema = @Schema(type = "string", format = "string")), - @Parameter(name = "isOnlyActiveGeneration", description = "활동기수만 참여여부", example = "true", schema = @Schema(type = "boolean", format = "boolean")), - @Parameter(name = "joinableParts", description = "검색할 활동 파트 다중 선택. OR 조건으로 검색됨
Available values : PM, DESIGN, IOS, ANDROID, SERVER, WEB", example = "PM,DESIGN,IOS,ANDROID,SERVER,WEB", schema = @Schema(type = "array[string]", format = "array[string]")), - @Parameter(name = "query", description = "검색 내용", example = "고수스터디 검색", schema = @Schema(type = "string", format = "string")), - }) - ResponseEntity getMeetings(@ModelAttribute MeetingV2GetAllMeetingQueryDto queryCommand, - Principal principal); - - @Operation(summary = "[TEMP] 모임 전체 조회/검색/필터링", description = "모임 전체 조회/검색/필터링\n") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "모임 지원자/참여자 조회 성공")}) - @Parameters({ - @Parameter(name = "page", description = "페이지, default = 1", example = "1", schema = @Schema(type = "integer", format = "int32")), - @Parameter(name = "take", description = "가져올 데이터 개수, default = 12", example = "50", schema = @Schema(type = "integer", format = "int32")), - @Parameter(name = "category", description = "카테고리", example = "스터디,번개", schema = @Schema(type = "string", format = "string")), - @Parameter(name = "status", description = "모임 모집 상태", example = "0,1", schema = @Schema(type = "string", format = "string")), - @Parameter(name = "isOnlyActiveGeneration", description = "활동기수만 참여여부", example = "true", schema = @Schema(type = "boolean", format = "boolean")), - @Parameter(name = "joinableParts", description = "검색할 활동 파트 다중 선택. OR 조건으로 검색됨
Available values : PM, DESIGN, IOS, ANDROID, SERVER, WEB", example = "PM,DESIGN,IOS,ANDROID,SERVER,WEB", schema = @Schema(type = "array[string]", format = "array[string]")), - @Parameter(name = "query", description = "검색 내용", example = "고수스터디 검색", schema = @Schema(type = "string", format = "string")), - }) - ResponseEntity> getMeetingsTemp(@ModelAttribute MeetingV2GetAllMeetingQueryDto queryCommand, - Principal principal); - - @Operation(summary = "모임 삭제", description = "모임 삭제합니다.") - ResponseEntity deleteMeeting(@PathVariable Integer meetingId, Principal principal); - - @Operation(summary = "모임 수정", description = "모임 내용을 수정합니다.") - ResponseEntity updateMeeting(@PathVariable Integer meetingId, @RequestBody @Valid MeetingV2CreateMeetingBodyDto requestBody ,Principal principal); - - @Operation(summary = "모임 지원자 상태 변경", description = "모임 지원자의 지원 상태를 변경합니다.") - ResponseEntity updateApplyStatus(@PathVariable Integer meetingId, @RequestBody @Valid ApplyV2UpdateStatusBodyDto requestBody ,Principal principal); - - @Operation(summary = "Meeting 썸네일 업로드용 Pre-Signed URL 발급", description = "Meeting 썸네일 업로드용 Pre-Signed URL 발급합니다.") - ResponseEntity createPreSignedUrl(@PathParam("contentType") String contentType ,Principal principal); - - @Operation(summary = "모임 지원자 목록 csv 파일 다운로드", description = "모임 지원자 목록 csv 파일 다운로드") - @Parameters({ - @Parameter(name = "status", description = "0: 대기, 1: 승인된 신청자, 2: 거절된 신청자", example = "0,1", required = true, schema = @Schema(type = "string")), - @Parameter(name = "type", description = "0: 지원, 1: 초대", example = "0,1", required = true, schema = @Schema(type = "string")), - @Parameter(name = "order", description = "정렬순", example = "desc", schema = @Schema(type = "string", format = "string"))}) - ResponseEntity getAppliesCsvFileUrl( - @PathVariable Integer meetingId, - @ModelAttribute @Valid @Parameter(hidden = true) MeetingGetAppliesCsvQueryDto queryCommand, - Principal principal); - - @Operation(summary = "모임 상세 조회", description = "모임 상세 조회") - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "모임 상세 조회 성공"), - @ApiResponse(responseCode = "400", description = "모임이 없습니다.", content = @Content),}) - ResponseEntity getMeetingById(@PathVariable Integer meetingId, Principal principal); + @Operation(summary = "플레이그라운드 마이페이지 내 모임 정보 조회") + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "성공")}) + @Parameters({@Parameter(name = "page", description = "페이지, default = 1", example = "1"), + @Parameter(name = "take", description = "가져올 데이터 개수, default = 12", example = "50"), + @Parameter(name = "orgUserId", description = "플레이그라운드 유저 id", example = "0")}) + ResponseEntity getAllMeetingByOrgUser( + @ModelAttribute @Parameter(hidden = true) MeetingV2GetAllMeetingByOrgUserQueryDto queryDto); + + @Operation(summary = "모임 둘러보기 조회") + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "성공"), + @ApiResponse(responseCode = "204", description = "모임이 없습니다.", content = @Content),}) + ResponseEntity> getMeetingBanner( + Principal principal); + + @Operation(summary = "모임 생성") + @ApiResponses(value = {@ApiResponse(responseCode = "201", description = "성공"), + @ApiResponse(responseCode = "400", description = "\"이미지 파일이 없습니다.\" or \"한 개 이상의 파트를 입력해주세요\" or \"프로필을 입력해주세요\"", content = @Content),}) + ResponseEntity createMeeting( + @Valid @RequestBody MeetingV2CreateMeetingBodyDto requestBody, + Principal principal); + + @Operation(summary = "모임 지원") + @ApiResponses(value = {@ApiResponse(responseCode = "201", description = "지원 완료"), + @ApiResponse(responseCode = "400", description = + "\"모임이 없습니다\" or \"기수/파트를 설정해주세요\" or \"정원이 꽉찼습니다\" or \"활동 기수가 아닙니다\" " + + "or \"지원 가능한 파트가 아닙니다\" or \"지원 가능한 기간이 아닙니다\"", content = @Content),}) + ResponseEntity applyMeeting(@RequestBody MeetingV2ApplyMeetingDto requestBody, + Principal principal); + + @Operation(summary = "모임 지원 취소") + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "지원 취소 완료"), + @ApiResponse(responseCode = "400", description = + "존재하지 않는 모임 신청입니다.", content = @Content),}) + ResponseEntity applyMeetingCancel(@PathVariable Integer meetingId, + Principal principal); + + @Operation(summary = "모임 지원자/참여자 조회", description = "모임 지원자/참여자 조회 (모임장이면 지원자, 아니면 참여자 조회)") + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "모임 지원자/참여자 조회 성공"), + @ApiResponse(responseCode = "400", description = "모임이 없습니다.", content = @Content),}) + ResponseEntity findApplyList(@PathVariable Integer meetingId, + @ModelAttribute MeetingGetAppliesQueryDto queryCommand, + Principal principal); + + @Operation(summary = "모임 전체 조회/검색/필터링", description = "모임 전체 조회/검색/필터링\n") + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "모임 지원자/참여자 조회 성공")}) + @Parameters({ + @Parameter(name = "page", description = "페이지, default = 1", example = "1", schema = @Schema(type = "integer", format = "int32")), + @Parameter(name = "take", description = "가져올 데이터 개수, default = 12", example = "50", schema = @Schema(type = "integer", format = "int32")), + @Parameter(name = "category", description = "카테고리", example = "스터디,번개", schema = @Schema(type = "string", format = "string")), + @Parameter(name = "status", description = "모임 모집 상태", example = "0,1", schema = @Schema(type = "string", format = "string")), + @Parameter(name = "isOnlyActiveGeneration", description = "활동기수만 참여여부", example = "true", schema = @Schema(type = "boolean", format = "boolean")), + @Parameter(name = "joinableParts", description = "검색할 활동 파트 다중 선택. OR 조건으로 검색됨
Available values : PM, DESIGN, IOS, ANDROID, SERVER, WEB", example = "PM,DESIGN,IOS,ANDROID,SERVER,WEB", schema = @Schema(type = "array[string]", format = "array[string]")), + @Parameter(name = "query", description = "검색 내용", example = "고수스터디 검색", schema = @Schema(type = "string", format = "string")), + }) + ResponseEntity getMeetings(@ModelAttribute MeetingV2GetAllMeetingQueryDto queryCommand, + Principal principal); + + @Operation(summary = "모임 삭제", description = "모임 삭제합니다.") + ResponseEntity deleteMeeting(@PathVariable Integer meetingId, Principal principal); + + @Operation(summary = "모임 수정", description = "모임 내용을 수정합니다.") + ResponseEntity updateMeeting(@PathVariable Integer meetingId, + @RequestBody @Valid MeetingV2CreateMeetingBodyDto requestBody, Principal principal); + + @Operation(summary = "모임 지원자 상태 변경", description = "모임 지원자의 지원 상태를 변경합니다.") + ResponseEntity updateApplyStatus(@PathVariable Integer meetingId, + @RequestBody @Valid ApplyV2UpdateStatusBodyDto requestBody, Principal principal); + + @Operation(summary = "Meeting 썸네일 업로드용 Pre-Signed URL 발급", description = "Meeting 썸네일 업로드용 Pre-Signed URL 발급합니다.") + ResponseEntity createPreSignedUrl(@PathParam("contentType") String contentType, + Principal principal); + + @Operation(summary = "모임 지원자 목록 csv 파일 다운로드", description = "모임 지원자 목록 csv 파일 다운로드") + @Parameters({ + @Parameter(name = "status", description = "0: 대기, 1: 승인된 신청자, 2: 거절된 신청자", example = "0,1", required = true, schema = @Schema(type = "string")), + @Parameter(name = "type", description = "0: 지원, 1: 초대", example = "0,1", required = true, schema = @Schema(type = "string")), + @Parameter(name = "order", description = "정렬순", example = "desc", schema = @Schema(type = "string", format = "string"))}) + ResponseEntity getAppliesCsvFileUrl( + @PathVariable Integer meetingId, + @ModelAttribute @Valid @Parameter(hidden = true) MeetingGetAppliesCsvQueryDto queryCommand, + Principal principal); + + @Operation(summary = "모임 상세 조회", description = "모임 상세 조회") + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "모임 상세 조회 성공"), + @ApiResponse(responseCode = "400", description = "모임이 없습니다.", content = @Content),}) + ResponseEntity getMeetingById(@PathVariable Integer meetingId, + Principal principal); } diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Controller.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Controller.java index 617d4443..5fb75b3c 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Controller.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Controller.java @@ -8,8 +8,7 @@ import lombok.RequiredArgsConstructor; -import org.sopt.makers.crew.main.common.dto.TempResponseDto; -import org.sopt.makers.crew.main.common.util.UserUtil; +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.meeting.v2.dto.query.MeetingGetAppliesCsvQueryDto; import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingGetAppliesQueryDto; @@ -118,14 +117,6 @@ public ResponseEntity getMeetings( return ResponseEntity.ok().body(meetings); } - @Override - @GetMapping("/temp") - public ResponseEntity> getMeetingsTemp( - MeetingV2GetAllMeetingQueryDto queryCommand, Principal principal) { - MeetingV2GetAllMeetingDto meetings = meetingV2Service.getMeetings(queryCommand); - return ResponseEntity.ok().body(TempResponseDto.of(meetings)); - } - @Override @DeleteMapping("/{meetingId}") public ResponseEntity deleteMeeting(@PathVariable Integer meetingId, Principal principal) { diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/MeetingMapper.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/MeetingMapper.java index 1dbcd6a4..3685c7a4 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/MeetingMapper.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/MeetingMapper.java @@ -1,8 +1,8 @@ package org.sopt.makers.crew.main.meeting.v2.dto; -import static org.sopt.makers.crew.main.common.constant.CrewConst.DAY_END_TIME; -import static org.sopt.makers.crew.main.common.constant.CrewConst.DAY_START_TIME; -import static org.sopt.makers.crew.main.common.constant.CrewConst.DAY_TIME_FORMAT; +import static org.sopt.makers.crew.main.global.constant.CrewConst.DAY_END_TIME; +import static org.sopt.makers.crew.main.global.constant.CrewConst.DAY_START_TIME; +import static org.sopt.makers.crew.main.global.constant.CrewConst.DAY_TIME_FORMAT; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingGetAppliesQueryDto.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingGetAppliesQueryDto.java index 3edecb09..90bb4e0e 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingGetAppliesQueryDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingGetAppliesQueryDto.java @@ -5,7 +5,7 @@ import lombok.Builder; import lombok.Getter; import lombok.Setter; -import org.sopt.makers.crew.main.common.pagination.dto.PageOptionsDto; +import org.sopt.makers.crew.main.global.pagination.dto.PageOptionsDto; import org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus; @Getter diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingV2GetAllMeetingByOrgUserQueryDto.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingV2GetAllMeetingByOrgUserQueryDto.java index 6389dcc4..f0717423 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingV2GetAllMeetingByOrgUserQueryDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingV2GetAllMeetingByOrgUserQueryDto.java @@ -2,7 +2,7 @@ import jakarta.validation.constraints.NotNull; import lombok.Getter; -import org.sopt.makers.crew.main.common.pagination.dto.PageOptionsDto; +import org.sopt.makers.crew.main.global.pagination.dto.PageOptionsDto; @Getter public class MeetingV2GetAllMeetingByOrgUserQueryDto extends PageOptionsDto { diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingV2GetAllMeetingQueryDto.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingV2GetAllMeetingQueryDto.java index 2b97b770..941326cd 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingV2GetAllMeetingQueryDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/query/MeetingV2GetAllMeetingQueryDto.java @@ -2,7 +2,7 @@ import java.util.List; -import org.sopt.makers.crew.main.common.pagination.dto.PageOptionsDto; +import org.sopt.makers.crew.main.global.pagination.dto.PageOptionsDto; import org.sopt.makers.crew.main.entity.meeting.enums.MeetingJoinablePart; import jakarta.validation.constraints.NotNull; diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/request/MeetingV2CreateMeetingBodyDto.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/request/MeetingV2CreateMeetingBodyDto.java index b46fc5d7..05e1abcc 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/request/MeetingV2CreateMeetingBodyDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/request/MeetingV2CreateMeetingBodyDto.java @@ -61,13 +61,8 @@ public class MeetingV2CreateMeetingBodyDto { private String mEndDate; @Schema(example = "안녕하세요 기획 파트 000입니다", description = "개설자 소개") - @NotNull private String leaderDesc; - @Schema(example = "개발 모르는 사람도 환영", description = "모집 대상 소개") - @NotNull - private String targetDesc; - @Schema(example = "유의할 사항", description = "유의할 사항") private String note; diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/ApplicantDto.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/ApplicantDto.java index 9a23b106..3ad390e8 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/ApplicantDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/ApplicantDto.java @@ -2,14 +2,13 @@ import com.querydsl.core.annotations.QueryProjection; -import java.util.Comparator; import java.util.List; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import lombok.Getter; -import org.sopt.makers.crew.main.common.util.UserUtil; +import org.sopt.makers.crew.main.global.util.UserUtil; import org.sopt.makers.crew.main.entity.user.vo.UserActivityVO; @Getter diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingGetApplyListResponseDto.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingGetApplyListResponseDto.java index 87e50fca..d0cb43e6 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingGetApplyListResponseDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingGetApplyListResponseDto.java @@ -7,7 +7,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; -import org.sopt.makers.crew.main.common.pagination.dto.PageMetaDto; +import org.sopt.makers.crew.main.global.pagination.dto.PageMetaDto; @Getter @AllArgsConstructor(staticName = "of") diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetAllMeetingByOrgUserDto.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetAllMeetingByOrgUserDto.java index 2fea813b..707906b1 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetAllMeetingByOrgUserDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetAllMeetingByOrgUserDto.java @@ -7,7 +7,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; -import org.sopt.makers.crew.main.common.pagination.dto.PageMetaDto; +import org.sopt.makers.crew.main.global.pagination.dto.PageMetaDto; @Getter @AllArgsConstructor(staticName = "of") diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetAllMeetingDto.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetAllMeetingDto.java index 5d17f6d9..b43a6517 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetAllMeetingDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetAllMeetingDto.java @@ -2,8 +2,8 @@ import java.util.List; -import org.sopt.makers.crew.main.common.dto.MeetingResponseDto; -import org.sopt.makers.crew.main.common.pagination.dto.PageMetaDto; +import org.sopt.makers.crew.main.global.dto.MeetingResponseDto; +import org.sopt.makers.crew.main.global.pagination.dto.PageMetaDto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetMeetingByIdResponseDto.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetMeetingByIdResponseDto.java index 5e6a1ac6..a9b385f0 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetMeetingByIdResponseDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/dto/response/MeetingV2GetMeetingByIdResponseDto.java @@ -3,7 +3,7 @@ import java.time.LocalDateTime; import java.util.List; -import org.sopt.makers.crew.main.common.dto.MeetingCreatorDto; +import org.sopt.makers.crew.main.global.dto.MeetingCreatorDto; import org.sopt.makers.crew.main.entity.meeting.Meeting; import org.sopt.makers.crew.main.entity.meeting.enums.MeetingJoinablePart; import org.sopt.makers.crew.main.entity.meeting.vo.ImageUrlVO; @@ -68,13 +68,8 @@ public class MeetingV2GetMeetingByIdResponseDto { private final LocalDateTime mEndDate; @Schema(description = "개설자 소개", example = "개설자 소개 입니다.") - @NotNull private final String leaderDesc; - @Schema(description = "모집 대상 소개", example = "모집 대상 소개입니다.") - @NotNull - private final String targetDesc; - @Schema(description = "유의사항", example = "유의사항입니다.") @NotNull private final String note; @@ -145,7 +140,7 @@ public static MeetingV2GetMeetingByIdResponseDto of(Meeting meeting, long approv return new MeetingV2GetMeetingByIdResponseDto(meeting.getId(), meeting.getUserId(), meeting.getTitle(), meeting.getCategory().getValue(), meeting.getImageURL(), meeting.getStartDate(), meeting.getEndDate(), meeting.getCapacity(), meeting.getDesc(), meeting.getProcessDesc(), meeting.getMStartDate(), - meeting.getMEndDate(), meeting.getLeaderDesc(), meeting.getTargetDesc(), meeting.getNote(), + meeting.getMEndDate(), meeting.getLeaderDesc(), meeting.getNote(), meeting.getIsMentorNeeded(), meeting.getCanJoinOnlyActiveGeneration(), meeting.getCreatedGeneration(), meeting.getTargetActiveGeneration(), meeting.getJoinableParts(), meetingStatus, approvedCount, isHost, isApply, isApproved, meetingCreatorDto, appliedInfo); diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java index 0af1a27f..4cd9a638 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java @@ -1,7 +1,7 @@ package org.sopt.makers.crew.main.meeting.v2.service; -import static org.sopt.makers.crew.main.common.constant.CrewConst.*; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.*; +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.FileWriter; @@ -22,14 +22,14 @@ import lombok.RequiredArgsConstructor; -import org.sopt.makers.crew.main.common.dto.MeetingResponseDto; -import org.sopt.makers.crew.main.common.exception.BadRequestException; -import org.sopt.makers.crew.main.common.exception.ServerException; -import org.sopt.makers.crew.main.common.pagination.dto.PageMetaDto; -import org.sopt.makers.crew.main.common.pagination.dto.PageOptionsDto; -import org.sopt.makers.crew.main.common.util.CustomPageable; -import org.sopt.makers.crew.main.common.util.Time; -import org.sopt.makers.crew.main.common.util.UserPartUtil; +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; diff --git a/main/src/main/java/org/sopt/makers/crew/main/notice/service/NoticeV2Service.java b/main/src/main/java/org/sopt/makers/crew/main/notice/service/NoticeV2Service.java index 31610539..d030d7da 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/notice/service/NoticeV2Service.java +++ b/main/src/main/java/org/sopt/makers/crew/main/notice/service/NoticeV2Service.java @@ -1,12 +1,12 @@ package org.sopt.makers.crew.main.notice.service; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.FORBIDDEN_EXCEPTION; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.FORBIDDEN_EXCEPTION; import java.time.LocalDateTime; import java.util.List; import lombok.RequiredArgsConstructor; -import org.sopt.makers.crew.main.common.exception.ForbiddenException; +import org.sopt.makers.crew.main.global.exception.ForbiddenException; import org.sopt.makers.crew.main.entity.notice.Notice; import org.sopt.makers.crew.main.entity.notice.NoticeRepository; import org.sopt.makers.crew.main.notice.dto.request.NoticeV2CreateRequestDto; diff --git a/main/src/main/java/org/sopt/makers/crew/main/post/v2/PostV2Controller.java b/main/src/main/java/org/sopt/makers/crew/main/post/v2/PostV2Controller.java index 76b61f99..65d5ed10 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/post/v2/PostV2Controller.java +++ b/main/src/main/java/org/sopt/makers/crew/main/post/v2/PostV2Controller.java @@ -2,7 +2,7 @@ import java.security.Principal; -import org.sopt.makers.crew.main.common.util.UserUtil; +import org.sopt.makers.crew.main.global.util.UserUtil; import org.sopt.makers.crew.main.post.v2.dto.query.PostGetPostsCommand; import org.sopt.makers.crew.main.post.v2.dto.request.PostV2CreatePostBodyDto; import org.sopt.makers.crew.main.post.v2.dto.request.PostV2MentionUserInPostRequestDto; diff --git a/main/src/main/java/org/sopt/makers/crew/main/post/v2/dto/query/PostGetPostsCommand.java b/main/src/main/java/org/sopt/makers/crew/main/post/v2/dto/query/PostGetPostsCommand.java index cf516017..a8db77dc 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/post/v2/dto/query/PostGetPostsCommand.java +++ b/main/src/main/java/org/sopt/makers/crew/main/post/v2/dto/query/PostGetPostsCommand.java @@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; -import org.sopt.makers.crew.main.common.pagination.dto.PageOptionsDto; +import org.sopt.makers.crew.main.global.pagination.dto.PageOptionsDto; @Getter @Schema(name = "PostGetPostsCommand", description = "게시글 조회 요청 Dto") diff --git a/main/src/main/java/org/sopt/makers/crew/main/post/v2/dto/response/PostV2GetPostsResponseDto.java b/main/src/main/java/org/sopt/makers/crew/main/post/v2/dto/response/PostV2GetPostsResponseDto.java index 6f47e304..ceca43a5 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/post/v2/dto/response/PostV2GetPostsResponseDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/post/v2/dto/response/PostV2GetPostsResponseDto.java @@ -2,7 +2,7 @@ import java.util.List; -import org.sopt.makers.crew.main.common.pagination.dto.PageMetaDto; +import org.sopt.makers.crew.main.global.pagination.dto.PageMetaDto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; diff --git a/main/src/main/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceImpl.java b/main/src/main/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceImpl.java index ef18de60..03357acc 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceImpl.java @@ -1,19 +1,19 @@ package org.sopt.makers.crew.main.post.v2.service; import static java.util.stream.Collectors.*; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.*; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import static org.sopt.makers.crew.main.internal.notification.PushNotificationEnums.*; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import org.sopt.makers.crew.main.common.exception.BadRequestException; -import org.sopt.makers.crew.main.common.exception.ForbiddenException; -import org.sopt.makers.crew.main.common.pagination.dto.PageMetaDto; -import org.sopt.makers.crew.main.common.pagination.dto.PageOptionsDto; -import org.sopt.makers.crew.main.common.util.CustomPageable; -import org.sopt.makers.crew.main.common.util.Time; +import org.sopt.makers.crew.main.global.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.ForbiddenException; +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.entity.apply.Apply; import org.sopt.makers.crew.main.entity.apply.ApplyRepository; import org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus; diff --git a/main/src/main/java/org/sopt/makers/crew/main/user/v2/UserV2Api.java b/main/src/main/java/org/sopt/makers/crew/main/user/v2/UserV2Api.java index bff76d4a..932fee5c 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/user/v2/UserV2Api.java +++ b/main/src/main/java/org/sopt/makers/crew/main/user/v2/UserV2Api.java @@ -9,7 +9,7 @@ import java.security.Principal; import java.util.List; -import org.sopt.makers.crew.main.common.dto.TempResponseDto; +import org.sopt.makers.crew.main.global.dto.TempResponseDto; import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMeetingByUserMeetingDto; import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMentionUserDto; import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAppliedMeetingByUserResponseDto; diff --git a/main/src/main/java/org/sopt/makers/crew/main/user/v2/UserV2Controller.java b/main/src/main/java/org/sopt/makers/crew/main/user/v2/UserV2Controller.java index 6363619a..ff280f01 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/user/v2/UserV2Controller.java +++ b/main/src/main/java/org/sopt/makers/crew/main/user/v2/UserV2Controller.java @@ -5,8 +5,8 @@ import lombok.RequiredArgsConstructor; -import org.sopt.makers.crew.main.common.dto.TempResponseDto; -import org.sopt.makers.crew.main.common.util.UserUtil; +import org.sopt.makers.crew.main.global.dto.TempResponseDto; +import org.sopt.makers.crew.main.global.util.UserUtil; import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMeetingByUserMeetingDto; import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMentionUserDto; import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAppliedMeetingByUserResponseDto; diff --git a/main/src/main/java/org/sopt/makers/crew/main/user/v2/dto/response/MeetingV2GetCreatedMeetingByUserResponseDto.java b/main/src/main/java/org/sopt/makers/crew/main/user/v2/dto/response/MeetingV2GetCreatedMeetingByUserResponseDto.java index f632d100..6a4b8e6a 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/user/v2/dto/response/MeetingV2GetCreatedMeetingByUserResponseDto.java +++ b/main/src/main/java/org/sopt/makers/crew/main/user/v2/dto/response/MeetingV2GetCreatedMeetingByUserResponseDto.java @@ -3,8 +3,8 @@ import java.time.LocalDateTime; import java.util.List; -import org.sopt.makers.crew.main.common.constant.CrewConst; -import org.sopt.makers.crew.main.common.dto.MeetingCreatorDto; +import org.sopt.makers.crew.main.global.constant.CrewConst; +import org.sopt.makers.crew.main.global.dto.MeetingCreatorDto; import org.sopt.makers.crew.main.entity.meeting.Meeting; import org.sopt.makers.crew.main.entity.meeting.enums.MeetingJoinablePart; import org.sopt.makers.crew.main.entity.meeting.vo.ImageUrlVO; diff --git a/main/src/main/java/org/sopt/makers/crew/main/user/v2/service/UserV2ServiceImpl.java b/main/src/main/java/org/sopt/makers/crew/main/user/v2/service/UserV2ServiceImpl.java index 17e792c5..9787ba61 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/user/v2/service/UserV2ServiceImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/user/v2/service/UserV2ServiceImpl.java @@ -5,8 +5,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.sopt.makers.crew.main.common.exception.BaseException; -import org.sopt.makers.crew.main.common.util.Time; +import org.sopt.makers.crew.main.global.exception.BaseException; +import org.sopt.makers.crew.main.global.util.Time; 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; diff --git a/main/src/main/resources/application-dev.yml b/main/src/main/resources/application-dev.yml index 0b56ef0d..835f3e2c 100644 --- a/main/src/main/resources/application-dev.yml +++ b/main/src/main/resources/application-dev.yml @@ -19,7 +19,7 @@ spring: open-in-view: false hibernate: naming: - physical-strategy: org.sopt.makers.crew.main.common.config.CamelCaseNamingStrategy + physical-strategy: org.sopt.makers.crew.main.global.config.CamelCaseNamingStrategy ddl-auto: validate properties: hibernate: diff --git a/main/src/main/resources/application-local.yml b/main/src/main/resources/application-local.yml index 4daa22f6..7e76915c 100644 --- a/main/src/main/resources/application-local.yml +++ b/main/src/main/resources/application-local.yml @@ -19,7 +19,7 @@ spring: open-in-view: false hibernate: naming: - physical-strategy: org.sopt.makers.crew.main.common.config.CamelCaseNamingStrategy + physical-strategy: org.sopt.makers.crew.main.global.config.CamelCaseNamingStrategy ddl-auto: update properties: hibernate: diff --git a/main/src/main/resources/application-prod.yml b/main/src/main/resources/application-prod.yml index 9d256eee..311a8aa7 100644 --- a/main/src/main/resources/application-prod.yml +++ b/main/src/main/resources/application-prod.yml @@ -19,7 +19,7 @@ spring: open-in-view: false hibernate: naming: - physical-strategy: org.sopt.makers.crew.main.common.config.CamelCaseNamingStrategy + physical-strategy: org.sopt.makers.crew.main.global.config.CamelCaseNamingStrategy ddl-auto: validate properties: hibernate: diff --git a/main/src/main/resources/application-test.yml b/main/src/main/resources/application-test.yml index ad43358a..05f9b3e5 100644 --- a/main/src/main/resources/application-test.yml +++ b/main/src/main/resources/application-test.yml @@ -16,7 +16,7 @@ spring: open-in-view: false hibernate: naming: - physical-strategy: org.sopt.makers.crew.main.common.config.CamelCaseNamingStrategy + physical-strategy: org.sopt.makers.crew.main.global.config.CamelCaseNamingStrategy ddl-auto: none properties: hibernate: diff --git a/main/src/main/resources/schema.sql b/main/src/main/resources/schema.sql index 9b2d7880..1cd8c405 100644 --- a/main/src/main/resources/schema.sql +++ b/main/src/main/resources/schema.sql @@ -1,3 +1,13 @@ +drop table if exists "advertisement" cascade; +drop table if exists "apply" cascade; +drop table if exists "comment" cascade; +drop table if exists "like" cascade; +drop table if exists "meeting" cascade; +drop table if exists "notice" cascade; +drop table if exists "post" cascade; +drop table if exists "report" cascade; +drop table if exists "user" cascade; + DROP TYPE IF EXISTS meeting_joinableparts_enum; create type meeting_joinableparts_enum as enum ('PM', 'DESIGN', 'IOS', 'ANDROID', 'SERVER', 'WEB'); @@ -13,12 +23,11 @@ create table if not exists "user" "orgId" integer not null, "profileImage" varchar, activities jsonb, - phone varchar + phone varchar, + "createdTimestamp" timestamp default CURRENT_TIMESTAMP, + "modifiedTimestamp" timestamp default CURRENT_TIMESTAMP ); --- alter table "user" --- owner to songmingyu; - create table if not exists meeting ( id serial @@ -40,14 +49,15 @@ create table if not exists meeting "processDesc" varchar not null, "mStartDate" timestamp not null, "mEndDate" timestamp not null, - "leaderDesc" varchar not null, - "targetDesc" varchar not null, + "leaderDesc" varchar, note varchar, "isMentorNeeded" boolean not null, "canJoinOnlyActiveGeneration" boolean not null, "targetActiveGeneration" integer, "joinableParts" meeting_joinableparts_enum[], - "createdGeneration" integer default 32 + "createdGeneration" integer default 32, + "createdTimestamp" timestamp default CURRENT_TIMESTAMP, + "modifiedTimestamp" timestamp default CURRENT_TIMESTAMP ); create table if not exists apply @@ -55,23 +65,22 @@ create table if not exists apply id serial constraint "PK_c61ed680472aa0f58499175d902" primary key, - type integer default 0 not null, - "meetingId" integer not null + type integer default 0 not null, + "meetingId" integer not null constraint "FK_b130d23f4642d1ef51c6e54d257" references meeting on delete cascade, - "userId" integer not null + "userId" integer not null constraint "FK_359c8244808809db5ee96ed066e" references "user" on delete cascade, - content varchar not null, - "appliedDate" timestamp not null, - status integer default 0 not null + content varchar not null, + "appliedDate" timestamp not null, + status integer default 0 not null, + "createdTimestamp" timestamp default CURRENT_TIMESTAMP, + "modifiedTimestamp" timestamp default CURRENT_TIMESTAMP ); --- alter table apply --- owner to songmingyu; - create index if not exists "meetingId_index" on apply ("meetingId"); @@ -90,7 +99,9 @@ create table if not exists notice contents varchar not null, "createdDate" timestamp not null, "exposeStartDate" timestamp not null, - "exposeEndDate" timestamp not null + "exposeEndDate" timestamp not null, + "createdTimestamp" timestamp default CURRENT_TIMESTAMP, + "modifiedTimestamp" timestamp default CURRENT_TIMESTAMP ); create table if not exists post @@ -100,25 +111,24 @@ create table if not exists post primary key constraint "UQ_be5fda3aac270b134ff9c21cdee" unique, - contents varchar not null, - "createdDate" timestamp not null, - "updatedDate" timestamp not null, - "likeCount" integer default 0 not null, - "userId" integer not null + contents varchar not null, + "createdDate" timestamp not null, + "updatedDate" timestamp not null, + "likeCount" integer default 0 not null, + "userId" integer not null constraint "FK_5c1cf55c308037b5aca1038a131" references "user", - "meetingId" integer not null + "meetingId" integer not null constraint "FK_85e980cf9166f5337c0b2b76bc0" references meeting, - title varchar not null, - "viewCount" integer default 0 not null, + title varchar not null, + "viewCount" integer default 0 not null, images text[], - "commentCount" integer default 0 not null + "commentCount" integer default 0 not null, + "createdTimestamp" timestamp default CURRENT_TIMESTAMP, + "modifiedTimestamp" timestamp default CURRENT_TIMESTAMP ); --- alter table post --- owner to songmingyu; - create table if not exists comment ( id serial @@ -126,20 +136,22 @@ create table if not exists comment primary key constraint "UQ_0b0e4bbc8415ec426f87f3a88e2" unique, - contents varchar not null, - depth integer default 0 not null, - "order" integer default 0 not null, - "createdDate" timestamp not null, - "updatedDate" timestamp not null, - "likeCount" integer default 0 not null, + contents varchar not null, + depth integer default 0 not null, + "order" integer default 0 not null, + "createdDate" timestamp not null, + "updatedDate" timestamp not null, + "likeCount" integer default 0 not null, "userId" integer constraint "FK_c0354a9a009d3bb45a08655ce3b" references "user", - "postId" integer not null + "postId" integer not null constraint "FK_94a85bb16d24033a2afdd5df060" references post on delete cascade, - "parentId" integer + "parentId" integer, + "createdTimestamp" timestamp default CURRENT_TIMESTAMP, + "modifiedTimestamp" timestamp default CURRENT_TIMESTAMP ); create table if not exists "like" @@ -160,7 +172,9 @@ create table if not exists "like" "commentId" integer constraint "FK_d86e0a3eeecc21faa0da415a18a" references comment - on delete cascade + on delete cascade, + "createdTimestamp" timestamp default CURRENT_TIMESTAMP, + "modifiedTimestamp" timestamp default CURRENT_TIMESTAMP ); create table if not exists report @@ -181,7 +195,9 @@ create table if not exists report "postId" integer constraint "FK_4b6fe2df37305bc075a4a16d3ea" references post - on delete cascade + on delete cascade, + "createdTimestamp" timestamp default CURRENT_TIMESTAMP, + "modifiedTimestamp" timestamp default CURRENT_TIMESTAMP ); create table if not exists advertisement @@ -197,5 +213,8 @@ create table if not exists advertisement check (("advertisementCategory")::text = ANY ((ARRAY ['POST'::character varying, 'MEETING'::character varying])::text[])), "advertisementDesktopImageUrl" varchar(255), - "advertisementMobileImageUrl" varchar(255) + "advertisementMobileImageUrl" varchar(255), + "isSponsoredContent" boolean default false not null, + "createdTimestamp" timestamp default CURRENT_TIMESTAMP, + "modifiedTimestamp" timestamp default CURRENT_TIMESTAMP ); \ No newline at end of file diff --git a/main/src/test/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceTest.java b/main/src/test/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceTest.java index 87690663..d969b636 100644 --- a/main/src/test/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceTest.java +++ b/main/src/test/java/org/sopt/makers/crew/main/comment/v2/service/CommentV2ServiceTest.java @@ -17,9 +17,9 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2ReportCommentResponseDto; import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2UpdateCommentResponseDto; -import org.sopt.makers.crew.main.common.exception.BadRequestException; -import org.sopt.makers.crew.main.common.exception.ForbiddenException; -import org.sopt.makers.crew.main.common.util.Time; +import org.sopt.makers.crew.main.global.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.ForbiddenException; +import org.sopt.makers.crew.main.global.util.Time; 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.meeting.Meeting; diff --git a/main/src/test/java/org/sopt/makers/crew/main/common/annotation/IntegratedTest.java b/main/src/test/java/org/sopt/makers/crew/main/global/annotation/IntegratedTest.java similarity index 93% rename from main/src/test/java/org/sopt/makers/crew/main/common/annotation/IntegratedTest.java rename to main/src/test/java/org/sopt/makers/crew/main/global/annotation/IntegratedTest.java index 4af63b6d..8c35d69a 100644 --- a/main/src/test/java/org/sopt/makers/crew/main/common/annotation/IntegratedTest.java +++ b/main/src/test/java/org/sopt/makers/crew/main/global/annotation/IntegratedTest.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.annotation; +package org.sopt.makers.crew.main.global.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/main/src/test/java/org/sopt/makers/crew/main/common/config/TestConfig.java b/main/src/test/java/org/sopt/makers/crew/main/global/config/TestConfig.java similarity index 91% rename from main/src/test/java/org/sopt/makers/crew/main/common/config/TestConfig.java rename to main/src/test/java/org/sopt/makers/crew/main/global/config/TestConfig.java index c8373182..325e9b2d 100644 --- a/main/src/test/java/org/sopt/makers/crew/main/common/config/TestConfig.java +++ b/main/src/test/java/org/sopt/makers/crew/main/global/config/TestConfig.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.config; +package org.sopt.makers.crew.main.global.config; import com.querydsl.jpa.JPQLTemplates; import com.querydsl.jpa.impl.JPAQueryFactory; diff --git a/main/src/test/java/org/sopt/makers/crew/main/common/util/StubTime.java b/main/src/test/java/org/sopt/makers/crew/main/global/util/StubTime.java similarity index 86% rename from main/src/test/java/org/sopt/makers/crew/main/common/util/StubTime.java rename to main/src/test/java/org/sopt/makers/crew/main/global/util/StubTime.java index 827894b6..04c1a6d5 100644 --- a/main/src/test/java/org/sopt/makers/crew/main/common/util/StubTime.java +++ b/main/src/test/java/org/sopt/makers/crew/main/global/util/StubTime.java @@ -1,4 +1,4 @@ -package org.sopt.makers.crew.main.common.util; +package org.sopt.makers.crew.main.global.util; import java.time.LocalDateTime; diff --git a/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/repository/ApplyRepositoryTest.java b/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/repository/ApplyRepositoryTest.java index e261317e..2c1b0e88 100644 --- a/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/repository/ApplyRepositoryTest.java +++ b/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/repository/ApplyRepositoryTest.java @@ -7,7 +7,6 @@ import java.time.LocalTime; import java.util.List; import org.junit.jupiter.api.Test; -import org.sopt.makers.crew.main.common.config.TestConfig; import org.sopt.makers.crew.main.entity.apply.ApplyRepository; import org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus; import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingGetAppliesQueryDto; diff --git a/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/repository/MeetingRepositoryTest.java b/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/repository/MeetingRepositoryTest.java new file mode 100644 index 00000000..21704787 --- /dev/null +++ b/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/repository/MeetingRepositoryTest.java @@ -0,0 +1,112 @@ +package org.sopt.makers.crew.main.meeting.v2.repository; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.sopt.makers.crew.main.global.annotation.IntegratedTest; +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.meeting.vo.ImageUrlVO; +import org.sopt.makers.crew.main.entity.user.User; +import org.sopt.makers.crew.main.entity.user.UserRepository; +import org.springframework.beans.factory.annotation.Autowired; + +@IntegratedTest +public class MeetingRepositoryTest { + + @Autowired + private MeetingRepository meetingRepository; + + @Autowired + private UserRepository userRepository; + + @Test + @DisplayName("정상적인 경우, 모임 저장시 성공한다.") + void normal_save_success(){ + // given + User user = User.builder() + .name("홍길동") + .orgId(1) + .activities(null) + .profileImage("image-url1") + .phone("010-1234-5678") + .build(); + User savedUser = userRepository.save(user); + + List imageUrlList = Arrays.asList( + new ImageUrlVO(1,"https://example.com/image1.jpg"), + new ImageUrlVO(2,"https://example.com/image2.jpg") + ); + + // Meeting 객체 생성 + Meeting meeting = Meeting.builder() + .user(user) + .userId(1) // userId 예시 + .title("Backend 개발 스터디") + .category(MeetingCategory.STUDY) + .imageURL(imageUrlList) + .startDate(LocalDateTime.of(2024, 10, 1, 9, 0)) + .endDate(LocalDateTime.of(2024, 10, 15, 18, 0)) + .capacity(10) + .desc("백엔드 개발에 관심 있는 사람들을 위한 스터디입니다.") + .processDesc("매주 온라인으로 진행되며, 발표와 토론이 포함됩니다.") + .mStartDate(LocalDateTime.of(2024, 10, 16, 9, 0)) + .mEndDate(LocalDateTime.of(2024, 12, 1, 18, 0)) + .leaderDesc("5년차 백엔드 개발자입니다.") + .note("준비물은 노트북과 열정입니다.") + .isMentorNeeded(false) + .canJoinOnlyActiveGeneration(true) + .createdGeneration(2024) + .targetActiveGeneration(2024) + .joinableParts(new MeetingJoinablePart[]{MeetingJoinablePart.SERVER, MeetingJoinablePart.IOS}) + .build(); + + // when + Meeting savedMeeting = meetingRepository.save(meeting); + + // then + Assertions.assertThat(savedMeeting) + .isNotNull() + .extracting( + "user", "userId", "title", "category", "imageURL", "startDate", "endDate", "capacity", "desc", + "processDesc", "mStartDate", "mEndDate", "leaderDesc", "note", "isMentorNeeded", + "canJoinOnlyActiveGeneration", "createdGeneration", "targetActiveGeneration", "joinableParts" + ) + .containsExactly( + savedUser, // user 필드 + savedUser.getId(), // userId 필드 + "Backend 개발 스터디", // title 필드 + MeetingCategory.STUDY, // category 필드 + imageUrlList, // imageURL 필드 + LocalDateTime.of(2024, 10, 1, 9, 0), // startDate 필드 + LocalDateTime.of(2024, 10, 15, 18, 0), // endDate 필드 + 10, // capacity 필드 + "백엔드 개발에 관심 있는 사람들을 위한 스터디입니다.", // desc 필드 + "매주 온라인으로 진행되며, 발표와 토론이 포함됩니다.", // processDesc 필드 + LocalDateTime.of(2024, 10, 16, 9, 0), // mStartDate 필드 + LocalDateTime.of(2024, 12, 1, 18, 0), // mEndDate 필드 + "5년차 백엔드 개발자입니다.", // leaderDesc 필드 + "준비물은 노트북과 열정입니다.", // note 필드 + false, // isMentorNeeded 필드 + true, // canJoinOnlyActiveGeneration 필드 + 2024, // createdGeneration 필드 + 2024, // targetActiveGeneration 필드 + new MeetingJoinablePart[]{MeetingJoinablePart.SERVER, MeetingJoinablePart.IOS} // joinableParts 필드 + ); + + // 추가적으로 imageURL 리스트도 개별적으로 검증 + Assertions.assertThat(savedMeeting.getImageURL()) + .hasSize(2) + .extracting("url") + .containsExactly( + "https://example.com/image1.jpg", + "https://example.com/image2.jpg" + ); + } +} diff --git a/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2MockServiceTest.java b/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2MockServiceTest.java new file mode 100644 index 00000000..cccd033b --- /dev/null +++ b/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2MockServiceTest.java @@ -0,0 +1,222 @@ +package org.sopt.makers.crew.main.meeting.v2.service; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.FULL_MEETING_CAPACITY; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.NOT_IN_APPLY_PERIOD; + +import java.time.LocalDateTime; +import java.time.Month; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.sopt.makers.crew.main.global.exception.BadRequestException; +import org.sopt.makers.crew.main.entity.apply.Apply; +import org.sopt.makers.crew.main.entity.apply.ApplyRepository; +import org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus; +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.meeting.vo.ImageUrlVO; +import org.sopt.makers.crew.main.entity.user.User; +import org.sopt.makers.crew.main.entity.user.UserFixture; +import org.sopt.makers.crew.main.entity.user.UserRepository; +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.meeting.v2.dto.ApplyMapper; +import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingV2GetAllMeetingByOrgUserQueryDto; +import org.sopt.makers.crew.main.meeting.v2.dto.request.MeetingV2ApplyMeetingDto; +import org.sopt.makers.crew.main.meeting.v2.dto.response.MeetingV2GetAllMeetingByOrgUserDto; + +@ExtendWith(MockitoExtension.class) +public class MeetingV2MockServiceTest { + @InjectMocks + private MeetingV2ServiceImpl meetingV2Service; + @Mock + private UserRepository userRepository; + @Mock + private ApplyRepository applyRepository; + @Mock + private MeetingRepository meetingRepository; + @Mock + private ApplyMapper applyMapper; + + + private List applies; + + private User ownerUser; + + private User applyUser; + + private Meeting meeting; + + @BeforeEach + void init() { + List activityVOS = new ArrayList<>(); + activityVOS.add(new UserActivityVO(UserPart.SERVER.getValue(), 33)); + + ownerUser = User.builder() + .name("송민규") + .orgId(1) + .activities(activityVOS) + .phone("010-9472-6796") + .build(); + ownerUser.setUserIdForTest(1); + + applyUser = User.builder() + .name("홍길동") + .orgId(2) + .activities(activityVOS) + .phone("010-1234-5678") + .build(); + applyUser.setUserIdForTest(2); + + ImageUrlVO imageUrlVO = new ImageUrlVO(1, "www.~~"); + + meeting = Meeting.builder() + .user(ownerUser) + .userId(ownerUser.getId()) + .title("사람 구해요") + .category(MeetingCategory.STUDY) + .imageURL(List.of(imageUrlVO)) + .startDate(LocalDateTime.of(2024, Month.MARCH, 17, 0, 0)) + .endDate(LocalDateTime.of(2024, Month.MARCH, 20, 23, 59)) + .capacity(10) + .desc("열정 많은 사람 구해요") + .processDesc("이렇게 할거에여") + .mStartDate(LocalDateTime.of(2024, Month.APRIL, 1, 0, 0)) + .mEndDate(LocalDateTime.of(2030, Month.APRIL, 20, 0, 0)) + .leaderDesc("저는 이런 사람이에요.") + .targetDesc("이런 사람이 왔으면 좋겠어요") + .note("유의사항은 이거에요") + .isMentorNeeded(true) + .canJoinOnlyActiveGeneration(true) + .createdGeneration(33) + .targetActiveGeneration(33) + .joinableParts(MeetingJoinablePart.values()) + .build(); + + Apply apply = Apply.builder() + .meeting(meeting) + .meetingId(1) + .user(applyUser) + .userId(2) + .content("제 지원동기는요") + .build(); + + //meeting.addApply(apply); + apply.updateApplyStatus(EnApplyStatus.APPROVE); + + applies = new ArrayList<>(); + applies.add(apply); + } + + @Test + void 내모임조회_성공() { + // given + User user = UserFixture.createStaticUser(); + user.setUserIdForTest(3); + doReturn(Optional.of(user)).when(userRepository).findByOrgId(any()); + doReturn(applies).when(applyRepository).findAllByUserIdAndStatus(any(), any()); + + MeetingV2GetAllMeetingByOrgUserQueryDto dto = new MeetingV2GetAllMeetingByOrgUserQueryDto( + applyUser.getOrgId(), 1, 12); + + // when + MeetingV2GetAllMeetingByOrgUserDto myMeetings = meetingV2Service.getAllMeetingByOrgUser(dto); + + // then + Assertions.assertThat(myMeetings.getMeetings().get(0)) + .extracting("isMeetingLeader", "title", "category", "mStartDate", "mEndDate", "isActiveMeeting") + .containsExactly(false, meeting.getTitle(), meeting.getCategory().getValue(), meeting.getMStartDate(), + meeting.getMEndDate(), true); + } + + @Test + public void 모임신청시_정원이찼을때_예외발생() { + // given + applies = new ArrayList<>(); + for (int i = 0; i < meeting.getCapacity(); i++) { + User tempUser = User.builder() + .name("user" + i) + .orgId(2 + i) + .phone("010-0000-000" + i) + .build(); + tempUser.setUserIdForTest(3 + i); // 3부터 시작하는 userId 설정 + + Apply apply = Apply.builder() + .meeting(meeting) + .meetingId(meeting.getId()) + .user(tempUser) + .userId(tempUser.getId()) + .content("꼭 하고 싶어요" + i) + .build(); + + apply.updateApplyStatus(EnApplyStatus.APPROVE); // 승인 상태로 변경 + applies.add(apply); + } + + MeetingV2ApplyMeetingDto requestBody = new MeetingV2ApplyMeetingDto(meeting.getId(), "열심히 하겠습니다."); + + doReturn(meeting).when(meetingRepository).findByIdOrThrow(requestBody.getMeetingId()); + doReturn(applyUser).when(userRepository).findByIdOrThrow(applyUser.getId()); + doReturn(applies).when(applyRepository).findAllByMeetingId(any()); + + // when & then + BadRequestException exception = assertThrows(BadRequestException.class, () -> { + meetingV2Service.applyMeeting(requestBody, applyUser.getId()); + }); + + assertEquals(FULL_MEETING_CAPACITY.getErrorCode(), exception.getMessage()); + } + + @Test + public void 모집시작시간이전_모임지원시_예외발생() { + // given + LocalDateTime oneMinuteAfterNow = LocalDateTime.now().plusMinutes(1); + + meeting = Meeting.builder() + .user(ownerUser) + .userId(ownerUser.getId()) + .title("사람 구해요") + .category(MeetingCategory.STUDY) + .startDate(oneMinuteAfterNow) // 모집 시작 시간을 현재 시간으로부터 1분 후로 설정 + .endDate(oneMinuteAfterNow.plusDays(1)) + .capacity(10) + .desc("열정 많은 사람 구해요") + .processDesc("이렇게 할거에여") + .mStartDate(LocalDateTime.of(2028, Month.APRIL, 20, 0, 0)) + .mEndDate(LocalDateTime.of(2030, Month.APRIL, 20, 0, 0)) + .leaderDesc("저는 이런 사람이에요.") + .targetDesc("이런 사람이 왔으면 좋겠어요") + .note("유의사항은 이거에요") + .isMentorNeeded(true) + .canJoinOnlyActiveGeneration(true) + .createdGeneration(33) + .targetActiveGeneration(33) + .joinableParts(MeetingJoinablePart.values()) + .build(); + + MeetingV2ApplyMeetingDto requestBody = new MeetingV2ApplyMeetingDto(meeting.getId(), "열심히 하겠습니다."); + + doReturn(meeting).when(meetingRepository).findByIdOrThrow(requestBody.getMeetingId()); + doReturn(applyUser).when(userRepository).findByIdOrThrow(applyUser.getId()); + + // when & then + BadRequestException exception = assertThrows(BadRequestException.class, () -> { + meetingV2Service.applyMeeting(requestBody, applyUser.getId()); + }); + + assertEquals(NOT_IN_APPLY_PERIOD.getErrorCode(), exception.getMessage()); + } +} diff --git a/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceTest.java b/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceTest.java index 475c75bd..69a6da93 100644 --- a/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceTest.java +++ b/main/src/test/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceTest.java @@ -1,222 +1,268 @@ package org.sopt.makers.crew.main.meeting.v2.service; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.FULL_MEETING_CAPACITY; -import static org.sopt.makers.crew.main.common.exception.ErrorStatus.NOT_IN_APPLY_PERIOD; +import static org.sopt.makers.crew.main.global.constant.CrewConst.*; +import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import java.time.LocalDateTime; -import java.time.Month; -import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -import java.util.Optional; + import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import org.sopt.makers.crew.main.common.exception.BadRequestException; -import org.sopt.makers.crew.main.entity.apply.Apply; -import org.sopt.makers.crew.main.entity.apply.ApplyRepository; -import org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.sopt.makers.crew.main.global.annotation.IntegratedTest; 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.meeting.vo.ImageUrlVO; import org.sopt.makers.crew.main.entity.user.User; -import org.sopt.makers.crew.main.entity.user.UserFixture; import org.sopt.makers.crew.main.entity.user.UserRepository; -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.meeting.v2.dto.ApplyMapper; -import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingV2GetAllMeetingByOrgUserQueryDto; -import org.sopt.makers.crew.main.meeting.v2.dto.request.MeetingV2ApplyMeetingDto; -import org.sopt.makers.crew.main.meeting.v2.dto.response.MeetingV2GetAllMeetingByOrgUserDto; +import org.sopt.makers.crew.main.meeting.v2.dto.request.MeetingV2CreateMeetingBodyDto; +import org.sopt.makers.crew.main.meeting.v2.dto.response.MeetingV2CreateMeetingResponseDto; +import org.springframework.beans.factory.annotation.Autowired; -@ExtendWith(MockitoExtension.class) +@IntegratedTest public class MeetingV2ServiceTest { - @InjectMocks - private MeetingV2ServiceImpl meetingV2Service; - @Mock - private UserRepository userRepository; - @Mock - private ApplyRepository applyRepository; - @Mock - private MeetingRepository meetingRepository; - @Mock - private ApplyMapper applyMapper; - - - private List applies; - - private User ownerUser; - - private User applyUser; - - private Meeting meeting; - - @BeforeEach - void init() { - List activityVOS = new ArrayList<>(); - activityVOS.add(new UserActivityVO(UserPart.SERVER.getValue(), 33)); - - ownerUser = User.builder() - .name("송민규") - .orgId(1) - .activities(activityVOS) - .phone("010-9472-6796") - .build(); - ownerUser.setUserIdForTest(1); - - applyUser = User.builder() - .name("홍길동") - .orgId(2) - .activities(activityVOS) - .phone("010-1234-5678") - .build(); - applyUser.setUserIdForTest(2); - - ImageUrlVO imageUrlVO = new ImageUrlVO(1, "www.~~"); - - meeting = Meeting.builder() - .user(ownerUser) - .userId(ownerUser.getId()) - .title("사람 구해요") - .category(MeetingCategory.STUDY) - .imageURL(List.of(imageUrlVO)) - .startDate(LocalDateTime.of(2024, Month.MARCH, 17, 0, 0)) - .endDate(LocalDateTime.of(2024, Month.MARCH, 20, 23, 59)) - .capacity(10) - .desc("열정 많은 사람 구해요") - .processDesc("이렇게 할거에여") - .mStartDate(LocalDateTime.of(2024, Month.APRIL, 1, 0, 0)) - .mEndDate(LocalDateTime.of(2030, Month.APRIL, 20, 0, 0)) - .leaderDesc("저는 이런 사람이에요.") - .targetDesc("이런 사람이 왔으면 좋겠어요") - .note("유의사항은 이거에요") - .isMentorNeeded(true) - .canJoinOnlyActiveGeneration(true) - .createdGeneration(33) - .targetActiveGeneration(33) - .joinableParts(MeetingJoinablePart.values()) - .build(); - - Apply apply = Apply.builder() - .meeting(meeting) - .meetingId(1) - .user(applyUser) - .userId(2) - .content("제 지원동기는요") - .build(); - - //meeting.addApply(apply); - apply.updateApplyStatus(EnApplyStatus.APPROVE); - - applies = new ArrayList<>(); - applies.add(apply); - } - - @Test - void 내모임조회_성공() { - // given - User user = UserFixture.createStaticUser(); - user.setUserIdForTest(3); - doReturn(Optional.of(user)).when(userRepository).findByOrgId(any()); - doReturn(applies).when(applyRepository).findAllByUserIdAndStatus(any(), any()); - - MeetingV2GetAllMeetingByOrgUserQueryDto dto = new MeetingV2GetAllMeetingByOrgUserQueryDto( - applyUser.getOrgId(), 1, 12); - - // when - MeetingV2GetAllMeetingByOrgUserDto myMeetings = meetingV2Service.getAllMeetingByOrgUser(dto); - - // then - Assertions.assertThat(myMeetings.getMeetings().get(0)) - .extracting("isMeetingLeader", "title", "category", "mStartDate", "mEndDate", "isActiveMeeting") - .containsExactly(false, meeting.getTitle(), meeting.getCategory().getValue(), meeting.getMStartDate(), - meeting.getMEndDate(), true); - } - - @Test - public void 모임신청시_정원이찼을때_예외발생() { - // given - applies = new ArrayList<>(); - for (int i = 0; i < meeting.getCapacity(); i++) { - User tempUser = User.builder() - .name("user" + i) - .orgId(2 + i) - .phone("010-0000-000" + i) - .build(); - tempUser.setUserIdForTest(3 + i); // 3부터 시작하는 userId 설정 - - Apply apply = Apply.builder() - .meeting(meeting) - .meetingId(meeting.getId()) - .user(tempUser) - .userId(tempUser.getId()) - .content("꼭 하고 싶어요" + i) - .build(); - - apply.updateApplyStatus(EnApplyStatus.APPROVE); // 승인 상태로 변경 - applies.add(apply); - } - - MeetingV2ApplyMeetingDto requestBody = new MeetingV2ApplyMeetingDto(meeting.getId(), "열심히 하겠습니다."); - - doReturn(meeting).when(meetingRepository).findByIdOrThrow(requestBody.getMeetingId()); - doReturn(applyUser).when(userRepository).findByIdOrThrow(applyUser.getId()); - doReturn(applies).when(applyRepository).findAllByMeetingId(any()); - - // when & then - BadRequestException exception = assertThrows(BadRequestException.class, () -> { - meetingV2Service.applyMeeting(requestBody, applyUser.getId()); - }); - - assertEquals(FULL_MEETING_CAPACITY.getErrorCode(), exception.getMessage()); - } - - @Test - public void 모집시작시간이전_모임지원시_예외발생() { - // given - LocalDateTime oneMinuteAfterNow = LocalDateTime.now().plusMinutes(1); - - meeting = Meeting.builder() - .user(ownerUser) - .userId(ownerUser.getId()) - .title("사람 구해요") - .category(MeetingCategory.STUDY) - .startDate(oneMinuteAfterNow) // 모집 시작 시간을 현재 시간으로부터 1분 후로 설정 - .endDate(oneMinuteAfterNow.plusDays(1)) - .capacity(10) - .desc("열정 많은 사람 구해요") - .processDesc("이렇게 할거에여") - .mStartDate(LocalDateTime.of(2028, Month.APRIL, 20, 0, 0)) - .mEndDate(LocalDateTime.of(2030, Month.APRIL, 20, 0, 0)) - .leaderDesc("저는 이런 사람이에요.") - .targetDesc("이런 사람이 왔으면 좋겠어요") - .note("유의사항은 이거에요") - .isMentorNeeded(true) - .canJoinOnlyActiveGeneration(true) - .createdGeneration(33) - .targetActiveGeneration(33) - .joinableParts(MeetingJoinablePart.values()) - .build(); - - MeetingV2ApplyMeetingDto requestBody = new MeetingV2ApplyMeetingDto(meeting.getId(), "열심히 하겠습니다."); - - doReturn(meeting).when(meetingRepository).findByIdOrThrow(requestBody.getMeetingId()); - doReturn(applyUser).when(userRepository).findByIdOrThrow(applyUser.getId()); - - // when & then - BadRequestException exception = assertThrows(BadRequestException.class, () -> { - meetingV2Service.applyMeeting(requestBody, applyUser.getId()); - }); - - assertEquals(NOT_IN_APPLY_PERIOD.getErrorCode(), exception.getMessage()); - } + + @Autowired + private MeetingV2Service meetingV2Service; + + @Autowired + private MeetingRepository meetingRepository; + + @Autowired + private UserRepository userRepository; + + @Nested + class 모임_생성 { + @ParameterizedTest + @ValueSource(booleans = {true, false}) // true와 false 두 가지 경우에 대해 테스트 + @DisplayName("모임 생성 성공 시, 생성된 모임 번호가 반환된다.") + void normal_createMeeting_meetingId(boolean canJoinOnlyActiveGeneration) { + // given + User user = User.builder() + .name("홍길동") + .orgId(1) + .activities(List.of(new UserActivityVO("서버", 33), new UserActivityVO("iOS", 34))) + .profileImage("image-url1") + .phone("010-1234-5678") + .build(); + User savedUser = userRepository.save(user); + + // 모임 이미지 리스트 + List files = Arrays.asList( + "https://example.com/image1.jpg" + ); + + // 대상 파트 목록 + MeetingJoinablePart[] joinableParts = { + MeetingJoinablePart.SERVER, + MeetingJoinablePart.IOS + }; + + // DTO 생성 + MeetingV2CreateMeetingBodyDto meetingDto = new MeetingV2CreateMeetingBodyDto( + "알고보면 쓸데있는 개발 프로세스", // title + files, // files (모임 이미지 리스트) + "스터디", // category + "2024.10.01", // startDate (모집 시작 날짜) + "2024.10.15", // endDate (모집 끝 날짜) + 10, // capacity (모집 인원) + "백엔드 개발에 관심 있는 사람들을 위한 스터디입니다.", // desc (모집 정보) + "매주 온라인으로 진행되며, 발표와 토론이 포함됩니다.", // processDesc (진행 방식 소개) + "2024.10.16", // mStartDate (모임 활동 시작 날짜) + "2024.12.30", // mEndDate (모임 활동 종료 날짜) + "5년차 백엔드 개발자입니다.", // leaderDesc (개설자 소개) + "준비물은 노트북과 열정입니다.", // note (유의할 사항) + false, // isMentorNeeded (멘토 필요 여부) + canJoinOnlyActiveGeneration, // canJoinOnlyActiveGeneration (활동기수만 지원 가능 여부) + joinableParts // joinableParts (대상 파트 목록) + ); + + // when + MeetingV2CreateMeetingResponseDto responseDto = meetingV2Service.createMeeting(meetingDto, savedUser.getId()); + Meeting foundMeeting = meetingRepository.findByIdOrThrow(responseDto.getMeetingId()); + + // then + Assertions.assertThat(foundMeeting.getId()).isEqualTo(responseDto.getMeetingId()); + + Assertions.assertThat(foundMeeting) + .isNotNull() + .extracting( + "user", "userId", "title", "category", "startDate", "endDate", "capacity", "desc", + "processDesc", "mStartDate", "mEndDate", "leaderDesc", "note", "isMentorNeeded", + "canJoinOnlyActiveGeneration", "createdGeneration", "targetActiveGeneration", "joinableParts" + ) + .containsExactly( + savedUser, // user 필드 + savedUser.getId(), // userId 필드 + "알고보면 쓸데있는 개발 프로세스", // title 필드 + MeetingCategory.STUDY, // category 필드 + LocalDateTime.of(2024, 10, 1, 0, 0,0), // startDate 필드 + LocalDateTime.of(2024, 10, 15, 23, 59,59), // endDate 필드 + 10, // capacity 필드 + "백엔드 개발에 관심 있는 사람들을 위한 스터디입니다.", // desc 필드 + "매주 온라인으로 진행되며, 발표와 토론이 포함됩니다.", // processDesc 필드 + LocalDateTime.of(2024, 10, 16, 0, 0,0), // mStartDate 필드 + LocalDateTime.of(2024, 12, 30, 23, 59, 59), // mEndDate 필드 + "5년차 백엔드 개발자입니다.", // leaderDesc 필드 + "준비물은 노트북과 열정입니다.", // note 필드 + false, // isMentorNeeded 필드 + canJoinOnlyActiveGeneration, // canJoinOnlyActiveGeneration 필드 + ACTIVE_GENERATION, // createdGeneration 필드 + canJoinOnlyActiveGeneration ? ACTIVE_GENERATION : null, // targetActiveGeneration 필드 + new MeetingJoinablePart[]{MeetingJoinablePart.SERVER, MeetingJoinablePart.IOS} // joinableParts 필드 + ); + + Assertions.assertThat(foundMeeting.getImageURL()) + .hasSize(1) + .extracting("url") + .containsExactly( + "https://example.com/image1.jpg" + ); + } + + @Test + @DisplayName("모임 개설자의 활동기수 정보가 없을 경우, 예외가 발생한다.") + void userHasNotActivities_createMeeting_exception() { + // given + User user = User.builder() + .name("홍길동") + .orgId(1) + .activities(null) + .profileImage("image-url1") + .phone("010-1234-5678") + .build(); + User savedUser = userRepository.save(user); + + // 모임 이미지 리스트 + List files = Arrays.asList( + "https://makers-web-img.s3.ap-northeast-2.amazonaws.com/meeting/2023/04/12/7bd87736-b557-4b26-a0d5-9b09f1f1d7df" + ); + + // 대상 파트 목록 + MeetingJoinablePart[] joinableParts = { + MeetingJoinablePart.ANDROID, + MeetingJoinablePart.IOS + }; + + // DTO 생성 + MeetingV2CreateMeetingBodyDto meetingDto = new MeetingV2CreateMeetingBodyDto( + "알고보면 쓸데있는 개발 프로세스", // title + files, // files (모임 이미지 리스트) + "스터디", // category + "2022.10.08", // startDate (모집 시작 날짜) + "2022.10.09", // endDate (모집 끝 날짜) + 5, // capacity (모집 인원) + "api 가 터졌다고? 깃이 터졌다고?", // desc (모집 정보) + "소요 시간 : 1시간 예상", // processDesc (진행 방식 소개) + "2022.10.29", // mStartDate (모임 활동 시작 날짜) + "2022.10.30", // mEndDate (모임 활동 종료 날짜) + "안녕하세요 기획 파트 000입니다", // leaderDesc (개설자 소개) + "유의할 사항", // note (유의할 사항) + false, // isMentorNeeded (멘토 필요 여부) + false, // canJoinOnlyActiveGeneration (활동기수만 지원 가능 여부) + joinableParts // joinableParts (대상 파트 목록) + ); + + // when, then + Assertions.assertThatThrownBy(() -> meetingV2Service.createMeeting(meetingDto, savedUser.getId())) + .hasMessageContaining(VALIDATION_EXCEPTION.getErrorCode()); + } + + @Test + @DisplayName("모임 생성할 때, 대상 파트 목록이 빈값이면 예외가 발생한다.") + void isJoinalbePartsEmpty_createMeeting_exception() { + // given + User user = User.builder() + .name("홍길동") + .orgId(1) + .activities(null) + .profileImage("image-url1") + .phone("010-1234-5678") + .build(); + User savedUser = userRepository.save(user); + + // 모임 이미지 리스트 + List files = Arrays.asList( + "https://makers-web-img.s3.ap-northeast-2.amazonaws.com/meeting/2023/04/12/7bd87736-b557-4b26-a0d5-9b09f1f1d7df" + ); + + // 대상 파트 목록 + MeetingJoinablePart[] joinableParts = null; + + // DTO 생성 + MeetingV2CreateMeetingBodyDto meetingDto = new MeetingV2CreateMeetingBodyDto( + "알고보면 쓸데있는 개발 프로세스", // title + files, // files (모임 이미지 리스트) + "스터디", // category + "2022.10.08", // startDate (모집 시작 날짜) + "2022.10.09", // endDate (모집 끝 날짜) + 5, // capacity (모집 인원) + "api 가 터졌다고? 깃이 터졌다고?", // desc (모집 정보) + "소요 시간 : 1시간 예상", // processDesc (진행 방식 소개) + "2022.10.29", // mStartDate (모임 활동 시작 날짜) + "2022.10.30", // mEndDate (모임 활동 종료 날짜) + "안녕하세요 기획 파트 000입니다", // leaderDesc (개설자 소개) + "유의할 사항", // note (유의할 사항) + false, // isMentorNeeded (멘토 필요 여부) + false, // canJoinOnlyActiveGeneration (활동기수만 지원 가능 여부) + joinableParts // joinableParts (대상 파트 목록) + ); + + // when, then + Assertions.assertThatThrownBy(() -> meetingV2Service.createMeeting(meetingDto, savedUser.getId())) + .hasMessageContaining(VALIDATION_EXCEPTION.getErrorCode()); + } + + @Test + @DisplayName("모임 생성할 때, 이미지가 없을 경우 예외가 발생한다.") + void isImageFileEmpty_createMeeting_exception() { + // given + User user = User.builder() + .name("홍길동") + .orgId(1) + .activities(null) + .profileImage("image-url1") + .phone("010-1234-5678") + .build(); + User savedUser = userRepository.save(user); + + // 모임 이미지 리스트 + List files = null; + + // 대상 파트 목록 + MeetingJoinablePart[] joinableParts = { + MeetingJoinablePart.ANDROID, + MeetingJoinablePart.IOS + }; + + // DTO 생성 + MeetingV2CreateMeetingBodyDto meetingDto = new MeetingV2CreateMeetingBodyDto( + "알고보면 쓸데있는 개발 프로세스", // title + files, // files (모임 이미지 리스트) + "스터디", // category + "2022.10.08", // startDate (모집 시작 날짜) + "2022.10.09", // endDate (모집 끝 날짜) + 5, // capacity (모집 인원) + "api 가 터졌다고? 깃이 터졌다고?", // desc (모집 정보) + "소요 시간 : 1시간 예상", // processDesc (진행 방식 소개) + "2022.10.29", // mStartDate (모임 활동 시작 날짜) + "2022.10.30", // mEndDate (모임 활동 종료 날짜) + "안녕하세요 기획 파트 000입니다", // leaderDesc (개설자 소개) + "유의할 사항", // note (유의할 사항) + false, // isMentorNeeded (멘토 필요 여부) + false, // canJoinOnlyActiveGeneration (활동기수만 지원 가능 여부) + joinableParts // joinableParts (대상 파트 목록) + ); + + // when, then + Assertions.assertThatThrownBy(() -> meetingV2Service.createMeeting(meetingDto, savedUser.getId())) + .hasMessageContaining(VALIDATION_EXCEPTION.getErrorCode()); + } + } } diff --git a/main/src/test/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceTest.java b/main/src/test/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceTest.java index ac15acb6..bcdbdbf4 100644 --- a/main/src/test/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceTest.java +++ b/main/src/test/java/org/sopt/makers/crew/main/post/v2/service/PostV2ServiceTest.java @@ -14,9 +14,9 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.sopt.makers.crew.main.common.exception.BadRequestException; -import org.sopt.makers.crew.main.common.exception.ForbiddenException; -import org.sopt.makers.crew.main.common.util.Time; +import org.sopt.makers.crew.main.global.exception.BadRequestException; +import org.sopt.makers.crew.main.global.exception.ForbiddenException; +import org.sopt.makers.crew.main.global.util.Time; import org.sopt.makers.crew.main.entity.like.LikeRepository; import org.sopt.makers.crew.main.entity.meeting.Meeting; import org.sopt.makers.crew.main.entity.meeting.enums.MeetingCategory; diff --git a/main/src/test/java/org/sopt/makers/crew/main/user/v2/UserServiceTest.java b/main/src/test/java/org/sopt/makers/crew/main/user/v2/UserServiceTest.java index 548a2779..f621c756 100644 --- a/main/src/test/java/org/sopt/makers/crew/main/user/v2/UserServiceTest.java +++ b/main/src/test/java/org/sopt/makers/crew/main/user/v2/UserServiceTest.java @@ -4,18 +4,13 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.sopt.makers.crew.main.common.annotation.IntegratedTest; +import org.sopt.makers.crew.main.global.annotation.IntegratedTest; import org.sopt.makers.crew.main.entity.user.User; import org.sopt.makers.crew.main.entity.user.UserRepository; import org.sopt.makers.crew.main.entity.user.vo.UserActivityVO; import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMentionUserDto; import org.sopt.makers.crew.main.user.v2.service.UserV2Service; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.transaction.annotation.Transactional; -import org.testcontainers.junit.jupiter.Testcontainers; @IntegratedTest public class UserServiceTest { diff --git a/main/src/test/resources/sql/apply-repository-test-data.sql b/main/src/test/resources/sql/apply-repository-test-data.sql index 00c2525e..8a6a85c0 100644 --- a/main/src/test/resources/sql/apply-repository-test-data.sql +++ b/main/src/test/resources/sql/apply-repository-test-data.sql @@ -13,7 +13,7 @@ VALUES (1, '김삼순', 1001, 'profile4.jpg', '010-5555-5555'); INSERT INTO meeting (id, "userId", title, category, "imageURL", "startDate", "endDate", capacity, - "desc", "processDesc", "mStartDate", "mEndDate", "leaderDesc", "targetDesc", + "desc", "processDesc", "mStartDate", "mEndDate", "leaderDesc", note, "isMentorNeeded", "canJoinOnlyActiveGeneration", "createdGeneration", "targetActiveGeneration", "joinableParts") VALUES (1, 1, '스터디 구합니다1', '행사', @@ -21,7 +21,7 @@ VALUES (1, 1, '스터디 구합니다1', '행사', '2024-05-19 00:00:00.000000', '2024-05-24 23:59:59.000000', 10, '스터디 설명입니다.', '스터디 진행방식입니다.', '2024-05-29 00:00:00.000000', '2024-05-31 00:00:00.000000', '스터디장 설명입니다.', - '누구나 들어올 수 있어요.', '시간지키세요.', true, false, 34, 34, '{PM,DESIGN,WEB,ANDROID,IOS,SERVER}'); + '시간지키세요.', true, false, 34, 34, '{PM,DESIGN,WEB,ANDROID,IOS,SERVER}'); INSERT INTO apply (type, "meetingId", "userId", content, "appliedDate", status) VALUES (0, 1, 2, '전할말입니다1', '2024-05-19 00:00:00.913489', 1), diff --git a/main/src/test/resources/sql/post-repository-test-data.sql b/main/src/test/resources/sql/post-repository-test-data.sql index f381c0bb..9e3c83ff 100644 --- a/main/src/test/resources/sql/post-repository-test-data.sql +++ b/main/src/test/resources/sql/post-repository-test-data.sql @@ -13,7 +13,7 @@ VALUES (1, '김삼순', 1001, 'profile4.jpg', '010-5555-5555'); INSERT INTO meeting (id, "userId", title, category, "imageURL", "startDate", "endDate", capacity, - "desc", "processDesc", "mStartDate", "mEndDate", "leaderDesc", "targetDesc", + "desc", "processDesc", "mStartDate", "mEndDate", "leaderDesc", note, "isMentorNeeded", "canJoinOnlyActiveGeneration", "createdGeneration", "targetActiveGeneration", "joinableParts") VALUES (1, 1, '스터디 구합니다1', '행사', @@ -21,10 +21,10 @@ VALUES (1, 1, '스터디 구합니다1', '행사', '2024-05-19 00:00:00.000000', '2024-05-24 23:59:59.000000', 10, '스터디 설명입니다.', '스터디 진행방식입니다.', '2024-05-29 00:00:00.000000', '2024-05-31 00:00:00.000000', '스터디장 설명입니다.', - '누구나 들어올 수 있어요.', '시간지키세요.', true, false, 34, 34, '{PM,DESIGN,WEB,ANDROID,IOS,SERVER}'); + '시간지키세요.', true, false, 34, 34, '{PM,DESIGN,WEB,ANDROID,IOS,SERVER}'); INSERT INTO meeting (id, "userId", title, category, "imageURL", "startDate", "endDate", capacity, - "desc", "processDesc", "mStartDate", "mEndDate", "leaderDesc", "targetDesc", + "desc", "processDesc", "mStartDate", "mEndDate", "leaderDesc", note, "isMentorNeeded", "canJoinOnlyActiveGeneration", "createdGeneration", "targetActiveGeneration", "joinableParts") VALUES (2, 1, '스터디 구합니다2', '스터디', @@ -32,7 +32,7 @@ VALUES (2, 1, '스터디 구합니다2', '스터디', '2024-05-20 00:00:00.000000', '2024-05-25 23:59:59.000000', 10, '스터디 설명입니다.', '스터디 진행방식입니다.', '2024-05-30 00:00:00.000000', '2024-06-01 00:00:00.000000', '스터디장 설명입니다.', - '누구나 들어올 수 있어요.', '시간지키세요.', true, false, 34, 34, '{PM,DESIGN,WEB,ANDROID,IOS,SERVER}'); + '시간지키세요.', true, false, 34, 34, '{PM,DESIGN,WEB,ANDROID,IOS,SERVER}'); INSERT INTO post (id, title, contents, "createdDate", "updatedDate", "viewCount", images, "userId", "meetingId", "commentCount", "likeCount") VALUES