Skip to content

Commit

Permalink
Merge pull request #139 from farmingsoon/develop
Browse files Browse the repository at this point in the history
배포를 위한 Main merge
  • Loading branch information
gkfktkrh153 authored Mar 19, 2024
2 parents 3c5fa92 + a3c764d commit d7c2291
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Cookie> viewCountCookie = Arrays.stream(cookies)
.filter(cookie -> cookie.getName().equals("viewCountCookie"))
Expand All @@ -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<Cookie> accessTokenCookie = Arrays.stream(cookies)
.filter(cookie -> cookie.getName().equals("AccessToken"))
Expand All @@ -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<Cookie> refreshTokenCookie = Arrays.stream(cookies)
.filter(cookie -> cookie.getName().equals("RefreshToken"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

public interface ChatRepositoryCustom {
List<Chat> findMyNotReadChatList(ChatRoom chatroom, Member member);
void readAllMyNotReadChatList(ChatRoom chatroom, Member member);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -21,6 +22,7 @@
public class ChatRepositoryCustomImpl implements ChatRepositoryCustom{

private final JPAQueryFactory queryFactory;
private final EntityManager em;

@Override
public List<Chat> findMyNotReadChatList(ChatRoom chatRoom, Member member) {
Expand All @@ -29,4 +31,15 @@ public List<Chat> 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();
em.flush();
em.clear();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Chat> myNotReadChatList = chatRepository.findMyNotReadChatList(chatRoom, member);
myNotReadChatList.forEach(Chat::read);
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 3 additions & 5 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions src/test/java/com/api/farmingsoon/domain/IntegrationTest.java
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<MockMultipartFile> images;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d7c2291

Please sign in to comment.