From f84f989e576cd713ca4a8edf1fcb25404f1f28a7 Mon Sep 17 00:00:00 2001 From: gkfktkrh153 Date: Thu, 14 Mar 2024 18:56:52 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=EC=B1=84=ED=8C=85=EB=B0=A9=20=EC=9E=85?= =?UTF-8?q?=EC=9E=A5=20=EC=8B=9C=20=EC=B1=84=ED=8C=85=20=EC=9D=BD=EC=9D=8C?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EB=B2=8C=ED=81=AC=20=EC=9D=B8=EC=84=9C?= =?UTF-8?q?=ED=8A=B8=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/repository/ChatRepositoryCustom.java | 1 + .../chat/repository/ChatRepositoryCustomImpl.java | 10 ++++++++++ .../farmingsoon/domain/chat/service/ChatService.java | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustom.java b/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustom.java index cdc7c01..fc57960 100644 --- a/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustom.java +++ b/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustom.java @@ -8,4 +8,5 @@ public interface ChatRepositoryCustom { List findMyNotReadChatList(ChatRoom chatroom, Member member); + void readAllMyNotReadChatList(ChatRoom chatroom, Member member); } diff --git a/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustomImpl.java b/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustomImpl.java index 44608f1..1372a9d 100644 --- a/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustomImpl.java +++ b/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustomImpl.java @@ -29,4 +29,14 @@ public List findMyNotReadChatList(ChatRoom chatRoom, Member member) { .fetch(); } + + @Override + public void readAllMyNotReadChatList(ChatRoom chatroom, Member member) { + queryFactory.update(chat) + .where(chat.chatRoom.eq(chatroom), chat.isRead.isFalse(), chat.sender.ne(member)) + .set(chat.isRead, true) + .execute(); + + + } } diff --git a/src/main/java/com/api/farmingsoon/domain/chat/service/ChatService.java b/src/main/java/com/api/farmingsoon/domain/chat/service/ChatService.java index 0a7f104..ba6ddf6 100644 --- a/src/main/java/com/api/farmingsoon/domain/chat/service/ChatService.java +++ b/src/main/java/com/api/farmingsoon/domain/chat/service/ChatService.java @@ -69,7 +69,11 @@ public ChatListResponse getChats(Long chatRoomId, Pageable pageable) { public void readAllMyNotReadChatList(Long chatRoomId, Long memberId) { ChatRoom chatRoom = chatRoomService.getChatRoom(chatRoomId); Member member = memberService.getMemberById(memberId); + chatRepository.readAllMyNotReadChatList(chatRoom, member); + + /* List myNotReadChatList = chatRepository.findMyNotReadChatList(chatRoom, member); myNotReadChatList.forEach(Chat::read); + */ } } From a24f27142ba4da6c58fdcac5eb920ef6f1d6b97f Mon Sep 17 00:00:00 2001 From: gkfktkrh153 Date: Fri, 15 Mar 2024 00:21:42 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=EB=B2=8C=ED=81=AC=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=ED=9B=84=20=EC=98=81=EC=86=8D=EC=84=B1=20?= =?UTF-8?q?=EC=BB=A8=ED=85=8D=EC=8A=A4=ED=8A=B8=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/repository/ChatRepositoryCustomImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustomImpl.java b/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustomImpl.java index 1372a9d..354125e 100644 --- a/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustomImpl.java +++ b/src/main/java/com/api/farmingsoon/domain/chat/repository/ChatRepositoryCustomImpl.java @@ -5,6 +5,7 @@ import com.api.farmingsoon.domain.chatroom.model.ChatRoom; import com.api.farmingsoon.domain.member.model.Member; import com.querydsl.jpa.impl.JPAQueryFactory; +import jakarta.persistence.EntityManager; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -21,6 +22,7 @@ public class ChatRepositoryCustomImpl implements ChatRepositoryCustom{ private final JPAQueryFactory queryFactory; + private final EntityManager em; @Override public List findMyNotReadChatList(ChatRoom chatRoom, Member member) { @@ -36,7 +38,8 @@ public void readAllMyNotReadChatList(ChatRoom chatroom, Member member) { .where(chat.chatRoom.eq(chatroom), chat.isRead.isFalse(), chat.sender.ne(member)) .set(chat.isRead, true) .execute(); - + em.flush(); + em.clear(); } } From 7e46fbf46809cc56397a675a9e1936fc8062d37d Mon Sep 17 00:00:00 2001 From: gkfktkrh153 Date: Sun, 17 Mar 2024 22:13:05 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=EA=B3=B5=ED=86=B5=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EB=90=98=EB=8A=94=20=EB=B9=88=20=EA=B5=AC?= =?UTF-8?q?=EC=84=B1=EB=93=A4=20=EC=83=81=EC=86=8D=EA=B5=AC=EC=A1=B0?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../farmingsoon/domain/IntegrationTest.java | 30 +++++++++++++++++++ .../chatting/ChattingIntegrationTest.java | 20 ++----------- .../domain/item/ItemIntegrationTest.java | 17 ++--------- .../like/LikeableItemIntegrationTest.java | 16 ++-------- .../domain/member/MemberIntegrationTest.java | 15 +++------- .../NotificationIntegrationTest.java | 17 ++--------- 6 files changed, 45 insertions(+), 70 deletions(-) create mode 100644 src/test/java/com/api/farmingsoon/domain/IntegrationTest.java diff --git a/src/test/java/com/api/farmingsoon/domain/IntegrationTest.java b/src/test/java/com/api/farmingsoon/domain/IntegrationTest.java new file mode 100644 index 0000000..a6cd391 --- /dev/null +++ b/src/test/java/com/api/farmingsoon/domain/IntegrationTest.java @@ -0,0 +1,30 @@ +package com.api.farmingsoon.domain; + + +import com.api.farmingsoon.common.clean.DatabaseCleanup; +import com.api.farmingsoon.common.util.Transaction; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.web.context.WebApplicationContext; + +@SpringBootTest +@ActiveProfiles("test") +@AutoConfigureMockMvc +public abstract class IntegrationTest { + + @Autowired + protected WebApplicationContext ctx; + + @Autowired + protected Transaction transaction; + @Autowired + protected ObjectMapper objectMapper; + @Autowired + protected MockMvc mockMvc; + @Autowired + protected DatabaseCleanup databaseCleanup; +} diff --git a/src/test/java/com/api/farmingsoon/domain/chatting/ChattingIntegrationTest.java b/src/test/java/com/api/farmingsoon/domain/chatting/ChattingIntegrationTest.java index d0cec4c..90085e1 100644 --- a/src/test/java/com/api/farmingsoon/domain/chatting/ChattingIntegrationTest.java +++ b/src/test/java/com/api/farmingsoon/domain/chatting/ChattingIntegrationTest.java @@ -3,6 +3,7 @@ import com.api.farmingsoon.common.clean.DatabaseCleanup; import com.api.farmingsoon.common.util.TimeUtils; import com.api.farmingsoon.common.util.Transaction; +import com.api.farmingsoon.domain.IntegrationTest; import com.api.farmingsoon.domain.chat.dto.ChatListResponse; import com.api.farmingsoon.domain.chat.dto.ChatMessageRequest; import com.api.farmingsoon.domain.chat.service.ChatService; @@ -50,32 +51,17 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@SpringBootTest -@ActiveProfiles("test") -@AutoConfigureMockMvc -public class ChattingIntegrationTest { + +public class ChattingIntegrationTest extends IntegrationTest { @Autowired private ItemService itemService; @Autowired private MemberService memberService; @Autowired - private WebApplicationContext ctx; - @Autowired private ChatService chatService; @Autowired private ChatRoomService chatRoomService; - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private MockMvc mockMvc; - - @Autowired - private Transaction transaction; - - @Autowired - private DatabaseCleanup databaseCleanup; private static MockMultipartFile profileImage; diff --git a/src/test/java/com/api/farmingsoon/domain/item/ItemIntegrationTest.java b/src/test/java/com/api/farmingsoon/domain/item/ItemIntegrationTest.java index 6a34dbb..f0add96 100644 --- a/src/test/java/com/api/farmingsoon/domain/item/ItemIntegrationTest.java +++ b/src/test/java/com/api/farmingsoon/domain/item/ItemIntegrationTest.java @@ -2,6 +2,7 @@ import com.api.farmingsoon.common.clean.DatabaseCleanup; import com.api.farmingsoon.common.util.TimeUtils; +import com.api.farmingsoon.domain.IntegrationTest; import com.api.farmingsoon.domain.bid.dto.BidRequest; import com.api.farmingsoon.domain.bid.service.BidService; import com.api.farmingsoon.domain.item.domain.Item; @@ -49,29 +50,17 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@SpringBootTest -@ActiveProfiles("test") -@AutoConfigureMockMvc -class ItemIntegrationTest { + +class ItemIntegrationTest extends IntegrationTest { @Autowired private MemberService memberService; @Autowired - private WebApplicationContext ctx; - @Autowired private ItemService itemService; @Autowired private BidService bidService; - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private MockMvc mockMvc; - - @Autowired - private DatabaseCleanup databaseCleanup; private static MockMultipartFile thumbnailImage; private static List images; diff --git a/src/test/java/com/api/farmingsoon/domain/like/LikeableItemIntegrationTest.java b/src/test/java/com/api/farmingsoon/domain/like/LikeableItemIntegrationTest.java index 4ab1720..d38ca45 100644 --- a/src/test/java/com/api/farmingsoon/domain/like/LikeableItemIntegrationTest.java +++ b/src/test/java/com/api/farmingsoon/domain/like/LikeableItemIntegrationTest.java @@ -3,6 +3,7 @@ import com.api.farmingsoon.common.clean.DatabaseCleanup; import com.api.farmingsoon.common.util.TimeUtils; import com.api.farmingsoon.common.util.Transaction; +import com.api.farmingsoon.domain.IntegrationTest; import com.api.farmingsoon.domain.item.domain.Item; import com.api.farmingsoon.domain.item.domain.ItemStatus; import com.api.farmingsoon.domain.item.dto.LikeableItemListResponse; @@ -46,21 +47,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@SpringBootTest -@ActiveProfiles("test") -@AutoConfigureMockMvc -class LikeableItemIntegrationTest { - @Autowired - private Transaction transaction; - @Autowired - private ObjectMapper objectMapper; - @Autowired - private MockMvc mockMvc; - @Autowired - private WebApplicationContext ctx; - @Autowired - private DatabaseCleanup databaseCleanup; +class LikeableItemIntegrationTest extends IntegrationTest { @Autowired private MemberService memberService; @Autowired diff --git a/src/test/java/com/api/farmingsoon/domain/member/MemberIntegrationTest.java b/src/test/java/com/api/farmingsoon/domain/member/MemberIntegrationTest.java index 3faae3c..baed6f3 100644 --- a/src/test/java/com/api/farmingsoon/domain/member/MemberIntegrationTest.java +++ b/src/test/java/com/api/farmingsoon/domain/member/MemberIntegrationTest.java @@ -1,6 +1,7 @@ package com.api.farmingsoon.domain.member; import com.api.farmingsoon.common.clean.DatabaseCleanup; +import com.api.farmingsoon.domain.IntegrationTest; import com.api.farmingsoon.domain.member.dto.JoinRequest; import com.api.farmingsoon.domain.member.dto.LoginRequest; import com.api.farmingsoon.domain.member.model.Member; @@ -29,22 +30,14 @@ import java.util.Arrays; import java.util.Optional; -@SpringBootTest -@ActiveProfiles("test") -@AutoConfigureMockMvc -class MemberIntegrationTest { - @Autowired - private ObjectMapper objectMapper; + +class MemberIntegrationTest extends IntegrationTest { + @Autowired private MemberService memberService; @Autowired private PasswordEncoder passwordEncoder; - @Autowired - private MockMvc mockMvc; - - @Autowired - private DatabaseCleanup databaseCleanup; private static MockMultipartFile profileImage; @BeforeAll static void beforeAll() throws IOException { diff --git a/src/test/java/com/api/farmingsoon/domain/notification/NotificationIntegrationTest.java b/src/test/java/com/api/farmingsoon/domain/notification/NotificationIntegrationTest.java index a9744cd..52e4a7e 100644 --- a/src/test/java/com/api/farmingsoon/domain/notification/NotificationIntegrationTest.java +++ b/src/test/java/com/api/farmingsoon/domain/notification/NotificationIntegrationTest.java @@ -3,6 +3,7 @@ import com.api.farmingsoon.common.clean.DatabaseCleanup; import com.api.farmingsoon.common.util.TimeUtils; import com.api.farmingsoon.common.util.Transaction; +import com.api.farmingsoon.domain.IntegrationTest; import com.api.farmingsoon.domain.bid.dto.BidRequest; import com.api.farmingsoon.domain.bid.model.Bid; import com.api.farmingsoon.domain.bid.model.BidResult; @@ -53,21 +54,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@SpringBootTest -@ActiveProfiles("test") -@AutoConfigureMockMvc -public class NotificationIntegrationTest { - @Autowired - private Transaction transaction; - @Autowired - private ObjectMapper objectMapper; - @Autowired - private MockMvc mockMvc; - @Autowired - private WebApplicationContext ctx; - @Autowired - private DatabaseCleanup databaseCleanup; +public class NotificationIntegrationTest extends IntegrationTest { + @Autowired private MemberService memberService; @Autowired From 34d7519bf9e8fa98ae7ea965fdbb6aa8fd2a95ae Mon Sep 17 00:00:00 2001 From: gkfktkrh153 Date: Tue, 19 Mar 2024 18:55:41 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EC=88=98=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=A3=BC=EC=84=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../farmingsoon/domain/item/service/ItemRedisService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/api/farmingsoon/domain/item/service/ItemRedisService.java b/src/main/java/com/api/farmingsoon/domain/item/service/ItemRedisService.java index c6e7c30..bb91b78 100644 --- a/src/main/java/com/api/farmingsoon/domain/item/service/ItemRedisService.java +++ b/src/main/java/com/api/farmingsoon/domain/item/service/ItemRedisService.java @@ -20,9 +20,9 @@ public void setBidEndTime(Long itemId, Integer expire){ /** * @Description - * 1. 중복된 접근이 아니라면 조회수를 증가시키고 접근 처리 - * 2. set이 없다면 만들고 만료기간 자정으로 설정 - * 3. 있다면 추가 + * 1. 중복된 접근이 아니라면 조회수를 증가시키고 접근 처리(Set 의 키 값이 없거나 set 내부에 value 가 없거나) + * 2. set 이 없다면 만들고 만료기간 자정으로 설정 + * 3. 있다면 set 에 value 추가 */ @Async("testExecutor") From c32a521a0e5cfe2ad0973a33330eedba492cc08e Mon Sep 17 00:00:00 2001 From: gkfktkrh153 Date: Tue, 19 Mar 2024 18:56:49 +0900 Subject: [PATCH 5/6] =?UTF-8?q?open-in-view=20=EB=B9=84=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 62b7937..361aff2 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -11,16 +11,14 @@ spring: h2: console: enabled: true -# jpa: + jpa: + open-in-view: false # show-sql: true # properties: # hibernate: # format_sql: true # highlight_sql: true - hibernate: - ddl-auto: create - # defer-datasource-initialization: true - open-in-view: false + data: redis: host: localhost From a3c764d48b53e9a6fa82be2d4c1c7ea597bd07ea Mon Sep 17 00:00:00 2001 From: gkfktkrh153 Date: Tue, 19 Mar 2024 19:10:26 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=EC=BF=A0=ED=82=A4=20=EC=9C=A0=ED=8B=B8?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=ED=86=A0=ED=81=B0=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EB=B9=84=ED=99=9C=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/api/farmingsoon/common/util/CookieUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/api/farmingsoon/common/util/CookieUtils.java b/src/main/java/com/api/farmingsoon/common/util/CookieUtils.java index 914beb5..9a665b0 100644 --- a/src/main/java/com/api/farmingsoon/common/util/CookieUtils.java +++ b/src/main/java/com/api/farmingsoon/common/util/CookieUtils.java @@ -18,7 +18,7 @@ public class CookieUtils { public static String getViewCountCookieValue(HttpServletRequest request, HttpServletResponse response) { Cookie[] cookies = request.getCookies(); - log.info(Arrays.toString(cookies)); + //log.info(Arrays.toString(cookies)); if (cookies != null) { Optional viewCountCookie = Arrays.stream(cookies) .filter(cookie -> cookie.getName().equals("viewCountCookie")) @@ -30,7 +30,7 @@ public static String getViewCountCookieValue(HttpServletRequest request, HttpSer } public static String getAccessTokenCookieValue(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); - log.info(Arrays.toString(cookies)); + //log.info(Arrays.toString(cookies)); if (cookies != null) { Optional accessTokenCookie = Arrays.stream(cookies) .filter(cookie -> cookie.getName().equals("AccessToken")) @@ -42,7 +42,7 @@ public static String getAccessTokenCookieValue(HttpServletRequest request) { } public static String getRefreshTokenCookieValue(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); - log.info(Arrays.toString(cookies)); + //log.info(Arrays.toString(cookies)); if (cookies != null) { Optional refreshTokenCookie = Arrays.stream(cookies) .filter(cookie -> cookie.getName().equals("RefreshToken"))