diff --git a/src/main/java/com/example/FixLog/common/exception/CustomException.java b/src/main/java/com/example/FixLog/common/exception/CustomException.java new file mode 100644 index 0000000..c9ad1c6 --- /dev/null +++ b/src/main/java/com/example/FixLog/common/exception/CustomException.java @@ -0,0 +1,19 @@ +package com.example.FixLog.common.exception; + +import com.example.FixLog.common.response.ErrorStatus; +import lombok.Getter; + +@Getter +public class CustomException extends RuntimeException { + private final ErrorStatus errorCode; + + public CustomException(ErrorStatus errorCode) { + super(errorCode.getMessage()); + this.errorCode = errorCode; + } + + public CustomException(ErrorStatus errorCode, String detailMessage) { + super(detailMessage); + this.errorCode = errorCode; + } +} diff --git a/src/main/java/com/example/FixLog/exception/GlobalExceptionHandler.java b/src/main/java/com/example/FixLog/common/exception/GlobalExceptionHandler.java similarity index 77% rename from src/main/java/com/example/FixLog/exception/GlobalExceptionHandler.java rename to src/main/java/com/example/FixLog/common/exception/GlobalExceptionHandler.java index af2110e..5dbe986 100644 --- a/src/main/java/com/example/FixLog/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/example/FixLog/common/exception/GlobalExceptionHandler.java @@ -1,6 +1,6 @@ -package com.example.FixLog.exception; +package com.example.FixLog.common.exception; -import com.example.FixLog.dto.Response; +import com.example.FixLog.common.response.ErrorStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; @@ -9,7 +9,7 @@ public class GlobalExceptionHandler { @ExceptionHandler(CustomException.class) protected ResponseEntity> handleDuplicateException(CustomException ex) { - ErrorCode errorCode = ex.getErrorCode(); + ErrorStatus errorCode = ex.getErrorCode(); ex.printStackTrace(); return new ResponseEntity(Response.fail(errorCode.getMessage()), errorCode.getStatus()); diff --git a/src/main/java/com/example/FixLog/dto/Response.java b/src/main/java/com/example/FixLog/common/exception/Response.java similarity index 94% rename from src/main/java/com/example/FixLog/dto/Response.java rename to src/main/java/com/example/FixLog/common/exception/Response.java index 6c93365..7d2747a 100644 --- a/src/main/java/com/example/FixLog/dto/Response.java +++ b/src/main/java/com/example/FixLog/common/exception/Response.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto; +package com.example.FixLog.common.exception; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/exception/ErrorCode.java b/src/main/java/com/example/FixLog/common/response/ErrorStatus.java similarity index 97% rename from src/main/java/com/example/FixLog/exception/ErrorCode.java rename to src/main/java/com/example/FixLog/common/response/ErrorStatus.java index 9e64cb0..0dcd118 100644 --- a/src/main/java/com/example/FixLog/exception/ErrorCode.java +++ b/src/main/java/com/example/FixLog/common/response/ErrorStatus.java @@ -1,4 +1,4 @@ -package com.example.FixLog.exception; +package com.example.FixLog.common.response; import lombok.AllArgsConstructor; import lombok.Getter; @@ -6,7 +6,7 @@ @Getter @AllArgsConstructor -public enum ErrorCode { +public enum ErrorStatus { USER_NICKNAME_NOT_FOUND(HttpStatus.NOT_FOUND,"존재하지 않는 사용자 아이디입니다."), USER_EMAIL_NOT_FOUND(HttpStatus.NOT_FOUND, "회원 이메일을 찾을 수 없습니다."), USER_DELETED(HttpStatus.FORBIDDEN, "탈퇴한 회원입니다."), diff --git a/src/main/java/com/example/FixLog/util/DefaultImage.java b/src/main/java/com/example/FixLog/common/util/DefaultImage.java similarity index 79% rename from src/main/java/com/example/FixLog/util/DefaultImage.java rename to src/main/java/com/example/FixLog/common/util/DefaultImage.java index 6300eef..f453f77 100644 --- a/src/main/java/com/example/FixLog/util/DefaultImage.java +++ b/src/main/java/com/example/FixLog/common/util/DefaultImage.java @@ -1,4 +1,4 @@ -package com.example.FixLog.util; +package com.example.FixLog.common.util; public class DefaultImage { public static final String PROFILE = "https://fixlogsmwubucket.s3.ap-northeast-2.amazonaws.com/default/DefaultImage.png"; diff --git a/src/main/java/com/example/FixLog/util/DefaultText.java b/src/main/java/com/example/FixLog/common/util/DefaultText.java similarity index 74% rename from src/main/java/com/example/FixLog/util/DefaultText.java rename to src/main/java/com/example/FixLog/common/util/DefaultText.java index defd0a6..4aa6ec3 100644 --- a/src/main/java/com/example/FixLog/util/DefaultText.java +++ b/src/main/java/com/example/FixLog/common/util/DefaultText.java @@ -1,4 +1,4 @@ -package com.example.FixLog.util; +package com.example.FixLog.common.util; public class DefaultText { public static final String BIO = "오늘도 에러 없는 하루 보내세요!"; diff --git a/src/main/java/com/example/FixLog/util/JwtUtil.java b/src/main/java/com/example/FixLog/common/util/JwtUtil.java similarity index 97% rename from src/main/java/com/example/FixLog/util/JwtUtil.java rename to src/main/java/com/example/FixLog/common/util/JwtUtil.java index 615c732..370d703 100644 --- a/src/main/java/com/example/FixLog/util/JwtUtil.java +++ b/src/main/java/com/example/FixLog/common/util/JwtUtil.java @@ -1,4 +1,4 @@ -package com.example.FixLog.util; +package com.example.FixLog.common.util; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; diff --git a/src/main/java/com/example/FixLog/config/JwtAuthenticationFilter.java b/src/main/java/com/example/FixLog/config/JwtAuthenticationFilter.java index bfded26..a5dbef9 100644 --- a/src/main/java/com/example/FixLog/config/JwtAuthenticationFilter.java +++ b/src/main/java/com/example/FixLog/config/JwtAuthenticationFilter.java @@ -1,9 +1,9 @@ package com.example.FixLog.config; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.exception.CustomException; -import com.example.FixLog.repository.MemberRepository; -import com.example.FixLog.util.JwtUtil; +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.common.exception.CustomException; +import com.example.FixLog.domain.member.repository.MemberRepository; +import com.example.FixLog.common.util.JwtUtil; import java.io.IOException; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; @@ -14,7 +14,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.util.StringUtils; import org.springframework.web.filter.OncePerRequestFilter; -import com.example.FixLog.exception.ErrorCode; +import com.example.FixLog.common.response.ErrorStatus; public class JwtAuthenticationFilter extends OncePerRequestFilter { @@ -37,7 +37,7 @@ protected void doFilterInternal(HttpServletRequest request, if (token != null && jwtUtil.isTokenValid(token)) { String email = jwtUtil.getEmailFromToken(token); Member member = memberRepository.findByEmail(email) - .orElseThrow(() -> new CustomException(ErrorCode.USER_NICKNAME_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_NICKNAME_NOT_FOUND)); Authentication auth = new UsernamePasswordAuthenticationToken(member, null, member.getAuthorities()); SecurityContextHolder.getContext().setAuthentication(auth); diff --git a/src/main/java/com/example/FixLog/config/SecurityConfig.java b/src/main/java/com/example/FixLog/config/SecurityConfig.java index 8509595..16273af 100644 --- a/src/main/java/com/example/FixLog/config/SecurityConfig.java +++ b/src/main/java/com/example/FixLog/config/SecurityConfig.java @@ -1,7 +1,7 @@ package com.example.FixLog.config; -import com.example.FixLog.repository.MemberRepository; -import com.example.FixLog.util.JwtUtil; +import com.example.FixLog.domain.member.repository.MemberRepository; +import com.example.FixLog.common.util.JwtUtil; import jakarta.servlet.Filter; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/com/example/FixLog/controller/BookmarkFolderController.java b/src/main/java/com/example/FixLog/domain/bookmark/BookmarkFolderController.java similarity index 84% rename from src/main/java/com/example/FixLog/controller/BookmarkFolderController.java rename to src/main/java/com/example/FixLog/domain/bookmark/BookmarkFolderController.java index 73321d5..d61497c 100644 --- a/src/main/java/com/example/FixLog/controller/BookmarkFolderController.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/BookmarkFolderController.java @@ -1,15 +1,13 @@ -package com.example.FixLog.controller; +package com.example.FixLog.domain.bookmark; -import com.example.FixLog.dto.PageResponseDto; -import com.example.FixLog.dto.Response; -import com.example.FixLog.dto.bookmark.request.BookmarkFolderCreateRequest; -import com.example.FixLog.dto.bookmark.request.BookmarkFolderUpdateRequest; -import com.example.FixLog.dto.bookmark.request.BookmarkMoveRequest; -import com.example.FixLog.dto.bookmark.response.BookmarkFolderCreateResponse; -import com.example.FixLog.dto.bookmark.response.BookmarkFolderReadResponse; -import com.example.FixLog.dto.post.MyPostPageResponseDto; -import com.example.FixLog.service.BookmarkFolderService; -import com.example.FixLog.service.BookmarkService; +import com.example.FixLog.domain.mypage.dto.PageResponseDto; +import com.example.FixLog.common.exception.Response; +import com.example.FixLog.domain.bookmark.dto.request.BookmarkFolderCreateRequest; +import com.example.FixLog.domain.bookmark.dto.request.BookmarkFolderUpdateRequest; +import com.example.FixLog.domain.bookmark.dto.request.BookmarkMoveRequest; +import com.example.FixLog.domain.bookmark.dto.response.BookmarkFolderCreateResponse; +import com.example.FixLog.domain.bookmark.dto.response.BookmarkFolderReadResponse; +import com.example.FixLog.domain.post.dto.MyPostPageResponseDto; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; diff --git a/src/main/java/com/example/FixLog/service/BookmarkFolderService.java b/src/main/java/com/example/FixLog/domain/bookmark/BookmarkFolderService.java similarity index 62% rename from src/main/java/com/example/FixLog/service/BookmarkFolderService.java rename to src/main/java/com/example/FixLog/domain/bookmark/BookmarkFolderService.java index db28851..3fb9bb9 100644 --- a/src/main/java/com/example/FixLog/service/BookmarkFolderService.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/BookmarkFolderService.java @@ -1,22 +1,20 @@ -package com.example.FixLog.service; - -import com.example.FixLog.domain.bookmark.BookmarkFolder; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.dto.PageResponseDto; -import com.example.FixLog.dto.bookmark.response.BookmarkFolderCreateResponse; -import com.example.FixLog.dto.bookmark.response.BookmarkFolderReadResponse; -import com.example.FixLog.exception.CustomException; -import com.example.FixLog.exception.ErrorCode; -import com.example.FixLog.repository.MemberRepository; -import com.example.FixLog.repository.bookmark.BookmarkFolderRepository; +package com.example.FixLog.domain.bookmark; + +import com.example.FixLog.domain.bookmark.domain.BookmarkFolder; +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.domain.mypage.dto.PageResponseDto; +import com.example.FixLog.domain.bookmark.dto.response.BookmarkFolderCreateResponse; +import com.example.FixLog.domain.bookmark.dto.response.BookmarkFolderReadResponse; +import com.example.FixLog.common.exception.CustomException; +import com.example.FixLog.common.response.ErrorStatus; +import com.example.FixLog.domain.member.repository.MemberRepository; +import com.example.FixLog.domain.bookmark.repository.BookmarkFolderRepository; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import java.util.List; - @Service @RequiredArgsConstructor public class BookmarkFolderService { @@ -27,7 +25,7 @@ public class BookmarkFolderService { // 북마크 폴더 생성 public BookmarkFolderCreateResponse createFolder(String folderName, String requesterEmail) { Member member = memberRepository.findByEmail(requesterEmail) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); BookmarkFolder folder = new BookmarkFolder(member, folderName); BookmarkFolder saved = bookmarkFolderRepository.save(folder); @@ -38,7 +36,7 @@ public BookmarkFolderCreateResponse createFolder(String folderName, String reque // 북마크 폴더 목록 전체 조회 public PageResponseDto getFoldersByEmail(String email, int page, int size) { Member member = memberRepository.findByEmail(email) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); Pageable pageable = PageRequest.of(page, size); Page folderPage = bookmarkFolderRepository.findAllByUserId(member, pageable); @@ -48,14 +46,14 @@ public PageResponseDto getFoldersByEmail(String emai // 북마크 폴더 이름 수정 public void updateFolderName(Long folderId, String email, String newName) { Member member = memberRepository.findByEmail(email) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); BookmarkFolder folder = bookmarkFolderRepository.findById(folderId) - .orElseThrow(() -> new CustomException(ErrorCode.FOLDER_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.FOLDER_NOT_FOUND)); // 본인만 수정 가능 if (!folder.getUserId().equals(member)) { - throw new CustomException(ErrorCode.ACCESS_DENIED); + throw new CustomException(ErrorStatus.ACCESS_DENIED); } folder.updateName(newName); @@ -64,15 +62,15 @@ public void updateFolderName(Long folderId, String email, String newName) { // 북마크 폴더 삭제 -> 기본 폴더는 삭제 불가인지? public void deleteFolder(Long folderId, String email) { Member member = memberRepository.findByEmail(email) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); BookmarkFolder folder = bookmarkFolderRepository.findById(folderId) - .orElseThrow(() -> new CustomException(ErrorCode.FOLDER_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.FOLDER_NOT_FOUND)); // 본인만 삭제 가능 if (!folder.getUserId().equals(member)) { - throw new CustomException(ErrorCode.ACCESS_DENIED); + throw new CustomException(ErrorStatus.ACCESS_DENIED); } bookmarkFolderRepository.delete(folder); diff --git a/src/main/java/com/example/FixLog/service/BookmarkService.java b/src/main/java/com/example/FixLog/domain/bookmark/BookmarkService.java similarity index 64% rename from src/main/java/com/example/FixLog/service/BookmarkService.java rename to src/main/java/com/example/FixLog/domain/bookmark/BookmarkService.java index 66a406c..e9982e4 100644 --- a/src/main/java/com/example/FixLog/service/BookmarkService.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/BookmarkService.java @@ -1,17 +1,17 @@ -package com.example.FixLog.service; - -import com.example.FixLog.domain.bookmark.Bookmark; -import com.example.FixLog.domain.bookmark.BookmarkFolder; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.domain.post.Post; -import com.example.FixLog.dto.PageResponseDto; -import com.example.FixLog.dto.post.MyPostPageResponseDto; -import com.example.FixLog.exception.CustomException; -import com.example.FixLog.exception.ErrorCode; -import com.example.FixLog.repository.MemberRepository; -import com.example.FixLog.repository.bookmark.BookmarkFolderRepository; -import com.example.FixLog.repository.bookmark.BookmarkRepository; -import com.example.FixLog.repository.fork.ForkRepository; +package com.example.FixLog.domain.bookmark; + +import com.example.FixLog.domain.bookmark.domain.Bookmark; +import com.example.FixLog.domain.bookmark.domain.BookmarkFolder; +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.domain.post.domain.Post; +import com.example.FixLog.domain.mypage.dto.PageResponseDto; +import com.example.FixLog.domain.post.dto.MyPostPageResponseDto; +import com.example.FixLog.common.exception.CustomException; +import com.example.FixLog.common.response.ErrorStatus; +import com.example.FixLog.domain.member.repository.MemberRepository; +import com.example.FixLog.domain.bookmark.repository.BookmarkFolderRepository; +import com.example.FixLog.domain.bookmark.repository.BookmarkRepository; +import com.example.FixLog.domain.post.repository.ForkRepository; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -35,18 +35,18 @@ public class BookmarkService { // 북마크 폴더 이동 public void moveBookmarkToFolder(Long bookmarkId, Long newFolderId, String email) { Member member = memberRepository.findByEmail(email) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); Bookmark bookmark = bookmarkRepository.findById(bookmarkId) - .orElseThrow(() -> new CustomException(ErrorCode.BOOKMARK_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.BOOKMARK_NOT_FOUND)); // 폴더 주인만 이동 가능 if (!bookmark.getFolderId().getUserId().equals(member)) { - throw new CustomException(ErrorCode.ACCESS_DENIED); + throw new CustomException(ErrorStatus.ACCESS_DENIED); } BookmarkFolder targetFolder = bookmarkFolderRepository.findById(newFolderId) - .orElseThrow(() -> new CustomException(ErrorCode.FOLDER_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.FOLDER_NOT_FOUND)); bookmark.moveToFolder(targetFolder); } @@ -54,10 +54,10 @@ public void moveBookmarkToFolder(Long bookmarkId, Long newFolderId, String email // 특정 폴더의 북마크 목록 public PageResponseDto getBookmarksInFolder(String email, Long folderId, int page, int sort, int size) { Member member = memberRepository.findByEmail(email) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); BookmarkFolder folder = bookmarkFolderRepository.findById(folderId) - .orElseThrow(() -> new CustomException(ErrorCode.FOLDER_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.FOLDER_NOT_FOUND)); // 1: 오래된순, 0: 최신순 Sort.Direction direction = (sort == 1) ? Sort.Direction.ASC : Sort.Direction.DESC; diff --git a/src/main/java/com/example/FixLog/domain/bookmark/Bookmark.java b/src/main/java/com/example/FixLog/domain/bookmark/domain/Bookmark.java similarity index 90% rename from src/main/java/com/example/FixLog/domain/bookmark/Bookmark.java rename to src/main/java/com/example/FixLog/domain/bookmark/domain/Bookmark.java index 3faba00..9e5fdf5 100644 --- a/src/main/java/com/example/FixLog/domain/bookmark/Bookmark.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/domain/Bookmark.java @@ -1,6 +1,6 @@ -package com.example.FixLog.domain.bookmark; +package com.example.FixLog.domain.bookmark.domain; -import com.example.FixLog.domain.post.Post; +import com.example.FixLog.domain.post.domain.Post; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/com/example/FixLog/domain/bookmark/BookmarkFolder.java b/src/main/java/com/example/FixLog/domain/bookmark/domain/BookmarkFolder.java similarity index 91% rename from src/main/java/com/example/FixLog/domain/bookmark/BookmarkFolder.java rename to src/main/java/com/example/FixLog/domain/bookmark/domain/BookmarkFolder.java index ef3ff6b..f6aa98a 100644 --- a/src/main/java/com/example/FixLog/domain/bookmark/BookmarkFolder.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/domain/BookmarkFolder.java @@ -1,6 +1,6 @@ -package com.example.FixLog.domain.bookmark; +package com.example.FixLog.domain.bookmark.domain; -import com.example.FixLog.domain.member.Member; +import com.example.FixLog.domain.member.domain.Member; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/bookmark/request/BookmarkFolderCreateRequest.java b/src/main/java/com/example/FixLog/domain/bookmark/dto/request/BookmarkFolderCreateRequest.java similarity index 73% rename from src/main/java/com/example/FixLog/dto/bookmark/request/BookmarkFolderCreateRequest.java rename to src/main/java/com/example/FixLog/domain/bookmark/dto/request/BookmarkFolderCreateRequest.java index f9908d9..aedf63b 100644 --- a/src/main/java/com/example/FixLog/dto/bookmark/request/BookmarkFolderCreateRequest.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/dto/request/BookmarkFolderCreateRequest.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.bookmark.request; +package com.example.FixLog.domain.bookmark.dto.request; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/example/FixLog/dto/bookmark/request/BookmarkFolderUpdateRequest.java b/src/main/java/com/example/FixLog/domain/bookmark/dto/request/BookmarkFolderUpdateRequest.java similarity index 73% rename from src/main/java/com/example/FixLog/dto/bookmark/request/BookmarkFolderUpdateRequest.java rename to src/main/java/com/example/FixLog/domain/bookmark/dto/request/BookmarkFolderUpdateRequest.java index 8951508..a023f18 100644 --- a/src/main/java/com/example/FixLog/dto/bookmark/request/BookmarkFolderUpdateRequest.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/dto/request/BookmarkFolderUpdateRequest.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.bookmark.request; +package com.example.FixLog.domain.bookmark.dto.request; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/example/FixLog/dto/bookmark/request/BookmarkMoveRequest.java b/src/main/java/com/example/FixLog/domain/bookmark/dto/request/BookmarkMoveRequest.java similarity index 72% rename from src/main/java/com/example/FixLog/dto/bookmark/request/BookmarkMoveRequest.java rename to src/main/java/com/example/FixLog/domain/bookmark/dto/request/BookmarkMoveRequest.java index 22876dd..a52b16e 100644 --- a/src/main/java/com/example/FixLog/dto/bookmark/request/BookmarkMoveRequest.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/dto/request/BookmarkMoveRequest.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.bookmark.request; +package com.example.FixLog.domain.bookmark.dto.request; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/example/FixLog/dto/bookmark/response/BookmarkFolderCreateResponse.java b/src/main/java/com/example/FixLog/domain/bookmark/dto/response/BookmarkFolderCreateResponse.java similarity index 57% rename from src/main/java/com/example/FixLog/dto/bookmark/response/BookmarkFolderCreateResponse.java rename to src/main/java/com/example/FixLog/domain/bookmark/dto/response/BookmarkFolderCreateResponse.java index b867121..64fef1b 100644 --- a/src/main/java/com/example/FixLog/dto/bookmark/response/BookmarkFolderCreateResponse.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/dto/response/BookmarkFolderCreateResponse.java @@ -1,3 +1,3 @@ -package com.example.FixLog.dto.bookmark.response; +package com.example.FixLog.domain.bookmark.dto.response; public record BookmarkFolderCreateResponse(Long folder_id, String name) {} diff --git a/src/main/java/com/example/FixLog/dto/bookmark/response/BookmarkFolderReadResponse.java b/src/main/java/com/example/FixLog/domain/bookmark/dto/response/BookmarkFolderReadResponse.java similarity index 77% rename from src/main/java/com/example/FixLog/dto/bookmark/response/BookmarkFolderReadResponse.java rename to src/main/java/com/example/FixLog/domain/bookmark/dto/response/BookmarkFolderReadResponse.java index 0c5a698..e7d04fd 100644 --- a/src/main/java/com/example/FixLog/dto/bookmark/response/BookmarkFolderReadResponse.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/dto/response/BookmarkFolderReadResponse.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.bookmark.response; +package com.example.FixLog.domain.bookmark.dto.response; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/example/FixLog/repository/bookmark/BookmarkFolderRepository.java b/src/main/java/com/example/FixLog/domain/bookmark/repository/BookmarkFolderRepository.java similarity index 74% rename from src/main/java/com/example/FixLog/repository/bookmark/BookmarkFolderRepository.java rename to src/main/java/com/example/FixLog/domain/bookmark/repository/BookmarkFolderRepository.java index 430568d..aaf0066 100644 --- a/src/main/java/com/example/FixLog/repository/bookmark/BookmarkFolderRepository.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/repository/BookmarkFolderRepository.java @@ -1,12 +1,11 @@ -package com.example.FixLog.repository.bookmark; +package com.example.FixLog.domain.bookmark.repository; -import com.example.FixLog.domain.bookmark.BookmarkFolder; -import com.example.FixLog.domain.member.Member; +import com.example.FixLog.domain.bookmark.domain.BookmarkFolder; +import com.example.FixLog.domain.member.domain.Member; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import java.util.List; import java.util.Optional; diff --git a/src/main/java/com/example/FixLog/repository/bookmark/BookmarkRepository.java b/src/main/java/com/example/FixLog/domain/bookmark/repository/BookmarkRepository.java similarity index 64% rename from src/main/java/com/example/FixLog/repository/bookmark/BookmarkRepository.java rename to src/main/java/com/example/FixLog/domain/bookmark/repository/BookmarkRepository.java index d751110..559b2d6 100644 --- a/src/main/java/com/example/FixLog/repository/bookmark/BookmarkRepository.java +++ b/src/main/java/com/example/FixLog/domain/bookmark/repository/BookmarkRepository.java @@ -1,14 +1,12 @@ -package com.example.FixLog.repository.bookmark; +package com.example.FixLog.domain.bookmark.repository; -import com.example.FixLog.domain.bookmark.Bookmark; -import com.example.FixLog.domain.bookmark.BookmarkFolder; -import com.example.FixLog.domain.post.Post; +import com.example.FixLog.domain.bookmark.domain.Bookmark; +import com.example.FixLog.domain.bookmark.domain.BookmarkFolder; +import com.example.FixLog.domain.post.domain.Post; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; import java.util.Optional; diff --git a/src/main/java/com/example/FixLog/controller/FollowController.java b/src/main/java/com/example/FixLog/domain/follow/FollowController.java similarity index 85% rename from src/main/java/com/example/FixLog/controller/FollowController.java rename to src/main/java/com/example/FixLog/domain/follow/FollowController.java index ba7ade2..bd80c44 100644 --- a/src/main/java/com/example/FixLog/controller/FollowController.java +++ b/src/main/java/com/example/FixLog/domain/follow/FollowController.java @@ -1,12 +1,11 @@ -package com.example.FixLog.controller; +package com.example.FixLog.domain.follow; -import com.example.FixLog.dto.Response; -import com.example.FixLog.dto.follow.request.FollowRequestDto; -import com.example.FixLog.dto.follow.request.UnfollowRequestDto; -import com.example.FixLog.dto.follow.response.FollowResponseDto; -import com.example.FixLog.dto.follow.response.FollowerListResponseDto; -import com.example.FixLog.dto.follow.response.FollowingListResponseDto; -import com.example.FixLog.service.FollowService; +import com.example.FixLog.common.exception.Response; +import com.example.FixLog.domain.follow.dto.request.FollowRequestDto; +import com.example.FixLog.domain.follow.dto.request.UnfollowRequestDto; +import com.example.FixLog.domain.follow.dto.response.FollowResponseDto; +import com.example.FixLog.domain.follow.dto.response.FollowerListResponseDto; +import com.example.FixLog.domain.follow.dto.response.FollowingListResponseDto; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/com/example/FixLog/service/FollowService.java b/src/main/java/com/example/FixLog/domain/follow/FollowService.java similarity index 68% rename from src/main/java/com/example/FixLog/service/FollowService.java rename to src/main/java/com/example/FixLog/domain/follow/FollowService.java index 96f8522..2939f14 100644 --- a/src/main/java/com/example/FixLog/service/FollowService.java +++ b/src/main/java/com/example/FixLog/domain/follow/FollowService.java @@ -1,15 +1,15 @@ -package com.example.FixLog.service; - -import com.example.FixLog.dto.follow.response.FollowResponseDto; -import com.example.FixLog.dto.follow.response.FollowerListResponseDto; -import com.example.FixLog.dto.follow.response.FollowingListResponseDto; -import com.example.FixLog.exception.CustomException; -import com.example.FixLog.exception.ErrorCode; -import com.example.FixLog.repository.MemberRepository; -import com.example.FixLog.repository.follow.FollowRepository; +package com.example.FixLog.domain.follow; + +import com.example.FixLog.domain.follow.dto.response.FollowResponseDto; +import com.example.FixLog.domain.follow.dto.response.FollowerListResponseDto; +import com.example.FixLog.domain.follow.dto.response.FollowingListResponseDto; +import com.example.FixLog.common.exception.CustomException; +import com.example.FixLog.common.response.ErrorStatus; +import com.example.FixLog.domain.member.repository.MemberRepository; +import com.example.FixLog.domain.follow.repository.FollowRepository; import lombok.RequiredArgsConstructor; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.domain.follow.Follow; +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.domain.follow.domain.Follow; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -32,18 +32,18 @@ public String getDefaultProfile(String image) { @Transactional public FollowResponseDto follow(String requesterEmail, Long targetMemberId){ Member follower = memberRepository.findByEmail(requesterEmail) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); Member following = memberRepository.findById(targetMemberId) - .orElseThrow(() -> new CustomException(ErrorCode.USER_NICKNAME_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_NICKNAME_NOT_FOUND)); // 자기 자신은 팔로우 불가 if (follower.getUserId().equals(following.getUserId())) { - throw new CustomException(ErrorCode.SELF_FOLLOW_NOT_ALLOWED); + throw new CustomException(ErrorStatus.SELF_FOLLOW_NOT_ALLOWED); } // 중복 팔로우 방지 if (followRepository.existsByFollowerIdAndFollowingId(follower, following)) { - throw new CustomException(ErrorCode.ALREADY_FOLLOWING); + throw new CustomException(ErrorStatus.ALREADY_FOLLOWING); } Follow follow = new Follow(follower, following); @@ -56,18 +56,18 @@ public FollowResponseDto follow(String requesterEmail, Long targetMemberId){ @Transactional public void unfollow(String requesterEmail, Long targetMemberId) { Member follower = memberRepository.findByEmail(requesterEmail) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); Member following = memberRepository.findById(targetMemberId) - .orElseThrow(() -> new CustomException(ErrorCode.USER_NICKNAME_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_NICKNAME_NOT_FOUND)); // 자기 자신은 팔로우 불가 if (follower.getUserId().equals(following.getUserId())) { - throw new CustomException(ErrorCode.SELF_FOLLOW_NOT_ALLOWED); + throw new CustomException(ErrorStatus.SELF_FOLLOW_NOT_ALLOWED); } Follow follow = followRepository.findByFollowerIdAndFollowingId(follower, following) - .orElseThrow(() -> new CustomException(ErrorCode.SELF_UNFOLLOW_NOT_ALLOWED)); + .orElseThrow(() -> new CustomException(ErrorStatus.SELF_UNFOLLOW_NOT_ALLOWED)); followRepository.delete(follow); } @@ -76,7 +76,7 @@ public void unfollow(String requesterEmail, Long targetMemberId) { @Transactional(readOnly = true) public List getMyFollowers(String requesterEmail) { Member me = memberRepository.findByEmail(requesterEmail) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); List follows = followRepository.findByFollowingId(me); @@ -94,7 +94,7 @@ public List getMyFollowers(String requesterEmail) { @Transactional(readOnly = true) public List getMyFollowings(String requesterEmail) { Member me = memberRepository.findByEmail(requesterEmail) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); List follows = followRepository.findByFollowerId(me); diff --git a/src/main/java/com/example/FixLog/domain/follow/Follow.java b/src/main/java/com/example/FixLog/domain/follow/domain/Follow.java similarity index 87% rename from src/main/java/com/example/FixLog/domain/follow/Follow.java rename to src/main/java/com/example/FixLog/domain/follow/domain/Follow.java index 19a47cf..882086b 100644 --- a/src/main/java/com/example/FixLog/domain/follow/Follow.java +++ b/src/main/java/com/example/FixLog/domain/follow/domain/Follow.java @@ -1,6 +1,6 @@ -package com.example.FixLog.domain.follow; +package com.example.FixLog.domain.follow.domain; -import com.example.FixLog.domain.member.Member; +import com.example.FixLog.domain.member.domain.Member; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/follow/request/FollowRequestDto.java b/src/main/java/com/example/FixLog/domain/follow/dto/request/FollowRequestDto.java similarity index 83% rename from src/main/java/com/example/FixLog/dto/follow/request/FollowRequestDto.java rename to src/main/java/com/example/FixLog/domain/follow/dto/request/FollowRequestDto.java index 43b9561..98663ca 100644 --- a/src/main/java/com/example/FixLog/dto/follow/request/FollowRequestDto.java +++ b/src/main/java/com/example/FixLog/domain/follow/dto/request/FollowRequestDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.follow.request; +package com.example.FixLog.domain.follow.dto.request; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/follow/request/UnfollowRequestDto.java b/src/main/java/com/example/FixLog/domain/follow/dto/request/UnfollowRequestDto.java similarity index 81% rename from src/main/java/com/example/FixLog/dto/follow/request/UnfollowRequestDto.java rename to src/main/java/com/example/FixLog/domain/follow/dto/request/UnfollowRequestDto.java index a321ee1..f218d33 100644 --- a/src/main/java/com/example/FixLog/dto/follow/request/UnfollowRequestDto.java +++ b/src/main/java/com/example/FixLog/domain/follow/dto/request/UnfollowRequestDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.follow.request; +package com.example.FixLog.domain.follow.dto.request; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/follow/response/FollowResponseDto.java b/src/main/java/com/example/FixLog/domain/follow/dto/response/FollowResponseDto.java similarity index 85% rename from src/main/java/com/example/FixLog/dto/follow/response/FollowResponseDto.java rename to src/main/java/com/example/FixLog/domain/follow/dto/response/FollowResponseDto.java index 8eb8513..501b289 100644 --- a/src/main/java/com/example/FixLog/dto/follow/response/FollowResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/follow/dto/response/FollowResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.follow.response; +package com.example.FixLog.domain.follow.dto.response; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/example/FixLog/dto/follow/response/FollowerListResponseDto.java b/src/main/java/com/example/FixLog/domain/follow/dto/response/FollowerListResponseDto.java similarity index 86% rename from src/main/java/com/example/FixLog/dto/follow/response/FollowerListResponseDto.java rename to src/main/java/com/example/FixLog/domain/follow/dto/response/FollowerListResponseDto.java index 0f603a4..6ec30e6 100644 --- a/src/main/java/com/example/FixLog/dto/follow/response/FollowerListResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/follow/dto/response/FollowerListResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.follow.response; +package com.example.FixLog.domain.follow.dto.response; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/example/FixLog/dto/follow/response/FollowingListResponseDto.java b/src/main/java/com/example/FixLog/domain/follow/dto/response/FollowingListResponseDto.java similarity index 86% rename from src/main/java/com/example/FixLog/dto/follow/response/FollowingListResponseDto.java rename to src/main/java/com/example/FixLog/domain/follow/dto/response/FollowingListResponseDto.java index f814c39..42cfdc9 100644 --- a/src/main/java/com/example/FixLog/dto/follow/response/FollowingListResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/follow/dto/response/FollowingListResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.follow.response; +package com.example.FixLog.domain.follow.dto.response; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/example/FixLog/repository/follow/FollowRepository.java b/src/main/java/com/example/FixLog/domain/follow/repository/FollowRepository.java similarity index 80% rename from src/main/java/com/example/FixLog/repository/follow/FollowRepository.java rename to src/main/java/com/example/FixLog/domain/follow/repository/FollowRepository.java index bf6cf51..9b1fa02 100644 --- a/src/main/java/com/example/FixLog/repository/follow/FollowRepository.java +++ b/src/main/java/com/example/FixLog/domain/follow/repository/FollowRepository.java @@ -1,8 +1,8 @@ -package com.example.FixLog.repository.follow; +package com.example.FixLog.domain.follow.repository; -import com.example.FixLog.domain.follow.Follow; +import com.example.FixLog.domain.follow.domain.Follow; import org.springframework.data.jpa.repository.JpaRepository; -import com.example.FixLog.domain.member.Member; +import com.example.FixLog.domain.member.domain.Member; import java.util.List; import java.util.Optional; diff --git a/src/main/java/com/example/FixLog/controller/MainPageController.java b/src/main/java/com/example/FixLog/domain/mainPage/MainPageController.java similarity index 78% rename from src/main/java/com/example/FixLog/controller/MainPageController.java rename to src/main/java/com/example/FixLog/domain/mainPage/MainPageController.java index 91f8054..7acbc15 100644 --- a/src/main/java/com/example/FixLog/controller/MainPageController.java +++ b/src/main/java/com/example/FixLog/domain/mainPage/MainPageController.java @@ -1,19 +1,17 @@ -package com.example.FixLog.controller; +package com.example.FixLog.domain.mainPage; -import com.example.FixLog.dto.Response; -import com.example.FixLog.dto.main.MainPageResponseDto; -import com.example.FixLog.service.MainPageService; +import com.example.FixLog.common.exception.Response; +import com.example.FixLog.domain.mainPage.dto.MainPageResponseDto; +import com.example.FixLog.domain.mainPage.service.MainPageService; +import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; @RestController +@RequiredArgsConstructor @RequestMapping("/main") public class MainPageController { private final MainPageService mainPageService; - public MainPageController(MainPageService mainPageService){ - this.mainPageService = mainPageService; - } - @GetMapping public Response mainPageView(@RequestParam(value = "sort", defaultValue = "0") int sort, @RequestParam(value = "size", defaultValue = "12") int size){ diff --git a/src/main/java/com/example/FixLog/controller/SearchController.java b/src/main/java/com/example/FixLog/domain/mainPage/SearchController.java similarity index 82% rename from src/main/java/com/example/FixLog/controller/SearchController.java rename to src/main/java/com/example/FixLog/domain/mainPage/SearchController.java index e74145d..c5653a6 100644 --- a/src/main/java/com/example/FixLog/controller/SearchController.java +++ b/src/main/java/com/example/FixLog/domain/mainPage/SearchController.java @@ -1,9 +1,9 @@ -package com.example.FixLog.controller; +package com.example.FixLog.domain.mainPage; -import com.example.FixLog.dto.PageResponseDto; -import com.example.FixLog.dto.Response; -import com.example.FixLog.dto.search.SearchPostDto; -import com.example.FixLog.service.SearchService; +import com.example.FixLog.domain.mypage.dto.PageResponseDto; +import com.example.FixLog.common.exception.Response; +import com.example.FixLog.domain.mainPage.dto.search.SearchPostDto; +import com.example.FixLog.domain.mainPage.service.SearchService; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; diff --git a/src/main/java/com/example/FixLog/dto/main/MainPagePostResponseDto.java b/src/main/java/com/example/FixLog/domain/mainPage/dto/MainPagePostResponseDto.java similarity index 90% rename from src/main/java/com/example/FixLog/dto/main/MainPagePostResponseDto.java rename to src/main/java/com/example/FixLog/domain/mainPage/dto/MainPagePostResponseDto.java index e7b8adc..c1164c0 100644 --- a/src/main/java/com/example/FixLog/dto/main/MainPagePostResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/mainPage/dto/MainPagePostResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.main; +package com.example.FixLog.domain.mainPage.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/main/MainPageResponseDto.java b/src/main/java/com/example/FixLog/domain/mainPage/dto/MainPageResponseDto.java similarity index 93% rename from src/main/java/com/example/FixLog/dto/main/MainPageResponseDto.java rename to src/main/java/com/example/FixLog/domain/mainPage/dto/MainPageResponseDto.java index 9532959..e681fdd 100644 --- a/src/main/java/com/example/FixLog/dto/main/MainPageResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/mainPage/dto/MainPageResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.main; +package com.example.FixLog.domain.mainPage.dto; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/example/FixLog/dto/search/SearchPostDto.java b/src/main/java/com/example/FixLog/domain/mainPage/dto/search/SearchPostDto.java similarity index 90% rename from src/main/java/com/example/FixLog/dto/search/SearchPostDto.java rename to src/main/java/com/example/FixLog/domain/mainPage/dto/search/SearchPostDto.java index 527a2c0..49c6a9e 100644 --- a/src/main/java/com/example/FixLog/dto/search/SearchPostDto.java +++ b/src/main/java/com/example/FixLog/domain/mainPage/dto/search/SearchPostDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.search; +package com.example.FixLog.domain.mainPage.dto.search; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/search/SearchRequestDto.java b/src/main/java/com/example/FixLog/domain/mainPage/dto/search/SearchRequestDto.java similarity index 92% rename from src/main/java/com/example/FixLog/dto/search/SearchRequestDto.java rename to src/main/java/com/example/FixLog/domain/mainPage/dto/search/SearchRequestDto.java index 55a1d60..e9b834e 100644 --- a/src/main/java/com/example/FixLog/dto/search/SearchRequestDto.java +++ b/src/main/java/com/example/FixLog/domain/mainPage/dto/search/SearchRequestDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.search; +package com.example.FixLog.domain.mainPage.dto.search; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/service/MainPageService.java b/src/main/java/com/example/FixLog/domain/mainPage/service/MainPageService.java similarity index 89% rename from src/main/java/com/example/FixLog/service/MainPageService.java rename to src/main/java/com/example/FixLog/domain/mainPage/service/MainPageService.java index 6b3b246..88c42f0 100644 --- a/src/main/java/com/example/FixLog/service/MainPageService.java +++ b/src/main/java/com/example/FixLog/domain/mainPage/service/MainPageService.java @@ -1,12 +1,13 @@ -package com.example.FixLog.service; - -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.domain.post.Post; -import com.example.FixLog.dto.main.MainPagePostResponseDto; -import com.example.FixLog.dto.main.MainPageResponseDto; -import com.example.FixLog.exception.CustomException; -import com.example.FixLog.exception.ErrorCode; -import com.example.FixLog.repository.post.PostRepository; +package com.example.FixLog.domain.mainPage.service; + +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.domain.post.domain.Post; +import com.example.FixLog.domain.mainPage.dto.MainPagePostResponseDto; +import com.example.FixLog.domain.mainPage.dto.MainPageResponseDto; +import com.example.FixLog.common.exception.CustomException; +import com.example.FixLog.common.response.ErrorStatus; +import com.example.FixLog.domain.member.MemberService; +import com.example.FixLog.domain.post.repository.PostRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -66,7 +67,7 @@ public MainPageResponseDto mainPageView(int sort, int size){ // Todo : 이거 정렬할 때 좋아요 0인거 이상하고, 이거랑 연결해서인지 totalpages 계산도 이상하게 됨 sortOption = Sort.by(Sort.Direction.DESC, "postLikes"); } else - throw new CustomException(ErrorCode.SORT_NOT_EXIST); + throw new CustomException(ErrorStatus.SORT_NOT_EXIST); Pageable pageable = PageRequest.of(0, size, sortOption); posts = postRepository.findAll(pageable); @@ -112,7 +113,7 @@ public MainPageResponseDto mainPageFullView(int sort, int page, int size){ } else if (sort == 1) { // 인기순 정렬 postPage = postRepository.findAllByOrderByPostLikesDesc(pageable); } else - throw new CustomException(ErrorCode.SORT_NOT_EXIST); + throw new CustomException(ErrorStatus.SORT_NOT_EXIST); List postList = postPage.stream() .map(post -> new MainPagePostResponseDto( diff --git a/src/main/java/com/example/FixLog/service/SearchService.java b/src/main/java/com/example/FixLog/domain/mainPage/service/SearchService.java similarity index 67% rename from src/main/java/com/example/FixLog/service/SearchService.java rename to src/main/java/com/example/FixLog/domain/mainPage/service/SearchService.java index 3ab5572..51a978e 100644 --- a/src/main/java/com/example/FixLog/service/SearchService.java +++ b/src/main/java/com/example/FixLog/domain/mainPage/service/SearchService.java @@ -1,9 +1,9 @@ -package com.example.FixLog.service; +package com.example.FixLog.domain.mainPage.service; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import java.util.List; -import com.example.FixLog.dto.search.SearchPostDto; +import com.example.FixLog.domain.mainPage.dto.search.SearchPostDto; public interface SearchService { Page searchPosts(String keyword, List tags, Pageable pageable); diff --git a/src/main/java/com/example/FixLog/service/impl/SearchServiceImpl.java b/src/main/java/com/example/FixLog/domain/mainPage/service/impl/SearchServiceImpl.java similarity index 78% rename from src/main/java/com/example/FixLog/service/impl/SearchServiceImpl.java rename to src/main/java/com/example/FixLog/domain/mainPage/service/impl/SearchServiceImpl.java index ab171f8..308ecce 100644 --- a/src/main/java/com/example/FixLog/service/impl/SearchServiceImpl.java +++ b/src/main/java/com/example/FixLog/domain/mainPage/service/impl/SearchServiceImpl.java @@ -1,16 +1,14 @@ -package com.example.FixLog.service.impl; +package com.example.FixLog.domain.mainPage.service.impl; -import com.example.FixLog.domain.tag.Tag; -import com.example.FixLog.dto.search.SearchPostDto; -import com.example.FixLog.repository.post.PostRepository; -import com.example.FixLog.repository.tag.TagRepository; -import com.example.FixLog.service.SearchService; +import com.example.FixLog.domain.mainPage.dto.search.SearchPostDto; +import com.example.FixLog.domain.post.repository.PostRepository; +import com.example.FixLog.domain.tag.repository.TagRepository; +import com.example.FixLog.domain.mainPage.service.SearchService; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import java.util.Comparator; import java.util.List; @Service diff --git a/src/main/java/com/example/FixLog/controller/AuthController.java b/src/main/java/com/example/FixLog/domain/member/AuthController.java similarity index 74% rename from src/main/java/com/example/FixLog/controller/AuthController.java rename to src/main/java/com/example/FixLog/domain/member/AuthController.java index 4acd281..32b5913 100644 --- a/src/main/java/com/example/FixLog/controller/AuthController.java +++ b/src/main/java/com/example/FixLog/domain/member/AuthController.java @@ -1,10 +1,9 @@ -package com.example.FixLog.controller; +package com.example.FixLog.domain.member; -import com.example.FixLog.dto.Response; -import com.example.FixLog.dto.member.LoginRequestDto; -import com.example.FixLog.dto.member.LoginResponseDto; -import com.example.FixLog.exception.ErrorCode; -import com.example.FixLog.service.AuthService; +import com.example.FixLog.common.exception.Response; +import com.example.FixLog.domain.member.dto.LoginRequestDto; +import com.example.FixLog.domain.member.dto.LoginResponseDto; +import com.example.FixLog.common.response.ErrorStatus; import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; @@ -32,7 +31,7 @@ public ResponseEntity> logout(HttpServletRequest request) { } else { return ResponseEntity .badRequest() - .body(Response.fail(ErrorCode.UNAUTHORIZED.getMessage())); + .body(Response.fail(ErrorStatus.UNAUTHORIZED.getMessage())); } } diff --git a/src/main/java/com/example/FixLog/service/AuthService.java b/src/main/java/com/example/FixLog/domain/member/AuthService.java similarity index 60% rename from src/main/java/com/example/FixLog/service/AuthService.java rename to src/main/java/com/example/FixLog/domain/member/AuthService.java index c2a0950..5a7363f 100644 --- a/src/main/java/com/example/FixLog/service/AuthService.java +++ b/src/main/java/com/example/FixLog/domain/member/AuthService.java @@ -1,12 +1,12 @@ -package com.example.FixLog.service; - -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.dto.member.LoginRequestDto; -import com.example.FixLog.dto.member.LoginResponseDto; -import com.example.FixLog.exception.CustomException; -import com.example.FixLog.exception.ErrorCode; -import com.example.FixLog.repository.MemberRepository; -import com.example.FixLog.util.JwtUtil; +package com.example.FixLog.domain.member; + +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.domain.member.dto.LoginRequestDto; +import com.example.FixLog.domain.member.dto.LoginResponseDto; +import com.example.FixLog.common.exception.CustomException; +import com.example.FixLog.common.response.ErrorStatus; +import com.example.FixLog.domain.member.repository.MemberRepository; +import com.example.FixLog.common.util.JwtUtil; import lombok.RequiredArgsConstructor; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; @@ -24,14 +24,14 @@ public LoginResponseDto login(LoginRequestDto requestDto) { System.out.println("로그인 요청: " + requestDto.getEmail()); Member member = memberRepository.findByEmail(requestDto.getEmail()) - .orElseThrow(() -> new CustomException(ErrorCode.USER_NICKNAME_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_NICKNAME_NOT_FOUND)); if (member.getIsDeleted()) { - throw new CustomException(ErrorCode.USER_DELETED); + throw new CustomException(ErrorStatus.USER_DELETED); } if (!passwordEncoder.matches(requestDto.getPassword(), member.getPassword())) { - throw new CustomException(ErrorCode.INVALID_PASSWORD); + throw new CustomException(ErrorStatus.INVALID_PASSWORD); } String token = jwtUtil.createToken(member.getUserId(), member.getEmail()); diff --git a/src/main/java/com/example/FixLog/controller/MemberController.java b/src/main/java/com/example/FixLog/domain/member/MemberController.java similarity index 86% rename from src/main/java/com/example/FixLog/controller/MemberController.java rename to src/main/java/com/example/FixLog/domain/member/MemberController.java index 88bd6a2..94222c4 100644 --- a/src/main/java/com/example/FixLog/controller/MemberController.java +++ b/src/main/java/com/example/FixLog/domain/member/MemberController.java @@ -1,13 +1,12 @@ -package com.example.FixLog.controller; +package com.example.FixLog.domain.member; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.dto.Response; -import com.example.FixLog.dto.WithdrawRequestDto; -import com.example.FixLog.dto.member.MemberInfoResponseDto; -import com.example.FixLog.dto.member.ProfilePreviewResponseDto; -import com.example.FixLog.dto.member.SignupRequestDto; -import com.example.FixLog.dto.member.DuplicateCheckResponseDto; -import com.example.FixLog.service.MemberService; +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.common.exception.Response; +import com.example.FixLog.domain.member.dto.WithdrawRequestDto; +import com.example.FixLog.domain.member.dto.MemberInfoResponseDto; +import com.example.FixLog.domain.member.dto.ProfilePreviewResponseDto; +import com.example.FixLog.domain.member.dto.SignupRequestDto; +import com.example.FixLog.domain.member.dto.DuplicateCheckResponseDto; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; diff --git a/src/main/java/com/example/FixLog/service/MemberService.java b/src/main/java/com/example/FixLog/domain/member/MemberService.java similarity index 82% rename from src/main/java/com/example/FixLog/service/MemberService.java rename to src/main/java/com/example/FixLog/domain/member/MemberService.java index fb899d6..132c86b 100644 --- a/src/main/java/com/example/FixLog/service/MemberService.java +++ b/src/main/java/com/example/FixLog/domain/member/MemberService.java @@ -1,18 +1,18 @@ -package com.example.FixLog.service; - -import com.example.FixLog.domain.bookmark.BookmarkFolder; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.domain.member.SocialType; -import com.example.FixLog.dto.member.LoginResponseDto; -import com.example.FixLog.dto.member.MemberInfoResponseDto; -import com.example.FixLog.dto.member.SignupRequestDto; -import com.example.FixLog.dto.member.edit.EditPasswordRequestDto; -import com.example.FixLog.exception.CustomException; -import com.example.FixLog.exception.ErrorCode; -import com.example.FixLog.repository.MemberRepository; -import com.example.FixLog.repository.bookmark.BookmarkFolderRepository; -import com.example.FixLog.util.DefaultImage; -import com.example.FixLog.util.DefaultText; +package com.example.FixLog.domain.member; + +import com.example.FixLog.domain.bookmark.domain.BookmarkFolder; +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.domain.member.domain.SocialType; +import com.example.FixLog.domain.member.dto.LoginResponseDto; +import com.example.FixLog.domain.member.dto.MemberInfoResponseDto; +import com.example.FixLog.domain.member.dto.SignupRequestDto; +import com.example.FixLog.domain.member.dto.edit.EditPasswordRequestDto; +import com.example.FixLog.common.exception.CustomException; +import com.example.FixLog.common.response.ErrorStatus; +import com.example.FixLog.domain.member.repository.MemberRepository; +import com.example.FixLog.domain.bookmark.repository.BookmarkFolderRepository; +import com.example.FixLog.common.util.DefaultImage; +import com.example.FixLog.common.util.DefaultText; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; @@ -62,7 +62,7 @@ public Member getCurrentMemberInfo() { // 예외 처리 O String email = authentication.getName(); return memberRepository.findByEmail(email) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); } @Transactional(readOnly = true) @@ -128,7 +128,7 @@ public void editBio(Member member, String newBio) { @Transactional public void withdraw(Member member, String password) { if (!passwordEncoder.matches(password, member.getPassword())) { - throw new CustomException(ErrorCode.INVALID_PASSWORD); + throw new CustomException(ErrorStatus.INVALID_PASSWORD); } member.markAsDeleted(); memberRepository.save(member); @@ -172,14 +172,14 @@ public LoginResponseDto getLoginResponse(Member member, String accessToken) { public void validateEmail(String email) { System.out.println("이메일 중복 검사 진행 중: " + email); if (isEmailDuplicated(email)) { - throw new CustomException(ErrorCode.EMAIL_DUPLICATED); + throw new CustomException(ErrorStatus.EMAIL_DUPLICATED); } } public void validateNickname(String nickname) { System.out.println(" 닉네임 중복 검사 진행 중: " + nickname); if (isNicknameDuplicated(nickname)) { - throw new CustomException(ErrorCode.NICKNAME_DUPLICATED); + throw new CustomException(ErrorStatus.NICKNAME_DUPLICATED); } } @@ -193,10 +193,10 @@ public boolean isNicknameDuplicated(String nickname) { public void validatePasswordChange(String currentPassword, String newPassword, String encodedPassword) { if (!passwordEncoder.matches(currentPassword, encodedPassword)) { - throw new CustomException(ErrorCode.INVALID_PASSWORD); + throw new CustomException(ErrorStatus.INVALID_PASSWORD); } if (passwordEncoder.matches(newPassword, encodedPassword)) { - throw new CustomException(ErrorCode.SAME_AS_OLD_PASSWORD); + throw new CustomException(ErrorStatus.SAME_AS_OLD_PASSWORD); } } } \ No newline at end of file diff --git a/src/main/java/com/example/FixLog/domain/member/Member.java b/src/main/java/com/example/FixLog/domain/member/domain/Member.java similarity index 95% rename from src/main/java/com/example/FixLog/domain/member/Member.java rename to src/main/java/com/example/FixLog/domain/member/domain/Member.java index 51ea83d..0aa7e65 100644 --- a/src/main/java/com/example/FixLog/domain/member/Member.java +++ b/src/main/java/com/example/FixLog/domain/member/domain/Member.java @@ -1,7 +1,7 @@ -package com.example.FixLog.domain.member; +package com.example.FixLog.domain.member.domain; -import com.example.FixLog.domain.bookmark.BookmarkFolder; -import com.example.FixLog.domain.post.Post; +import com.example.FixLog.domain.bookmark.domain.BookmarkFolder; +import com.example.FixLog.domain.post.domain.Post; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/domain/member/SocialType.java b/src/main/java/com/example/FixLog/domain/member/domain/SocialType.java similarity index 50% rename from src/main/java/com/example/FixLog/domain/member/SocialType.java rename to src/main/java/com/example/FixLog/domain/member/domain/SocialType.java index 3f7c286..4e394d0 100644 --- a/src/main/java/com/example/FixLog/domain/member/SocialType.java +++ b/src/main/java/com/example/FixLog/domain/member/domain/SocialType.java @@ -1,4 +1,4 @@ -package com.example.FixLog.domain.member; +package com.example.FixLog.domain.member.domain; public enum SocialType { EMAIL, diff --git a/src/main/java/com/example/FixLog/dto/member/DuplicateCheckResponseDto.java b/src/main/java/com/example/FixLog/domain/member/dto/DuplicateCheckResponseDto.java similarity index 77% rename from src/main/java/com/example/FixLog/dto/member/DuplicateCheckResponseDto.java rename to src/main/java/com/example/FixLog/domain/member/dto/DuplicateCheckResponseDto.java index d896d70..f71e850 100644 --- a/src/main/java/com/example/FixLog/dto/member/DuplicateCheckResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/member/dto/DuplicateCheckResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.member; +package com.example.FixLog.domain.member.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/member/LoginRequestDto.java b/src/main/java/com/example/FixLog/domain/member/dto/LoginRequestDto.java similarity index 72% rename from src/main/java/com/example/FixLog/dto/member/LoginRequestDto.java rename to src/main/java/com/example/FixLog/domain/member/dto/LoginRequestDto.java index f1fd07f..fad30f3 100644 --- a/src/main/java/com/example/FixLog/dto/member/LoginRequestDto.java +++ b/src/main/java/com/example/FixLog/domain/member/dto/LoginRequestDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.member; +package com.example.FixLog.domain.member.dto; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/member/LoginResponseDto.java b/src/main/java/com/example/FixLog/domain/member/dto/LoginResponseDto.java similarity index 82% rename from src/main/java/com/example/FixLog/dto/member/LoginResponseDto.java rename to src/main/java/com/example/FixLog/domain/member/dto/LoginResponseDto.java index 3fe9560..bc566f3 100644 --- a/src/main/java/com/example/FixLog/dto/member/LoginResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/member/dto/LoginResponseDto.java @@ -1,7 +1,7 @@ -package com.example.FixLog.dto.member; +package com.example.FixLog.domain.member.dto; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.util.DefaultImage; +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.common.util.DefaultImage; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/member/MemberInfoResponseDto.java b/src/main/java/com/example/FixLog/domain/member/dto/MemberInfoResponseDto.java similarity index 75% rename from src/main/java/com/example/FixLog/dto/member/MemberInfoResponseDto.java rename to src/main/java/com/example/FixLog/domain/member/dto/MemberInfoResponseDto.java index 1596a53..3db0a7c 100644 --- a/src/main/java/com/example/FixLog/dto/member/MemberInfoResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/member/dto/MemberInfoResponseDto.java @@ -1,6 +1,6 @@ -package com.example.FixLog.dto.member; +package com.example.FixLog.domain.member.dto; -import com.example.FixLog.domain.member.SocialType; +import com.example.FixLog.domain.member.domain.SocialType; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/member/ProfilePreviewResponseDto.java b/src/main/java/com/example/FixLog/domain/member/dto/ProfilePreviewResponseDto.java similarity index 80% rename from src/main/java/com/example/FixLog/dto/member/ProfilePreviewResponseDto.java rename to src/main/java/com/example/FixLog/domain/member/dto/ProfilePreviewResponseDto.java index 17f8ec7..ff8fa7a 100644 --- a/src/main/java/com/example/FixLog/dto/member/ProfilePreviewResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/member/dto/ProfilePreviewResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.member; +package com.example.FixLog.domain.member.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/member/SignupRequestDto.java b/src/main/java/com/example/FixLog/domain/member/dto/SignupRequestDto.java similarity index 83% rename from src/main/java/com/example/FixLog/dto/member/SignupRequestDto.java rename to src/main/java/com/example/FixLog/domain/member/dto/SignupRequestDto.java index 60fac74..64fd600 100644 --- a/src/main/java/com/example/FixLog/dto/member/SignupRequestDto.java +++ b/src/main/java/com/example/FixLog/domain/member/dto/SignupRequestDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.member; +package com.example.FixLog.domain.member.dto; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/example/FixLog/dto/WithdrawRequestDto.java b/src/main/java/com/example/FixLog/domain/member/dto/WithdrawRequestDto.java similarity index 67% rename from src/main/java/com/example/FixLog/dto/WithdrawRequestDto.java rename to src/main/java/com/example/FixLog/domain/member/dto/WithdrawRequestDto.java index 680dafd..5d491ad 100644 --- a/src/main/java/com/example/FixLog/dto/WithdrawRequestDto.java +++ b/src/main/java/com/example/FixLog/domain/member/dto/WithdrawRequestDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto; +package com.example.FixLog.domain.member.dto; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/member/edit/EditBioRequestDto.java b/src/main/java/com/example/FixLog/domain/member/dto/edit/EditBioRequestDto.java similarity index 84% rename from src/main/java/com/example/FixLog/dto/member/edit/EditBioRequestDto.java rename to src/main/java/com/example/FixLog/domain/member/dto/edit/EditBioRequestDto.java index 488b097..f3cd42f 100644 --- a/src/main/java/com/example/FixLog/dto/member/edit/EditBioRequestDto.java +++ b/src/main/java/com/example/FixLog/domain/member/dto/edit/EditBioRequestDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.member.edit; +package com.example.FixLog.domain.member.dto.edit; import jakarta.validation.constraints.Size; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/member/edit/EditNicknameRequestDto.java b/src/main/java/com/example/FixLog/domain/member/dto/edit/EditNicknameRequestDto.java similarity index 89% rename from src/main/java/com/example/FixLog/dto/member/edit/EditNicknameRequestDto.java rename to src/main/java/com/example/FixLog/domain/member/dto/edit/EditNicknameRequestDto.java index dbd4ce7..d700345 100644 --- a/src/main/java/com/example/FixLog/dto/member/edit/EditNicknameRequestDto.java +++ b/src/main/java/com/example/FixLog/domain/member/dto/edit/EditNicknameRequestDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.member.edit; +package com.example.FixLog.domain.member.dto.edit; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; diff --git a/src/main/java/com/example/FixLog/dto/member/edit/EditPasswordRequestDto.java b/src/main/java/com/example/FixLog/domain/member/dto/edit/EditPasswordRequestDto.java similarity index 91% rename from src/main/java/com/example/FixLog/dto/member/edit/EditPasswordRequestDto.java rename to src/main/java/com/example/FixLog/domain/member/dto/edit/EditPasswordRequestDto.java index 50d3931..13951d5 100644 --- a/src/main/java/com/example/FixLog/dto/member/edit/EditPasswordRequestDto.java +++ b/src/main/java/com/example/FixLog/domain/member/dto/edit/EditPasswordRequestDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.member.edit; +package com.example.FixLog.domain.member.dto.edit; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; diff --git a/src/main/java/com/example/FixLog/dto/member/edit/EditProfileImageRequestDto.java b/src/main/java/com/example/FixLog/domain/member/dto/edit/EditProfileImageRequestDto.java similarity index 84% rename from src/main/java/com/example/FixLog/dto/member/edit/EditProfileImageRequestDto.java rename to src/main/java/com/example/FixLog/domain/member/dto/edit/EditProfileImageRequestDto.java index f9d8603..734b9bc 100644 --- a/src/main/java/com/example/FixLog/dto/member/edit/EditProfileImageRequestDto.java +++ b/src/main/java/com/example/FixLog/domain/member/dto/edit/EditProfileImageRequestDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.member.edit; +package com.example.FixLog.domain.member.dto.edit; import jakarta.validation.constraints.NotBlank; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/repository/MemberRepository.java b/src/main/java/com/example/FixLog/domain/member/repository/MemberRepository.java similarity index 73% rename from src/main/java/com/example/FixLog/repository/MemberRepository.java rename to src/main/java/com/example/FixLog/domain/member/repository/MemberRepository.java index 2193c39..fbe04a7 100644 --- a/src/main/java/com/example/FixLog/repository/MemberRepository.java +++ b/src/main/java/com/example/FixLog/domain/member/repository/MemberRepository.java @@ -1,7 +1,7 @@ -package com.example.FixLog.repository; +package com.example.FixLog.domain.member.repository; import org.springframework.data.jpa.repository.JpaRepository; -import com.example.FixLog.domain.member.Member; +import com.example.FixLog.domain.member.domain.Member; import java.util.Optional; diff --git a/src/main/java/com/example/FixLog/controller/MypageMemberController.java b/src/main/java/com/example/FixLog/domain/mypage/MypageMemberController.java similarity index 78% rename from src/main/java/com/example/FixLog/controller/MypageMemberController.java rename to src/main/java/com/example/FixLog/domain/mypage/MypageMemberController.java index e5ace04..6d09b75 100644 --- a/src/main/java/com/example/FixLog/controller/MypageMemberController.java +++ b/src/main/java/com/example/FixLog/domain/mypage/MypageMemberController.java @@ -1,22 +1,22 @@ -package com.example.FixLog.controller; +package com.example.FixLog.domain.mypage; -import com.example.FixLog.dto.PresignResponseDto; -import com.example.FixLog.dto.Response; -import com.example.FixLog.dto.member.edit.EditNicknameRequestDto; -import com.example.FixLog.dto.member.edit.EditPasswordRequestDto; -import com.example.FixLog.dto.member.edit.EditBioRequestDto; -import com.example.FixLog.exception.CustomException; -import com.example.FixLog.exception.ErrorCode; -import com.example.FixLog.service.S3Service; -import com.example.FixLog.service.MemberService; -import com.example.FixLog.domain.member.Member; +import com.example.FixLog.domain.mypage.dto.PresignResponseDto; +import com.example.FixLog.common.exception.Response; +import com.example.FixLog.domain.member.dto.edit.EditNicknameRequestDto; +import com.example.FixLog.domain.member.dto.edit.EditPasswordRequestDto; +import com.example.FixLog.domain.member.dto.edit.EditBioRequestDto; +import com.example.FixLog.common.exception.CustomException; +import com.example.FixLog.common.response.ErrorStatus; +import com.example.FixLog.infra.s3.S3Service; +import com.example.FixLog.domain.member.MemberService; +import com.example.FixLog.domain.member.domain.Member; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import jakarta.validation.Valid; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; -import com.example.FixLog.dto.s3.PresignedUploadResponseDto; +import com.example.FixLog.infra.s3.PresignedUploadResponseDto; import java.util.Map; @@ -55,7 +55,7 @@ public ResponseEntity> presignProfileImage( @AuthenticationPrincipal Member member, @RequestParam String filename ) { - if (member == null) throw new CustomException(ErrorCode.UNAUTHORIZED); + if (member == null) throw new CustomException(ErrorStatus.UNAUTHORIZED); PresignedUploadResponseDto responseDto = s3Service.generatePresignedUploadUrl("profile", filename, 15); String uploadUrl = responseDto.getPresignedUrl(); @@ -73,7 +73,7 @@ public ResponseEntity> updateProfileImageUrl( ) { String imageUrl = body.get("imageUrl"); if (imageUrl == null || imageUrl.isBlank()) { - throw new CustomException(ErrorCode.INVALID_REQUEST); + throw new CustomException(ErrorStatus.INVALID_REQUEST); } memberService.editProfileImage(member, imageUrl); return ResponseEntity.ok(Response.success("프로필 이미지 저장 성공", "SUCCESS")); diff --git a/src/main/java/com/example/FixLog/controller/MypagePostController.java b/src/main/java/com/example/FixLog/domain/mypage/MypagePostController.java similarity index 89% rename from src/main/java/com/example/FixLog/controller/MypagePostController.java rename to src/main/java/com/example/FixLog/domain/mypage/MypagePostController.java index efd76e7..b26d37f 100644 --- a/src/main/java/com/example/FixLog/controller/MypagePostController.java +++ b/src/main/java/com/example/FixLog/domain/mypage/MypagePostController.java @@ -1,9 +1,8 @@ -package com.example.FixLog.controller; +package com.example.FixLog.domain.mypage; -import com.example.FixLog.dto.PageResponseDto; -import com.example.FixLog.dto.Response; -import com.example.FixLog.dto.post.MyPostPageResponseDto; -import com.example.FixLog.service.MypagePostService; +import com.example.FixLog.domain.mypage.dto.PageResponseDto; +import com.example.FixLog.common.exception.Response; +import com.example.FixLog.domain.post.dto.MyPostPageResponseDto; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; diff --git a/src/main/java/com/example/FixLog/service/MypagePostService.java b/src/main/java/com/example/FixLog/domain/mypage/MypagePostService.java similarity index 78% rename from src/main/java/com/example/FixLog/service/MypagePostService.java rename to src/main/java/com/example/FixLog/domain/mypage/MypagePostService.java index 84873af..b5ca537 100644 --- a/src/main/java/com/example/FixLog/service/MypagePostService.java +++ b/src/main/java/com/example/FixLog/domain/mypage/MypagePostService.java @@ -1,16 +1,16 @@ -package com.example.FixLog.service; +package com.example.FixLog.domain.mypage; -import com.example.FixLog.domain.like.PostLike; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.domain.post.Post; -import com.example.FixLog.dto.PageResponseDto; -import com.example.FixLog.dto.post.MyPostPageResponseDto; -import com.example.FixLog.exception.CustomException; -import com.example.FixLog.exception.ErrorCode; -import com.example.FixLog.repository.MemberRepository; -import com.example.FixLog.repository.fork.ForkRepository; -import com.example.FixLog.repository.like.PostLikeRepository; -import com.example.FixLog.repository.post.PostRepository; +import com.example.FixLog.domain.post.domain.PostLike; +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.domain.post.domain.Post; +import com.example.FixLog.domain.mypage.dto.PageResponseDto; +import com.example.FixLog.domain.post.dto.MyPostPageResponseDto; +import com.example.FixLog.common.exception.CustomException; +import com.example.FixLog.common.response.ErrorStatus; +import com.example.FixLog.domain.member.repository.MemberRepository; +import com.example.FixLog.domain.post.repository.ForkRepository; +import com.example.FixLog.domain.post.repository.PostLikeRepository; +import com.example.FixLog.domain.post.repository.PostRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -39,7 +39,7 @@ public MypagePostService(PostRepository postRepository, MemberRepository memberR // 내가 쓴 글 보기 public PageResponseDto getMyPosts(String email, int page, int sort, int size) { Member member = memberRepository.findByEmail(email) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); // 1: 오래된순, 0: 최신순 Sort.Direction direction = (sort == 1) ? Sort.Direction.ASC : Sort.Direction.DESC; @@ -64,7 +64,7 @@ public PageResponseDto getMyPosts(String email, int page, // 내가 좋아요한 글 보기 public PageResponseDto getLikedPosts(String email, int page, int sort, int size) { Member member = memberRepository.findByEmail(email) - .orElseThrow(() -> new CustomException(ErrorCode.USER_EMAIL_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.USER_EMAIL_NOT_FOUND)); // 1: 오래된순, 0: 최신순 Sort.Direction direction = (sort == 1) ? Sort.Direction.ASC : Sort.Direction.DESC; diff --git a/src/main/java/com/example/FixLog/dto/PageResponseDto.java b/src/main/java/com/example/FixLog/domain/mypage/dto/PageResponseDto.java similarity index 95% rename from src/main/java/com/example/FixLog/dto/PageResponseDto.java rename to src/main/java/com/example/FixLog/domain/mypage/dto/PageResponseDto.java index 8cfc04e..0a2d714 100644 --- a/src/main/java/com/example/FixLog/dto/PageResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/mypage/dto/PageResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto; +package com.example.FixLog.domain.mypage.dto; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/PresignResponseDto.java b/src/main/java/com/example/FixLog/domain/mypage/dto/PresignResponseDto.java similarity index 84% rename from src/main/java/com/example/FixLog/dto/PresignResponseDto.java rename to src/main/java/com/example/FixLog/domain/mypage/dto/PresignResponseDto.java index 39ec68f..6088d22 100644 --- a/src/main/java/com/example/FixLog/dto/PresignResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/mypage/dto/PresignResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto; +package com.example.FixLog.domain.mypage.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/controller/PostController.java b/src/main/java/com/example/FixLog/domain/post/PostController.java similarity index 86% rename from src/main/java/com/example/FixLog/controller/PostController.java rename to src/main/java/com/example/FixLog/domain/post/PostController.java index 84d6601..565d98c 100644 --- a/src/main/java/com/example/FixLog/controller/PostController.java +++ b/src/main/java/com/example/FixLog/domain/post/PostController.java @@ -1,21 +1,18 @@ -package com.example.FixLog.controller; +package com.example.FixLog.domain.post; -import com.example.FixLog.dto.post.PostRequestDto; -import com.example.FixLog.dto.Response; -import com.example.FixLog.dto.post.PostResponseDto; -import com.example.FixLog.service.PostService; +import com.example.FixLog.domain.post.dto.PostRequestDto; +import com.example.FixLog.common.exception.Response; +import com.example.FixLog.domain.post.dto.PostResponseDto; +import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @RestController +@RequiredArgsConstructor @RequestMapping("/posts") public class PostController { private final PostService postService; - public PostController(PostService postService){ - this.postService = postService; - } - // 게시글 작성하기 @PostMapping public Response createPost(@RequestBody PostRequestDto postRequestDto){ diff --git a/src/main/java/com/example/FixLog/service/PostService.java b/src/main/java/com/example/FixLog/domain/post/PostService.java similarity index 86% rename from src/main/java/com/example/FixLog/service/PostService.java rename to src/main/java/com/example/FixLog/domain/post/PostService.java index 9c7dfe1..9e214f9 100644 --- a/src/main/java/com/example/FixLog/service/PostService.java +++ b/src/main/java/com/example/FixLog/domain/post/PostService.java @@ -1,23 +1,25 @@ -package com.example.FixLog.service; - -import com.example.FixLog.domain.bookmark.Bookmark; -import com.example.FixLog.domain.bookmark.BookmarkFolder; -import com.example.FixLog.domain.like.PostLike; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.domain.post.Post; -import com.example.FixLog.domain.post.PostTag; -import com.example.FixLog.domain.tag.Tag; -import com.example.FixLog.domain.tag.TagCategory; -import com.example.FixLog.dto.post.PostDto; -import com.example.FixLog.dto.post.PostRequestDto; -import com.example.FixLog.dto.post.PostResponseDto; -import com.example.FixLog.exception.CustomException; -import com.example.FixLog.exception.ErrorCode; -import com.example.FixLog.repository.bookmark.BookmarkFolderRepository; -import com.example.FixLog.repository.bookmark.BookmarkRepository; -import com.example.FixLog.repository.like.PostLikeRepository; -import com.example.FixLog.repository.post.PostRepository; -import com.example.FixLog.repository.tag.TagRepository; +package com.example.FixLog.domain.post; + +import com.example.FixLog.domain.bookmark.domain.Bookmark; +import com.example.FixLog.domain.bookmark.domain.BookmarkFolder; +import com.example.FixLog.domain.post.domain.PostLike; +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.domain.post.domain.Post; +import com.example.FixLog.domain.post.domain.PostTag; +import com.example.FixLog.domain.tag.domain.Tag; +import com.example.FixLog.domain.tag.domain.TagCategory; +import com.example.FixLog.domain.post.dto.PostDto; +import com.example.FixLog.domain.post.dto.PostRequestDto; +import com.example.FixLog.domain.post.dto.PostResponseDto; +import com.example.FixLog.common.exception.CustomException; +import com.example.FixLog.common.response.ErrorStatus; +import com.example.FixLog.domain.bookmark.repository.BookmarkFolderRepository; +import com.example.FixLog.domain.bookmark.repository.BookmarkRepository; +import com.example.FixLog.domain.post.repository.PostLikeRepository; +import com.example.FixLog.domain.post.repository.PostRepository; +import com.example.FixLog.domain.tag.repository.TagRepository; +import com.example.FixLog.domain.member.MemberService; +import com.example.FixLog.infra.s3.S3Service; import jakarta.transaction.Transactional; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; @@ -111,7 +113,7 @@ private List fetchAndValidateTags(List tagNames){ // 태그 이름으로 Tag 엔티티 조회 List tags = tagNames.stream() .map(tagName -> tagRepository.findByTagName(tagName) - .orElseThrow(() -> new CustomException(ErrorCode.TAG_NOT_FOUND))) + .orElseThrow(() -> new CustomException(ErrorStatus.TAG_NOT_FOUND))) .toList(); // 태그 종류별로 그룹화 @@ -141,7 +143,7 @@ else if (categories.size()> 1) if (!issues.isEmpty()) { String message = String.join(" / ", issues); - throw new CustomException(ErrorCode.REQUIRED_TAGS_MISSING, message); + throw new CustomException(ErrorStatus.REQUIRED_TAGS_MISSING, message); } return tags; } @@ -154,7 +156,7 @@ private void validatePost(PostRequestDto postRequestDto){ || !StringUtils.hasText(postRequestDto.getEnvironment()) || !StringUtils.hasText(postRequestDto.getReproduceCode()) || !StringUtils.hasText(postRequestDto.getSolutionCode())) - throw new CustomException(ErrorCode.REQUIRED_CONTENT_MISSING); + throw new CustomException(ErrorStatus.REQUIRED_CONTENT_MISSING); } // 이미지 파일 마크다운으로 변경 @@ -163,7 +165,7 @@ public String uploadImage(MultipartFile imageFile){ SecurityContextHolder.getContext().getAuthentication(); if (imageFile == null || imageFile.isEmpty()){ - throw new CustomException(ErrorCode.IMAGE_UPLOAD_FAILED); + throw new CustomException(ErrorStatus.IMAGE_UPLOAD_FAILED); } String imageUrl = s3Service.upload(imageFile, "post-image"); @@ -175,11 +177,11 @@ public String uploadImage(MultipartFile imageFile){ public void editPost(Long postId, PostRequestDto postRequestDto) { Member member = memberService.getCurrentMemberInfo(); Post post = postRepository.findById(postId) - .orElseThrow(() -> new CustomException(ErrorCode.POST_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.POST_NOT_FOUND)); // 게시글 작성자가 본인이 맞는지 if (!member.getUserId().equals(post.getUserId().getUserId())) { - throw new CustomException(ErrorCode.POST_UPDATE_FORBIDDEN); + throw new CustomException(ErrorStatus.POST_UPDATE_FORBIDDEN); } // 북마크 카테고리별로 선택 제한 두기 @@ -197,7 +199,7 @@ public void editPost(Long postId, PostRequestDto postRequestDto) { && Objects.equals(post.getReferenceLink(), postRequestDto.getReferenceLink()) && Objects.equals(post.getExtraContent(), postRequestDto.getExtraContent()) && compareTags(post.getPostTags(), tags)){ - throw new CustomException(ErrorCode.NO_CONTENT_CHANGED); + throw new CustomException(ErrorStatus.NO_CONTENT_CHANGED); } // 필드 업데이트 @@ -236,7 +238,7 @@ public PostResponseDto viewPost(Long postId){ Optional optionalMember = memberService.getCurrentOptionalMemberInfo(); Post currentPost = postRepository.findById(postId) - .orElseThrow(() -> new CustomException(ErrorCode.POST_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.POST_NOT_FOUND)); PostDto postInfo = new PostDto( currentPost.getUserId().getUserId(), @@ -286,7 +288,7 @@ public String togglePostLike(Long postIdInput){ Member member = memberService.getCurrentMemberInfo(); Post postId = postRepository.findById(postIdInput) - .orElseThrow(() -> new CustomException(ErrorCode.POST_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.POST_NOT_FOUND)); Optional optionalLike = postLikeRepository.findByUserIdAndPostId(member, postId); @@ -309,14 +311,14 @@ public String togglePostLike(Long postIdInput){ public String toggleBookmark(Long postIdInput){ Member member = memberService.getCurrentMemberInfo(); Post postId = postRepository.findById(postIdInput) - .orElseThrow(() -> new CustomException(ErrorCode.POST_NOT_FOUND)); + .orElseThrow(() -> new CustomException(ErrorStatus.POST_NOT_FOUND)); BookmarkFolder folderId = bookmarkFolderRepository.findByUserId(member); // 이 코드는 폴더가 하나일 때만 적용됨 Optional optionalBookmark = bookmarkRepository.findByFolderIdAndPostId(folderId, postId); // 본인 글은 북마크 못하도록 if (member == postId.getUserId()) - throw new CustomException(ErrorCode.SELF_BOOKMARK_NOT_ALLOWED); + throw new CustomException(ErrorStatus.SELF_BOOKMARK_NOT_ALLOWED); // 북마크 처리 if (optionalBookmark.isEmpty()){ // 객체 없는 경우 Bookmark newBookmark = new Bookmark(folderId, postId); diff --git a/src/main/java/com/example/FixLog/domain/fork/Fork.java b/src/main/java/com/example/FixLog/domain/post/domain/Fork.java similarity index 84% rename from src/main/java/com/example/FixLog/domain/fork/Fork.java rename to src/main/java/com/example/FixLog/domain/post/domain/Fork.java index 81911ee..666ce7e 100644 --- a/src/main/java/com/example/FixLog/domain/fork/Fork.java +++ b/src/main/java/com/example/FixLog/domain/post/domain/Fork.java @@ -1,7 +1,6 @@ -package com.example.FixLog.domain.fork; +package com.example.FixLog.domain.post.domain; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.domain.post.Post; +import com.example.FixLog.domain.member.domain.Member; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/domain/post/Post.java b/src/main/java/com/example/FixLog/domain/post/domain/Post.java similarity index 94% rename from src/main/java/com/example/FixLog/domain/post/Post.java rename to src/main/java/com/example/FixLog/domain/post/domain/Post.java index af74e14..7cefcca 100644 --- a/src/main/java/com/example/FixLog/domain/post/Post.java +++ b/src/main/java/com/example/FixLog/domain/post/domain/Post.java @@ -1,8 +1,7 @@ -package com.example.FixLog.domain.post; +package com.example.FixLog.domain.post.domain; -import com.example.FixLog.domain.bookmark.Bookmark; -import com.example.FixLog.domain.like.PostLike; -import com.example.FixLog.domain.member.Member; +import com.example.FixLog.domain.bookmark.domain.Bookmark; +import com.example.FixLog.domain.member.domain.Member; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/com/example/FixLog/domain/like/PostLike.java b/src/main/java/com/example/FixLog/domain/post/domain/PostLike.java similarity index 86% rename from src/main/java/com/example/FixLog/domain/like/PostLike.java rename to src/main/java/com/example/FixLog/domain/post/domain/PostLike.java index f4f224d..4d4b313 100644 --- a/src/main/java/com/example/FixLog/domain/like/PostLike.java +++ b/src/main/java/com/example/FixLog/domain/post/domain/PostLike.java @@ -1,7 +1,6 @@ -package com.example.FixLog.domain.like; +package com.example.FixLog.domain.post.domain; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.domain.post.Post; +import com.example.FixLog.domain.member.domain.Member; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/domain/post/PostTag.java b/src/main/java/com/example/FixLog/domain/post/domain/PostTag.java similarity index 87% rename from src/main/java/com/example/FixLog/domain/post/PostTag.java rename to src/main/java/com/example/FixLog/domain/post/domain/PostTag.java index 549fbe0..80a8d92 100644 --- a/src/main/java/com/example/FixLog/domain/post/PostTag.java +++ b/src/main/java/com/example/FixLog/domain/post/domain/PostTag.java @@ -1,6 +1,6 @@ -package com.example.FixLog.domain.post; +package com.example.FixLog.domain.post.domain; -import com.example.FixLog.domain.tag.Tag; +import com.example.FixLog.domain.tag.domain.Tag; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/post/MyPostPageResponseDto.java b/src/main/java/com/example/FixLog/domain/post/dto/MyPostPageResponseDto.java similarity index 95% rename from src/main/java/com/example/FixLog/dto/post/MyPostPageResponseDto.java rename to src/main/java/com/example/FixLog/domain/post/dto/MyPostPageResponseDto.java index 7b86fd0..1396b21 100644 --- a/src/main/java/com/example/FixLog/dto/post/MyPostPageResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/post/dto/MyPostPageResponseDto.java @@ -1,6 +1,6 @@ -package com.example.FixLog.dto.post; +package com.example.FixLog.domain.post.dto; -import com.example.FixLog.domain.post.Post; +import com.example.FixLog.domain.post.domain.Post; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/post/PostDto.java b/src/main/java/com/example/FixLog/domain/post/dto/PostDto.java similarity index 92% rename from src/main/java/com/example/FixLog/dto/post/PostDto.java rename to src/main/java/com/example/FixLog/domain/post/dto/PostDto.java index 726115b..770c429 100644 --- a/src/main/java/com/example/FixLog/dto/post/PostDto.java +++ b/src/main/java/com/example/FixLog/domain/post/dto/PostDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.post; +package com.example.FixLog.domain.post.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/post/PostRequestDto.java b/src/main/java/com/example/FixLog/domain/post/dto/PostRequestDto.java similarity index 91% rename from src/main/java/com/example/FixLog/dto/post/PostRequestDto.java rename to src/main/java/com/example/FixLog/domain/post/dto/PostRequestDto.java index 6efad06..7c7c9f4 100644 --- a/src/main/java/com/example/FixLog/dto/post/PostRequestDto.java +++ b/src/main/java/com/example/FixLog/domain/post/dto/PostRequestDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.post; +package com.example.FixLog.domain.post.dto; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/post/PostResponseDto.java b/src/main/java/com/example/FixLog/domain/post/dto/PostResponseDto.java similarity index 88% rename from src/main/java/com/example/FixLog/dto/post/PostResponseDto.java rename to src/main/java/com/example/FixLog/domain/post/dto/PostResponseDto.java index a7ecd19..1c7729e 100644 --- a/src/main/java/com/example/FixLog/dto/post/PostResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/post/dto/PostResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.post; +package com.example.FixLog.domain.post.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/repository/fork/ForkRepository.java b/src/main/java/com/example/FixLog/domain/post/repository/ForkRepository.java similarity index 77% rename from src/main/java/com/example/FixLog/repository/fork/ForkRepository.java rename to src/main/java/com/example/FixLog/domain/post/repository/ForkRepository.java index 7cb6a77..e3a9bdb 100644 --- a/src/main/java/com/example/FixLog/repository/fork/ForkRepository.java +++ b/src/main/java/com/example/FixLog/domain/post/repository/ForkRepository.java @@ -1,7 +1,7 @@ -package com.example.FixLog.repository.fork; +package com.example.FixLog.domain.post.repository; -import com.example.FixLog.domain.fork.Fork; -import com.example.FixLog.domain.post.Post; +import com.example.FixLog.domain.post.domain.Fork; +import com.example.FixLog.domain.post.domain.Post; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; diff --git a/src/main/java/com/example/FixLog/repository/like/PostLikeRepository.java b/src/main/java/com/example/FixLog/domain/post/repository/PostLikeRepository.java similarity index 65% rename from src/main/java/com/example/FixLog/repository/like/PostLikeRepository.java rename to src/main/java/com/example/FixLog/domain/post/repository/PostLikeRepository.java index 301f1ec..fa831ca 100644 --- a/src/main/java/com/example/FixLog/repository/like/PostLikeRepository.java +++ b/src/main/java/com/example/FixLog/domain/post/repository/PostLikeRepository.java @@ -1,8 +1,8 @@ -package com.example.FixLog.repository.like; +package com.example.FixLog.domain.post.repository; -import com.example.FixLog.domain.like.PostLike; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.domain.post.Post; +import com.example.FixLog.domain.post.domain.PostLike; +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.domain.post.domain.Post; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/com/example/FixLog/repository/post/PostRepository.java b/src/main/java/com/example/FixLog/domain/post/repository/PostRepository.java similarity index 81% rename from src/main/java/com/example/FixLog/repository/post/PostRepository.java rename to src/main/java/com/example/FixLog/domain/post/repository/PostRepository.java index f818a33..3f78ce0 100644 --- a/src/main/java/com/example/FixLog/repository/post/PostRepository.java +++ b/src/main/java/com/example/FixLog/domain/post/repository/PostRepository.java @@ -1,7 +1,7 @@ -package com.example.FixLog.repository.post; +package com.example.FixLog.domain.post.repository; -import com.example.FixLog.domain.member.Member; -import com.example.FixLog.domain.post.Post; +import com.example.FixLog.domain.member.domain.Member; +import com.example.FixLog.domain.post.domain.Post; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.EntityGraph; diff --git a/src/main/java/com/example/FixLog/repository/post/PostRepositoryCustom.java b/src/main/java/com/example/FixLog/domain/post/repository/PostRepositoryCustom.java similarity index 68% rename from src/main/java/com/example/FixLog/repository/post/PostRepositoryCustom.java rename to src/main/java/com/example/FixLog/domain/post/repository/PostRepositoryCustom.java index 6c820ae..4721137 100644 --- a/src/main/java/com/example/FixLog/repository/post/PostRepositoryCustom.java +++ b/src/main/java/com/example/FixLog/domain/post/repository/PostRepositoryCustom.java @@ -1,6 +1,6 @@ -package com.example.FixLog.repository.post; +package com.example.FixLog.domain.post.repository; -import com.example.FixLog.dto.search.SearchPostDto; +import com.example.FixLog.domain.mainPage.dto.search.SearchPostDto; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/src/main/java/com/example/FixLog/repository/post/PostRepositoryImpl.java b/src/main/java/com/example/FixLog/domain/post/repository/PostRepositoryImpl.java similarity index 91% rename from src/main/java/com/example/FixLog/repository/post/PostRepositoryImpl.java rename to src/main/java/com/example/FixLog/domain/post/repository/PostRepositoryImpl.java index 231abd1..54ae07c 100644 --- a/src/main/java/com/example/FixLog/repository/post/PostRepositoryImpl.java +++ b/src/main/java/com/example/FixLog/domain/post/repository/PostRepositoryImpl.java @@ -1,7 +1,7 @@ -package com.example.FixLog.repository.post; +package com.example.FixLog.domain.post.repository; -import com.example.FixLog.domain.post.Post; -import com.example.FixLog.dto.search.SearchPostDto; +import com.example.FixLog.domain.post.domain.Post; +import com.example.FixLog.domain.mainPage.dto.search.SearchPostDto; import com.querydsl.core.BooleanBuilder; import com.querydsl.core.types.dsl.NumberExpression; import com.querydsl.jpa.JPQLQuery; @@ -14,9 +14,9 @@ import java.util.List; import java.util.stream.Collectors; -import static com.example.FixLog.domain.post.QPost.post; -import static com.example.FixLog.domain.post.QPostTag.postTag; -import static com.example.FixLog.domain.tag.QTag.tag; +import static com.example.FixLog.domain.post.domain.QPost.post; +import static com.example.FixLog.domain.post.domain.QPostTag.postTag; +import static com.example.FixLog.domain.tag.domain.QTag.tag; @RequiredArgsConstructor public class PostRepositoryImpl implements PostRepositoryCustom { diff --git a/src/main/java/com/example/FixLog/repository/post/PostTagRepository.java b/src/main/java/com/example/FixLog/domain/post/repository/PostTagRepository.java similarity index 57% rename from src/main/java/com/example/FixLog/repository/post/PostTagRepository.java rename to src/main/java/com/example/FixLog/domain/post/repository/PostTagRepository.java index 50c25e5..ec519ea 100644 --- a/src/main/java/com/example/FixLog/repository/post/PostTagRepository.java +++ b/src/main/java/com/example/FixLog/domain/post/repository/PostTagRepository.java @@ -1,6 +1,6 @@ -package com.example.FixLog.repository.post; +package com.example.FixLog.domain.post.repository; -import com.example.FixLog.domain.post.PostTag; +import com.example.FixLog.domain.post.domain.PostTag; import org.springframework.data.jpa.repository.JpaRepository; public interface PostTagRepository extends JpaRepository { diff --git a/src/main/java/com/example/FixLog/controller/TagController.java b/src/main/java/com/example/FixLog/domain/tag/TagController.java similarity index 63% rename from src/main/java/com/example/FixLog/controller/TagController.java rename to src/main/java/com/example/FixLog/domain/tag/TagController.java index cd367e9..48d76a5 100644 --- a/src/main/java/com/example/FixLog/controller/TagController.java +++ b/src/main/java/com/example/FixLog/domain/tag/TagController.java @@ -1,19 +1,16 @@ -package com.example.FixLog.controller; +package com.example.FixLog.domain.tag; -import com.example.FixLog.dto.Response; -import com.example.FixLog.dto.tag.TagResponseDto; -import com.example.FixLog.service.TagService; +import com.example.FixLog.common.exception.Response; +import com.example.FixLog.domain.tag.dto.TagResponseDto; +import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; @RestController +@RequiredArgsConstructor @RequestMapping("/tags") public class TagController { private final TagService tagService; - public TagController(TagService tagService){ - this.tagService = tagService; - } - @GetMapping public Response viewTags(@RequestParam("page") int page, @RequestParam("size") int size){ diff --git a/src/main/java/com/example/FixLog/service/TagService.java b/src/main/java/com/example/FixLog/domain/tag/TagService.java similarity index 78% rename from src/main/java/com/example/FixLog/service/TagService.java rename to src/main/java/com/example/FixLog/domain/tag/TagService.java index 77822da..4b565de 100644 --- a/src/main/java/com/example/FixLog/service/TagService.java +++ b/src/main/java/com/example/FixLog/domain/tag/TagService.java @@ -1,10 +1,10 @@ -package com.example.FixLog.service; +package com.example.FixLog.domain.tag; -import com.example.FixLog.domain.tag.Tag; -import com.example.FixLog.domain.tag.TagCategory; -import com.example.FixLog.dto.tag.TagDto; -import com.example.FixLog.dto.tag.TagResponseDto; -import com.example.FixLog.repository.tag.TagRepository; +import com.example.FixLog.domain.tag.domain.Tag; +import com.example.FixLog.domain.tag.domain.TagCategory; +import com.example.FixLog.domain.tag.dto.TagDto; +import com.example.FixLog.domain.tag.dto.TagResponseDto; +import com.example.FixLog.domain.tag.repository.TagRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; diff --git a/src/main/java/com/example/FixLog/domain/tag/Tag.java b/src/main/java/com/example/FixLog/domain/tag/domain/Tag.java similarity index 95% rename from src/main/java/com/example/FixLog/domain/tag/Tag.java rename to src/main/java/com/example/FixLog/domain/tag/domain/Tag.java index 31f290c..ffdaa75 100644 --- a/src/main/java/com/example/FixLog/domain/tag/Tag.java +++ b/src/main/java/com/example/FixLog/domain/tag/domain/Tag.java @@ -1,4 +1,4 @@ -package com.example.FixLog.domain.tag; +package com.example.FixLog.domain.tag.domain; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/com/example/FixLog/domain/tag/TagCategory.java b/src/main/java/com/example/FixLog/domain/tag/domain/TagCategory.java similarity index 89% rename from src/main/java/com/example/FixLog/domain/tag/TagCategory.java rename to src/main/java/com/example/FixLog/domain/tag/domain/TagCategory.java index 19458c2..f49ca16 100644 --- a/src/main/java/com/example/FixLog/domain/tag/TagCategory.java +++ b/src/main/java/com/example/FixLog/domain/tag/domain/TagCategory.java @@ -1,4 +1,4 @@ -package com.example.FixLog.domain.tag; +package com.example.FixLog.domain.tag.domain; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/tag/TagDto.java b/src/main/java/com/example/FixLog/domain/tag/dto/TagDto.java similarity index 79% rename from src/main/java/com/example/FixLog/dto/tag/TagDto.java rename to src/main/java/com/example/FixLog/domain/tag/dto/TagDto.java index 0cdc0c1..d190378 100644 --- a/src/main/java/com/example/FixLog/dto/tag/TagDto.java +++ b/src/main/java/com/example/FixLog/domain/tag/dto/TagDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.tag; +package com.example.FixLog.domain.tag.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/dto/tag/TagResponseDto.java b/src/main/java/com/example/FixLog/domain/tag/dto/TagResponseDto.java similarity index 82% rename from src/main/java/com/example/FixLog/dto/tag/TagResponseDto.java rename to src/main/java/com/example/FixLog/domain/tag/dto/TagResponseDto.java index a91d005..0bcb638 100644 --- a/src/main/java/com/example/FixLog/dto/tag/TagResponseDto.java +++ b/src/main/java/com/example/FixLog/domain/tag/dto/TagResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.tag; +package com.example.FixLog.domain.tag.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/repository/tag/TagRepository.java b/src/main/java/com/example/FixLog/domain/tag/repository/TagRepository.java similarity index 73% rename from src/main/java/com/example/FixLog/repository/tag/TagRepository.java rename to src/main/java/com/example/FixLog/domain/tag/repository/TagRepository.java index aba16ce..659739b 100644 --- a/src/main/java/com/example/FixLog/repository/tag/TagRepository.java +++ b/src/main/java/com/example/FixLog/domain/tag/repository/TagRepository.java @@ -1,7 +1,7 @@ -package com.example.FixLog.repository.tag; +package com.example.FixLog.domain.tag.repository; -import com.example.FixLog.domain.tag.Tag; -import com.example.FixLog.domain.tag.TagCategory; +import com.example.FixLog.domain.tag.domain.Tag; +import com.example.FixLog.domain.tag.domain.TagCategory; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/com/example/FixLog/exception/CustomException.java b/src/main/java/com/example/FixLog/exception/CustomException.java deleted file mode 100644 index 4db97c7..0000000 --- a/src/main/java/com/example/FixLog/exception/CustomException.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.example.FixLog.exception; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -public class CustomException extends RuntimeException { - private final ErrorCode errorCode; - - public CustomException(ErrorCode errorCode) { - super(errorCode.getMessage()); - this.errorCode = errorCode; - } - - public CustomException(ErrorCode errorCode, String detailMessage) { - super(detailMessage); - this.errorCode = errorCode; - } -} diff --git a/src/main/java/com/example/FixLog/dto/s3/PresignedUploadResponseDto.java b/src/main/java/com/example/FixLog/infra/s3/PresignedUploadResponseDto.java similarity index 88% rename from src/main/java/com/example/FixLog/dto/s3/PresignedUploadResponseDto.java rename to src/main/java/com/example/FixLog/infra/s3/PresignedUploadResponseDto.java index 3571185..66d27ad 100644 --- a/src/main/java/com/example/FixLog/dto/s3/PresignedUploadResponseDto.java +++ b/src/main/java/com/example/FixLog/infra/s3/PresignedUploadResponseDto.java @@ -1,4 +1,4 @@ -package com.example.FixLog.dto.s3; +package com.example.FixLog.infra.s3; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/example/FixLog/service/S3Service.java b/src/main/java/com/example/FixLog/infra/s3/S3Service.java similarity index 88% rename from src/main/java/com/example/FixLog/service/S3Service.java rename to src/main/java/com/example/FixLog/infra/s3/S3Service.java index 5af4290..37f81ef 100644 --- a/src/main/java/com/example/FixLog/service/S3Service.java +++ b/src/main/java/com/example/FixLog/infra/s3/S3Service.java @@ -1,12 +1,11 @@ -package com.example.FixLog.service; +package com.example.FixLog.infra.s3; import com.amazonaws.HttpMethod; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest; import com.amazonaws.services.s3.model.ObjectMetadata; -import com.example.FixLog.dto.s3.PresignedUploadResponseDto; -import com.example.FixLog.exception.CustomException; -import com.example.FixLog.exception.ErrorCode; +import com.example.FixLog.common.exception.CustomException; +import com.example.FixLog.common.response.ErrorStatus; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -37,7 +36,7 @@ public String upload(MultipartFile file, String dirName) { try (InputStream is = file.getInputStream()) { amazonS3.putObject(bucket, key, is, metadata); } catch (IOException e) { - throw new CustomException(ErrorCode.S3_UPLOAD_FAILED); + throw new CustomException(ErrorStatus.S3_UPLOAD_FAILED); } return getObjectUrl(key); diff --git a/src/main/java/com/example/FixLog/mock/BookmarkFolderTestDataInitializer.java b/src/main/java/com/example/FixLog/mock/BookmarkFolderTestDataInitializer.java index 81504ba..8d6368e 100644 --- a/src/main/java/com/example/FixLog/mock/BookmarkFolderTestDataInitializer.java +++ b/src/main/java/com/example/FixLog/mock/BookmarkFolderTestDataInitializer.java @@ -1,8 +1,8 @@ package com.example.FixLog.mock; -import com.example.FixLog.domain.bookmark.BookmarkFolder; -import com.example.FixLog.repository.MemberRepository; -import com.example.FixLog.repository.bookmark.BookmarkFolderRepository; +import com.example.FixLog.domain.bookmark.domain.BookmarkFolder; +import com.example.FixLog.domain.member.repository.MemberRepository; +import com.example.FixLog.domain.bookmark.repository.BookmarkFolderRepository; import lombok.RequiredArgsConstructor; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; diff --git a/src/main/java/com/example/FixLog/mock/PostMockDataInitializer.java b/src/main/java/com/example/FixLog/mock/PostMockDataInitializer.java index a8d79ea..7e9ce28 100644 --- a/src/main/java/com/example/FixLog/mock/PostMockDataInitializer.java +++ b/src/main/java/com/example/FixLog/mock/PostMockDataInitializer.java @@ -3,16 +3,16 @@ // import com.example.FixLog.domain.bookmark.Bookmark; // import com.example.FixLog.domain.like.PostLike; // import com.example.FixLog.domain.member.Member; -// import com.example.FixLog.domain.post.Post; -// import com.example.FixLog.domain.post.PostTag; -// import com.example.FixLog.domain.tag.Tag; -// import com.example.FixLog.repository.MemberRepository; -// import com.example.FixLog.repository.bookmark.BookmarkFolderRepository; -// import com.example.FixLog.repository.bookmark.BookmarkRepository; -// import com.example.FixLog.repository.like.PostLikeRepository; -// import com.example.FixLog.repository.post.PostRepository; -// import com.example.FixLog.repository.post.PostTagRepository; -// import com.example.FixLog.repository.tag.TagRepository; +// import com.example.FixLog.post.domain.Post; +// import com.example.FixLog.post.domain.PostTag; +// import com.example.FixLog.tag.domain.Tag; +// import com.example.FixLog.member.repository.MemberRepository; +// import com.example.FixLog.bookmark.repository.BookmarkFolderRepository; +// import com.example.FixLog.bookmark.repository.BookmarkRepository; +// import com.example.FixLog.post.repository.PostLikeRepository; +// import com.example.FixLog.post.repository.PostRepository; +// import com.example.FixLog.post.repository.PostTagRepository; +// import com.example.FixLog.tag.repository.TagRepository; // import jakarta.transaction.Transactional; // import lombok.RequiredArgsConstructor; // import org.springframework.boot.CommandLineRunner; diff --git a/src/main/java/com/example/FixLog/mock/TagMockDataInitializer.java b/src/main/java/com/example/FixLog/mock/TagMockDataInitializer.java index 2a36345..7184999 100644 --- a/src/main/java/com/example/FixLog/mock/TagMockDataInitializer.java +++ b/src/main/java/com/example/FixLog/mock/TagMockDataInitializer.java @@ -1,7 +1,7 @@ package com.example.FixLog.mock; -import com.example.FixLog.domain.tag.Tag; -import com.example.FixLog.repository.tag.TagRepository; +import com.example.FixLog.domain.tag.domain.Tag; +import com.example.FixLog.domain.tag.repository.TagRepository; import lombok.RequiredArgsConstructor; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; @@ -12,7 +12,7 @@ import java.util.Set; import java.util.stream.Collectors; -import static com.example.FixLog.domain.tag.TagCategory.*; +import static com.example.FixLog.domain.tag.domain.TagCategory.*; @Component @RequiredArgsConstructor diff --git a/src/main/java/com/example/FixLog/tset/TestController.java b/src/main/java/com/example/FixLog/test/TestController.java similarity index 95% rename from src/main/java/com/example/FixLog/tset/TestController.java rename to src/main/java/com/example/FixLog/test/TestController.java index f32c179..c986a10 100644 --- a/src/main/java/com/example/FixLog/tset/TestController.java +++ b/src/main/java/com/example/FixLog/test/TestController.java @@ -1,4 +1,4 @@ -package com.example.FixLog.tset; +package com.example.FixLog.test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; diff --git a/src/main/java/com/example/FixLog/tset/TestMember.java b/src/main/java/com/example/FixLog/test/TestMember.java similarity index 91% rename from src/main/java/com/example/FixLog/tset/TestMember.java rename to src/main/java/com/example/FixLog/test/TestMember.java index 9bd34c3..6910ef2 100644 --- a/src/main/java/com/example/FixLog/tset/TestMember.java +++ b/src/main/java/com/example/FixLog/test/TestMember.java @@ -1,4 +1,4 @@ -package com.example.FixLog.tset; +package com.example.FixLog.test; import jakarta.persistence.Entity; import jakarta.persistence.Id; diff --git a/src/main/java/com/example/FixLog/tset/TestMemberRepository.java b/src/main/java/com/example/FixLog/test/TestMemberRepository.java similarity index 81% rename from src/main/java/com/example/FixLog/tset/TestMemberRepository.java rename to src/main/java/com/example/FixLog/test/TestMemberRepository.java index 159b945..bacc9be 100644 --- a/src/main/java/com/example/FixLog/tset/TestMemberRepository.java +++ b/src/main/java/com/example/FixLog/test/TestMemberRepository.java @@ -1,4 +1,4 @@ -package com.example.FixLog.tset; +package com.example.FixLog.test; import org.springframework.data.jpa.repository.JpaRepository;

AltStyle によって変換されたページ (->オリジナル) /