diff --git a/backend/ddang/src/main/java/com/ddang/ddang/authentication/application/AuthenticationService.java b/backend/ddang/src/main/java/com/ddang/ddang/authentication/application/AuthenticationService.java index 41136ac33..6380f877a 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/authentication/application/AuthenticationService.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/authentication/application/AuthenticationService.java @@ -14,6 +14,7 @@ import com.ddang.ddang.authentication.infrastructure.oauth2.Oauth2Type; import com.ddang.ddang.device.application.DeviceTokenService; import com.ddang.ddang.device.application.dto.PersistDeviceTokenDto; +import com.ddang.ddang.device.infrastructure.persistence.JpaDeviceTokenRepository; import com.ddang.ddang.image.application.exception.ImageNotFoundException; import com.ddang.ddang.image.domain.ProfileImage; import com.ddang.ddang.image.infrastructure.persistence.JpaProfileImageRepository; @@ -42,6 +43,7 @@ public class AuthenticationService { private final TokenEncoder tokenEncoder; private final TokenDecoder tokenDecoder; private final BlackListTokenService blackListTokenService; + private final JpaDeviceTokenRepository deviceTokenRepository; @Transactional public TokenDto login(final Oauth2Type oauth2Type, final String oauth2AccessToken, final String deviceToken) { @@ -142,6 +144,7 @@ public void withdrawal( user.withdrawal(); blackListTokenService.registerBlackListToken(accessToken, refreshToken); + deviceTokenRepository.deleteByUserId(user.getId()); provider.unlinkUserBy(user.getOauthId()); } } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/device/infrastructure/persistence/JpaDeviceTokenRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/device/infrastructure/persistence/JpaDeviceTokenRepository.java index 34e990e62..13fc6f49b 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/device/infrastructure/persistence/JpaDeviceTokenRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/device/infrastructure/persistence/JpaDeviceTokenRepository.java @@ -8,4 +8,6 @@ public interface JpaDeviceTokenRepository extends JpaRepository { Optional findByUserId(final Long userId); + + void deleteByUserId(Long id); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/application/AuctionReportService.java b/backend/ddang/src/main/java/com/ddang/ddang/report/application/AuctionReportService.java index de592a2b9..d38c222f1 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/application/AuctionReportService.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/application/AuctionReportService.java @@ -55,7 +55,7 @@ private void checkInvalidAuctionReport(final User reporter, final Auction auctio } public List readAll() { - final List auctionReports = auctionReportRepository.findAll(); + final List auctionReports = auctionReportRepository.findAllByOrderByIdAsc(); return auctionReports.stream() .map(ReadAuctionReportDto::from) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/application/ChatRoomReportService.java b/backend/ddang/src/main/java/com/ddang/ddang/report/application/ChatRoomReportService.java index a063f039d..ff9997521 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/application/ChatRoomReportService.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/application/ChatRoomReportService.java @@ -28,7 +28,7 @@ public class ChatRoomReportService { private final JpaChatRoomRepository chatRoomRepository; private final JpaChatRoomReportRepository chatRoomReportRepository; - + @Transactional public Long create(final CreateChatRoomReportDto chatRoomReportDto) { final User reporter = userRepository.findById(chatRoomReportDto.reporterId()) .orElseThrow(() -> new UserNotFoundException("해당 사용자를 찾을 수 없습니다.")); @@ -53,7 +53,7 @@ private void checkInvalidChatRoomReport(final User reporter, final ChatRoom chat } public List readAll() { - final List auctionReports = chatRoomReportRepository.findAll(); + final List auctionReports = chatRoomReportRepository.findAllByOrderByIdAsc(); return auctionReports.stream() .map(auctionReport -> ReadChatRoomReportDto.from(auctionReport, LocalDateTime.now())) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepository.java index 307d2c296..c426a4051 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepository.java @@ -10,7 +10,6 @@ public interface JpaAuctionReportRepository extends JpaRepository findAll(); + List findAllByOrderByIdAsc(); } diff --git a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepository.java b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepository.java index 9cd667057..d6965e7df 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepository.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepository.java @@ -10,7 +10,6 @@ public interface JpaChatRoomReportRepository extends JpaRepository findAll(); + List findAllByOrderByIdAsc(); } diff --git a/backend/ddang/src/main/resources/static/docs/docs.html b/backend/ddang/src/main/resources/static/docs/docs.html index e623aa38b..a43851b6b 100644 --- a/backend/ddang/src/main/resources/static/docs/docs.html +++ b/backend/ddang/src/main/resources/static/docs/docs.html @@ -1399,7 +1399,7 @@

요청

Content-Disposition: form-data; name=request; filename=request Content-Type: application/json -{"title":"경매 상품 1","description":"이것은 경매 상품 1 입니다.","bidUnit":1000,"startPrice":1000,"closingTime":"2023-09-21T21:19:23.572151","subCategoryId":2,"thirdRegionIds":[3]} +{"title":"경매 상품 1","description":"이것은 경매 상품 1 입니다.","bidUnit":1000,"startPrice":1000,"closingTime":"2023-09-24T09:49:27.766331","subCategoryId":2,"thirdRegionIds":[3]} --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm-- @@ -2006,8 +2006,8 @@

응답

"lastBidPrice" : null, "status" : "FAILURE", "bidUnit" : 1000, - "registerTime" : "2023-09-18T21:19:23", - "closingTime" : "2023-09-18T21:19:23", + "registerTime" : "2023-09-21T09:49:27", + "closingTime" : "2023-09-21T09:49:27", "directRegions" : [ { "first" : "서울특별시", "second" : "강서구", @@ -2339,12 +2339,12 @@

응답

"name" : "사용자1", "profileImage" : "http://localhost:8080/users/images/1", "price" : 10000, - "bidTime" : "2023-09-18T21:19:25" + "bidTime" : "2023-09-21T09:49:29" }, { "name" : "사용자2", "profileImage" : "http://localhost:8080/users/images/2", "price" : 12000, - "bidTime" : "2023-09-18T21:19:25" + "bidTime" : "2023-09-21T09:49:29" } ] } @@ -2539,7 +2539,7 @@

응답

"price" : 10000 }, "lastMessage" : { - "createdAt" : "2023-09-18T21:19:27", + "createdAt" : "2023-09-21T09:49:31", "contents" : "메시지1" }, "isChatAvailable" : true @@ -2557,7 +2557,7 @@

응답

"price" : 20000 }, "lastMessage" : { - "createdAt" : "2023-09-18T21:19:27", + "createdAt" : "2023-09-21T09:49:31", "contents" : "메시지2" }, "isChatAvailable" : true @@ -2995,7 +2995,7 @@

응답

[ { "id" : 1, - "createdAt" : "2023-09-18T21:19:27", + "createdAt" : "2023-09-21T09:49:31", "isMyMessage" : true, "contents" : "메시지내용" } ] @@ -3145,7 +3145,7 @@

응답

"id" : 1, "name" : "회원1" }, - "createdTime" : "2023-09-18T21:19:29", + "createdTime" : "2023-09-21T09:49:33", "auction" : { "id" : 1, "title" : "제목" @@ -3157,7 +3157,7 @@

응답

"id" : 2, "name" : "회원2" }, - "createdTime" : "2023-09-18T21:19:29", + "createdTime" : "2023-09-21T09:49:33", "auction" : { "id" : 1, "title" : "제목" @@ -3169,7 +3169,7 @@

응답

"id" : 3, "name" : "회원3" }, - "createdTime" : "2023-09-18T21:19:29", + "createdTime" : "2023-09-21T09:49:33", "auction" : { "id" : 1, "title" : "제목" @@ -3333,7 +3333,7 @@

응답

"id" : 1, "name" : "회원1" }, - "createdTime" : "2023-09-18T21:19:29", + "createdTime" : "2023-09-21T09:49:34", "chatRoom" : { "id" : 1 }, @@ -3344,7 +3344,7 @@

