Skip to content

Commit

Permalink
Revert "Style: 코드 포맷팅 통일 (#36)" (#38)
Browse files Browse the repository at this point in the history
This reverts commit ad9062e.
  • Loading branch information
hynseoj authored Sep 29, 2024
1 parent ad9062e commit 849ac01
Show file tree
Hide file tree
Showing 42 changed files with 128 additions and 438 deletions.
5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

5 changes: 2 additions & 3 deletions src/main/java/notai/auth/Auth.java
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/notai/auth/TokenPair.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
package notai.auth;

public record TokenPair(
String accessToken,
String refreshToken
) {
public record TokenPair(String accessToken, String refreshToken) {
}
28 changes: 17 additions & 11 deletions src/main/java/notai/auth/TokenService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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("유효하지 않은 토큰입니다.");
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/notai/client/oauth/OauthClientComposite.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {

Expand Down
48 changes: 22 additions & 26 deletions src/main/java/notai/client/oauth/kakao/KakaoMemberResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}
}
7 changes: 3 additions & 4 deletions src/main/java/notai/comment/domain/Comment.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
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;
import notai.common.domain.RootEntity;
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
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/notai/common/config/AuthInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/notai/common/domain/RootEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,8 +13,6 @@
import java.time.LocalDateTime;
import java.util.Objects;

import static lombok.AccessLevel.PROTECTED;

@Getter
@NoArgsConstructor(access = PROTECTED)
@EntityListeners(AuditingEntityListener.class)
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/notai/document/domain/Document.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 0 additions & 25 deletions src/main/java/notai/folder/application/FolderQueryService.java
Original file line number Diff line number Diff line change
@@ -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<FolderFindResult> getFolders(Long memberId, Long parentFolderId) {
List<Folder> folders = getFoldersWithMemberAndParent(memberId, parentFolderId);
// document read
return folders.stream().map(this::getFolderResult).toList();
}

private List<Folder> 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());
}
}
60 changes: 0 additions & 60 deletions src/main/java/notai/folder/application/FolderService.java
Original file line number Diff line number Diff line change
@@ -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());
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 849ac01

Please sign in to comment.