From c4c1651002f2ada074060e9485db5a5f2a5de936 Mon Sep 17 00:00:00 2001 From: soogoori Date: Tue, 1 Aug 2023 15:19:54 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=91=93=20Feat=20#63=20:=20=EA=B0=80?= =?UTF-8?q?=EA=B3=84=EB=B6=80=20=EA=B3=B5=EC=9C=A0=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=95=84=20=EA=B3=B5=EA=B0=90=20=EA=B8=80=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharing/repository/SharingSympathyRepository.java | 4 ++++ .../domain/profile/service/AccountBookProfileService.java | 6 +++++- src/main/resources/application.yml | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingSympathyRepository.java b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingSympathyRepository.java index e08eb8c..ffdee75 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingSympathyRepository.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/sharing/repository/SharingSympathyRepository.java @@ -18,4 +18,8 @@ public interface SharingSympathyRepository extends JpaRepository findByUser_Id(long user_id); + + @Query(value = "select s from SharingSympathy s join fetch s.sharingBoard sb " + + "where s.user.id = :userId order by s.createdAt desc") + List getSharingSympathyByUserId(@Param("userId") Long userId); } diff --git a/src/main/java/com/umc/DongnaeFriend/domain/profile/service/AccountBookProfileService.java b/src/main/java/com/umc/DongnaeFriend/domain/profile/service/AccountBookProfileService.java index e8d0db0..c760804 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/profile/service/AccountBookProfileService.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/profile/service/AccountBookProfileService.java @@ -4,6 +4,7 @@ import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingBoard; import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingComment; import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingImg; +import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingSympathy; import com.umc.DongnaeFriend.domain.account.sharing.repository.SharingBoardRepository; import com.umc.DongnaeFriend.domain.account.sharing.repository.SharingCommentRepository; import com.umc.DongnaeFriend.domain.account.sharing.repository.SharingImgRepository; @@ -77,9 +78,12 @@ public List getWrittenContent(Long us List sharingBoardList; if(category==0){ sharingBoardList= sharingBoardRepository.findAllByUserId(user.getId(), pageable); - }else{ + }else if(category==1){ sharingBoardList = sharingCommentRepository.getCommentByUserIdAndBoard(user.getId()) .stream().map(SharingComment::getSharingBoard).distinct().collect(Collectors.toList()); + }else{ + sharingBoardList = sharingSympathyRepository.getSharingSympathyByUserId(user.getId()) + .stream().map(SharingSympathy::getSharingBoard).collect(Collectors.toList()); } return getProfileListResponse(sharingBoardList); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index faaaa10..dbd617d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -14,7 +14,7 @@ spring: datasource: url: jdbc:mysql://localhost:3306/dongnae?characterEncoding=UTF-8&serverTimezone=UTC&useLegacyDatetimeCode=false username: dongnae - password: + password: Tnqls9004^^ driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernate.ddl-auto: update From bc308d68cd162174e26e25f11f799b37d4ce1c41 Mon Sep 17 00:00:00 2001 From: soogoori Date: Thu, 10 Aug 2023 19:37:04 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8Ffix=20#69=20:=20?= =?UTF-8?q?=EA=B0=80=EA=B3=84=EB=B6=80=20=EC=A1=B0=ED=9A=8C=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EA=B5=AC=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accountBook/AccountBookRepository.java | 2 +- .../account/book/service/AccountBookService.java | 12 ++++++++---- .../domain/account/book/service/MemoService.java | 5 +++-- .../account/book/service/TransactionService.java | 3 ++- .../DongnaeFriend/global/exception/ErrorCode.java | 3 ++- src/main/resources/application.yml | 2 +- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java b/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java index 073eb30..693d036 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java @@ -10,7 +10,7 @@ public interface AccountBookRepository extends JpaRepository, AccountBookRepositoryCustom { - Optional findByYearAndMonth(Integer year, Integer month); + Optional findByYearAndMonthAndUser(Integer year, Integer month, Long userId); @Modifying @Query(value = "update AccountBook ab " + "set ab.expenditure = ab.expenditure + :expenditure " diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java index eb5f197..cd29c10 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java @@ -29,13 +29,17 @@ public class AccountBookService { @Transactional public void createBudget(Integer year, Integer month, Long budget){ User user = findUser(); - accountBookRepository.save(AccountBookDto.BudgetRequest.toEntity(year, month, budget, user)); + if (accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()).isEmpty()) { + accountBookRepository.save(AccountBookDto.BudgetRequest.toEntity(year, month, budget, user)); + }else{ + throw new CustomException(ErrorCode.ACCOUNTBOOK_ALREADY_EXISTS); + } } // 가계부 예산 설정 조회 public AccountBookDto.BudgetResponse getBudget(Integer year, Integer month){ User user = findUser(); - AccountBook accountBook = accountBookRepository.findByYearAndMonth(year, month) + AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); return AccountBookDto.BudgetResponse.of(accountBook.getId(),accountBook.getBudget()); } @@ -45,7 +49,7 @@ public AccountBookDto.BudgetResponse getBudget(Integer year, Integer month){ public void updateBudget(Integer year, Integer month, Long budget){ User user = findUser(); - AccountBook accountBook = accountBookRepository.findByYearAndMonth(year, month) + AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); if (!Objects.equals(accountBook.getUser().getId(), user.getId())) { @@ -59,7 +63,7 @@ public void updateBudget(Integer year, Integer month, Long budget){ public AccountBookDto.AccountBookResponse getAccountBookResponse(Integer year, Integer month) { User user = findUser(); - AccountBook accountBook = accountBookRepository.findByYearAndMonth(year, month) + AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); if (!Objects.equals(accountBook.getUser().getId(), user.getId())) { diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/MemoService.java b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/MemoService.java index db471a9..800ed32 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/MemoService.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/MemoService.java @@ -30,7 +30,8 @@ public class MemoService { // 메모 전체 조회 -> 리스트 public MemoDto.MemoListResponse getMemoList(Integer year, Integer month){ - AccountBook accountBook = accountBookRepository.findByYearAndMonth(year, month) + User user = findUser(); + AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); List memoList = memoRepository.findMemoListByAccountBookId(accountBook.getId()); @@ -42,7 +43,7 @@ public MemoDto.MemoListResponse getMemoList(Integer year, Integer month){ public void createMemo(MemoDto.MemoRequest memoRequest, Integer year, Integer month){ User user = findUser(); - AccountBook accountBook = accountBookRepository.findByYearAndMonth(year, month) + AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); if (!Objects.equals(accountBook.getUser().getId(), user.getId())) { diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/TransactionService.java b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/TransactionService.java index 2e260ff..59bbbce 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/TransactionService.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/TransactionService.java @@ -102,7 +102,8 @@ public void updateTransaction(TransactionDto.TransactionRequest request, Long tr } private AccountBook findTarget(Integer year, Integer month){ - return accountBookRepository.findByYearAndMonth(year, month) + User user = findUser(); + return accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); } diff --git a/src/main/java/com/umc/DongnaeFriend/global/exception/ErrorCode.java b/src/main/java/com/umc/DongnaeFriend/global/exception/ErrorCode.java index e277552..180374b 100644 --- a/src/main/java/com/umc/DongnaeFriend/global/exception/ErrorCode.java +++ b/src/main/java/com/umc/DongnaeFriend/global/exception/ErrorCode.java @@ -10,7 +10,8 @@ @AllArgsConstructor public enum ErrorCode { /* 10* 가계부 */ - MEMO_LIMIT(BAD_REQUEST, 10, "메모는 8개까지 작성 가능합니다."), + MEMO_LIMIT(BAD_REQUEST, 100, "메모는 8개까지 작성 가능합니다."), + ACCOUNTBOOK_ALREADY_EXISTS(BAD_REQUEST, 101, "가계부가 이미 존재합니다."), /* 20* 동네정보 */ POST_NOT_EXISTS(BAD_REQUEST, 200, "없는 게시글입니다."), COMMENT_NOT_EXISTS(BAD_REQUEST, 201, "없는 댓글입니다."), diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index dbd617d..28f19f1 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -30,4 +30,4 @@ kakao: jwt: secret-key: 6B64DCA4EA2F53EDIKU9AAB215FE7 - +👓 From 98738209e27377a9ca05568b54434f64684397c3 Mon Sep 17 00:00:00 2001 From: soogoori Date: Thu, 10 Aug 2023 23:12:05 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8Ffix=20#69=20:=20?= =?UTF-8?q?=EA=B0=80=EA=B3=84=EB=B6=80=20=EC=A1=B0=ED=9A=8C=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EA=B5=AC=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accountBook/AccountBookRepository.java | 3 ++- .../account/book/service/AccountBookService.java | 14 +++++++++----- .../domain/account/book/service/MemoService.java | 4 ++-- .../account/book/service/TransactionService.java | 2 +- .../umc/DongnaeFriend/domain/user/entity/User.java | 4 ++-- src/main/resources/application.yml | 2 +- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java b/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java index 693d036..4b3a9f4 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java @@ -1,6 +1,7 @@ package com.umc.DongnaeFriend.domain.account.book.repository.accountBook; import com.umc.DongnaeFriend.domain.account.book.entity.AccountBook; +import com.umc.DongnaeFriend.domain.user.entity.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; @@ -10,7 +11,7 @@ public interface AccountBookRepository extends JpaRepository, AccountBookRepositoryCustom { - Optional findByYearAndMonthAndUser(Integer year, Integer month, Long userId); + Optional findByYearAndMonthAndUser(Integer year, Integer month, User user); @Modifying @Query(value = "update AccountBook ab " + "set ab.expenditure = ab.expenditure + :expenditure " diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java index cd29c10..551b2a7 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java @@ -3,6 +3,11 @@ import com.umc.DongnaeFriend.domain.account.book.dto.AccountBookDto; import com.umc.DongnaeFriend.domain.account.book.entity.AccountBook; import com.umc.DongnaeFriend.domain.account.book.repository.accountBook.AccountBookRepository; +import com.umc.DongnaeFriend.domain.dongnae.entity.Dongnae; +import com.umc.DongnaeFriend.domain.dongnae.respository.DongnaeRepository; +import com.umc.DongnaeFriend.domain.type.Age; +import com.umc.DongnaeFriend.domain.type.Gender; +import com.umc.DongnaeFriend.domain.type.YesNo; import com.umc.DongnaeFriend.domain.user.entity.User; import com.umc.DongnaeFriend.domain.user.repository.UserRepository; import com.umc.DongnaeFriend.global.exception.CustomException; @@ -24,12 +29,11 @@ public class AccountBookService { private final AccountBookRepository accountBookRepository; private final UserRepository userRepository; - // 가계부 예산 설정 (한달) @Transactional public void createBudget(Integer year, Integer month, Long budget){ User user = findUser(); - if (accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()).isEmpty()) { + if (accountBookRepository.findByYearAndMonthAndUser(year, month, user).isEmpty()) { accountBookRepository.save(AccountBookDto.BudgetRequest.toEntity(year, month, budget, user)); }else{ throw new CustomException(ErrorCode.ACCOUNTBOOK_ALREADY_EXISTS); @@ -39,7 +43,7 @@ public void createBudget(Integer year, Integer month, Long budget){ // 가계부 예산 설정 조회 public AccountBookDto.BudgetResponse getBudget(Integer year, Integer month){ User user = findUser(); - AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) + AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); return AccountBookDto.BudgetResponse.of(accountBook.getId(),accountBook.getBudget()); } @@ -49,7 +53,7 @@ public AccountBookDto.BudgetResponse getBudget(Integer year, Integer month){ public void updateBudget(Integer year, Integer month, Long budget){ User user = findUser(); - AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) + AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); if (!Objects.equals(accountBook.getUser().getId(), user.getId())) { @@ -63,7 +67,7 @@ public void updateBudget(Integer year, Integer month, Long budget){ public AccountBookDto.AccountBookResponse getAccountBookResponse(Integer year, Integer month) { User user = findUser(); - AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) + AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); if (!Objects.equals(accountBook.getUser().getId(), user.getId())) { diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/MemoService.java b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/MemoService.java index 800ed32..cf23a9d 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/MemoService.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/MemoService.java @@ -31,7 +31,7 @@ public class MemoService { public MemoDto.MemoListResponse getMemoList(Integer year, Integer month){ User user = findUser(); - AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) + AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); List memoList = memoRepository.findMemoListByAccountBookId(accountBook.getId()); @@ -43,7 +43,7 @@ public MemoDto.MemoListResponse getMemoList(Integer year, Integer month){ public void createMemo(MemoDto.MemoRequest memoRequest, Integer year, Integer month){ User user = findUser(); - AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) + AccountBook accountBook = accountBookRepository.findByYearAndMonthAndUser(year, month, user) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); if (!Objects.equals(accountBook.getUser().getId(), user.getId())) { diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/TransactionService.java b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/TransactionService.java index c85d1af..ca73a60 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/TransactionService.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/TransactionService.java @@ -103,7 +103,7 @@ public void updateTransaction(TransactionDto.TransactionRequest request, Long tr private AccountBook findTarget(Integer year, Integer month){ User user = findUser(); - return accountBookRepository.findByYearAndMonthAndUser(year, month, user.getId()) + return accountBookRepository.findByYearAndMonthAndUser(year, month, user) .orElseThrow(() -> new CustomException(ErrorCode.NO_CONTENT_FOUND)); } public User findUser() { diff --git a/src/main/java/com/umc/DongnaeFriend/domain/user/entity/User.java b/src/main/java/com/umc/DongnaeFriend/domain/user/entity/User.java index 2ed546f..057864c 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/user/entity/User.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/user/entity/User.java @@ -21,10 +21,10 @@ @AllArgsConstructor(access = PRIVATE) @Entity @Table(name = "users") -public class User extends BaseTimeEntity { +public class User extends BaseTimeEntity { @Id - @GeneratedValue(strategy = IDENTITY) + //@GeneratedValue(strategy = IDENTITY) @Column(name = "user_id") private Long id; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d2a8516..f617624 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -8,7 +8,7 @@ spring: datasource: url: jdbc:mysql://localhost:3306/dongnae?characterEncoding=UTF-8&serverTimezone=UTC&useLegacyDatetimeCode=false username: dongnae - password: + password: Tnqls9004^^ driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernate.ddl-auto: update From 99b99ceb2f067f5bdaecdcddaee7a768690dc8f9 Mon Sep 17 00:00:00 2001 From: soogoori Date: Fri, 11 Aug 2023 00:05:16 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8Ffix=20#69=20:=20?= =?UTF-8?q?=EA=B0=80=EA=B3=84=EB=B6=80=20=EC=A1=B0=ED=9A=8C=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=20=EA=B5=AC=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/repository/accountBook/AccountBookRepository.java | 6 ++++++ .../domain/account/book/service/AccountBookService.java | 1 + src/main/resources/application.yml | 1 + 3 files changed, 8 insertions(+) diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java b/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java index 4b3a9f4..468753a 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/book/repository/accountBook/AccountBookRepository.java @@ -11,6 +11,12 @@ public interface AccountBookRepository extends JpaRepository, AccountBookRepositoryCustom { + /*@Query(value = "select ab " + + "from AccountBook ab " + + "where ab.year = :year and ab.month = :month and ab.user.id = :userId") + Optional findByYearAndMonthAndUser(@Param("year")Integer year, @Param("month")Integer month, @Param("userId")Long userId); +*/ + Optional findByYearAndMonthAndUser(Integer year, Integer month, User user); @Modifying @Query(value = "update AccountBook ab " diff --git a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java index 551b2a7..0c5704a 100644 --- a/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java +++ b/src/main/java/com/umc/DongnaeFriend/domain/account/book/service/AccountBookService.java @@ -83,6 +83,7 @@ public AccountBookDto.AccountBookResponse getAccountBookResponse(Integer year, I public User findUser() { Object userId = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); + return userRepository.findById((Long) userId) .orElseThrow(() -> new CustomException(ErrorCode.USER_NOT_FOUND)); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f617624..c1b23b6 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -9,6 +9,7 @@ spring: url: jdbc:mysql://localhost:3306/dongnae?characterEncoding=UTF-8&serverTimezone=UTC&useLegacyDatetimeCode=false username: dongnae password: Tnqls9004^^ + driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernate.ddl-auto: update