응답

"id" : 1, "name" : "회원1" }, - "createdTime" : "2023-09-18T21:19:29", + "createdTime" : "2023-09-21T09:49:34", "chatRoom" : { "id" : 1 }, @@ -3355,7 +3355,7 @@

응답

"id" : 1, "name" : "회원1" }, - "createdTime" : "2023-09-18T21:19:29", + "createdTime" : "2023-09-21T09:49:34", "chatRoom" : { "id" : 1 }, diff --git a/backend/ddang/src/test/java/com/ddang/ddang/authentication/application/AuthenticationServiceTest.java b/backend/ddang/src/test/java/com/ddang/ddang/authentication/application/AuthenticationServiceTest.java index 651a9cdce..c954e29b1 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/authentication/application/AuthenticationServiceTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/authentication/application/AuthenticationServiceTest.java @@ -78,6 +78,9 @@ class AuthenticationServiceTest { @Autowired BlackListTokenService mockBlackListTokenService; + @Autowired + JpaDeviceTokenRepository mockDeviceTokenRepository; + @Autowired JwtEncoder jwtEncoder; @@ -93,6 +96,7 @@ void setUp( mockProvider = mock(OAuth2UserInformationProvider.class); mockProviderComposite = mock(Oauth2UserInformationProviderComposite.class); mockBlackListTokenService = mock(BlackListTokenService.class); + mockDeviceTokenRepository = mock(JpaDeviceTokenRepository.class); authenticationService = new AuthenticationService( deviceTokenService, mockProviderComposite, @@ -100,7 +104,8 @@ void setUp( profileImageRepository, tokenEncoder, tokenDecoder, - mockBlackListTokenService + mockBlackListTokenService, + mockDeviceTokenRepository ); doNothing().when(deviceTokenService).persist(anyLong(), any(PersistDeviceTokenDto.class)); @@ -346,6 +351,7 @@ void setUp( given(mockProviderComposite.findProvider(Oauth2Type.KAKAO)).willReturn(mockProvider); given(mockProvider.findUserInformation(anyString())).willReturn(userInformationDto); + willDoNothing().given(mockDeviceTokenRepository).deleteById(anyLong()); willDoNothing().given(mockBlackListTokenService).registerBlackListToken(anyString(), anyString()); // when diff --git a/backend/ddang/src/test/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepositoryTest.java b/backend/ddang/src/test/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepositoryTest.java index 296f109f2..8b82c4ede 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepositoryTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/report/infrastructure/persistence/JpaAuctionReportRepositoryTest.java @@ -203,7 +203,7 @@ class JpaAuctionReportRepositoryTest { em.clear(); // when - final List actual = auctionReportRepository.findAll(); + final List actual = auctionReportRepository.findAllByOrderByIdAsc(); // then SoftAssertions.assertSoftly(softAssertions -> { diff --git a/backend/ddang/src/test/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepositoryTest.java b/backend/ddang/src/test/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepositoryTest.java index f0a96476a..1f79db7bf 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepositoryTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/report/infrastructure/persistence/JpaChatRoomReportRepositoryTest.java @@ -204,7 +204,7 @@ class JpaChatRoomReportRepositoryTest { em.clear(); // when - final List actual = chatRoomReportRepository.findAll(); + final List actual = chatRoomReportRepository.findAllByOrderByIdAsc(); // then SoftAssertions.assertSoftly(softAssertions -> {