diff --git a/api/src/main/java/org/sopt/common/ApiResponse.java b/api/src/main/java/org/sopt/api/common/ApiResponse.java similarity index 96% rename from api/src/main/java/org/sopt/common/ApiResponse.java rename to api/src/main/java/org/sopt/api/common/ApiResponse.java index 6154735..c785d3c 100644 --- a/api/src/main/java/org/sopt/common/ApiResponse.java +++ b/api/src/main/java/org/sopt/api/common/ApiResponse.java @@ -1,11 +1,11 @@ -package org.sopt.common; +package org.sopt.api.common; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; -import org.sopt.error.ErrorStatus; +import org.sopt.common.error.ErrorStatus; import org.springframework.http.ResponseEntity; @Builder(access = AccessLevel.PRIVATE) diff --git a/api/src/main/java/org/sopt/common/SuccessStatus.java b/api/src/main/java/org/sopt/api/common/SuccessStatus.java similarity index 93% rename from api/src/main/java/org/sopt/common/SuccessStatus.java rename to api/src/main/java/org/sopt/api/common/SuccessStatus.java index 15188b1..d5480f4 100644 --- a/api/src/main/java/org/sopt/common/SuccessStatus.java +++ b/api/src/main/java/org/sopt/api/common/SuccessStatus.java @@ -1,4 +1,4 @@ -package org.sopt.common; +package org.sopt.api.common; import lombok.AccessLevel; import lombok.Getter; diff --git a/api/src/main/java/org/sopt/error/GlobalExceptionHandler.java b/api/src/main/java/org/sopt/api/error/GlobalExceptionHandler.java similarity index 88% rename from api/src/main/java/org/sopt/error/GlobalExceptionHandler.java rename to api/src/main/java/org/sopt/api/error/GlobalExceptionHandler.java index 854034a..931b85c 100644 --- a/api/src/main/java/org/sopt/error/GlobalExceptionHandler.java +++ b/api/src/main/java/org/sopt/api/error/GlobalExceptionHandler.java @@ -1,7 +1,9 @@ -package org.sopt.error; +package org.sopt.api.error; import lombok.extern.slf4j.Slf4j; -import org.sopt.common.ApiResponse; +import org.sopt.api.common.ApiResponse; +import org.sopt.common.error.BusinessException; +import org.sopt.common.error.ErrorStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.annotation.ControllerAdvice; diff --git a/api/src/main/java/org/sopt/member/api/MemberApiController.java b/api/src/main/java/org/sopt/api/member/api/MemberApiController.java similarity index 82% rename from api/src/main/java/org/sopt/member/api/MemberApiController.java rename to api/src/main/java/org/sopt/api/member/api/MemberApiController.java index 0fb8372..cf6ec07 100644 --- a/api/src/main/java/org/sopt/member/api/MemberApiController.java +++ b/api/src/main/java/org/sopt/api/member/api/MemberApiController.java @@ -1,13 +1,13 @@ -package org.sopt.member.api; +package org.sopt.api.member.api; import lombok.RequiredArgsConstructor; -import org.sopt.common.ApiResponse; -import org.sopt.common.SuccessStatus; -import org.sopt.member.dto.request.MemberSaveRequest; -import org.sopt.member.dto.request.MemberUpdateRequest; -import org.sopt.member.dto.response.MemberGetResponse; -import org.sopt.member.dto.response.MemberSaveResponse; -import org.sopt.member.service.MemberService; +import org.sopt.api.common.ApiResponse; +import org.sopt.api.common.SuccessStatus; +import org.sopt.api.member.dto.request.MemberSaveRequest; +import org.sopt.api.member.dto.request.MemberUpdateRequest; +import org.sopt.api.member.dto.response.MemberGetResponse; +import org.sopt.api.member.dto.response.MemberSaveResponse; +import org.sopt.api.member.service.MemberService; import org.springframework.data.domain.Pageable; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; diff --git a/api/src/main/java/org/sopt/member/dto/request/MemberSaveRequest.java b/api/src/main/java/org/sopt/api/member/dto/request/MemberSaveRequest.java similarity index 59% rename from api/src/main/java/org/sopt/member/dto/request/MemberSaveRequest.java rename to api/src/main/java/org/sopt/api/member/dto/request/MemberSaveRequest.java index 9a4917c..b891b19 100644 --- a/api/src/main/java/org/sopt/member/dto/request/MemberSaveRequest.java +++ b/api/src/main/java/org/sopt/api/member/dto/request/MemberSaveRequest.java @@ -1,6 +1,6 @@ -package org.sopt.member.dto.request; +package org.sopt.api.member.dto.request; -import org.sopt.member.domain.Sopt; +import org.sopt.domain.member.domain.Sopt; public record MemberSaveRequest( String name, diff --git a/api/src/main/java/org/sopt/member/dto/request/MemberUpdateRequest.java b/api/src/main/java/org/sopt/api/member/dto/request/MemberUpdateRequest.java similarity index 50% rename from api/src/main/java/org/sopt/member/dto/request/MemberUpdateRequest.java rename to api/src/main/java/org/sopt/api/member/dto/request/MemberUpdateRequest.java index a4bed65..34123fd 100644 --- a/api/src/main/java/org/sopt/member/dto/request/MemberUpdateRequest.java +++ b/api/src/main/java/org/sopt/api/member/dto/request/MemberUpdateRequest.java @@ -1,6 +1,6 @@ -package org.sopt.member.dto.request; +package org.sopt.api.member.dto.request; -import org.sopt.member.domain.Part; +import org.sopt.domain.member.domain.Part; public record MemberUpdateRequest( int generation, diff --git a/api/src/main/java/org/sopt/member/dto/response/MemberGetResponse.java b/api/src/main/java/org/sopt/api/member/dto/response/MemberGetResponse.java similarity index 79% rename from api/src/main/java/org/sopt/member/dto/response/MemberGetResponse.java rename to api/src/main/java/org/sopt/api/member/dto/response/MemberGetResponse.java index d760ab5..93578fe 100644 --- a/api/src/main/java/org/sopt/member/dto/response/MemberGetResponse.java +++ b/api/src/main/java/org/sopt/api/member/dto/response/MemberGetResponse.java @@ -1,9 +1,9 @@ -package org.sopt.member.dto.response; +package org.sopt.api.member.dto.response; import lombok.AccessLevel; import lombok.Builder; -import org.sopt.member.domain.Member; -import org.sopt.member.domain.Sopt; +import org.sopt.domain.member.domain.Member; +import org.sopt.domain.member.domain.Sopt; @Builder(access = AccessLevel.PRIVATE) public record MemberGetResponse( diff --git a/api/src/main/java/org/sopt/member/dto/response/MemberSaveResponse.java b/api/src/main/java/org/sopt/api/member/dto/response/MemberSaveResponse.java similarity index 67% rename from api/src/main/java/org/sopt/member/dto/response/MemberSaveResponse.java rename to api/src/main/java/org/sopt/api/member/dto/response/MemberSaveResponse.java index 0c81327..7137d00 100644 --- a/api/src/main/java/org/sopt/member/dto/response/MemberSaveResponse.java +++ b/api/src/main/java/org/sopt/api/member/dto/response/MemberSaveResponse.java @@ -1,6 +1,6 @@ -package org.sopt.member.dto.response; +package org.sopt.api.member.dto.response; -import org.sopt.member.domain.Member; +import org.sopt.domain.member.domain.Member; public record MemberSaveResponse( Long memberId diff --git a/api/src/main/java/org/sopt/member/service/MemberService.java b/api/src/main/java/org/sopt/api/member/service/MemberService.java similarity index 76% rename from api/src/main/java/org/sopt/member/service/MemberService.java rename to api/src/main/java/org/sopt/api/member/service/MemberService.java index e885ffd..9819cb8 100644 --- a/api/src/main/java/org/sopt/member/service/MemberService.java +++ b/api/src/main/java/org/sopt/api/member/service/MemberService.java @@ -1,22 +1,22 @@ -package org.sopt.member.service; +package org.sopt.api.member.service; import lombok.RequiredArgsConstructor; -import org.sopt.error.ConflictException; -import org.sopt.error.ErrorStatus; -import org.sopt.member.domain.Member; -import org.sopt.member.domain.Sopt; -import org.sopt.member.dto.request.MemberSaveRequest; -import org.sopt.member.dto.request.MemberUpdateRequest; -import org.sopt.member.dto.response.MemberGetResponse; -import org.sopt.member.dto.response.MemberSaveResponse; -import org.sopt.member.repository.MemberRepository; +import org.sopt.common.error.ConflictException; +import org.sopt.common.error.ErrorStatus; +import org.sopt.domain.member.domain.Member; +import org.sopt.domain.member.domain.Sopt; +import org.sopt.api.member.dto.request.MemberSaveRequest; +import org.sopt.api.member.dto.request.MemberUpdateRequest; +import org.sopt.api.member.dto.response.MemberGetResponse; +import org.sopt.api.member.dto.response.MemberSaveResponse; +import org.sopt.domain.member.repository.MemberRepository; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; -import static org.sopt.member.domain.Member.createMember; +import static org.sopt.domain.member.domain.Member.createMember; @RequiredArgsConstructor @Transactional(readOnly = true) diff --git a/api/src/main/java/org/sopt/post/api/PostApiController.java b/api/src/main/java/org/sopt/api/post/api/PostApiController.java similarity index 86% rename from api/src/main/java/org/sopt/post/api/PostApiController.java rename to api/src/main/java/org/sopt/api/post/api/PostApiController.java index c784a45..c822e41 100644 --- a/api/src/main/java/org/sopt/post/api/PostApiController.java +++ b/api/src/main/java/org/sopt/api/post/api/PostApiController.java @@ -1,12 +1,12 @@ -package org.sopt.post.api; +package org.sopt.api.post.api; import lombok.RequiredArgsConstructor; -import org.sopt.common.ApiResponse; -import org.sopt.common.SuccessStatus; -import org.sopt.post.dto.request.PostSaveOrUpdateRequest; -import org.sopt.post.dto.response.PostGetResponse; -import org.sopt.post.dto.response.PostSaveResponse; -import org.sopt.post.service.PostService; +import org.sopt.api.common.ApiResponse; +import org.sopt.api.common.SuccessStatus; +import org.sopt.api.post.dto.request.PostSaveOrUpdateRequest; +import org.sopt.api.post.dto.response.PostGetResponse; +import org.sopt.api.post.dto.response.PostSaveResponse; +import org.sopt.api.post.service.PostService; import org.springframework.data.domain.Pageable; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; diff --git a/api/src/main/java/org/sopt/post/dto/request/PostSaveOrUpdateRequest.java b/api/src/main/java/org/sopt/api/post/dto/request/PostSaveOrUpdateRequest.java similarity index 76% rename from api/src/main/java/org/sopt/post/dto/request/PostSaveOrUpdateRequest.java rename to api/src/main/java/org/sopt/api/post/dto/request/PostSaveOrUpdateRequest.java index f35e65f..e0c8474 100644 --- a/api/src/main/java/org/sopt/post/dto/request/PostSaveOrUpdateRequest.java +++ b/api/src/main/java/org/sopt/api/post/dto/request/PostSaveOrUpdateRequest.java @@ -1,4 +1,4 @@ -package org.sopt.post.dto.request; +package org.sopt.api.post.dto.request; public record PostSaveOrUpdateRequest( String title, diff --git a/api/src/main/java/org/sopt/post/dto/response/PostGetResponse.java b/api/src/main/java/org/sopt/api/post/dto/response/PostGetResponse.java similarity index 80% rename from api/src/main/java/org/sopt/post/dto/response/PostGetResponse.java rename to api/src/main/java/org/sopt/api/post/dto/response/PostGetResponse.java index 9661b7d..4263163 100644 --- a/api/src/main/java/org/sopt/post/dto/response/PostGetResponse.java +++ b/api/src/main/java/org/sopt/api/post/dto/response/PostGetResponse.java @@ -1,9 +1,9 @@ -package org.sopt.post.dto.response; +package org.sopt.api.post.dto.response; import lombok.AccessLevel; import lombok.Builder; -import org.sopt.post.domain.Category; -import org.sopt.post.domain.Post; +import org.sopt.domain.post.domain.Category; +import org.sopt.domain.post.domain.Post; @Builder(access = AccessLevel.PRIVATE) public record PostGetResponse( diff --git a/api/src/main/java/org/sopt/post/dto/response/PostSaveResponse.java b/api/src/main/java/org/sopt/api/post/dto/response/PostSaveResponse.java similarity index 67% rename from api/src/main/java/org/sopt/post/dto/response/PostSaveResponse.java rename to api/src/main/java/org/sopt/api/post/dto/response/PostSaveResponse.java index 2c3a9bc..b389831 100644 --- a/api/src/main/java/org/sopt/post/dto/response/PostSaveResponse.java +++ b/api/src/main/java/org/sopt/api/post/dto/response/PostSaveResponse.java @@ -1,6 +1,6 @@ -package org.sopt.post.dto.response; +package org.sopt.api.post.dto.response; -import org.sopt.post.domain.Post; +import org.sopt.domain.post.domain.Post; public record PostSaveResponse( Long postId diff --git a/api/src/main/java/org/sopt/post/service/PostService.java b/api/src/main/java/org/sopt/api/post/service/PostService.java similarity index 67% rename from api/src/main/java/org/sopt/post/service/PostService.java rename to api/src/main/java/org/sopt/api/post/service/PostService.java index a0f1872..a44940f 100644 --- a/api/src/main/java/org/sopt/post/service/PostService.java +++ b/api/src/main/java/org/sopt/api/post/service/PostService.java @@ -1,21 +1,27 @@ -package org.sopt.post.service; +package org.sopt.api.post.service; import lombok.RequiredArgsConstructor; -import org.sopt.member.domain.Member; -import org.sopt.member.repository.MemberRepository; -import org.sopt.post.domain.Category; -import org.sopt.post.domain.Post; -import org.sopt.post.dto.request.PostSaveOrUpdateRequest; -import org.sopt.post.dto.response.PostGetResponse; -import org.sopt.post.dto.response.PostSaveResponse; -import org.sopt.post.repository.CategoryRepository; -import org.sopt.post.repository.PostRepository; +import org.sopt.common.error.ConflictException; +import org.sopt.common.error.ErrorStatus; +import org.sopt.domain.member.domain.Member; +import org.sopt.domain.member.repository.MemberRepository; +import org.sopt.domain.post.domain.Category; +import org.sopt.domain.post.domain.Post; +import org.sopt.api.post.dto.request.PostSaveOrUpdateRequest; +import org.sopt.api.post.dto.response.PostGetResponse; +import org.sopt.api.post.dto.response.PostSaveResponse; + +import org.sopt.domain.post.repository.CategoryRepository; +import org.sopt.domain.post.repository.PostRepository; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; +import static org.sopt.domain.post.domain.Category.createCategory; +import static org.sopt.domain.post.domain.Post.createPost; + @RequiredArgsConstructor @Transactional(readOnly = true) @Service @@ -27,6 +33,7 @@ public class PostService { @Transactional public PostSaveResponse savePost(Long memberId, PostSaveOrUpdateRequest postSaveOrUpdateRequest) { Member findMember = findMember(memberId); + validateDuplicateCategory(postSaveOrUpdateRequest.categoryContent()); Category savedCategory = createCategoryAndGetSavedCategory(postSaveOrUpdateRequest); Post savedPost = createPostAndGetSavedPost(postSaveOrUpdateRequest, findMember, savedCategory); return PostSaveResponse.of(savedPost); @@ -60,13 +67,19 @@ private Member findMember(Long memberId) { return memberRepository.findByIdOrThrow(memberId); } + private void validateDuplicateCategory(String content) { + if (categoryRepository.existsByContent(content)) { + throw new ConflictException(ErrorStatus.DUPLICATE_CATEGORY); + } + } + private Category createCategoryAndGetSavedCategory(PostSaveOrUpdateRequest postSaveOrUpdateRequest) { - Category category = Category.createCategory(postSaveOrUpdateRequest.categoryContent()); + Category category = createCategory(postSaveOrUpdateRequest.categoryContent()); return categoryRepository.save(category); } private Post createPostAndGetSavedPost(PostSaveOrUpdateRequest postSaveOrUpdateRequest, Member member, Category category) { - Post post = Post.createPost(postSaveOrUpdateRequest.title(), postSaveOrUpdateRequest.postContent(), category, member); + Post post = createPost(postSaveOrUpdateRequest.title(), postSaveOrUpdateRequest.postContent(), category, member); return postRepository.save(post); } diff --git a/build.gradle b/build.gradle index 039b00d..6803218 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,11 @@ subprojects { useJUnitPlatform() } - jar { + bootJar { enabled = false } + + jar { + enabled = true + } } \ No newline at end of file diff --git a/common/src/main/java/org/sopt/error/BusinessException.java b/common/src/main/java/org/sopt/common/error/BusinessException.java similarity index 90% rename from common/src/main/java/org/sopt/error/BusinessException.java rename to common/src/main/java/org/sopt/common/error/BusinessException.java index 770e4a8..0f2da61 100644 --- a/common/src/main/java/org/sopt/error/BusinessException.java +++ b/common/src/main/java/org/sopt/common/error/BusinessException.java @@ -1,4 +1,4 @@ -package org.sopt.error; +package org.sopt.common.error; import lombok.Getter; diff --git a/common/src/main/java/org/sopt/error/ConflictException.java b/common/src/main/java/org/sopt/common/error/ConflictException.java similarity index 88% rename from common/src/main/java/org/sopt/error/ConflictException.java rename to common/src/main/java/org/sopt/common/error/ConflictException.java index 964e6b1..274160c 100644 --- a/common/src/main/java/org/sopt/error/ConflictException.java +++ b/common/src/main/java/org/sopt/common/error/ConflictException.java @@ -1,4 +1,4 @@ -package org.sopt.error; +package org.sopt.common.error; public class ConflictException extends BusinessException { public ConflictException() { diff --git a/common/src/main/java/org/sopt/error/EntityNotFoundException.java b/common/src/main/java/org/sopt/common/error/EntityNotFoundException.java similarity index 89% rename from common/src/main/java/org/sopt/error/EntityNotFoundException.java rename to common/src/main/java/org/sopt/common/error/EntityNotFoundException.java index 9793f50..5f11799 100644 --- a/common/src/main/java/org/sopt/error/EntityNotFoundException.java +++ b/common/src/main/java/org/sopt/common/error/EntityNotFoundException.java @@ -1,4 +1,4 @@ -package org.sopt.error; +package org.sopt.common.error; public class EntityNotFoundException extends BusinessException { public EntityNotFoundException() { diff --git a/common/src/main/java/org/sopt/error/ErrorStatus.java b/common/src/main/java/org/sopt/common/error/ErrorStatus.java similarity index 90% rename from common/src/main/java/org/sopt/error/ErrorStatus.java rename to common/src/main/java/org/sopt/common/error/ErrorStatus.java index 37083ff..56fa0ac 100644 --- a/common/src/main/java/org/sopt/error/ErrorStatus.java +++ b/common/src/main/java/org/sopt/common/error/ErrorStatus.java @@ -1,4 +1,4 @@ -package org.sopt.error; +package org.sopt.common.error; import lombok.AccessLevel; import lombok.Getter; @@ -30,6 +30,7 @@ public enum ErrorStatus { */ CONFLICT(HttpStatus.CONFLICT, "이미 존재하는 리소스입니다."), DUPLICATE_MEMBER(HttpStatus.CONFLICT, "이미 존재하는 회원입니다."), + DUPLICATE_CATEGORY(HttpStatus.CONFLICT, "이미 존재하는 카테고리입니다."), /** * 500 Internal Server Error diff --git a/common/src/main/java/org/sopt/error/InvalidValueException.java b/common/src/main/java/org/sopt/common/error/InvalidValueException.java similarity index 88% rename from common/src/main/java/org/sopt/error/InvalidValueException.java rename to common/src/main/java/org/sopt/common/error/InvalidValueException.java index ecc8b88..ec7a515 100644 --- a/common/src/main/java/org/sopt/error/InvalidValueException.java +++ b/common/src/main/java/org/sopt/common/error/InvalidValueException.java @@ -1,4 +1,4 @@ -package org.sopt.error; +package org.sopt.common.error; public class InvalidValueException extends BusinessException { public InvalidValueException() { diff --git a/domain/src/main/java/org/sopt/common/BaseTimeEntity.java b/domain/src/main/java/org/sopt/domain/common/BaseTimeEntity.java similarity index 95% rename from domain/src/main/java/org/sopt/common/BaseTimeEntity.java rename to domain/src/main/java/org/sopt/domain/common/BaseTimeEntity.java index 8e5797a..1a8475f 100644 --- a/domain/src/main/java/org/sopt/common/BaseTimeEntity.java +++ b/domain/src/main/java/org/sopt/domain/common/BaseTimeEntity.java @@ -1,4 +1,4 @@ -package org.sopt.common; +package org.sopt.domain.common; import jakarta.persistence.Column; import jakarta.persistence.EntityListeners; diff --git a/domain/src/main/java/org/sopt/config/JpaConfig.java b/domain/src/main/java/org/sopt/domain/config/JpaConfig.java similarity index 86% rename from domain/src/main/java/org/sopt/config/JpaConfig.java rename to domain/src/main/java/org/sopt/domain/config/JpaConfig.java index e0ea3c1..69facbd 100644 --- a/domain/src/main/java/org/sopt/config/JpaConfig.java +++ b/domain/src/main/java/org/sopt/domain/config/JpaConfig.java @@ -1,4 +1,4 @@ -package org.sopt.config; +package org.sopt.domain.config; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; diff --git a/domain/src/main/java/org/sopt/member/domain/Member.java b/domain/src/main/java/org/sopt/domain/member/domain/Member.java similarity index 90% rename from domain/src/main/java/org/sopt/member/domain/Member.java rename to domain/src/main/java/org/sopt/domain/member/domain/Member.java index a645dcd..e2d767c 100644 --- a/domain/src/main/java/org/sopt/member/domain/Member.java +++ b/domain/src/main/java/org/sopt/domain/member/domain/Member.java @@ -1,10 +1,10 @@ -package org.sopt.member.domain; +package org.sopt.domain.member.domain; import jakarta.persistence.*; import lombok.*; import org.hibernate.annotations.DynamicUpdate; -import org.sopt.common.BaseTimeEntity; -import org.sopt.post.domain.Post; +import org.sopt.domain.common.BaseTimeEntity; +import org.sopt.domain.post.domain.Post; import java.util.ArrayList; import java.util.List; diff --git a/domain/src/main/java/org/sopt/member/domain/Part.java b/domain/src/main/java/org/sopt/domain/member/domain/Part.java similarity index 88% rename from domain/src/main/java/org/sopt/member/domain/Part.java rename to domain/src/main/java/org/sopt/domain/member/domain/Part.java index fbec7c5..9ad1a88 100644 --- a/domain/src/main/java/org/sopt/member/domain/Part.java +++ b/domain/src/main/java/org/sopt/domain/member/domain/Part.java @@ -1,4 +1,4 @@ -package org.sopt.member.domain; +package org.sopt.domain.member.domain; import lombok.AccessLevel; import lombok.Getter; diff --git a/domain/src/main/java/org/sopt/member/domain/Sopt.java b/domain/src/main/java/org/sopt/domain/member/domain/Sopt.java similarity index 93% rename from domain/src/main/java/org/sopt/member/domain/Sopt.java rename to domain/src/main/java/org/sopt/domain/member/domain/Sopt.java index c737f01..385afc1 100644 --- a/domain/src/main/java/org/sopt/member/domain/Sopt.java +++ b/domain/src/main/java/org/sopt/domain/member/domain/Sopt.java @@ -1,4 +1,4 @@ -package org.sopt.member.domain; +package org.sopt.domain.member.domain; import jakarta.persistence.Embeddable; import jakarta.persistence.EnumType; diff --git a/domain/src/main/java/org/sopt/member/repository/MemberRepository.java b/domain/src/main/java/org/sopt/domain/member/repository/MemberRepository.java similarity index 66% rename from domain/src/main/java/org/sopt/member/repository/MemberRepository.java rename to domain/src/main/java/org/sopt/domain/member/repository/MemberRepository.java index e727293..551173c 100644 --- a/domain/src/main/java/org/sopt/member/repository/MemberRepository.java +++ b/domain/src/main/java/org/sopt/domain/member/repository/MemberRepository.java @@ -1,8 +1,8 @@ -package org.sopt.member.repository; +package org.sopt.domain.member.repository; -import org.sopt.error.EntityNotFoundException; -import org.sopt.error.ErrorStatus; -import org.sopt.member.domain.Member; +import org.sopt.common.error.EntityNotFoundException; +import org.sopt.common.error.ErrorStatus; +import org.sopt.domain.member.domain.Member; import org.springframework.data.jpa.repository.JpaRepository; public interface MemberRepository extends JpaRepository { diff --git a/domain/src/main/java/org/sopt/post/domain/Category.java b/domain/src/main/java/org/sopt/domain/post/domain/Category.java similarity index 83% rename from domain/src/main/java/org/sopt/post/domain/Category.java rename to domain/src/main/java/org/sopt/domain/post/domain/Category.java index 65d2668..a0c537e 100644 --- a/domain/src/main/java/org/sopt/post/domain/Category.java +++ b/domain/src/main/java/org/sopt/domain/post/domain/Category.java @@ -1,8 +1,8 @@ -package org.sopt.post.domain; +package org.sopt.domain.post.domain; import jakarta.persistence.*; import lombok.*; -import org.sopt.common.BaseTimeEntity; +import org.sopt.domain.common.BaseTimeEntity; import java.util.ArrayList; import java.util.List; @@ -14,11 +14,11 @@ @Entity public class Category extends BaseTimeEntity { @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "category_id") private Short id; private String content; - @OneToMany + @OneToMany(mappedBy = "category") @Builder.Default private List posts = new ArrayList<>(); diff --git a/domain/src/main/java/org/sopt/post/domain/Post.java b/domain/src/main/java/org/sopt/domain/post/domain/Post.java similarity index 92% rename from domain/src/main/java/org/sopt/post/domain/Post.java rename to domain/src/main/java/org/sopt/domain/post/domain/Post.java index c8ffbff..169c184 100644 --- a/domain/src/main/java/org/sopt/post/domain/Post.java +++ b/domain/src/main/java/org/sopt/domain/post/domain/Post.java @@ -1,9 +1,9 @@ -package org.sopt.post.domain; +package org.sopt.domain.post.domain; import jakarta.persistence.*; import lombok.*; -import org.sopt.common.BaseTimeEntity; -import org.sopt.member.domain.Member; +import org.sopt.domain.common.BaseTimeEntity; +import org.sopt.domain.member.domain.Member; @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) diff --git a/domain/src/main/java/org/sopt/post/repository/CategoryRepository.java b/domain/src/main/java/org/sopt/domain/post/repository/CategoryRepository.java similarity index 52% rename from domain/src/main/java/org/sopt/post/repository/CategoryRepository.java rename to domain/src/main/java/org/sopt/domain/post/repository/CategoryRepository.java index 906e5c8..0909379 100644 --- a/domain/src/main/java/org/sopt/post/repository/CategoryRepository.java +++ b/domain/src/main/java/org/sopt/domain/post/repository/CategoryRepository.java @@ -1,7 +1,8 @@ -package org.sopt.post.repository; +package org.sopt.domain.post.repository; -import org.sopt.post.domain.Category; +import org.sopt.domain.post.domain.Category; import org.springframework.data.jpa.repository.JpaRepository; public interface CategoryRepository extends JpaRepository { + boolean existsByContent(String content); } diff --git a/domain/src/main/java/org/sopt/post/repository/PostRepository.java b/domain/src/main/java/org/sopt/domain/post/repository/PostRepository.java similarity index 72% rename from domain/src/main/java/org/sopt/post/repository/PostRepository.java rename to domain/src/main/java/org/sopt/domain/post/repository/PostRepository.java index c753f8b..5e442db 100644 --- a/domain/src/main/java/org/sopt/post/repository/PostRepository.java +++ b/domain/src/main/java/org/sopt/domain/post/repository/PostRepository.java @@ -1,8 +1,8 @@ -package org.sopt.post.repository; +package org.sopt.domain.post.repository; -import org.sopt.error.EntityNotFoundException; -import org.sopt.error.ErrorStatus; -import org.sopt.post.domain.Post; +import org.sopt.common.error.EntityNotFoundException; +import org.sopt.common.error.ErrorStatus; +import org.sopt.domain.post.domain.Post; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository;