diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
deleted file mode 100644
index 7f9d6a5..0000000
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/notai/auth/Auth.java b/src/main/java/notai/auth/Auth.java
index d3eedd0..62c5c00 100644
--- a/src/main/java/notai/auth/Auth.java
+++ b/src/main/java/notai/auth/Auth.java
@@ -1,13 +1,12 @@
package notai.auth;
import io.swagger.v3.oas.annotations.Hidden;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
@Hidden
@Target(PARAMETER)
@Retention(RUNTIME)
diff --git a/src/main/java/notai/auth/TokenPair.java b/src/main/java/notai/auth/TokenPair.java
index 0051082..4e51456 100644
--- a/src/main/java/notai/auth/TokenPair.java
+++ b/src/main/java/notai/auth/TokenPair.java
@@ -1,7 +1,4 @@
package notai.auth;
-public record TokenPair(
- String accessToken,
- String refreshToken
-) {
+public record TokenPair(String accessToken, String refreshToken) {
}
diff --git a/src/main/java/notai/auth/TokenService.java b/src/main/java/notai/auth/TokenService.java
index 9204e5a..b4b8510 100644
--- a/src/main/java/notai/auth/TokenService.java
+++ b/src/main/java/notai/auth/TokenService.java
@@ -29,17 +29,20 @@ public TokenService(TokenProperty tokenProperty, MemberRepository memberReposito
}
public String createAccessToken(Long memberId) {
- return Jwts.builder().claim(MEMBER_ID_CLAIM,
- memberId
- ).issuedAt(new Date()).expiration(new Date(System.currentTimeMillis() + accessTokenExpirationMillis)).signWith(secretKey,
- Jwts.SIG.HS512
- ).compact();
+ return Jwts.builder()
+ .claim(MEMBER_ID_CLAIM, memberId)
+ .issuedAt(new Date())
+ .expiration(new Date(System.currentTimeMillis() + accessTokenExpirationMillis))
+ .signWith(secretKey, Jwts.SIG.HS512)
+ .compact();
}
private String createRefreshToken() {
- return Jwts.builder().issuedAt(new Date()).expiration(new Date(System.currentTimeMillis() + refreshTokenExpirationMillis)).signWith(secretKey,
- Jwts.SIG.HS512
- ).compact();
+ return Jwts.builder()
+ .issuedAt(new Date())
+ .expiration(new Date(System.currentTimeMillis() + refreshTokenExpirationMillis))
+ .signWith(secretKey, Jwts.SIG.HS512)
+ .compact();
}
public TokenPair createTokenPair(Long memberId) {
@@ -68,9 +71,12 @@ public TokenPair refreshTokenPair(String refreshToken) {
public Long extractMemberId(String token) {
try {
- return Jwts.parser().verifyWith(secretKey).build().parseSignedClaims(token).getPayload().get(MEMBER_ID_CLAIM,
- Long.class
- );
+ return Jwts.parser()
+ .verifyWith(secretKey)
+ .build()
+ .parseSignedClaims(token)
+ .getPayload()
+ .get(MEMBER_ID_CLAIM, Long.class);
} catch (Exception e) {
throw new UnAuthorizedException("유효하지 않은 토큰입니다.");
}
diff --git a/src/main/java/notai/client/oauth/OauthClientComposite.java b/src/main/java/notai/client/oauth/OauthClientComposite.java
index de12050..e4f349b 100644
--- a/src/main/java/notai/client/oauth/OauthClientComposite.java
+++ b/src/main/java/notai/client/oauth/OauthClientComposite.java
@@ -1,5 +1,7 @@
package notai.client.oauth;
+import static java.util.function.Function.identity;
+import static java.util.stream.Collectors.toMap;
import notai.common.exception.type.BadRequestException;
import notai.member.domain.Member;
import notai.member.domain.OauthProvider;
@@ -9,9 +11,6 @@
import java.util.Optional;
import java.util.Set;
-import static java.util.function.Function.identity;
-import static java.util.stream.Collectors.toMap;
-
@Component
public class OauthClientComposite {
diff --git a/src/main/java/notai/client/oauth/kakao/KakaoMemberResponse.java b/src/main/java/notai/client/oauth/kakao/KakaoMemberResponse.java
index 6e81ed8..a6a473e 100644
--- a/src/main/java/notai/client/oauth/kakao/KakaoMemberResponse.java
+++ b/src/main/java/notai/client/oauth/kakao/KakaoMemberResponse.java
@@ -10,33 +10,29 @@
@JsonNaming(value = SnakeCaseStrategy.class)
public record KakaoMemberResponse(
- Long id,
- boolean hasSignedUp,
- LocalDateTime connectedAt,
- KakaoAccount kakaoAccount
-) {
+ Long id,
+ boolean hasSignedUp,
+ LocalDateTime connectedAt,
+ KakaoAccount kakaoAccount) {
- public Member toDomain() {
- return new Member(
- new OauthId(String.valueOf(id), OauthProvider.KAKAO),
- kakaoAccount.email,
- kakaoAccount.profile.nickname
- );
- }
+ public Member toDomain() {
+ return new Member(
+ new OauthId(String.valueOf(id), OauthProvider.KAKAO),
+ kakaoAccount.email,
+ kakaoAccount.profile.nickname);
+ }
- @JsonNaming(value = SnakeCaseStrategy.class)
- public record KakaoAccount(
- Profile profile,
- boolean emailNeedsAgreement,
- boolean isEmailValid,
- boolean isEmailVerified,
- String email
- ) {
- }
+ @JsonNaming(value = SnakeCaseStrategy.class)
+ public record KakaoAccount(
+ Profile profile,
+ boolean emailNeedsAgreement,
+ boolean isEmailValid,
+ boolean isEmailVerified,
+ String email) {
+ }
- @JsonNaming(value = SnakeCaseStrategy.class)
- public record Profile(
- String nickname
- ) {
- }
+ @JsonNaming(value = SnakeCaseStrategy.class)
+ public record Profile(
+ String nickname) {
+ }
}
diff --git a/src/main/java/notai/comment/domain/Comment.java b/src/main/java/notai/comment/domain/Comment.java
index d3bb860..269cda6 100644
--- a/src/main/java/notai/comment/domain/Comment.java
+++ b/src/main/java/notai/comment/domain/Comment.java
@@ -1,7 +1,10 @@
package notai.comment.domain;
import jakarta.persistence.*;
+import static jakarta.persistence.FetchType.LAZY;
+import static jakarta.persistence.GenerationType.IDENTITY;
import jakarta.validation.constraints.NotNull;
+import static lombok.AccessLevel.PROTECTED;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
@@ -9,10 +12,6 @@
import notai.member.domain.Member;
import notai.post.domain.Post;
-import static jakarta.persistence.FetchType.LAZY;
-import static jakarta.persistence.GenerationType.IDENTITY;
-import static lombok.AccessLevel.PROTECTED;
-
@Entity
@Table(name = "comment")
@Getter
diff --git a/src/main/java/notai/common/config/AuthInterceptor.java b/src/main/java/notai/common/config/AuthInterceptor.java
index 87c168c..327a0f2 100644
--- a/src/main/java/notai/common/config/AuthInterceptor.java
+++ b/src/main/java/notai/common/config/AuthInterceptor.java
@@ -3,11 +3,10 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import notai.auth.TokenService;
+import static org.springframework.http.HttpHeaders.AUTHORIZATION;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
-import static org.springframework.http.HttpHeaders.AUTHORIZATION;
-
@Component
public class AuthInterceptor implements HandlerInterceptor {
private final TokenService tokenService;
diff --git a/src/main/java/notai/common/domain/RootEntity.java b/src/main/java/notai/common/domain/RootEntity.java
index c8220c2..7fcd71b 100644
--- a/src/main/java/notai/common/domain/RootEntity.java
+++ b/src/main/java/notai/common/domain/RootEntity.java
@@ -2,6 +2,7 @@
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
+import static lombok.AccessLevel.PROTECTED;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
@@ -12,8 +13,6 @@
import java.time.LocalDateTime;
import java.util.Objects;
-import static lombok.AccessLevel.PROTECTED;
-
@Getter
@NoArgsConstructor(access = PROTECTED)
@EntityListeners(AuditingEntityListener.class)
diff --git a/src/main/java/notai/document/domain/Document.java b/src/main/java/notai/document/domain/Document.java
index 7a77110..8135234 100644
--- a/src/main/java/notai/document/domain/Document.java
+++ b/src/main/java/notai/document/domain/Document.java
@@ -1,15 +1,14 @@
package notai.document.domain;
import jakarta.persistence.*;
+import static jakarta.persistence.GenerationType.IDENTITY;
import jakarta.validation.constraints.NotNull;
+import static lombok.AccessLevel.PROTECTED;
import lombok.Getter;
import lombok.NoArgsConstructor;
import notai.common.domain.RootEntity;
import notai.folder.domain.Folder;
-import static jakarta.persistence.GenerationType.IDENTITY;
-import static lombok.AccessLevel.PROTECTED;
-
@Entity
@Table(name = "document")
@Getter
diff --git a/src/main/java/notai/folder/application/FolderQueryService.java b/src/main/java/notai/folder/application/FolderQueryService.java
index 1a3a830..b51c863 100644
--- a/src/main/java/notai/folder/application/FolderQueryService.java
+++ b/src/main/java/notai/folder/application/FolderQueryService.java
@@ -1,34 +1,9 @@
package notai.folder.application;
import lombok.RequiredArgsConstructor;
-import notai.folder.application.result.FolderFindResult;
-import notai.folder.domain.Folder;
-import notai.folder.domain.FolderRepository;
import org.springframework.stereotype.Service;
-import java.util.List;
-
@Service
@RequiredArgsConstructor
public class FolderQueryService {
-
- private final FolderRepository folderRepository;
-
- public List getFolders(Long memberId, Long parentFolderId) {
- List folders = getFoldersWithMemberAndParent(memberId, parentFolderId);
- // document read
- return folders.stream().map(this::getFolderResult).toList();
- }
-
- private List getFoldersWithMemberAndParent(Long memberId, Long parentFolderId) {
- if (parentFolderId == null) {
- return folderRepository.findAllByMemberIdAndParentFolderIsNull(memberId);
- }
- return folderRepository.findAllByMemberIdAndParentFolderId(memberId, parentFolderId);
- }
-
- private FolderFindResult getFolderResult(Folder folder) {
- Long parentFolderId = folder.getParentFolder() != null ? folder.getParentFolder().getId() : null;
- return FolderFindResult.of(folder.getId(), parentFolderId, folder.getName());
- }
}
diff --git a/src/main/java/notai/folder/application/FolderService.java b/src/main/java/notai/folder/application/FolderService.java
index 4e5e5ec..74ca5c6 100644
--- a/src/main/java/notai/folder/application/FolderService.java
+++ b/src/main/java/notai/folder/application/FolderService.java
@@ -1,69 +1,9 @@
package notai.folder.application;
import lombok.RequiredArgsConstructor;
-import notai.common.exception.type.BadRequestException;
-import notai.folder.application.result.FolderMoveResult;
-import notai.folder.application.result.FolderSaveResult;
-import notai.folder.domain.Folder;
-import notai.folder.domain.FolderRepository;
-import notai.folder.presentation.request.FolderMoveRequest;
-import notai.folder.presentation.request.FolderSaveRequest;
-import notai.member.domain.Member;
-import notai.member.domain.MemberRepository;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class FolderService {
-
- private final FolderRepository folderRepository;
- private final MemberRepository memberRepository;
-
- public FolderSaveResult saveRootFolder(Long memberId, FolderSaveRequest folderSaveRequest) {
- Member member = memberRepository.getById(memberId);
- Folder folder = new Folder(member, folderSaveRequest.name());
- Folder savedFolder = folderRepository.save(folder);
- return getFolderSaveResult(savedFolder);
- }
-
- public FolderSaveResult saveSubFolder(Long memberId, FolderSaveRequest folderSaveRequest) {
- Member member = memberRepository.getById(memberId);
- Folder parentFolder = folderRepository.getById(folderSaveRequest.parentFolderId());
- Folder folder = new Folder(member, folderSaveRequest.name(), parentFolder);
- Folder savedFolder = folderRepository.save(folder);
- return getFolderSaveResult(savedFolder);
- }
-
- public FolderMoveResult moveRootFolder(Long memberId, Long id) {
- Folder folder = folderRepository.getById(id);
- folder.validateOwner(memberId);
- folder.moveRootFolder();
- folderRepository.save(folder);
- return getFolderMoveResult(folder);
- }
-
- public FolderMoveResult moveNewParentFolder(Long memberId, Long id, FolderMoveRequest folderMoveRequest) {
- Folder folder = folderRepository.getById(id);
- Folder parentFolder = folderRepository.getById(folderMoveRequest.targetFolderId());
- folder.validateOwner(memberId);
- folder.moveNewParentFolder(parentFolder);
- folderRepository.save(folder);
- return getFolderMoveResult(folder);
- }
-
- public void deleteFolder(Long memberId, Long id) {
- if (!folderRepository.existsByMemberIdAndId(memberId, id)) {
- throw new BadRequestException("올바르지 않은 요청입니다.");
- }
- folderRepository.deleteById(id);
- }
-
- private FolderSaveResult getFolderSaveResult(Folder folder) {
- Long parentFolderId = folder.getParentFolder() != null ? folder.getParentFolder().getId() : null;
- return FolderSaveResult.of(folder.getId(), parentFolderId, folder.getName());
- }
-
- private FolderMoveResult getFolderMoveResult(Folder folder) {
- return FolderMoveResult.of(folder.getId(), folder.getName());
- }
}
diff --git a/src/main/java/notai/folder/application/result/FolderFindResult.java b/src/main/java/notai/folder/application/result/FolderFindResult.java
deleted file mode 100644
index 3014ac0..0000000
--- a/src/main/java/notai/folder/application/result/FolderFindResult.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package notai.folder.application.result;
-
-public record FolderFindResult(
- Long id,
- Long parentId,
- String name
-) {
- public static FolderFindResult of(Long id, Long parentId, String name) {
- return new FolderFindResult(id, parentId, name);
- }
-}
diff --git a/src/main/java/notai/folder/application/result/FolderMoveResult.java b/src/main/java/notai/folder/application/result/FolderMoveResult.java
deleted file mode 100644
index 4004836..0000000
--- a/src/main/java/notai/folder/application/result/FolderMoveResult.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package notai.folder.application.result;
-
-public record FolderMoveResult(
- Long id,
- String name
-) {
- public static FolderMoveResult of(Long id, String name) {
- return new FolderMoveResult(id, name);
- }
-}
diff --git a/src/main/java/notai/folder/application/result/FolderSaveResult.java b/src/main/java/notai/folder/application/result/FolderSaveResult.java
deleted file mode 100644
index bb01f50..0000000
--- a/src/main/java/notai/folder/application/result/FolderSaveResult.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package notai.folder.application.result;
-
-public record FolderSaveResult(
- Long id,
- Long parentId,
- String name
-) {
- public static FolderSaveResult of(Long id, Long parentId, String name) {
- return new FolderSaveResult(id, parentId, name);
- }
-}
diff --git a/src/main/java/notai/folder/domain/Folder.java b/src/main/java/notai/folder/domain/Folder.java
index f8a141f..f6367e8 100644
--- a/src/main/java/notai/folder/domain/Folder.java
+++ b/src/main/java/notai/folder/domain/Folder.java
@@ -1,17 +1,13 @@
package notai.folder.domain;
import jakarta.persistence.*;
+import static jakarta.persistence.GenerationType.IDENTITY;
import jakarta.validation.constraints.NotNull;
+import static lombok.AccessLevel.PROTECTED;
import lombok.Getter;
import lombok.NoArgsConstructor;
import notai.common.domain.RootEntity;
-import notai.common.exception.type.NotFoundException;
import notai.member.domain.Member;
-import org.hibernate.annotations.OnDelete;
-import org.hibernate.annotations.OnDeleteAction;
-
-import static jakarta.persistence.GenerationType.IDENTITY;
-import static lombok.AccessLevel.PROTECTED;
@Entity
@Table(name = "folder")
@@ -24,7 +20,7 @@ public class Folder extends RootEntity {
private Long id;
@NotNull
- @ManyToOne(fetch = FetchType.LAZY)
+ @ManyToOne
@JoinColumn(name = "member_id", nullable = false)
private Member member;
@@ -34,7 +30,6 @@ public class Folder extends RootEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_folder_id", referencedColumnName = "id")
- @OnDelete(action = OnDeleteAction.CASCADE)
private Folder parentFolder;
public Folder(Member member, String name) {
@@ -55,10 +50,4 @@ public void moveRootFolder() {
public void moveNewParentFolder(Folder parentFolder) {
this.parentFolder = parentFolder;
}
-
- public void validateOwner(Long memberId) {
- if (!this.member.getId().equals(memberId)) {
- throw new NotFoundException("해당 이용자가 보유한 폴더 중 이 폴더가 존재하지 않습니다.");
- }
- }
}
diff --git a/src/main/java/notai/folder/domain/FolderRepository.java b/src/main/java/notai/folder/domain/FolderRepository.java
index d95fc33..40a2231 100644
--- a/src/main/java/notai/folder/domain/FolderRepository.java
+++ b/src/main/java/notai/folder/domain/FolderRepository.java
@@ -1,18 +1,7 @@
package notai.folder.domain;
-import notai.common.exception.type.NotFoundException;
+import notai.folder.query.FolderQueryRepository;
import org.springframework.data.jpa.repository.JpaRepository;
-import java.util.List;
-
-public interface FolderRepository extends JpaRepository {
- default Folder getById(Long id) {
- return findById(id).orElseThrow(() -> new NotFoundException("폴더 정보를 찾을 수 없습니다."));
- }
-
- List findAllByMemberIdAndParentFolderIsNull(Long memberId);
-
- List findAllByMemberIdAndParentFolderId(Long memberId, Long parentFolderId);
-
- boolean existsByMemberIdAndId(Long memberId, Long id);
+public interface FolderRepository extends JpaRepository, FolderQueryRepository {
}
diff --git a/src/main/java/notai/folder/presentation/FolderController.java b/src/main/java/notai/folder/presentation/FolderController.java
index 2f503dc..0c0383c 100644
--- a/src/main/java/notai/folder/presentation/FolderController.java
+++ b/src/main/java/notai/folder/presentation/FolderController.java
@@ -1,24 +1,10 @@
package notai.folder.presentation;
-import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
-import notai.auth.Auth;
import notai.folder.application.FolderQueryService;
import notai.folder.application.FolderService;
-import notai.folder.application.result.FolderFindResult;
-import notai.folder.application.result.FolderMoveResult;
-import notai.folder.application.result.FolderSaveResult;
-import notai.folder.presentation.request.FolderMoveRequest;
-import notai.folder.presentation.request.FolderSaveRequest;
-import notai.folder.presentation.response.FolderFindResponse;
-import notai.folder.presentation.response.FolderMoveResponse;
-import notai.folder.presentation.response.FolderSaveResponse;
-import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.*;
-
-import java.net.URI;
-import java.util.List;
+import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/api/folders")
@@ -27,53 +13,4 @@ public class FolderController {
private final FolderService folderService;
private final FolderQueryService folderQueryService;
-
- @PostMapping
- public ResponseEntity saveFolder(
- @Auth Long memberId, @Valid @RequestBody FolderSaveRequest folderSaveRequest
- ) {
- FolderSaveResult folderResult = saveFolderResult(memberId, folderSaveRequest);
- FolderSaveResponse response = FolderSaveResponse.from(folderResult);
- return ResponseEntity.created(URI.create("/api/folders/" + response.id())).body(response);
- }
-
- @PostMapping("/{id}/move")
- public ResponseEntity moveFolder(
- @Auth Long memberId, @PathVariable Long id, @Valid @RequestBody FolderMoveRequest folderMoveRequest
- ) {
- FolderMoveResult folderResult = moveFolderWithRequest(memberId, id, folderMoveRequest);
- FolderMoveResponse response = FolderMoveResponse.from(folderResult);
- return ResponseEntity.ok(response);
- }
-
- @GetMapping
- public ResponseEntity> getFolders(
- @Auth Long memberId, @RequestParam(required = false) Long parentFolderId
- ) {
- List folderResults = folderQueryService.getFolders(memberId, parentFolderId);
- List response = folderResults.stream().map(FolderFindResponse::from).toList();
- return ResponseEntity.ok(response);
- }
-
- @DeleteMapping("/{id}")
- public ResponseEntity deleteFolder(
- @Auth Long memberId, @PathVariable Long id
- ) {
- folderService.deleteFolder(memberId, id);
- return ResponseEntity.noContent().build();
- }
-
- private FolderSaveResult saveFolderResult(Long memberId, FolderSaveRequest folderSaveRequest) {
- if (folderSaveRequest.parentFolderId() != null) {
- return folderService.saveSubFolder(memberId, folderSaveRequest);
- }
- return folderService.saveRootFolder(memberId, folderSaveRequest);
- }
-
- private FolderMoveResult moveFolderWithRequest(Long memberId, Long id, FolderMoveRequest folderMoveRequest) {
- if (folderMoveRequest.targetFolderId() != null) {
- return folderService.moveNewParentFolder(memberId, id, folderMoveRequest);
- }
- return folderService.moveRootFolder(memberId, id);
- }
}
diff --git a/src/main/java/notai/folder/presentation/request/FolderMoveRequest.java b/src/main/java/notai/folder/presentation/request/FolderMoveRequest.java
deleted file mode 100644
index a1f6ff3..0000000
--- a/src/main/java/notai/folder/presentation/request/FolderMoveRequest.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package notai.folder.presentation.request;
-
-public record FolderMoveRequest(
- Long targetFolderId
-) {
-}
diff --git a/src/main/java/notai/folder/presentation/request/FolderSaveRequest.java b/src/main/java/notai/folder/presentation/request/FolderSaveRequest.java
deleted file mode 100644
index b16f7f9..0000000
--- a/src/main/java/notai/folder/presentation/request/FolderSaveRequest.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package notai.folder.presentation.request;
-
-public record FolderSaveRequest(
- Long parentFolderId,
- String name
-) {
-}
diff --git a/src/main/java/notai/folder/presentation/response/FolderFindResponse.java b/src/main/java/notai/folder/presentation/response/FolderFindResponse.java
deleted file mode 100644
index 8d0a687..0000000
--- a/src/main/java/notai/folder/presentation/response/FolderFindResponse.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package notai.folder.presentation.response;
-
-import notai.folder.application.result.FolderFindResult;
-
-public record FolderFindResponse(
- Long id,
- Long parentId,
- String name
-) {
- public static FolderFindResponse from(FolderFindResult folderFindResult) {
- return new FolderFindResponse(folderFindResult.id(), folderFindResult.parentId(), folderFindResult.name());
- }
-}
diff --git a/src/main/java/notai/folder/presentation/response/FolderMoveResponse.java b/src/main/java/notai/folder/presentation/response/FolderMoveResponse.java
deleted file mode 100644
index 0801a69..0000000
--- a/src/main/java/notai/folder/presentation/response/FolderMoveResponse.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package notai.folder.presentation.response;
-
-import notai.folder.application.result.FolderMoveResult;
-
-public record FolderMoveResponse(
- Long id,
- String name
-) {
- public static FolderMoveResponse from(FolderMoveResult folderMoveResult) {
- return new FolderMoveResponse(folderMoveResult.id(), folderMoveResult.name());
- }
-}
diff --git a/src/main/java/notai/folder/presentation/response/FolderSaveResponse.java b/src/main/java/notai/folder/presentation/response/FolderSaveResponse.java
deleted file mode 100644
index cfc552f..0000000
--- a/src/main/java/notai/folder/presentation/response/FolderSaveResponse.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package notai.folder.presentation.response;
-
-import notai.folder.application.result.FolderSaveResult;
-
-public record FolderSaveResponse(
- Long id,
- Long parentId,
- String name
-) {
- public static FolderSaveResponse from(FolderSaveResult folderSaveResult) {
- return new FolderSaveResponse(folderSaveResult.id(), folderSaveResult.parentId(), folderSaveResult.name());
- }
-}
diff --git a/src/main/java/notai/folder/query/FolderQueryRepository.java b/src/main/java/notai/folder/query/FolderQueryRepository.java
new file mode 100644
index 0000000..93bdaee
--- /dev/null
+++ b/src/main/java/notai/folder/query/FolderQueryRepository.java
@@ -0,0 +1,4 @@
+package notai.folder.query;
+
+public interface FolderQueryRepository {
+}
diff --git a/src/main/java/notai/folder/query/FolderQueryRepositoryImpl.java b/src/main/java/notai/folder/query/FolderQueryRepositoryImpl.java
new file mode 100644
index 0000000..c7b7681
--- /dev/null
+++ b/src/main/java/notai/folder/query/FolderQueryRepositoryImpl.java
@@ -0,0 +1,10 @@
+package notai.folder.query;
+
+import com.querydsl.jpa.impl.JPAQueryFactory;
+import lombok.RequiredArgsConstructor;
+
+@RequiredArgsConstructor
+public class FolderQueryRepositoryImpl implements FolderQueryRepository {
+
+ private final JPAQueryFactory jpaQueryFactory;
+}
diff --git a/src/main/java/notai/llm/application/LLMQueryService.java b/src/main/java/notai/llm/application/LLMQueryService.java
index 07627a9..2858c2a 100644
--- a/src/main/java/notai/llm/application/LLMQueryService.java
+++ b/src/main/java/notai/llm/application/LLMQueryService.java
@@ -1,6 +1,7 @@
package notai.llm.application;
import lombok.RequiredArgsConstructor;
+import notai.common.exception.type.BadRequestException;
import notai.common.exception.type.InternalServerErrorException;
import notai.common.exception.type.NotFoundException;
import notai.document.domain.DocumentRepository;
@@ -79,7 +80,7 @@ private static void checkSummaryAndProblemCountsEqual(
private List getSummaryIds(Long documentId) {
List summaryIds = summaryQueryRepository.getSummaryIdsByDocumentId(documentId);
if (summaryIds.isEmpty()) {
- throw new NotFoundException("AI 기능을 요청한 기록이 없습니다.");
+ throw new BadRequestException("AI 기능을 요청한 기록이 없습니다.");
}
return summaryIds;
}
diff --git a/src/main/java/notai/llm/application/result/LLMStatusResult.java b/src/main/java/notai/llm/application/result/LLMStatusResult.java
index 158e099..a9a3768 100644
--- a/src/main/java/notai/llm/application/result/LLMStatusResult.java
+++ b/src/main/java/notai/llm/application/result/LLMStatusResult.java
@@ -8,9 +8,7 @@ public record LLMStatusResult(
Integer totalPages,
Integer completedPages
) {
- public static LLMStatusResult of(
- Long documentId, TaskStatus overallStatus, Integer totalPages, Integer completedPages
- ) {
+ public static LLMStatusResult of(Long documentId, TaskStatus overallStatus, Integer totalPages, Integer completedPages) {
return new LLMStatusResult(documentId, overallStatus, totalPages, completedPages);
}
}
diff --git a/src/main/java/notai/llm/domain/TaskStatus.java b/src/main/java/notai/llm/domain/TaskStatus.java
index aa0b6dd..be44ed8 100644
--- a/src/main/java/notai/llm/domain/TaskStatus.java
+++ b/src/main/java/notai/llm/domain/TaskStatus.java
@@ -1,5 +1,7 @@
package notai.llm.domain;
public enum TaskStatus {
- PENDING, IN_PROGRESS, COMPLETED
+ PENDING,
+ IN_PROGRESS,
+ COMPLETED
}
diff --git a/src/main/java/notai/llm/presentation/request/LLMSubmitRequest.java b/src/main/java/notai/llm/presentation/request/LLMSubmitRequest.java
index 1226bb5..8f78f1d 100644
--- a/src/main/java/notai/llm/presentation/request/LLMSubmitRequest.java
+++ b/src/main/java/notai/llm/presentation/request/LLMSubmitRequest.java
@@ -8,7 +8,8 @@
public record LLMSubmitRequest(
- @NotNull(message = "문서 ID는 필수 입력 값입니다.") Long documentId,
+ @NotNull(message = "문서 ID는 필수 입력 값입니다.")
+ Long documentId,
List<@Positive(message = "페이지 번호는 양수여야 합니다.") Integer> pages
) {
diff --git a/src/main/java/notai/member/application/result/MemberFindResult.java b/src/main/java/notai/member/application/result/MemberFindResult.java
index 13b2169..261e83e 100644
--- a/src/main/java/notai/member/application/result/MemberFindResult.java
+++ b/src/main/java/notai/member/application/result/MemberFindResult.java
@@ -3,8 +3,7 @@
import notai.member.domain.Member;
public record MemberFindResult(
- Long id,
- String nickname
+ Long id, String nickname
) {
public static MemberFindResult from(Member member) {
return new MemberFindResult(member.getId(), member.getNickname());
diff --git a/src/main/java/notai/member/domain/Member.java b/src/main/java/notai/member/domain/Member.java
index 90cb75a..2cbb807 100644
--- a/src/main/java/notai/member/domain/Member.java
+++ b/src/main/java/notai/member/domain/Member.java
@@ -1,15 +1,14 @@
package notai.member.domain;
import jakarta.persistence.*;
+import static jakarta.persistence.GenerationType.IDENTITY;
import jakarta.validation.constraints.NotNull;
+import static lombok.AccessLevel.PROTECTED;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import notai.common.domain.RootEntity;
-import static jakarta.persistence.GenerationType.IDENTITY;
-import static lombok.AccessLevel.PROTECTED;
-
@Entity
@Table(name = "member")
@Getter
diff --git a/src/main/java/notai/member/domain/OauthId.java b/src/main/java/notai/member/domain/OauthId.java
index cb2bf87..b1765fd 100644
--- a/src/main/java/notai/member/domain/OauthId.java
+++ b/src/main/java/notai/member/domain/OauthId.java
@@ -2,15 +2,14 @@
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
+import static jakarta.persistence.EnumType.STRING;
import jakarta.persistence.Enumerated;
import jakarta.validation.constraints.NotNull;
+import static lombok.AccessLevel.PROTECTED;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
-import static jakarta.persistence.EnumType.STRING;
-import static lombok.AccessLevel.PROTECTED;
-
@Getter
@Embeddable
@AllArgsConstructor
diff --git a/src/main/java/notai/member/presentation/MemberController.java b/src/main/java/notai/member/presentation/MemberController.java
index 770b655..2843b03 100644
--- a/src/main/java/notai/member/presentation/MemberController.java
+++ b/src/main/java/notai/member/presentation/MemberController.java
@@ -12,7 +12,7 @@
import notai.member.presentation.request.OauthLoginRequest;
import notai.member.presentation.request.TokenRefreshRequest;
import notai.member.presentation.response.MemberFindResponse;
-import notai.member.presentation.response.MemberOauthLoginResponse;
+import notai.member.presentation.response.MemberOauthLoginResopnse;
import notai.member.presentation.response.MemberTokenRefreshResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@@ -28,13 +28,13 @@ public class MemberController {
private final TokenService tokenService;
@PostMapping("/oauth/login/{oauthProvider}")
- public ResponseEntity loginWithOauth(
+ public ResponseEntity loginWithOauth(
@PathVariable(value = "oauthProvider") OauthProvider oauthProvider, @RequestBody OauthLoginRequest request
) {
Member member = oauthClient.fetchMember(oauthProvider, request.oauthAccessToken());
Long memberId = memberService.login(member);
TokenPair tokenPair = tokenService.createTokenPair(memberId);
- return ResponseEntity.ok(MemberOauthLoginResponse.from(tokenPair));
+ return ResponseEntity.ok(MemberOauthLoginResopnse.from(tokenPair));
}
@PostMapping("/token/refresh")
diff --git a/src/main/java/notai/member/presentation/response/MemberFindResponse.java b/src/main/java/notai/member/presentation/response/MemberFindResponse.java
index ebd525b..a1b8115 100644
--- a/src/main/java/notai/member/presentation/response/MemberFindResponse.java
+++ b/src/main/java/notai/member/presentation/response/MemberFindResponse.java
@@ -3,8 +3,7 @@
import notai.member.application.result.MemberFindResult;
public record MemberFindResponse(
- Long id,
- String nickname
+ Long id, String nickname
) {
public static MemberFindResponse from(MemberFindResult result) {
return new MemberFindResponse(result.id(), result.nickname());
diff --git a/src/main/java/notai/member/presentation/response/MemberOauthLoginResopnse.java b/src/main/java/notai/member/presentation/response/MemberOauthLoginResopnse.java
new file mode 100644
index 0000000..7655d6d
--- /dev/null
+++ b/src/main/java/notai/member/presentation/response/MemberOauthLoginResopnse.java
@@ -0,0 +1,11 @@
+package notai.member.presentation.response;
+
+import notai.auth.TokenPair;
+
+public record MemberOauthLoginResopnse(
+ String accessToken, String refreshToken
+) {
+ public static MemberOauthLoginResopnse from(TokenPair tokenPair) {
+ return new MemberOauthLoginResopnse(tokenPair.accessToken(), tokenPair.refreshToken());
+ }
+}
diff --git a/src/main/java/notai/member/presentation/response/MemberOauthLoginResponse.java b/src/main/java/notai/member/presentation/response/MemberOauthLoginResponse.java
deleted file mode 100644
index 0713d11..0000000
--- a/src/main/java/notai/member/presentation/response/MemberOauthLoginResponse.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package notai.member.presentation.response;
-
-import notai.auth.TokenPair;
-
-public record MemberOauthLoginResponse(
- String accessToken,
- String refreshToken
-) {
- public static MemberOauthLoginResponse from(TokenPair tokenPair) {
- return new MemberOauthLoginResponse(tokenPair.accessToken(), tokenPair.refreshToken());
- }
-}
diff --git a/src/main/java/notai/member/presentation/response/MemberTokenRefreshResponse.java b/src/main/java/notai/member/presentation/response/MemberTokenRefreshResponse.java
index 6273edd..b10b135 100644
--- a/src/main/java/notai/member/presentation/response/MemberTokenRefreshResponse.java
+++ b/src/main/java/notai/member/presentation/response/MemberTokenRefreshResponse.java
@@ -3,8 +3,7 @@
import notai.auth.TokenPair;
public record MemberTokenRefreshResponse(
- String accessToken,
- String refreshToken
+ String accessToken, String refreshToken
) {
public static MemberTokenRefreshResponse from(TokenPair tokenPair) {
return new MemberTokenRefreshResponse(tokenPair.accessToken(), tokenPair.refreshToken());
diff --git a/src/main/java/notai/post/domain/Post.java b/src/main/java/notai/post/domain/Post.java
index 44e18b1..9202ab6 100644
--- a/src/main/java/notai/post/domain/Post.java
+++ b/src/main/java/notai/post/domain/Post.java
@@ -1,16 +1,15 @@
package notai.post.domain;
import jakarta.persistence.*;
+import static jakarta.persistence.FetchType.LAZY;
+import static jakarta.persistence.GenerationType.IDENTITY;
import jakarta.validation.constraints.NotNull;
+import static lombok.AccessLevel.PROTECTED;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import notai.member.domain.Member;
-import static jakarta.persistence.FetchType.LAZY;
-import static jakarta.persistence.GenerationType.IDENTITY;
-import static lombok.AccessLevel.PROTECTED;
-
@Getter
@NoArgsConstructor(access = PROTECTED)
@AllArgsConstructor
diff --git a/src/main/java/notai/summary/query/SummaryQueryRepository.java b/src/main/java/notai/summary/query/SummaryQueryRepository.java
index d71edaa..b767161 100644
--- a/src/main/java/notai/summary/query/SummaryQueryRepository.java
+++ b/src/main/java/notai/summary/query/SummaryQueryRepository.java
@@ -3,8 +3,8 @@
import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
-import notai.summary.domain.QSummary;
import notai.summary.query.result.SummaryPageContentResult;
+import notai.summary.domain.QSummary;
import org.springframework.stereotype.Repository;
import java.util.List;
@@ -18,16 +18,25 @@ public class SummaryQueryRepository {
public List getSummaryIdsByDocumentId(Long documentId) {
QSummary summary = QSummary.summary;
- return queryFactory.select(summary.id).from(summary).where(summary.document.id.eq(documentId)).fetch();
+ return queryFactory
+ .select(summary.id)
+ .from(summary)
+ .where(summary.document.id.eq(documentId))
+ .fetch();
}
public List getPageNumbersAndContentByDocumentId(Long documentId) {
QSummary summary = QSummary.summary;
- return queryFactory.select(Projections.constructor(
- SummaryPageContentResult.class,
- summary.pageNumber,
- summary.content
- )).from(summary).where(summary.document.id.eq(documentId).and(summary.content.isNotNull())).fetch();
+ return queryFactory
+ .select(Projections.constructor(
+ SummaryPageContentResult.class,
+ summary.pageNumber,
+ summary.content
+ ))
+ .from(summary)
+ .where(summary.document.id.eq(documentId)
+ .and(summary.content.isNotNull()))
+ .fetch();
}
}
diff --git a/src/test/java/notai/BackendApplicationTests.java b/src/test/java/notai/BackendApplicationTests.java
index e34c1e0..b50683a 100644
--- a/src/test/java/notai/BackendApplicationTests.java
+++ b/src/test/java/notai/BackendApplicationTests.java
@@ -6,8 +6,8 @@
@SpringBootTest
class BackendApplicationTests {
- @Test
- void contextLoads() {
- }
+ @Test
+ void contextLoads() {
+ }
}
diff --git a/src/test/java/notai/client/oauth/kakao/KakaoOauthClientTest.java b/src/test/java/notai/client/oauth/kakao/KakaoOauthClientTest.java
index 880eb1b..2dd7dcb 100644
--- a/src/test/java/notai/client/oauth/kakao/KakaoOauthClientTest.java
+++ b/src/test/java/notai/client/oauth/kakao/KakaoOauthClientTest.java
@@ -2,16 +2,17 @@
import notai.member.domain.Member;
import notai.member.domain.OauthProvider;
-import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import static org.mockito.Mockito.when;
import org.mockito.MockitoAnnotations;
import java.time.LocalDateTime;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.when;
+
public class KakaoOauthClientTest {
@Mock
@@ -38,12 +39,12 @@ public void testFetchMember() {
String nickname = "nickname";
KakaoMemberResponse.Profile profile = new KakaoMemberResponse.Profile(nickname);
- KakaoMemberResponse.KakaoAccount kakaoAccount = new KakaoMemberResponse.KakaoAccount(profile,
+ KakaoMemberResponse.KakaoAccount kakaoAccount = new KakaoMemberResponse.KakaoAccount(
+ profile,
emailNeedsAgreement,
isEmailValid,
isEmailVerified,
- email
- );
+ email);
KakaoMemberResponse kakaoMemberResponse = new KakaoMemberResponse(id, hasSignedUp, connectedAt, kakaoAccount);
diff --git a/src/test/java/notai/folder/application/FolderQueryServiceTest.java b/src/test/java/notai/folder/application/FolderQueryServiceTest.java
deleted file mode 100644
index a567e1d..0000000
--- a/src/test/java/notai/folder/application/FolderQueryServiceTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package notai.folder.application;
-
-import notai.folder.application.result.FolderFindResult;
-import notai.folder.domain.Folder;
-import notai.folder.domain.FolderRepository;
-import notai.member.domain.Member;
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import static org.mockito.ArgumentMatchers.any;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import static org.mockito.Mockito.*;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import java.util.List;
-
-@ExtendWith(MockitoExtension.class)
-class FolderQueryServiceTest {
-
- @Mock
- private FolderRepository folderRepository;
- @InjectMocks
- private FolderQueryService folderQueryService;
-
- @Test
- @DisplayName("루트 폴더 조회")
- void getFolders_success_parentFolderIdIsNull() {
- //given
- Folder folder = getFolder(1L, null, "루트폴더");
- List expectedResults = List.of(folder);
-
- when(folderRepository.findAllByMemberIdAndParentFolderIsNull(any(Long.class))).thenReturn(expectedResults);
- //when
- List folders = folderQueryService.getFolders(1L, null);
-
- Assertions.assertThat(folders.size()).isEqualTo(1);
- }
-
- @Test
- @DisplayName("계층적 구조의 폴더 조회")
- void getFolders_success_parentFolderId() {
- //given
- Folder folder1 = getFolder(1L, null, "루트폴더");
- Folder folder2 = getFolder(2L, folder1, "서브폴더");
- Folder folder3 = getFolder(3L, folder1, "서브폴더");
- List expectedResults = List.of(folder2, folder3);
-
- when(folderRepository.findAllByMemberIdAndParentFolderId(any(Long.class), any(Long.class))).thenReturn(
- expectedResults);
- //when
- List folders = folderQueryService.getFolders(1L, 1L);
-
- Assertions.assertThat(folders.size()).isEqualTo(2);
- }
-
- private Folder getFolder(Long id, Folder parentFolder, String name) {
- Member member = mock(Member.class);
- Folder folder = spy(new Folder(member, name, parentFolder));
- lenient().when(folder.getId()).thenReturn(id);
- return folder;
- }
-}