diff --git a/.github/workflows/someup_dev.yml b/.github/workflows/someup_dev.yml index c395e85..4ccbc27 100644 --- a/.github/workflows/someup_dev.yml +++ b/.github/workflows/someup_dev.yml @@ -31,6 +31,7 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} restore-keys: | ${{ runner.os }}-gradle- + # application-dev.yml - name: Copy dev Secret env: @@ -55,7 +56,7 @@ jobs: DEV_SECRET_DIR_FILE_NAME: application-jwt.yml run: echo $DEV_SECRET | base64 --decode >> $DEV_SECRET_DIR/$DEV_SECRET_DIR_FILE_NAME - # application-ai.yml (새로운 파일 추가) + # application-ai.yml - name: Copy ai Secret env: DEV_SECRET: ${{ secrets.APPLICATION_AI_YML }} @@ -63,6 +64,14 @@ jobs: DEV_SECRET_DIR_FILE_NAME: application-ai.yml run: echo $DEV_SECRET | base64 --decode >> $DEV_SECRET_DIR/$DEV_SECRET_DIR_FILE_NAME + # application-swagger.yml + - name: Copy swagger Secret + env: + DEV_SECRET: ${{ secrets.APPLICATION_SWAGGER_YML }} + DEV_SECRET_DIR: src/main/resources + DEV_SECRET_DIR_FILE_NAME: application-swagger.yml + run: echo $DEV_SECRET | base64 --decode >> $DEV_SECRET_DIR/$DEV_SECRET_DIR_FILE_NAME + # ./gradlew 권한 설정 - name: ./gradlew 권한 설정 run: chmod +x ./gradlew @@ -73,6 +82,8 @@ jobs: ./gradlew clean ./gradlew compileJava ./gradlew build + env: + SPRING_PROFILES_ACTIVE: dev # Docker Build하고 DockerHub에 Push - name: Docker Build & Push to DockerHub @@ -124,6 +135,7 @@ jobs: sudo docker-compose pull sudo docker-compose up -d sudo docker image prune -f + # Security Group에서 Github IP를 삭제 - name: Remove Github IP From Security Group run: | diff --git a/build.gradle b/build.gradle index c5a8771..367020b 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ dependencies { implementation platform("org.springframework.ai:spring-ai-bom:1.0.0-SNAPSHOT") implementation 'org.springframework.ai:spring-ai-vertex-ai-gemini-spring-boot-starter:1.0.0-SNAPSHOT' - //swagger + // Swagger implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' compileOnly 'org.projectlombok:lombok' diff --git a/src/main/java/project/backend/business/archive/ArchiveService.java b/src/main/java/project/backend/business/archive/ArchiveService.java new file mode 100644 index 0000000..d2cb7bf --- /dev/null +++ b/src/main/java/project/backend/business/archive/ArchiveService.java @@ -0,0 +1,59 @@ +package project.backend.business.archive; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import project.backend.business.archive.implement.ArchiveManager; +import project.backend.business.archive.implement.ArchiveReader; +import project.backend.business.archive.request.CreateUpdateArchiveServiceRequest; +import project.backend.business.archive.respone.ArchiveListResponse; +import project.backend.business.archive.respone.CreateUpdateArchiveResponse; +import project.backend.business.user.implement.UserReader; +import project.backend.entity.archive.Archive; +import project.backend.entity.user.User; + +@Slf4j +@Service +@RequiredArgsConstructor +public class ArchiveService { + + private final ArchiveManager archiveManager; + private final ArchiveReader archiveReader; + private final UserReader userReader; + + @Transactional(readOnly = true) + public ArchiveListResponse getArchives(Long userId) { + List archives = archiveReader.readActivatedArchivesByUserId(userId); + return ArchiveListResponse.from(archives); + } + + @Transactional + public CreateUpdateArchiveResponse createArchive(Long userId, + CreateUpdateArchiveServiceRequest request) { + User user = userReader.readUserById(userId); + + Archive archive = archiveManager.createArchive(user, request.getName()); + return CreateUpdateArchiveResponse.from(archive); + } + + @Transactional + public CreateUpdateArchiveResponse updateArchiveName(Long userId, Long archiveId, + CreateUpdateArchiveServiceRequest request) { + User user = userReader.readUserById(userId); + Archive archive = archiveReader.readActivatedArchiveById(archiveId); + archiveManager.checkArchiveOwner(archive, user); + + Archive updatedArchive = archiveManager.updateArchiveName(archive, request.getName()); + return CreateUpdateArchiveResponse.from(updatedArchive); + } + + @Transactional + public void deleteArchive(Long userId, Long archiveId) { + User user = userReader.readUserById(userId); + Archive archive = archiveReader.readActivatedArchiveById(archiveId); + archiveManager.checkArchiveOwner(archive, user); + archiveManager.deleteArchive(archive); + } +} diff --git a/src/main/java/project/backend/business/archive/implement/ArchiveManager.java b/src/main/java/project/backend/business/archive/implement/ArchiveManager.java new file mode 100644 index 0000000..fcebe56 --- /dev/null +++ b/src/main/java/project/backend/business/archive/implement/ArchiveManager.java @@ -0,0 +1,37 @@ +package project.backend.business.archive.implement; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import project.backend.common.error.CustomException; +import project.backend.common.error.ErrorCode; +import project.backend.entity.archive.Archive; +import project.backend.entity.user.User; +import project.backend.repository.archive.ArchiveRepository; + +@Component +@RequiredArgsConstructor +public class ArchiveManager { + + private final ArchiveRepository archiveRepository; + + public Archive createArchive(User user, String name) { + Archive newArchive = Archive.createArchive(user, name); + return archiveRepository.save(newArchive); + } + + public Archive updateArchiveName(Archive archive, String newName) { + archive.updateName(newName); + return archiveRepository.save(archive); + } + + public void checkArchiveOwner(Archive archive, User user) { + if (!archive.getUser().equals(user)) { + throw new CustomException(ErrorCode.BAD_REQUEST); + } + } + + public void deleteArchive(Archive archive) { + archive.setActivated(Boolean.FALSE); + archiveRepository.save(archive); + } +} diff --git a/src/main/java/project/backend/business/archive/implement/ArchiveReader.java b/src/main/java/project/backend/business/archive/implement/ArchiveReader.java new file mode 100644 index 0000000..1f97f3e --- /dev/null +++ b/src/main/java/project/backend/business/archive/implement/ArchiveReader.java @@ -0,0 +1,25 @@ +package project.backend.business.archive.implement; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import project.backend.common.error.CustomException; +import project.backend.common.error.ErrorCode; +import project.backend.entity.archive.Archive; +import project.backend.repository.archive.ArchiveRepository; + +@Component +@RequiredArgsConstructor +public class ArchiveReader { + + private final ArchiveRepository archiveRepository; + + public Archive readActivatedArchiveById(Long archiveId) { + return archiveRepository.findByIdAndActivatedTrue(archiveId) + .orElseThrow(() -> new CustomException(ErrorCode.BAD_REQUEST)); + } + + public List readActivatedArchivesByUserId(Long userId) { + return archiveRepository.findByUserIdAndActivatedTrue(userId); + } +} diff --git a/src/main/java/project/backend/business/archive/request/CreateUpdateArchiveServiceRequest.java b/src/main/java/project/backend/business/archive/request/CreateUpdateArchiveServiceRequest.java new file mode 100644 index 0000000..66af657 --- /dev/null +++ b/src/main/java/project/backend/business/archive/request/CreateUpdateArchiveServiceRequest.java @@ -0,0 +1,11 @@ +package project.backend.business.archive.request; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class CreateUpdateArchiveServiceRequest { + + private final String name; +} diff --git a/src/main/java/project/backend/business/archive/respone/ArchiveListResponse.java b/src/main/java/project/backend/business/archive/respone/ArchiveListResponse.java new file mode 100644 index 0000000..0804da3 --- /dev/null +++ b/src/main/java/project/backend/business/archive/respone/ArchiveListResponse.java @@ -0,0 +1,27 @@ +package project.backend.business.archive.respone; + +import java.util.List; +import lombok.Builder; +import lombok.Getter; +import project.backend.business.archive.respone.dto.ArchiveDto; +import project.backend.entity.archive.Archive; + +@Getter +@Builder +public class ArchiveListResponse { + + private final List archives; + + public static ArchiveListResponse from(List archiveList) { + List archiveDtos = archiveList.stream() + .map(archive -> ArchiveDto.builder() + .id(archive.getId()) + .name(archive.getName()) + .build()) + .toList(); + + return ArchiveListResponse.builder() + .archives(archiveDtos) + .build(); + } +} diff --git a/src/main/java/project/backend/business/archive/respone/CreateUpdateArchiveResponse.java b/src/main/java/project/backend/business/archive/respone/CreateUpdateArchiveResponse.java new file mode 100644 index 0000000..7afd0b7 --- /dev/null +++ b/src/main/java/project/backend/business/archive/respone/CreateUpdateArchiveResponse.java @@ -0,0 +1,16 @@ +package project.backend.business.archive.respone; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import project.backend.entity.archive.Archive; + +@Getter +@RequiredArgsConstructor +public class CreateUpdateArchiveResponse { + + private final Long archiveId; + + public static CreateUpdateArchiveResponse from(Archive archive) { + return new CreateUpdateArchiveResponse(archive.getId()); + } +} diff --git a/src/main/java/project/backend/business/archive/respone/dto/ArchiveDto.java b/src/main/java/project/backend/business/archive/respone/dto/ArchiveDto.java new file mode 100644 index 0000000..aa81b4d --- /dev/null +++ b/src/main/java/project/backend/business/archive/respone/dto/ArchiveDto.java @@ -0,0 +1,12 @@ +package project.backend.business.archive.respone.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class ArchiveDto { + + private final Long id; + private final String name; +} diff --git a/src/main/java/project/backend/business/auth/request/TokenServiceRequest.java b/src/main/java/project/backend/business/auth/request/TokenServiceRequest.java index 30ef701..96f6d0f 100644 --- a/src/main/java/project/backend/business/auth/request/TokenServiceRequest.java +++ b/src/main/java/project/backend/business/auth/request/TokenServiceRequest.java @@ -5,8 +5,8 @@ import lombok.Getter; @Getter -@AllArgsConstructor @Builder +@AllArgsConstructor public class TokenServiceRequest { private String accessToken; private String refreshToken; diff --git a/src/main/java/project/backend/business/memo/MemoService.java b/src/main/java/project/backend/business/memo/MemoService.java index 9483727..806d6f3 100644 --- a/src/main/java/project/backend/business/memo/MemoService.java +++ b/src/main/java/project/backend/business/memo/MemoService.java @@ -26,5 +26,4 @@ public void deleteMemo(Long userId, Long postId) { Post post = postReader.readActivatedPublishedPost(userId, postId); memoManager.deleteMemo(post); } - } diff --git a/src/main/java/project/backend/business/memo/implement/MemoManager.java b/src/main/java/project/backend/business/memo/implement/MemoManager.java index b893df3..262f84d 100644 --- a/src/main/java/project/backend/business/memo/implement/MemoManager.java +++ b/src/main/java/project/backend/business/memo/implement/MemoManager.java @@ -1,7 +1,7 @@ package project.backend.business.memo.implement; import java.time.LocalDateTime; -import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import project.backend.entity.post.Post; @@ -9,7 +9,7 @@ @Slf4j @Component -@AllArgsConstructor +@RequiredArgsConstructor public class MemoManager { private final PostRepository postRepository; diff --git a/src/main/java/project/backend/business/memo/request/CreateUpdateMemoServiceRequest.java b/src/main/java/project/backend/business/memo/request/CreateUpdateMemoServiceRequest.java index 874235a..6d1b6b7 100644 --- a/src/main/java/project/backend/business/memo/request/CreateUpdateMemoServiceRequest.java +++ b/src/main/java/project/backend/business/memo/request/CreateUpdateMemoServiceRequest.java @@ -9,5 +9,4 @@ public class CreateUpdateMemoServiceRequest { private Long postId; private String content; - } diff --git a/src/main/java/project/backend/business/post/PostService.java b/src/main/java/project/backend/business/post/PostService.java index 9d92248..347f087 100644 --- a/src/main/java/project/backend/business/post/PostService.java +++ b/src/main/java/project/backend/business/post/PostService.java @@ -16,9 +16,9 @@ import project.backend.business.post.request.PostDetailServiceRequest; import project.backend.business.post.request.PostListServiceRequest; import project.backend.business.post.response.CreateUpdatePostResponse; -import project.backend.business.post.response.PostDetailDto; +import project.backend.business.post.response.dto.PostDetailDto; import project.backend.business.post.response.PostDetailResponse; -import project.backend.business.post.response.PostListDto; +import project.backend.business.post.response.dto.PostListDto; import project.backend.business.post.response.PostListResponse; import project.backend.business.user.implement.UserReader; import project.backend.common.error.CustomException; @@ -40,7 +40,7 @@ public class PostService { private final SummaryAIManager summaryAIManager; @Transactional(readOnly = true) - public PostListResponse getPostList(Long userId, PostListServiceRequest postListServiceRequest) { + public PostListResponse getPosts(Long userId, PostListServiceRequest postListServiceRequest) { Specification spec = Specification.where(PostSpecification.getUser(userId)) .and(PostSpecification.getPublished()) diff --git a/src/main/java/project/backend/business/post/implement/PostManager.java b/src/main/java/project/backend/business/post/implement/PostManager.java index da8d4ce..c5daa8b 100644 --- a/src/main/java/project/backend/business/post/implement/PostManager.java +++ b/src/main/java/project/backend/business/post/implement/PostManager.java @@ -1,11 +1,10 @@ package project.backend.business.post.implement; -import jakarta.transaction.Transactional; import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import project.backend.business.common.DateTimeManager; -import project.backend.business.post.response.PostDetailDto; +import project.backend.business.post.response.dto.PostDetailDto; +import project.backend.business.post.util.DateTimeManager; import project.backend.business.tag.implement.TagManager; import project.backend.entity.post.Post; import project.backend.entity.post.PostStatus; @@ -49,7 +48,6 @@ public void deletePost(Post post) { postRepository.save(post); } - @Transactional public void updateSummary(Post post, String url, String summary) { post.setContent(summary); post.setUrl(url); diff --git a/src/main/java/project/backend/business/post/implement/PostReader.java b/src/main/java/project/backend/business/post/implement/PostReader.java index 116b5e6..4c60ac2 100644 --- a/src/main/java/project/backend/business/post/implement/PostReader.java +++ b/src/main/java/project/backend/business/post/implement/PostReader.java @@ -2,15 +2,15 @@ import java.util.List; import java.util.Map; -import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.PageRequest; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Component; -import project.backend.business.common.DateTimeManager; import project.backend.business.post.request.PostDetailServiceRequest; -import project.backend.business.post.response.PostDetailDto; -import project.backend.business.post.response.PostListDto; +import project.backend.business.post.response.dto.PostDetailDto; +import project.backend.business.post.response.dto.PostListDto; +import project.backend.business.post.util.DateTimeManager; import project.backend.business.tag.implement.TagReader; import project.backend.common.error.CustomException; import project.backend.common.error.ErrorCode; @@ -20,7 +20,7 @@ @Slf4j @Component -@AllArgsConstructor +@RequiredArgsConstructor public class PostReader { private final PostRepository postRepository; diff --git a/src/main/java/project/backend/business/post/response/CreateUpdatePostResponse.java b/src/main/java/project/backend/business/post/response/CreateUpdatePostResponse.java index 583f214..24b0b59 100644 --- a/src/main/java/project/backend/business/post/response/CreateUpdatePostResponse.java +++ b/src/main/java/project/backend/business/post/response/CreateUpdatePostResponse.java @@ -1,14 +1,12 @@ package project.backend.business.post.response; -import lombok.Builder; import lombok.Getter; @Getter public class CreateUpdatePostResponse { - Long postId; + private final Long postId; - @Builder public CreateUpdatePostResponse(Long postId) { this.postId = postId; } diff --git a/src/main/java/project/backend/business/post/response/PostDetailResponse.java b/src/main/java/project/backend/business/post/response/PostDetailResponse.java index 82df43e..ba1fbb6 100644 --- a/src/main/java/project/backend/business/post/response/PostDetailResponse.java +++ b/src/main/java/project/backend/business/post/response/PostDetailResponse.java @@ -1,9 +1,8 @@ package project.backend.business.post.response; import java.util.List; -import lombok.Builder; import lombok.Getter; - +import project.backend.business.post.response.dto.PostDetailDto; @Getter public class PostDetailResponse { @@ -16,7 +15,6 @@ public class PostDetailResponse { private final String memoContent; private final String memoCreatedAt; - @Builder public PostDetailResponse(PostDetailDto postDetailDto) { this.title = postDetailDto.getTitle(); this.content = postDetailDto.getContent(); diff --git a/src/main/java/project/backend/business/post/response/PostListResponse.java b/src/main/java/project/backend/business/post/response/PostListResponse.java index aa626f0..9773fd1 100644 --- a/src/main/java/project/backend/business/post/response/PostListResponse.java +++ b/src/main/java/project/backend/business/post/response/PostListResponse.java @@ -1,15 +1,14 @@ package project.backend.business.post.response; import java.util.List; -import lombok.Builder; import lombok.Getter; +import project.backend.business.post.response.dto.PostListDto; @Getter public class PostListResponse { - List postList; + private final List postList; - @Builder public PostListResponse(List postList) { this.postList = postList; } diff --git a/src/main/java/project/backend/business/post/response/PostDetailDto.java b/src/main/java/project/backend/business/post/response/dto/PostDetailDto.java similarity index 88% rename from src/main/java/project/backend/business/post/response/PostDetailDto.java rename to src/main/java/project/backend/business/post/response/dto/PostDetailDto.java index 801b490..7906014 100644 --- a/src/main/java/project/backend/business/post/response/PostDetailDto.java +++ b/src/main/java/project/backend/business/post/response/dto/PostDetailDto.java @@ -1,4 +1,4 @@ -package project.backend.business.post.response; +package project.backend.business.post.response.dto; import java.util.List; import lombok.Builder; diff --git a/src/main/java/project/backend/business/post/response/PostListDto.java b/src/main/java/project/backend/business/post/response/dto/PostListDto.java similarity index 82% rename from src/main/java/project/backend/business/post/response/PostListDto.java rename to src/main/java/project/backend/business/post/response/dto/PostListDto.java index a07aca3..ecd4d76 100644 --- a/src/main/java/project/backend/business/post/response/PostListDto.java +++ b/src/main/java/project/backend/business/post/response/dto/PostListDto.java @@ -1,4 +1,4 @@ -package project.backend.business.post.response; +package project.backend.business.post.response.dto; import java.util.List; import lombok.Builder; diff --git a/src/main/java/project/backend/business/common/DateTimeManager.java b/src/main/java/project/backend/business/post/util/DateTimeManager.java similarity index 91% rename from src/main/java/project/backend/business/common/DateTimeManager.java rename to src/main/java/project/backend/business/post/util/DateTimeManager.java index 62a4b22..690fa25 100644 --- a/src/main/java/project/backend/business/common/DateTimeManager.java +++ b/src/main/java/project/backend/business/post/util/DateTimeManager.java @@ -1,4 +1,4 @@ -package project.backend.business.common; +package project.backend.business.post.util; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; diff --git a/src/main/java/project/backend/business/tag/implement/TagManager.java b/src/main/java/project/backend/business/tag/implement/TagManager.java index 48e7ece..ab10331 100644 --- a/src/main/java/project/backend/business/tag/implement/TagManager.java +++ b/src/main/java/project/backend/business/tag/implement/TagManager.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import project.backend.entity.post.Post; import project.backend.entity.tag.PostTag; @@ -13,7 +13,7 @@ import project.backend.repository.tag.TagRepository; @Component -@AllArgsConstructor +@RequiredArgsConstructor public class TagManager { private final TagReader tagReader; diff --git a/src/main/java/project/backend/business/tag/implement/TagReader.java b/src/main/java/project/backend/business/tag/implement/TagReader.java index c633057..ea25c9d 100644 --- a/src/main/java/project/backend/business/tag/implement/TagReader.java +++ b/src/main/java/project/backend/business/tag/implement/TagReader.java @@ -3,13 +3,13 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import project.backend.entity.tag.Tag; import project.backend.repository.tag.TagRepository; @Component -@AllArgsConstructor +@RequiredArgsConstructor public class TagReader { private final TagRepository tagRepository; diff --git a/src/main/java/project/backend/business/user/UserService.java b/src/main/java/project/backend/business/user/UserService.java index 9bc4b77..9000e34 100644 --- a/src/main/java/project/backend/business/user/UserService.java +++ b/src/main/java/project/backend/business/user/UserService.java @@ -16,6 +16,10 @@ public class UserService { @Transactional(readOnly = true) public UserInfoResponse getUserInfo(Long id) { User user = userReader.readUserById(id); - return new UserInfoResponse(user.getName(), user.getEmail(), user.getProfileImageUrl()); + return UserInfoResponse.builder() + .name(user.getName()) + .email(user.getEmail()) + .profileImageUrl(user.getProfileImageUrl()) + .build(); } } diff --git a/src/main/java/project/backend/business/user/implement/UserReader.java b/src/main/java/project/backend/business/user/implement/UserReader.java index 372ee61..2e12949 100644 --- a/src/main/java/project/backend/business/user/implement/UserReader.java +++ b/src/main/java/project/backend/business/user/implement/UserReader.java @@ -1,6 +1,6 @@ package project.backend.business.user.implement; -import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import project.backend.common.error.CustomException; import project.backend.common.error.ErrorCode; @@ -8,7 +8,7 @@ import project.backend.repository.user.UserRepository; @Component -@AllArgsConstructor +@RequiredArgsConstructor public class UserReader { private final UserRepository userRepository; diff --git a/src/main/java/project/backend/business/user/response/UserInfoResponse.java b/src/main/java/project/backend/business/user/response/UserInfoResponse.java index 050b40d..f3c7fa0 100644 --- a/src/main/java/project/backend/business/user/response/UserInfoResponse.java +++ b/src/main/java/project/backend/business/user/response/UserInfoResponse.java @@ -1,10 +1,10 @@ package project.backend.business.user.response; -import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; @Getter -@AllArgsConstructor +@Builder public class UserInfoResponse { private final String name; diff --git a/src/main/java/project/backend/common/error/ErrorCode.java b/src/main/java/project/backend/common/error/ErrorCode.java index c100184..e616a5c 100644 --- a/src/main/java/project/backend/common/error/ErrorCode.java +++ b/src/main/java/project/backend/common/error/ErrorCode.java @@ -14,6 +14,7 @@ public enum ErrorCode { TOKEN_INVALID("유효하지 않은 토큰입니다.", HttpStatus.UNAUTHORIZED), ACCESS_DENIED("접근 권한이 없습니다.", HttpStatus.FORBIDDEN), NOT_EXIST_REFRESH_TOKEN("존재하지 않는 리프레시 토큰입니다.", HttpStatus.BAD_REQUEST); + private final String message; private final HttpStatus httpStatus; diff --git a/src/main/java/project/backend/entity/BaseEntity.java b/src/main/java/project/backend/entity/BaseEntity.java index 7c68e8e..003a5d7 100644 --- a/src/main/java/project/backend/entity/BaseEntity.java +++ b/src/main/java/project/backend/entity/BaseEntity.java @@ -12,8 +12,8 @@ @Getter @Setter -@MappedSuperclass // BaseEntity 를 상속한 엔티티들은 아래 필드들을 컬럼 인식 -@EntityListeners(AuditingEntityListener.class) // 자동 값 매핑 +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) public class BaseEntity { @Column diff --git a/src/main/java/project/backend/entity/archive/Archive.java b/src/main/java/project/backend/entity/archive/Archive.java index a4c39cb..cf1aed6 100644 --- a/src/main/java/project/backend/entity/archive/Archive.java +++ b/src/main/java/project/backend/entity/archive/Archive.java @@ -6,7 +6,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; import project.backend.entity.BaseEntity; -import project.backend.entity.post.Post; import project.backend.entity.user.User; @Entity @@ -14,34 +13,33 @@ @Table(name = "archive") @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Archive extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(nullable = false) - private User user; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(nullable = false) - private Post post; - - @Column(nullable = false) - private String name; - - @Builder - private Archive(User user, Post post, String name) { - this.user = user; - this.post = post; - this.name = name; - } - - public static Archive createArchive(User user, Post post, String name) { - return Archive.builder() - .user(user) - .post(post) - .name(name) - .build(); - } + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(nullable = false) + private User user; + + @Column(nullable = false) + private String name; + + @Builder + private Archive(User user, String name) { + this.user = user; + this.name = name; + } + + public static Archive createArchive(User user, String name) { + return Archive.builder() + .user(user) + .name(name) + .build(); + } + + public void updateName(String newName) { + this.name = newName; + } } diff --git a/src/main/java/project/backend/entity/post/Post.java b/src/main/java/project/backend/entity/post/Post.java index 179a4d9..dea062c 100644 --- a/src/main/java/project/backend/entity/post/Post.java +++ b/src/main/java/project/backend/entity/post/Post.java @@ -1,6 +1,9 @@ package project.backend.entity.post; import jakarta.persistence.*; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; import lombok.*; import project.backend.entity.BaseEntity; import project.backend.entity.post.converter.PostStatusConverter; @@ -8,10 +11,6 @@ import project.backend.entity.tag.PostTag; import project.backend.entity.user.User; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - @Entity @Getter @Setter @@ -19,68 +18,68 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Post extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn - private User user; - - @Column(nullable = false) - private String title; - - @Column(columnDefinition = "TEXT", nullable = false) - private String content; - - @Column(nullable = false) - @Convert(converter = PostTypeConverter.class) - private PostType type; - - @Column(nullable = false) - @Convert(converter = PostStatusConverter.class) - private PostStatus status; - - @Column(nullable = false, length = 2084) - private String url; - - @Column - private String memo; - - @Column - private LocalDateTime memoCreatedAt; - - - @OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true) - private List postTagList = new ArrayList<>(); - - @Builder - private Post(User user, String title, String content, PostStatus status, PostType type, String url, boolean activated) { - this.user = user; - this.title = title; - this.content = content; - this.type = type; - this.status = status; - this.url = url; - this.setActivated(activated); - } - - public static Post createPost(User user, String title, String content, PostStatus status, String url) { - Post post = Post.builder() - .title(title) - .content(content) - .type(PostType.PRIVATE) - .status(status) - .url(url) - .activated(true) - .build(); - - if (user != null) { - post.setUser(user); - } - - return post; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn + private User user; + + @Column(nullable = false) + private String title; + + @Column(columnDefinition = "TEXT", nullable = false) + private String content; + + @Column(nullable = false) + @Convert(converter = PostTypeConverter.class) + private PostType type; + + @Column(nullable = false) + @Convert(converter = PostStatusConverter.class) + private PostStatus status; + + @Column(nullable = false, length = 2084) + private String url; + + @Column + private String memo; + + @Column + private LocalDateTime memoCreatedAt; + + @OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true) + private List postTagList = new ArrayList<>(); + + @Builder + private Post(User user, String title, String content, PostStatus status, PostType type, + String url, boolean activated) { + this.user = user; + this.title = title; + this.content = content; + this.type = type; + this.status = status; + this.url = url; + this.setActivated(activated); + } + + public static Post createPost(User user, String title, String content, PostStatus status, + String url) { + Post post = Post.builder() + .title(title) + .content(content) + .type(PostType.PRIVATE) + .status(status) + .url(url) + .activated(true) + .build(); + + if (user != null) { + post.setUser(user); } + return post; + } } diff --git a/src/main/java/project/backend/presentation/archive/ArchiveController.java b/src/main/java/project/backend/presentation/archive/ArchiveController.java new file mode 100644 index 0000000..90db3b2 --- /dev/null +++ b/src/main/java/project/backend/presentation/archive/ArchiveController.java @@ -0,0 +1,61 @@ +package project.backend.presentation.archive; + +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import project.backend.business.archive.ArchiveService; +import project.backend.business.archive.respone.ArchiveListResponse; +import project.backend.business.archive.respone.CreateUpdateArchiveResponse; +import project.backend.presentation.archive.docs.ArchiveControllerDocs; +import project.backend.presentation.archive.request.CreateUpdateArchiveRequest; +import project.backend.security.aop.AssignCurrentUserInfo; +import project.backend.security.aop.CurrentUserInfo; + +@RestController +@RequestMapping("/archives") +@RequiredArgsConstructor +public class ArchiveController implements ArchiveControllerDocs { + + private final ArchiveService archiveService; + + @AssignCurrentUserInfo + @GetMapping + public ResponseEntity getUserArchives(CurrentUserInfo userInfo) { + ArchiveListResponse response = archiveService.getArchives(userInfo.getUserId()); + return new ResponseEntity<>(response, HttpStatus.OK); + } + + @AssignCurrentUserInfo + @PostMapping + public ResponseEntity createArchive(CurrentUserInfo userInfo, + @Valid @RequestBody CreateUpdateArchiveRequest archiveRequest) { + CreateUpdateArchiveResponse response = archiveService.createArchive( + userInfo.getUserId(), archiveRequest.toServiceRequest()); + return new ResponseEntity<>(response, HttpStatus.OK); + } + + @AssignCurrentUserInfo + @PatchMapping("/{archiveId}") + public ResponseEntity updateArchiveName(CurrentUserInfo userInfo, + @PathVariable Long archiveId, @Valid @RequestBody CreateUpdateArchiveRequest archiveRequest) { + CreateUpdateArchiveResponse response = archiveService.updateArchiveName( + userInfo.getUserId(), archiveId, archiveRequest.toServiceRequest()); + return new ResponseEntity<>(response, HttpStatus.OK); + } + + @AssignCurrentUserInfo + @DeleteMapping("/{archiveId}") + public ResponseEntity deleteArchive(CurrentUserInfo userInfo, @PathVariable Long archiveId) { + archiveService.deleteArchive(userInfo.getUserId(), archiveId); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/src/main/java/project/backend/presentation/archive/docs/ArchiveControllerDocs.java b/src/main/java/project/backend/presentation/archive/docs/ArchiveControllerDocs.java new file mode 100644 index 0000000..c53e62d --- /dev/null +++ b/src/main/java/project/backend/presentation/archive/docs/ArchiveControllerDocs.java @@ -0,0 +1,38 @@ +package project.backend.presentation.archive.docs; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import project.backend.business.archive.respone.ArchiveListResponse; +import project.backend.business.archive.respone.CreateUpdateArchiveResponse; +import project.backend.presentation.archive.request.CreateUpdateArchiveRequest; +import project.backend.security.aop.CurrentUserInfo; + +@Tag(name = "아카이브 API") +public interface ArchiveControllerDocs { + + @Operation(summary = "유저의 아카이브 목록 조회 API", description = "로그인한 유저의 모든 아카이브 목록을 조회합니다.") + @Parameter(name = "userInfo", hidden = true) + ResponseEntity getUserArchives(CurrentUserInfo userInfo); + + @Operation(summary = "아카이브 생성 API", description = "새로운 아카이브를 생성합니다.") + @Parameter(name = "userInfo", hidden = true) + ResponseEntity createArchive( + @Schema(hidden = true) CurrentUserInfo userInfo, + CreateUpdateArchiveRequest archiveRequest); + + @Operation(summary = "아카이브 이름 수정 API", description = "특정 아카이브의 이름을 수정합니다.") + @Parameter(name = "userInfo", hidden = true) + @Parameter(name = "archiveId", description = "수정할 아카이브의 ID") + ResponseEntity updateArchiveName( + @Schema(hidden = true) CurrentUserInfo userInfo, + Long archiveId, + CreateUpdateArchiveRequest archiveRequest); + + @Operation(summary = "아카이브 삭제 API", description = "특정 아카이브를 비활성화(삭제)합니다.") + @Parameter(name = "userInfo", hidden = true) + @Parameter(name = "archiveId", description = "삭제할 아카이브의 ID") + ResponseEntity deleteArchive(CurrentUserInfo userInfo, Long archiveId); +} diff --git a/src/main/java/project/backend/presentation/archive/request/CreateUpdateArchiveRequest.java b/src/main/java/project/backend/presentation/archive/request/CreateUpdateArchiveRequest.java new file mode 100644 index 0000000..bf53a87 --- /dev/null +++ b/src/main/java/project/backend/presentation/archive/request/CreateUpdateArchiveRequest.java @@ -0,0 +1,18 @@ +package project.backend.presentation.archive.request; + +import jakarta.validation.constraints.NotBlank; +import lombok.Getter; +import project.backend.business.archive.request.CreateUpdateArchiveServiceRequest; + +@Getter +public class CreateUpdateArchiveRequest { + + @NotBlank(message = "아카이브 이름은 필수 입력 값입니다.") + private String name; + + public CreateUpdateArchiveServiceRequest toServiceRequest() { + return CreateUpdateArchiveServiceRequest.builder() + .name(name) + .build(); + } +} diff --git a/src/main/java/project/backend/presentation/auth/controller/AuthController.java b/src/main/java/project/backend/presentation/auth/AuthController.java similarity index 93% rename from src/main/java/project/backend/presentation/auth/controller/AuthController.java rename to src/main/java/project/backend/presentation/auth/AuthController.java index ec74edb..3bfcd8f 100644 --- a/src/main/java/project/backend/presentation/auth/controller/AuthController.java +++ b/src/main/java/project/backend/presentation/auth/AuthController.java @@ -1,4 +1,4 @@ -package project.backend.presentation.auth.controller; +package project.backend.presentation.auth; import com.fasterxml.jackson.core.JsonProcessingException; import jakarta.servlet.http.HttpServletRequest; @@ -14,6 +14,7 @@ import project.backend.business.auth.AuthService; import project.backend.business.auth.request.TokenServiceRequest; import project.backend.business.auth.response.TokenServiceResponse; +import project.backend.presentation.auth.docs.AuthControllerDocs; import project.backend.presentation.auth.util.TokenCookieManager; import project.backend.presentation.auth.util.TokenExtractor; @@ -26,7 +27,7 @@ public class AuthController implements AuthControllerDocs { private final TokenExtractor tokenExtractor; private final TokenCookieManager tokenCookieManager; - @PostMapping("/login/kakao") + @RequestMapping("/login/kakao") public ResponseEntity loginKakao( @RequestParam(name = "code") String code, HttpServletResponse response) throws JsonProcessingException { @@ -60,6 +61,6 @@ public ResponseEntity logout( tokenCookieManager.removeRefreshTokenCookie(response); - return ResponseEntity.ok().build(); + return new ResponseEntity<>(HttpStatus.OK); } } diff --git a/src/main/java/project/backend/presentation/auth/controller/AuthControllerDocs.java b/src/main/java/project/backend/presentation/auth/docs/AuthControllerDocs.java similarity index 95% rename from src/main/java/project/backend/presentation/auth/controller/AuthControllerDocs.java rename to src/main/java/project/backend/presentation/auth/docs/AuthControllerDocs.java index 390d6aa..2ec659d 100644 --- a/src/main/java/project/backend/presentation/auth/controller/AuthControllerDocs.java +++ b/src/main/java/project/backend/presentation/auth/docs/AuthControllerDocs.java @@ -1,4 +1,4 @@ -package project.backend.presentation.auth.controller; +package project.backend.presentation.auth.docs; import com.fasterxml.jackson.core.JsonProcessingException; import io.swagger.v3.oas.annotations.Operation; diff --git a/src/main/java/project/backend/presentation/memo/controller/MemoController.java b/src/main/java/project/backend/presentation/memo/MemoController.java similarity index 93% rename from src/main/java/project/backend/presentation/memo/controller/MemoController.java rename to src/main/java/project/backend/presentation/memo/MemoController.java index 7ec37ad..9ad4ec1 100644 --- a/src/main/java/project/backend/presentation/memo/controller/MemoController.java +++ b/src/main/java/project/backend/presentation/memo/MemoController.java @@ -1,4 +1,4 @@ -package project.backend.presentation.memo.controller; +package project.backend.presentation.memo; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import project.backend.business.memo.MemoService; +import project.backend.presentation.memo.docs.MemoControllerDocs; import project.backend.presentation.memo.request.CreateUpdateMemoRequest; import project.backend.security.aop.AssignCurrentUserInfo; import project.backend.security.aop.CurrentUserInfo; @@ -35,5 +36,4 @@ public ResponseEntity deleteMemo(CurrentUserInfo userInfo, @RequestParam L memoService.deleteMemo(userInfo.getUserId(), postId); return new ResponseEntity<>(HttpStatus.OK); } - } diff --git a/src/main/java/project/backend/presentation/memo/controller/MemoControllerDocs.java b/src/main/java/project/backend/presentation/memo/docs/MemoControllerDocs.java similarity index 95% rename from src/main/java/project/backend/presentation/memo/controller/MemoControllerDocs.java rename to src/main/java/project/backend/presentation/memo/docs/MemoControllerDocs.java index 2ad7b32..4d03083 100644 --- a/src/main/java/project/backend/presentation/memo/controller/MemoControllerDocs.java +++ b/src/main/java/project/backend/presentation/memo/docs/MemoControllerDocs.java @@ -1,4 +1,4 @@ -package project.backend.presentation.memo.controller; +package project.backend.presentation.memo.docs; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; diff --git a/src/main/java/project/backend/presentation/post/controller/PostController.java b/src/main/java/project/backend/presentation/post/PostController.java similarity index 83% rename from src/main/java/project/backend/presentation/post/controller/PostController.java rename to src/main/java/project/backend/presentation/post/PostController.java index 38803bf..cc7affa 100644 --- a/src/main/java/project/backend/presentation/post/controller/PostController.java +++ b/src/main/java/project/backend/presentation/post/PostController.java @@ -1,5 +1,6 @@ -package project.backend.presentation.post.controller; +package project.backend.presentation.post; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; @@ -19,6 +20,7 @@ import project.backend.business.post.response.CreateUpdatePostResponse; import project.backend.business.post.response.PostDetailResponse; import project.backend.business.post.response.PostListResponse; +import project.backend.presentation.post.docs.PostControllerDocs; import project.backend.presentation.post.request.SummaryUrlRequest; import project.backend.presentation.post.request.UpdatePostRequest; import project.backend.security.aop.AssignCurrentUserInfo; @@ -39,22 +41,18 @@ public ResponseEntity getPosts(CurrentUserInfo userInfo, @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer archiveId, @RequestParam(required = false) String search) { - PostListServiceRequest postListServiceRequest = PostListServiceRequest.of(page, archiveId, - search); - - PostListResponse postListResponse = postService.getPostList(userInfo.getUserId(), - postListServiceRequest); - - return new ResponseEntity<>(postListResponse, HttpStatus.OK); + PostListServiceRequest postListServiceRequest = PostListServiceRequest.of(page, archiveId, search); + PostListResponse response = postService.getPosts(userInfo.getUserId(), postListServiceRequest); + return new ResponseEntity<>(response, HttpStatus.OK); } @AssignOrNullCurrentUserInfo @PostMapping public ResponseEntity createNewPost(CurrentUserInfo userInfo, - @RequestBody SummaryUrlRequest summaryUrlRequest) { - CreateUpdatePostResponse createUpdatePostResponse = postService.createNewPostDetail( + @Valid @RequestBody SummaryUrlRequest summaryUrlRequest) { + CreateUpdatePostResponse response = postService.createNewPostDetail( userInfo.getUserId(), summaryUrlRequest.toServiceRequest()); - return new ResponseEntity<>(createUpdatePostResponse, HttpStatus.CREATED); + return new ResponseEntity<>(response, HttpStatus.CREATED); } @AssignOrNullCurrentUserInfo @@ -69,10 +67,9 @@ public ResponseEntity getPostDetail(CurrentUserInfo userInfo @AssignCurrentUserInfo @PatchMapping("/{id}") public ResponseEntity updatePost(CurrentUserInfo userInfo, - @PathVariable("id") Long postId, @RequestBody UpdatePostRequest updatePostRequest) { + @PathVariable("id") Long postId, @Valid @RequestBody UpdatePostRequest updatePostRequest) { CreateUpdatePostResponse response = postService.updatePostDetail(userInfo.getUserId(), postId, updatePostRequest.toServiceRequest()); - return new ResponseEntity<>(response, HttpStatus.OK); } @@ -87,7 +84,7 @@ public ResponseEntity deletePost(CurrentUserInfo userInfo, @AssignOrNullCurrentUserInfo @PatchMapping("/{id}/summary") public ResponseEntity updateSummaryPost(CurrentUserInfo userInfo, - @PathVariable("id") Long postId, @RequestBody SummaryUrlRequest summaryUrlRequest) { + @PathVariable("id") Long postId, @Valid @RequestBody SummaryUrlRequest summaryUrlRequest) { CreateUpdatePostResponse response = postService.updateSummaryPost(userInfo.getUserId(), postId, summaryUrlRequest.toServiceRequest()); return new ResponseEntity<>(response, HttpStatus.OK); diff --git a/src/main/java/project/backend/presentation/post/controller/PostControllerDocs.java b/src/main/java/project/backend/presentation/post/docs/PostControllerDocs.java similarity index 98% rename from src/main/java/project/backend/presentation/post/controller/PostControllerDocs.java rename to src/main/java/project/backend/presentation/post/docs/PostControllerDocs.java index 663fdef..82c568c 100644 --- a/src/main/java/project/backend/presentation/post/controller/PostControllerDocs.java +++ b/src/main/java/project/backend/presentation/post/docs/PostControllerDocs.java @@ -1,4 +1,4 @@ -package project.backend.presentation.post.controller; +package project.backend.presentation.post.docs; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; diff --git a/src/main/java/project/backend/presentation/post/request/SummaryUrlRequest.java b/src/main/java/project/backend/presentation/post/request/SummaryUrlRequest.java index d95bc0a..03b3b49 100644 --- a/src/main/java/project/backend/presentation/post/request/SummaryUrlRequest.java +++ b/src/main/java/project/backend/presentation/post/request/SummaryUrlRequest.java @@ -1,6 +1,5 @@ package project.backend.presentation.post.request; -import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; @@ -16,7 +15,6 @@ public class SummaryUrlRequest { private String url; @NotNull(message = "요약 옵션은 필수 값입니다.") - @Valid private SummaryOptionRequest options; public CreatePostServiceRequest toServiceRequest() { diff --git a/src/main/java/project/backend/presentation/post/request/UpdatePostRequest.java b/src/main/java/project/backend/presentation/post/request/UpdatePostRequest.java index dea4cf7..6e4376d 100644 --- a/src/main/java/project/backend/presentation/post/request/UpdatePostRequest.java +++ b/src/main/java/project/backend/presentation/post/request/UpdatePostRequest.java @@ -3,8 +3,7 @@ import jakarta.validation.constraints.*; import java.util.List; import lombok.Getter; -import project.backend.business.post.response.PostDetailDto; - +import project.backend.business.post.response.dto.PostDetailDto; @Getter public class UpdatePostRequest { diff --git a/src/main/java/project/backend/presentation/user/controller/UserController.java b/src/main/java/project/backend/presentation/user/UserController.java similarity index 80% rename from src/main/java/project/backend/presentation/user/controller/UserController.java rename to src/main/java/project/backend/presentation/user/UserController.java index 509b935..32a0981 100644 --- a/src/main/java/project/backend/presentation/user/controller/UserController.java +++ b/src/main/java/project/backend/presentation/user/UserController.java @@ -1,12 +1,14 @@ -package project.backend.presentation.user.controller; +package project.backend.presentation.user; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import project.backend.business.user.UserService; import project.backend.business.user.response.UserInfoResponse; +import project.backend.presentation.user.docs.UserControllerDocs; import project.backend.security.aop.AssignCurrentUserInfo; import project.backend.security.aop.CurrentUserInfo; @@ -21,6 +23,6 @@ public class UserController implements UserControllerDocs { @AssignCurrentUserInfo public ResponseEntity getUserInfo(CurrentUserInfo userInfo) { UserInfoResponse response = userService.getUserInfo(userInfo.getUserId()); - return ResponseEntity.ok(response); + return new ResponseEntity<>(response, HttpStatus.OK); } } diff --git a/src/main/java/project/backend/presentation/user/controller/UserControllerDocs.java b/src/main/java/project/backend/presentation/user/docs/UserControllerDocs.java similarity index 91% rename from src/main/java/project/backend/presentation/user/controller/UserControllerDocs.java rename to src/main/java/project/backend/presentation/user/docs/UserControllerDocs.java index 77c80ab..1836343 100644 --- a/src/main/java/project/backend/presentation/user/controller/UserControllerDocs.java +++ b/src/main/java/project/backend/presentation/user/docs/UserControllerDocs.java @@ -1,4 +1,4 @@ -package project.backend.presentation.user.controller; +package project.backend.presentation.user.docs; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; diff --git a/src/main/java/project/backend/repository/archive/ArchiveRepository.java b/src/main/java/project/backend/repository/archive/ArchiveRepository.java new file mode 100644 index 0000000..7801d56 --- /dev/null +++ b/src/main/java/project/backend/repository/archive/ArchiveRepository.java @@ -0,0 +1,14 @@ +package project.backend.repository.archive; + +import java.util.List; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import project.backend.entity.archive.Archive; + +@Repository +public interface ArchiveRepository extends JpaRepository { + + List findByUserIdAndActivatedTrue(Long userId); + Optional findByIdAndActivatedTrue(Long archiveId); +} diff --git a/src/main/java/project/backend/repository/tag/PostTagRepository.java b/src/main/java/project/backend/repository/tag/PostTagRepository.java index 56337f0..7ea8732 100644 --- a/src/main/java/project/backend/repository/tag/PostTagRepository.java +++ b/src/main/java/project/backend/repository/tag/PostTagRepository.java @@ -11,8 +11,8 @@ @Repository public interface PostTagRepository extends JpaRepository { + @Modifying @Query("DELETE FROM PostTag as pt WHERE pt.post.id = :postId AND pt.tag.id IN :tagIdList") void deletePostTagByPostIdAndTagIdListIn(@Param("postId") Long postId, @Param("tagIdList") List tagIdList); - } diff --git a/src/main/java/project/backend/security/aop/AssignCurrentUserInfoAspect.java b/src/main/java/project/backend/security/aop/AssignCurrentUserInfoAspect.java index f8edcae..b010628 100644 --- a/src/main/java/project/backend/security/aop/AssignCurrentUserInfoAspect.java +++ b/src/main/java/project/backend/security/aop/AssignCurrentUserInfoAspect.java @@ -27,9 +27,8 @@ public void assignUserId(JoinPoint joinPoint) { for (int i = 0; i < args.length; i++) { Object arg = args[i]; - if (arg == null) { - log.warn("Argument at index {} is null, skipping this argument.", i); - } else { + + if (arg instanceof CurrentUserInfo) { log.info("Processing argument at index {}: {}", i, arg.getClass().getSimpleName()); getMethod(arg.getClass()).ifPresentOrElse( setUserId -> { @@ -40,6 +39,8 @@ public void assignUserId(JoinPoint joinPoint) { () -> log.warn("No setUserId method found for class: {}", arg.getClass().getSimpleName()) ); + } else { + log.info("Skipping argument at index {}: Not a CurrentUserInfo instance", i); } } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index df77a35..f59943e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,7 +1,7 @@ spring: profiles: active: - local + dev group: local-env: - local