From d81f62343784e5dcc5353b6709a3c09806a2e48b Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Sun, 25 Aug 2024 20:10:54 +0900 Subject: [PATCH 01/15] =?UTF-8?q?feat:=20=EC=95=8C=EB=A6=BC=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pinu/familing/domain/alarm/AlarmType.java | 17 ++ .../alarm/controller/AlarmController.java | 25 ++ .../familing/domain/alarm/entity/Alarm.java | 47 ++++ .../alarm/repository/AlarmRepository.java | 13 + .../domain/alarm/service/AlarmService.java | 57 ++++ .../status/controller/StatusController.java | 2 +- .../status/dto/MyFamilyStatusResponse.java | 14 +- .../domain/status/service/StatusService.java | 2 +- .../familing/domain/user/entity/User.java | 2 +- familing/src/main/resources/data.sql | 2 +- .../alarm/service/AlarmServiceTest.java | 106 +++++++ .../status/service/StatusServiceTest.java | 265 +++++++++--------- 12 files changed, 404 insertions(+), 148 deletions(-) create mode 100644 familing/src/main/java/com/pinu/familing/domain/alarm/AlarmType.java create mode 100644 familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java create mode 100644 familing/src/main/java/com/pinu/familing/domain/alarm/entity/Alarm.java create mode 100644 familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java create mode 100644 familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java create mode 100644 familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/AlarmType.java b/familing/src/main/java/com/pinu/familing/domain/alarm/AlarmType.java new file mode 100644 index 0000000..ccb20da --- /dev/null +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/AlarmType.java @@ -0,0 +1,17 @@ +package com.pinu.familing.domain.alarm; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum AlarmType { + + SNAPSHOT_SUBJECT("스냅샷 주제등록"), + SNAPSHOT_REGISTER("스냅샷 등록"), + LOVECARD_RECEIVE("애정카드 받음"); + + + private String value; +} diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java b/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java new file mode 100644 index 0000000..f25b186 --- /dev/null +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java @@ -0,0 +1,25 @@ +package com.pinu.familing.domain.alarm.controller; + + +import com.pinu.familing.domain.alarm.service.AlarmService; +import com.pinu.familing.global.oauth.dto.CustomOAuth2User; +import com.pinu.familing.global.util.ApiUtils; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1") +public class AlarmController { + private final AlarmService alarmService; + + @GetMapping("alarm") + public ApiUtils.ApiResult getAlarm(@AuthenticationPrincipal CustomOAuth2User customOAuth2User) { + + + return ApiUtils.success("Successful addition of family"); + } +} diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/entity/Alarm.java b/familing/src/main/java/com/pinu/familing/domain/alarm/entity/Alarm.java new file mode 100644 index 0000000..86dc6f0 --- /dev/null +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/entity/Alarm.java @@ -0,0 +1,47 @@ +package com.pinu.familing.domain.alarm.entity; + +import com.pinu.familing.domain.BaseEntity; +import com.pinu.familing.domain.alarm.AlarmType; +import com.pinu.familing.domain.user.entity.User; +import jakarta.persistence.*; + +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor +public class Alarm extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private Boolean isRead = false; // 기본 값은 false로 읽지 않은 상태이다. + + @ManyToOne + @JoinColumn(name = "sender_id") + private User sender; + + @ManyToOne + @JoinColumn(name = "receiver_id") + private User receiver; + + private String message; + + @Enumerated(EnumType.STRING) + private AlarmType alarmType; + + private String AlarmImg; + + @Builder + private Alarm(Boolean isRead, User sender, User receiver, String message, AlarmType alarmType, String alarmImg) { + this.sender = sender; + this.receiver = receiver; + this.message = message; + this.alarmType = alarmType; + this.isRead = isRead != null ? isRead : false; // null일 경우 기본값으로 false 설정 + this.AlarmImg = alarmImg; + } +} diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java b/familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java new file mode 100644 index 0000000..742b7f7 --- /dev/null +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java @@ -0,0 +1,13 @@ +package com.pinu.familing.domain.alarm.repository; + +import com.pinu.familing.domain.alarm.entity.Alarm; +import com.pinu.familing.domain.user.entity.User; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +public interface AlarmRepository extends JpaRepository { + // 특정 수신자와 읽지 않은 상태의 알람 목록을 조회하는 메서드 + List findByReceiverAndIsReadFalse(User receiver); + +} diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java b/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java new file mode 100644 index 0000000..2468506 --- /dev/null +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java @@ -0,0 +1,57 @@ +package com.pinu.familing.domain.alarm.service; + +import com.pinu.familing.domain.alarm.AlarmType; +import com.pinu.familing.domain.alarm.entity.Alarm; +import com.pinu.familing.domain.alarm.repository.AlarmRepository; +import com.pinu.familing.domain.user.entity.User; +import com.pinu.familing.domain.user.repository.UserRepository; +import com.pinu.familing.global.error.CustomException; +import com.pinu.familing.global.error.ExceptionCode; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import static com.pinu.familing.global.error.ExceptionCode.USER_NOT_FOUND; + +@Service +@RequiredArgsConstructor +public class AlarmService { + + private final AlarmRepository alarmRepository; + private final UserRepository userRepository; + + @Transactional + public void sendAlarm(User sender, User receiver, AlarmType alarmType) { + + String message = ""; + String alarmImg = ""; + + if (alarmType == AlarmType.LOVECARD_RECEIVE) { + message = sender.getNickname() + "님이 애정카드를 보냈어요."; + alarmImg = sender.getProfileImg(); + } + else if (alarmType == AlarmType.SNAPSHOT_REGISTER) { + message = sender.getNickname() + "님이 SnapShot에 사진을 등록했어요."; + alarmImg = sender.getProfileImg(); + } + else if (alarmType == AlarmType.SNAPSHOT_SUBJECT) { + message = "Snap Shot의 주제 등록되었어요."; + alarmImg = ""; + } + + alarmRepository.save(Alarm.builder() + .sender(sender) + .message(message) + .receiver(receiver) + .alarmType(alarmType) + .alarmImg(alarmImg) + .build()); + } + +// @Transactional(readOnly = true) +// public void loadAlarm(String username){ +// User user = userRepository.findByUsername(username).orElseThrow(() -> new CustomException(USER_NOT_FOUND)); +// alarmRepository.findAllByUn +// } +} diff --git a/familing/src/main/java/com/pinu/familing/domain/status/controller/StatusController.java b/familing/src/main/java/com/pinu/familing/domain/status/controller/StatusController.java index 6eb2813..17752c0 100644 --- a/familing/src/main/java/com/pinu/familing/domain/status/controller/StatusController.java +++ b/familing/src/main/java/com/pinu/familing/domain/status/controller/StatusController.java @@ -40,4 +40,4 @@ public ApiUtils.ApiResult changeFamilyStatus(@AuthenticationPrincipal Princip statusService.getFamilyStatusList(principalDetails.getUsername()); return ApiUtils.success("User's status has been successfully changed."); } -} +} \ No newline at end of file diff --git a/familing/src/main/java/com/pinu/familing/domain/status/dto/MyFamilyStatusResponse.java b/familing/src/main/java/com/pinu/familing/domain/status/dto/MyFamilyStatusResponse.java index d32b9a7..f866470 100644 --- a/familing/src/main/java/com/pinu/familing/domain/status/dto/MyFamilyStatusResponse.java +++ b/familing/src/main/java/com/pinu/familing/domain/status/dto/MyFamilyStatusResponse.java @@ -15,18 +15,18 @@ public MyFamilyStatusResponse(User user) { this( new UserStatusResponse(user) ,user.getFamily().getUsers().stream() - .filter(familyUser -> !familyUser.equals(user)) // user와 동일한 객체는 건너뜀 - .map(UserStatusResponse::new) // UserResponse로 변환 - .collect(Collectors.toList()) // List로 변환 + .filter(familyUser -> !familyUser.equals(user)) // user와 동일한 객체는 건너뜀 + .map(UserStatusResponse::new) // UserResponse로 변환 + .collect(Collectors.toList()) // List로 변환 ); } @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) private record UserStatusResponse(String username, - String nickname, - String imageUrl, - String status) { + String nickname, + String imageUrl, + String status) { private UserStatusResponse(User user) { this( user.getUsername(), @@ -36,4 +36,4 @@ private UserStatusResponse(User user) { ); } } -} +} \ No newline at end of file diff --git a/familing/src/main/java/com/pinu/familing/domain/status/service/StatusService.java b/familing/src/main/java/com/pinu/familing/domain/status/service/StatusService.java index fdeb06e..10f2447 100644 --- a/familing/src/main/java/com/pinu/familing/domain/status/service/StatusService.java +++ b/familing/src/main/java/com/pinu/familing/domain/status/service/StatusService.java @@ -55,4 +55,4 @@ private User getUserWithFamily(String username) { return user; } -} +} \ No newline at end of file diff --git a/familing/src/main/java/com/pinu/familing/domain/user/entity/User.java b/familing/src/main/java/com/pinu/familing/domain/user/entity/User.java index 07dbd96..6e57ce4 100644 --- a/familing/src/main/java/com/pinu/familing/domain/user/entity/User.java +++ b/familing/src/main/java/com/pinu/familing/domain/user/entity/User.java @@ -105,4 +105,4 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(username); } -} +} \ No newline at end of file diff --git a/familing/src/main/resources/data.sql b/familing/src/main/resources/data.sql index 279f357..4c482de 100644 --- a/familing/src/main/resources/data.sql +++ b/familing/src/main/resources/data.sql @@ -57,4 +57,4 @@ VALUES ('이미지10'); INSERT INTO lovecard (image) VALUES ('이미지11'); INSERT INTO lovecard (image) -VALUES ('이미지12'); +VALUES ('이미지12'); \ No newline at end of file diff --git a/familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java b/familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java new file mode 100644 index 0000000..cb870e5 --- /dev/null +++ b/familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java @@ -0,0 +1,106 @@ +package com.pinu.familing.domain.alarm.service; + +import static org.junit.jupiter.api.Assertions.*; + + + +import com.pinu.familing.IntegrationTestSupport; +import com.pinu.familing.domain.alarm.AlarmType; +import com.pinu.familing.domain.alarm.entity.Alarm; +import com.pinu.familing.domain.alarm.repository.AlarmRepository; +import com.pinu.familing.domain.user.entity.User; +import com.pinu.familing.domain.user.repository.UserRepository; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import jakarta.transaction.Transactional; + +import static org.assertj.core.api.Assertions.assertThat; + +@Transactional +class AlarmServiceTest extends IntegrationTestSupport { + + @Autowired + private AlarmService alarmService; + + @Autowired + private AlarmRepository alarmRepository; + + @Autowired + private UserRepository userRepository; + + private User sender; + private User receiver; + + @BeforeEach + void setUp() { + sender = User.builder() + .nickname("Sender") + .username("senderUser") + .profileImg("senderProfileImg.png") + .build(); + receiver = User.builder() + .nickname("Receiver") + .username("receiverUser") + .build(); + userRepository.save(sender); + userRepository.save(receiver); + } + + @AfterEach + void tearDown() { + alarmRepository.deleteAll(); + userRepository.deleteAll(); + } + + @Test + @DisplayName("LOVECARD_RECEIVE 알림을 성공적으로 보낸다.") + void testSendLoveCardReceiveAlarm() { + // when + alarmService.sendAlarm(sender, receiver, AlarmType.LOVECARD_RECEIVE); + + // then + Alarm alarm = alarmRepository.findAll().get(0); + assertThat(alarm.getSender()).isEqualTo(sender); + assertThat(alarm.getReceiver()).isEqualTo(receiver); + assertThat(alarm.getAlarmType()).isEqualTo(AlarmType.LOVECARD_RECEIVE); + assertThat(alarm.getMessage()).isEqualTo(sender.getNickname() + "님이 애정카드를 보냈어요."); + assertThat(alarm.getAlarmImg()).isEqualTo(sender.getProfileImg()); + assertThat(alarm.getIsRead()).isFalse(); + } + + @Test + @DisplayName("SNAPSHOT_REGISTER 알림을 성공적으로 보낸다.") + void testSendSnapshotRegisterAlarm() { + // when + alarmService.sendAlarm(sender, receiver, AlarmType.SNAPSHOT_REGISTER); + + // then + Alarm alarm = alarmRepository.findAll().get(0); + assertThat(alarm.getSender()).isEqualTo(sender); + assertThat(alarm.getReceiver()).isEqualTo(receiver); + assertThat(alarm.getAlarmType()).isEqualTo(AlarmType.SNAPSHOT_REGISTER); + assertThat(alarm.getMessage()).isEqualTo(sender.getNickname() + "님이 SnapShot에 사진을 등록했어요."); + assertThat(alarm.getAlarmImg()).isEqualTo(sender.getProfileImg()); + assertThat(alarm.getIsRead()).isFalse(); + } + + @Test + @DisplayName("SNAPSHOT_SUBJECT 알림을 성공적으로 보낸다.") + void testSendSnapshotSubjectAlarm() { + // when + alarmService.sendAlarm(sender, receiver, AlarmType.SNAPSHOT_SUBJECT); + + // then + Alarm alarm = alarmRepository.findAll().get(0); + assertThat(alarm.getSender()).isEqualTo(sender); + assertThat(alarm.getReceiver()).isEqualTo(receiver); + assertThat(alarm.getAlarmType()).isEqualTo(AlarmType.SNAPSHOT_SUBJECT); + assertThat(alarm.getMessage()).isEqualTo("Snap Shot의 주제 등록되었어요."); + assertThat(alarm.getAlarmImg()).isEmpty(); + assertThat(alarm.getIsRead()).isFalse(); + } +} \ No newline at end of file diff --git a/familing/src/test/java/com/pinu/familing/domain/status/service/StatusServiceTest.java b/familing/src/test/java/com/pinu/familing/domain/status/service/StatusServiceTest.java index 71a81f9..0c0f1d4 100644 --- a/familing/src/test/java/com/pinu/familing/domain/status/service/StatusServiceTest.java +++ b/familing/src/test/java/com/pinu/familing/domain/status/service/StatusServiceTest.java @@ -1,137 +1,128 @@ -//package com.pinu.familing.domain.status.service; -// -//import com.pinu.familing.IntegrationTestSupport; -//import com.pinu.familing.domain.family.entity.Family; -//import com.pinu.familing.domain.family.repository.FamilyRepository; -//import com.pinu.familing.domain.status.dto.MyFamilyStatusResponse; -//import com.pinu.familing.domain.user.entity.User; -//import com.pinu.familing.domain.user.repository.UserRepository; -//import com.pinu.familing.domain.status.dto.StatusRequest; -//import com.pinu.familing.domain.status.entity.Status; -//import com.pinu.familing.domain.status.repository.StatusRepository; -//import jakarta.persistence.EntityManager; -//import org.junit.jupiter.api.AfterEach; -//import org.junit.jupiter.api.BeforeEach; -//import org.junit.jupiter.api.DisplayName; -//import org.junit.jupiter.api.Test; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.transaction.annotation.Transactional; -// -//import java.util.List; -// -//import static org.assertj.core.api.Assertions.assertThat; -// -//class StatusServiceTest extends IntegrationTestSupport { -// -// private final StatusService statusService; -// private final UserRepository userRepository; -// private final StatusRepository statusRepository; -// private final FamilyRepository familyRepository; -// private final EntityManager entityManager; -// -// @Autowired -// StatusServiceTest(StatusService StatusService, -// UserRepository userRepository, -// StatusRepository StatusRepository, -// FamilyRepository familyRepository, -// EntityManager entityManager) { -// this.statusService = StatusService; -// this.userRepository = userRepository; -// this.statusRepository = StatusRepository; -// this.familyRepository = familyRepository; -// this.entityManager = entityManager; -// } -// -// @BeforeEach -// public void setUp() { -// statusRepository.save(Status.builder().text("공부 중").build()); -// statusRepository.save(Status.builder().text("노는 중").build()); -// statusRepository.save(Status.builder().text("쉬는 중").build()); -// statusRepository.save(Status.builder().text("일하는 중").build()); -// -// User user1 = userRepository.save( -// User.builder() -// .username("user1") -// .nickname("유저1").build()); -// -// -// User user2 = userRepository.save( -// User.builder() -// .username("user2") -// .nickname("유저2").build()); -// -// Family family = familyRepository.save(new Family("가족", "code")); -// -// user1.registerFamily(family); -// user2.registerFamily(family); -// -// entityManager.flush(); -// entityManager.clear(); -// -// } -// -// -// -// @AfterEach -// public void tearDown() { -// userRepository.deleteAll(); -// statusRepository.deleteAll(); -// familyRepository.deleteAll(); -// } -// -// -// @Test -// @DisplayName("상태리스트조회 메서드 테스트") -// @Transactional -// void getStatusListTest() { -// //give -// //when -// List StatusList =statusService.getStatusList(); -// //then -// assertThat(StatusList.size()).isEqualTo(4); -// System.out.println("StatusList = " + StatusList); -// } -// -// @Test -// @DisplayName("유저의 상태 변경되는지 테스트") -// @Transactional -// void changeStatusTest() { -// entityManager.clear(); -// //give -// StatusRequest statusRequest = new StatusRequest(statusRepository.findByText("쉬는 중").get().getId()); -// //when -// statusService.changeUserStatus("user1", statusRequest); -// //then -// assertThat(userRepository.findByUsername("user1").get().getStatus().getText()).isEqualTo("쉬는 중"); -// -// } -// -// @Test -// @DisplayName("유저 기준 가족의 상태조회") -// @Transactional -// void getFamilyStatusListTest() { -// //give -// Status status1 = statusRepository.findByText("공부 중").get(); -// User user1 = userRepository.findByUsername("user1").get(); -// user1.changeStatus(status1); -// -// userRepository.save(user1); -// -// System.out.println("user1.getFamily().getUsers() = " + user1.getFamily().getUsers()); -// -// Status status2 = statusRepository.findByText("노는 중").get(); -// User user2 = userRepository.findByUsername("user2").get(); -// user2.changeStatus(status2); -// -// userRepository.save(user2); -// -// System.out.println("user2 = " + user2.getFamily()); -// //when -// MyFamilyStatusResponse myFamilyStatusResponse = statusService.getFamilyStatusList("user1"); -// -// //then -// System.out.println("myFamilyStatusResponse = " + myFamilyStatusResponse); -// -// } -// -//} \ No newline at end of file +package com.pinu.familing.domain.status.service; + +import com.pinu.familing.IntegrationTestSupport; +import com.pinu.familing.domain.family.entity.Family; +import com.pinu.familing.domain.family.repository.FamilyRepository; +import com.pinu.familing.domain.status.dto.MyFamilyStatusResponse; +import com.pinu.familing.domain.user.entity.User; +import com.pinu.familing.domain.user.repository.UserRepository; +import com.pinu.familing.domain.status.dto.StatusRequest; +import com.pinu.familing.domain.status.entity.Status; +import com.pinu.familing.domain.status.repository.StatusRepository; +import jakarta.persistence.EntityManager; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +class StatusServiceTest extends IntegrationTestSupport { + + private final StatusService statusService; + private final UserRepository userRepository; + private final StatusRepository statusRepository; + private final FamilyRepository familyRepository; + private final EntityManager entityManager; + + @Autowired + StatusServiceTest(StatusService StatusService, + UserRepository userRepository, + StatusRepository StatusRepository, + FamilyRepository familyRepository, + EntityManager entityManager) { + this.statusService = StatusService; + this.userRepository = userRepository; + this.statusRepository = StatusRepository; + this.familyRepository = familyRepository; + this.entityManager = entityManager; + } + + @BeforeEach + public void setUp() { + statusRepository.save(Status.builder().text("공부 중").build()); + statusRepository.save(Status.builder().text("노는 중").build()); + statusRepository.save(Status.builder().text("쉬는 중").build()); + statusRepository.save(Status.builder().text("일하는 중").build()); + + User user1 = userRepository.save( + User.builder() + .username("user1") + .nickname("유저1").build()); + + + User user2 = userRepository.save( + User.builder() + .username("user2") + .nickname("유저2").build()); + + Family family = familyRepository.save(new Family("가족", "code")); + + user1.registerFamily(family); + user2.registerFamily(family); + + entityManager.flush(); + entityManager.clear(); + + } + + + + @Test + @DisplayName("상태리스트조회 메서드 테스트") + @Transactional + void getStatusListTest() { + //give + //when + List StatusList =statusService.getStatusList(); + //then + assertThat(StatusList.size()).isEqualTo(4); + System.out.println("StatusList = " + StatusList); + } + + @Test + @DisplayName("유저의 상태 변경되는지 테스트") + @Transactional + void changeStatusTest() { + entityManager.clear(); + //give + StatusRequest statusRequest = new StatusRequest(statusRepository.findByText("쉬는 중").get().getId()); + //when + statusService.changeUserStatus("user1", statusRequest); + //then + assertThat(userRepository.findByUsername("user1").get().getStatus().getText()).isEqualTo("쉬는 중"); + + } + + @Test + @DisplayName("유저 기준 가족의 상태조회") + @Transactional + void getFamilyStatusListTest() { + //give + Status status1 = statusRepository.findByText("공부 중").get(); + User user1 = userRepository.findByUsername("user1").get(); + user1.changeStatus(status1); + + userRepository.save(user1); + + System.out.println("user1.getFamily().getUsers() = " + user1.getFamily().getUsers()); + + Status status2 = statusRepository.findByText("노는 중").get(); + User user2 = userRepository.findByUsername("user2").get(); + user2.changeStatus(status2); + + userRepository.save(user2); + + System.out.println("user2 = " + user2.getFamily()); + //when + MyFamilyStatusResponse myFamilyStatusResponse = statusService.getFamilyStatusList("user1"); + + //then + System.out.println("myFamilyStatusResponse = " + myFamilyStatusResponse); + + } + +} \ No newline at end of file From 748600d07e7d75dbec3a65a72d936a0dc5156fd6 Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 17:53:06 +0900 Subject: [PATCH 02/15] =?UTF-8?q?feat:=20=EC=95=8C=EB=A6=BC=20load=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/controller/AlarmController.java | 9 +++++-- .../familing/domain/alarm/dto/AlarmDto.java | 22 +++++++++++++++ .../domain/alarm/dto/AlarmResponseDto.java | 12 +++++++++ .../alarm/repository/AlarmRepository.java | 1 + .../domain/alarm/service/AlarmService.java | 27 +++++++++++++++---- 5 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmDto.java create mode 100644 familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmResponseDto.java diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java b/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java index f25b186..d5038db 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java @@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -19,7 +20,11 @@ public class AlarmController { @GetMapping("alarm") public ApiUtils.ApiResult getAlarm(@AuthenticationPrincipal CustomOAuth2User customOAuth2User) { - - return ApiUtils.success("Successful addition of family"); + return ApiUtils.success(alarmService.loadAlarm(customOAuth2User.getName())); } + +// @PostMapping("alamr") +// public ApiUtils.ApiResult sendAlarmTest() { +// alarmService.sendAlarm(); +// } } diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmDto.java b/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmDto.java new file mode 100644 index 0000000..cdb5e03 --- /dev/null +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmDto.java @@ -0,0 +1,22 @@ +package com.pinu.familing.domain.alarm.dto; + +import com.pinu.familing.domain.alarm.AlarmType; +import com.pinu.familing.domain.alarm.entity.Alarm; + +public record AlarmDto( + Long id, + Boolean isRead, + String message, + AlarmType alarmType, + String alarmImg +) { + public static AlarmDto fromEntity(Alarm alarm) { + return new AlarmDto( + alarm.getId(), + alarm.getIsRead(), + alarm.getMessage(), + alarm.getAlarmType(), + alarm.getAlarmImg() + ); + } +} diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmResponseDto.java b/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmResponseDto.java new file mode 100644 index 0000000..21d7b96 --- /dev/null +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmResponseDto.java @@ -0,0 +1,12 @@ +package com.pinu.familing.domain.alarm.dto; + +import lombok.Builder; + +import java.util.List; + +@Builder +public record AlarmResponseDto( + List read, + List unread +) { +} \ No newline at end of file diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java b/familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java index 742b7f7..ecd59f6 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java @@ -9,5 +9,6 @@ public interface AlarmRepository extends JpaRepository { // 특정 수신자와 읽지 않은 상태의 알람 목록을 조회하는 메서드 List findByReceiverAndIsReadFalse(User receiver); + List findByReceiverAndIsReadTrue(User receiver); } diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java b/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java index 2468506..b60ba53 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java @@ -1,6 +1,8 @@ package com.pinu.familing.domain.alarm.service; import com.pinu.familing.domain.alarm.AlarmType; +import com.pinu.familing.domain.alarm.dto.AlarmDto; +import com.pinu.familing.domain.alarm.dto.AlarmResponseDto; import com.pinu.familing.domain.alarm.entity.Alarm; import com.pinu.familing.domain.alarm.repository.AlarmRepository; import com.pinu.familing.domain.user.entity.User; @@ -12,6 +14,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; +import java.util.stream.Collectors; + import static com.pinu.familing.global.error.ExceptionCode.USER_NOT_FOUND; @Service @@ -49,9 +54,21 @@ else if (alarmType == AlarmType.SNAPSHOT_SUBJECT) { .build()); } -// @Transactional(readOnly = true) -// public void loadAlarm(String username){ -// User user = userRepository.findByUsername(username).orElseThrow(() -> new CustomException(USER_NOT_FOUND)); -// alarmRepository.findAllByUn -// } + @Transactional(readOnly = true) + public AlarmResponseDto loadAlarm(String username){ + User user = userRepository.findByUsername(username) + .orElseThrow(() -> new CustomException(USER_NOT_FOUND)); + List byReceiverAndIsReadFalse = alarmRepository.findByReceiverAndIsReadFalse(user); + List byReceiverAndIsReadTrue = alarmRepository.findByReceiverAndIsReadTrue(user); + + + return AlarmResponseDto.builder() + .read(byReceiverAndIsReadTrue.stream() + .map(AlarmDto::fromEntity) + .collect(Collectors.toList())) + .unread(byReceiverAndIsReadFalse.stream() + .map(AlarmDto::fromEntity) + .collect(Collectors.toList())) + .build(); + } } From 9db9062966ea3f6052be33ba850e04c175a6869e Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 18:28:06 +0900 Subject: [PATCH 03/15] =?UTF-8?q?feat:=20=EC=95=A0=EC=A0=95=EC=B9=B4?= =?UTF-8?q?=EB=93=9C=20=EC=A0=84=EC=86=A1=20=EC=95=8C=EB=A6=BC=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../familing/domain/alarm/controller/AlarmController.java | 5 +---- .../domain/lovecard/controller/LovecardController.java | 4 ++-- .../familing/domain/lovecard/service/LovecardService.java | 8 +++++++- familing/src/main/resources/data.sql | 8 -------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java b/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java index d5038db..6db4e3a 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java @@ -17,14 +17,11 @@ public class AlarmController { private final AlarmService alarmService; + //나의 알람을 불러온다. @GetMapping("alarm") public ApiUtils.ApiResult getAlarm(@AuthenticationPrincipal CustomOAuth2User customOAuth2User) { return ApiUtils.success(alarmService.loadAlarm(customOAuth2User.getName())); } -// @PostMapping("alamr") -// public ApiUtils.ApiResult sendAlarmTest() { -// alarmService.sendAlarm(); -// } } diff --git a/familing/src/main/java/com/pinu/familing/domain/lovecard/controller/LovecardController.java b/familing/src/main/java/com/pinu/familing/domain/lovecard/controller/LovecardController.java index 2515388..50d9728 100644 --- a/familing/src/main/java/com/pinu/familing/domain/lovecard/controller/LovecardController.java +++ b/familing/src/main/java/com/pinu/familing/domain/lovecard/controller/LovecardController.java @@ -33,8 +33,8 @@ public ApiUtils.ApiResult getLoveCardLogList(@AuthenticationPrincipal Princip } //원하는 가족에게 카드보내기 - @PostMapping("/familys/{familys_username}") - public ApiUtils.ApiResult getLoveCardLogList(@AuthenticationPrincipal PrincipalDetails principalDetails, + @PostMapping("/familys/{family_username}") + public ApiUtils.ApiResult sendLoveCard(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("family_username") String familyUsername, @RequestBody LovecardRequest lovecardRequest) { lovecardService.sendLoveCardToFamily(principalDetails.getUsername(), familyUsername, lovecardRequest); diff --git a/familing/src/main/java/com/pinu/familing/domain/lovecard/service/LovecardService.java b/familing/src/main/java/com/pinu/familing/domain/lovecard/service/LovecardService.java index 99bdea6..f4eed96 100644 --- a/familing/src/main/java/com/pinu/familing/domain/lovecard/service/LovecardService.java +++ b/familing/src/main/java/com/pinu/familing/domain/lovecard/service/LovecardService.java @@ -1,5 +1,7 @@ package com.pinu.familing.domain.lovecard.service; +import com.pinu.familing.domain.alarm.AlarmType; +import com.pinu.familing.domain.alarm.service.AlarmService; import com.pinu.familing.domain.lovecard.dto.LovecardLogResponse; import com.pinu.familing.domain.lovecard.dto.LovecardResponse; import com.pinu.familing.domain.lovecard.entity.Lovecard; @@ -15,14 +17,17 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor @Service +@Transactional(readOnly = true) public class LovecardService { private final LovecardLogRepository lovecardLogRepository; private final LovecardRepository lovecardRepository; private final UserRepository userRepository; + private final AlarmService alarmService; public Page getLovecardPage(Pageable pageable) { Page lovecardResponsePage= lovecardRepository.findAll(pageable) @@ -42,6 +47,7 @@ public Page getLovecardByFamilyLogPage(String username, Str return lovecardLogResponses; } + @Transactional public void sendLoveCardToFamily(String username, String familyUsername, LovecardRequest lovecardRequest) { User sender = userRepository.findByUsername(username) .orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_FOUND)); @@ -51,7 +57,7 @@ public void sendLoveCardToFamily(String username, String familyUsername, Lovecar Lovecard lovecard = lovecardRepository.findById(lovecardRequest.cardId()) .orElseThrow(()-> new CustomException(ExceptionCode.LOVECARD_NOT_FOUND)); - + alarmService.sendAlarm(sender, receiver, AlarmType.LOVECARD_RECEIVE); lovecardLogRepository.save(LovecardLog.builder().lovecard(lovecard).receiver(receiver).sender(sender).build()); } } diff --git a/familing/src/main/resources/data.sql b/familing/src/main/resources/data.sql index 4c482de..d3d62ba 100644 --- a/familing/src/main/resources/data.sql +++ b/familing/src/main/resources/data.sql @@ -26,14 +26,6 @@ VALUES ('테스트용9'); INSERT INTO snapshot_title (title) VALUES ('테스트용10'); -INSERT INTO status (text) -VALUES ('공부 중'); -INSERT INTO status (text) -VALUES ('노는 중'); -INSERT INTO status (text) -VALUES ('쉬는 중'); -INSERT INTO status (text) -VALUES ('일하는 중'); INSERT INTO lovecard (image) VALUES ('이미지1'); INSERT INTO lovecard (image) From 35d9d2e3dce2a894cd95d5a727fdb53a95dbfd94 Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 18:35:06 +0900 Subject: [PATCH 04/15] =?UTF-8?q?feat:=20=EC=8A=A4=EB=83=85=EC=83=B7=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=EC=97=90=20=EC=95=8C=EB=A6=BC=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../familing/domain/snapshot/service/SnapshotService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/familing/src/main/java/com/pinu/familing/domain/snapshot/service/SnapshotService.java b/familing/src/main/java/com/pinu/familing/domain/snapshot/service/SnapshotService.java index 3e276cb..6d44b35 100644 --- a/familing/src/main/java/com/pinu/familing/domain/snapshot/service/SnapshotService.java +++ b/familing/src/main/java/com/pinu/familing/domain/snapshot/service/SnapshotService.java @@ -1,5 +1,7 @@ package com.pinu.familing.domain.snapshot.service; +import com.pinu.familing.domain.alarm.AlarmType; +import com.pinu.familing.domain.alarm.service.AlarmService; import com.pinu.familing.domain.family.entity.Family; import com.pinu.familing.domain.family.repository.FamilyRepository; import com.pinu.familing.domain.snapshot.dto.SnapshotImageRequest; @@ -33,6 +35,7 @@ public class SnapshotService { private final UserRepository userRepository; private final TitleService titleService; private final AwsS3Service awsS3Service; + private final AlarmService alarmService; // 스냅샷에 이미지 등록하기 (스냅샷 이미지가 없으면 생성) @@ -47,6 +50,9 @@ public void registerSnapshotImage(LocalDate day, String username, MultipartFile .orElseGet(() -> createSnapshotImage(snapshot, user, day)); snapshotImage.updateImage(s3ImgDto.getUploadFileUrl()); + user.getFamily().getUsers().stream() + .filter(familyMember -> !familyMember.equals(user)) // 본인을 제외하고 알람을 보내고 싶다면 이 필터를 추가합니다. + .forEach(familyMember -> alarmService.sendAlarm(user, familyMember, AlarmType.SNAPSHOT_REGISTER)); } // 스냅샷 페이지 조회 From 8c10c667830d19ba5bd5b2187fae982a638d3be8 Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 19:42:47 +0900 Subject: [PATCH 05/15] =?UTF-8?q?feat:=20=EC=95=8C=EB=A6=BC=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=EC=8B=9C=20=EC=A1=B0=ED=9A=8C=ED=95=98=EB=A9=B4=20?= =?UTF-8?q?=EC=9D=BD=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD=EB=90=98?= =?UTF-8?q?=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/pinu/familing/domain/alarm/entity/Alarm.java | 4 ++++ .../pinu/familing/domain/alarm/service/AlarmService.java | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/entity/Alarm.java b/familing/src/main/java/com/pinu/familing/domain/alarm/entity/Alarm.java index 86dc6f0..bd8a928 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/entity/Alarm.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/entity/Alarm.java @@ -44,4 +44,8 @@ private Alarm(Boolean isRead, User sender, User receiver, String message, AlarmT this.isRead = isRead != null ? isRead : false; // null일 경우 기본값으로 false 설정 this.AlarmImg = alarmImg; } + + public void readAlarm() { + this.isRead = true; + } } diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java b/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java index b60ba53..8d65724 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java @@ -61,8 +61,7 @@ public AlarmResponseDto loadAlarm(String username){ List byReceiverAndIsReadFalse = alarmRepository.findByReceiverAndIsReadFalse(user); List byReceiverAndIsReadTrue = alarmRepository.findByReceiverAndIsReadTrue(user); - - return AlarmResponseDto.builder() + AlarmResponseDto alarmResponseDto = AlarmResponseDto.builder() .read(byReceiverAndIsReadTrue.stream() .map(AlarmDto::fromEntity) .collect(Collectors.toList())) @@ -70,5 +69,11 @@ public AlarmResponseDto loadAlarm(String username){ .map(AlarmDto::fromEntity) .collect(Collectors.toList())) .build(); + // 조회한 알림 읽음으로 처리 + byReceiverAndIsReadFalse.forEach(alarm -> { + alarm.readAlarm(); + alarmRepository.save(alarm); // 변경된 상태를 저장하기 위해 필요 + }); + return alarmResponseDto; } } From acd1a71078579975d6230016297d6f879f917246 Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 19:43:17 +0900 Subject: [PATCH 06/15] =?UTF-8?q?test:=20=EC=95=8C=EB=A6=BC=20=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=EC=8B=9C=20unread=20->=20read=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=EB=90=98=EB=8A=94=EC=A7=80=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alarm/service/AlarmServiceTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java b/familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java index cb870e5..273eb5e 100644 --- a/familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java +++ b/familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java @@ -6,6 +6,7 @@ import com.pinu.familing.IntegrationTestSupport; import com.pinu.familing.domain.alarm.AlarmType; +import com.pinu.familing.domain.alarm.dto.AlarmResponseDto; import com.pinu.familing.domain.alarm.entity.Alarm; import com.pinu.familing.domain.alarm.repository.AlarmRepository; import com.pinu.familing.domain.user.entity.User; @@ -18,6 +19,8 @@ import jakarta.transaction.Transactional; +import java.util.List; + import static org.assertj.core.api.Assertions.assertThat; @Transactional @@ -103,4 +106,37 @@ void testSendSnapshotSubjectAlarm() { assertThat(alarm.getAlarmImg()).isEmpty(); assertThat(alarm.getIsRead()).isFalse(); } + + @Test + @DisplayName("사용자가 알람을 조회하면 읽지 않은 알람이 읽음 상태로 변경된다.") + void testLoadAlarmAndMarkAsRead() { + //given + + Alarm unreadAlarm = Alarm.builder() + .sender(sender) + .receiver(receiver) + .alarmType(AlarmType.LOVECARD_RECEIVE) + .message("Unread alarm message") + .isRead(false) + .build(); + + Alarm readAlarm = Alarm.builder() + .sender(sender) + .receiver(receiver) + .alarmType(AlarmType.SNAPSHOT_REGISTER) + .message("Read alarm message") + .isRead(true) + .build(); + + alarmRepository.save(unreadAlarm); + alarmRepository.save(readAlarm); + // when + + AlarmResponseDto responseDto = alarmService.loadAlarm(receiver.getUsername()); + + + // 다시 불러오기를 하여 읽지 않은 알람이 모두 읽음 상태로 변경되었는지 확인 + List allAlarms = alarmRepository.findByReceiverAndIsReadTrue(receiver); + assertThat(allAlarms).hasSize(2); + } } \ No newline at end of file From 5f83fb3901503551f458aade543aef6a01e40e94 Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 19:50:27 +0900 Subject: [PATCH 07/15] =?UTF-8?q?test:=20=EC=95=A0=EC=A0=95=EC=B9=B4?= =?UTF-8?q?=EB=93=9C=20test=20teardown=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lovecard/service/LovecardServiceTest.java | 248 +++++++++--------- 1 file changed, 128 insertions(+), 120 deletions(-) diff --git a/familing/src/test/java/com/pinu/familing/domain/lovecard/service/LovecardServiceTest.java b/familing/src/test/java/com/pinu/familing/domain/lovecard/service/LovecardServiceTest.java index 745dc43..3c0d070 100644 --- a/familing/src/test/java/com/pinu/familing/domain/lovecard/service/LovecardServiceTest.java +++ b/familing/src/test/java/com/pinu/familing/domain/lovecard/service/LovecardServiceTest.java @@ -1,120 +1,128 @@ -//package com.pinu.familing.domain.lovecard.service; -// -//import com.fasterxml.jackson.core.JsonProcessingException; -//import com.fasterxml.jackson.databind.ObjectMapper; -//import com.fasterxml.jackson.databind.SerializationFeature; -//import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -//import com.pinu.familing.IntegrationTestSupport; -//import com.pinu.familing.domain.lovecard.dto.LovecardLogResponse; -//import com.pinu.familing.domain.lovecard.dto.LovecardRequest; -//import com.pinu.familing.domain.lovecard.entity.Lovecard; -//import com.pinu.familing.domain.lovecard.entity.LovecardLog; -//import com.pinu.familing.domain.lovecard.repository.LovecardLogRepository; -//import com.pinu.familing.domain.lovecard.repository.LovecardRepository; -//import com.pinu.familing.domain.snapshot.dto.CustomPage; -//import com.pinu.familing.domain.user.entity.User; -//import com.pinu.familing.domain.user.repository.UserRepository; -//import org.junit.jupiter.api.DisplayName; -//import org.junit.jupiter.api.Test; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.data.domain.Page; -//import org.springframework.data.domain.PageRequest; -//import org.springframework.data.domain.Pageable; -//import org.springframework.transaction.annotation.Transactional; -// -//import static org.assertj.core.api.Assertions.assertThat; -// -//class LovecardServiceTest extends IntegrationTestSupport { -// -// @Autowired -// private LovecardService lovecardService; -// @Autowired -// private LovecardLogRepository lovecardLogRepository; -// @Autowired -// private LovecardRepository lovecardRepository; -// @Autowired -// private UserRepository userRepository; -// -// @Test -// @DisplayName("애정카드 페이지 보이는지 확인") -// void getLovecardPage() { -// //given -// Pageable pageable = PageRequest.of(0, 12); -// //when -// Page page = lovecardService.getLovecardPage(pageable); -// -// //then -// assertThat(page.getContent()).isNotNull(); -// -// CustomPage customPage = new CustomPage(page); -// System.out.println("customPage = " + customPage); -// } -// -// -// @Test -// @DisplayName("특정 가족과 주고 받은 애정카드 정상 조회 테스트") -// void getLovecardByFamilyLogPage() throws JsonProcessingException { -// //given -// User receiver = userRepository.save(User.builder() -// .username("user1") -// .realname("서현") -// .nickname("동생") -// .build()); -// -// User sender = userRepository.save(User.builder() -// .username("user2") -// .realname("서경") -// .nickname("언니") -// .build()); -// -// Lovecard lovecard = lovecardRepository.findById(1L).get(); -// -// Pageable pageable = PageRequest.of(0, 12); -// -// lovecardLogRepository.save(LovecardLog.builder().lovecard(lovecard).receiver(receiver).sender(sender).build()); -// -// //then -// Page lovecardLogResponses = lovecardService.getLovecardByFamilyLogPage(receiver.getUsername(), sender.getUsername(), pageable); -// -// System.out.println("lovecardLogResponses = " + lovecardLogResponses); -// -// // Create ObjectMapper instance -// ObjectMapper objectMapper = new ObjectMapper(); -// objectMapper.registerModule(new JavaTimeModule()); // Register JavaTimeModule -// objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); // Disable writing dates as timestamps -// objectMapper.enable(SerializationFeature.INDENT_OUTPUT); // For pretty-printing -// -// // Convert to JSON string -// String json = objectMapper.writeValueAsString(lovecardLogResponses); -// -// // Print JSON string -// System.out.println("lovecardLogResponses (JSON) = " + json); -// } -// -// @Test -// @Transactional -// @DisplayName("원하는 가족에게 애정카드 보내주는 기능 정상 작동") -// void sendLoveCardToFamily() { -// //given -// User user1 = userRepository.save(User.builder() -// .username("user1") -// .realname("서현") -// .nickname("동생") -// .build()); -// -// User user2 = userRepository.save(User.builder() -// .username("user2") -// .realname("서경") -// .nickname("언니") -// .build()); -// -// -// //when -// lovecardService.sendLoveCardToFamily(user1.getUsername(), user2.getUsername(), new LovecardRequest(1L)); -// -// //then -// assertThat(lovecardLogRepository.findById(1L).get().getSender().getUsername()).isEqualTo("user1"); -// -// -// } -//} \ No newline at end of file +package com.pinu.familing.domain.lovecard.service; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.pinu.familing.IntegrationTestSupport; +import com.pinu.familing.domain.lovecard.dto.LovecardLogResponse; +import com.pinu.familing.domain.lovecard.dto.LovecardRequest; +import com.pinu.familing.domain.lovecard.entity.Lovecard; +import com.pinu.familing.domain.lovecard.entity.LovecardLog; +import com.pinu.familing.domain.lovecard.repository.LovecardLogRepository; +import com.pinu.familing.domain.lovecard.repository.LovecardRepository; +import com.pinu.familing.domain.snapshot.dto.CustomPage; +import com.pinu.familing.domain.user.entity.User; +import com.pinu.familing.domain.user.repository.UserRepository; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.transaction.annotation.Transactional; + +import static org.assertj.core.api.Assertions.assertThat; + +class LovecardServiceTest extends IntegrationTestSupport { + + @Autowired + private LovecardService lovecardService; + @Autowired + private LovecardLogRepository lovecardLogRepository; + @Autowired + private LovecardRepository lovecardRepository; + @Autowired + private UserRepository userRepository; + + + @AfterEach + void tearDown() { + lovecardLogRepository.deleteAll(); + userRepository.deleteAll(); + } + + @Test + @DisplayName("애정카드 페이지 보이는지 확인") + void getLovecardPage() { + //given + Pageable pageable = PageRequest.of(0, 12); + //when + Page page = lovecardService.getLovecardPage(pageable); + + //then + assertThat(page.getContent()).isNotNull(); + + CustomPage customPage = new CustomPage(page); + System.out.println("customPage = " + customPage); + } + + + @Test + @DisplayName("특정 가족과 주고 받은 애정카드 정상 조회 테스트") + void getLovecardByFamilyLogPage() throws JsonProcessingException { + //given + User receiver = userRepository.save(User.builder() + .username("user1") + .realname("서현") + .nickname("동생") + .build()); + + User sender = userRepository.save(User.builder() + .username("user2") + .realname("서경") + .nickname("언니") + .build()); + + Lovecard lovecard = lovecardRepository.findById(1L).get(); + + Pageable pageable = PageRequest.of(0, 12); + + lovecardLogRepository.save(LovecardLog.builder().lovecard(lovecard).receiver(receiver).sender(sender).build()); + + //then + Page lovecardLogResponses = lovecardService.getLovecardByFamilyLogPage(receiver.getUsername(), sender.getUsername(), pageable); + + System.out.println("lovecardLogResponses = " + lovecardLogResponses); + + // Create ObjectMapper instance + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new JavaTimeModule()); // Register JavaTimeModule + objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); // Disable writing dates as timestamps + objectMapper.enable(SerializationFeature.INDENT_OUTPUT); // For pretty-printing + + // Convert to JSON string + String json = objectMapper.writeValueAsString(lovecardLogResponses); + + // Print JSON string + System.out.println("lovecardLogResponses (JSON) = " + json); + } + + @Test + @Transactional + @DisplayName("원하는 가족에게 애정카드 보내주는 기능 정상 작동") + void sendLoveCardToFamily() { + //given + User user1 = userRepository.save(User.builder() + .username("user1") + .realname("서현") + .nickname("동생") + .build()); + + User user2 = userRepository.save(User.builder() + .username("user2") + .realname("서경") + .nickname("언니") + .build()); + + + //when + lovecardService.sendLoveCardToFamily(user1.getUsername(), user2.getUsername(), new LovecardRequest(1L)); + + //then + assertThat(lovecardLogRepository.findById(1L).get().getSender().getUsername()).isEqualTo("user1"); + + + } +} \ No newline at end of file From 4b9505acbcfe94aa3235f208b2ae84ad53bc1b79 Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 19:52:57 +0900 Subject: [PATCH 08/15] =?UTF-8?q?fix:=20loadAlarm=20=ED=8A=B8=EB=9E=9C?= =?UTF-8?q?=EC=A0=9D=EC=85=98=20readOnly=20=EC=98=B5=EC=85=98=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/pinu/familing/domain/alarm/service/AlarmService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java b/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java index 8d65724..c32b1c1 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java @@ -54,7 +54,7 @@ else if (alarmType == AlarmType.SNAPSHOT_SUBJECT) { .build()); } - @Transactional(readOnly = true) + @Transactional public AlarmResponseDto loadAlarm(String username){ User user = userRepository.findByUsername(username) .orElseThrow(() -> new CustomException(USER_NOT_FOUND)); From 4fbce8328add3a191e2ffc14988fc7c2375f2859 Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 20:18:31 +0900 Subject: [PATCH 09/15] =?UTF-8?q?fix:=20=EC=95=8C=EB=A6=BC=20dto=20snake?= =?UTF-8?q?=EB=A1=9C=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/pinu/familing/domain/alarm/dto/AlarmDto.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmDto.java b/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmDto.java index cdb5e03..2fbdd40 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmDto.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmDto.java @@ -1,8 +1,11 @@ package com.pinu.familing.domain.alarm.dto; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; import com.pinu.familing.domain.alarm.AlarmType; import com.pinu.familing.domain.alarm.entity.Alarm; +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public record AlarmDto( Long id, Boolean isRead, From dae179a262841b78ffd7ae4937d14213694bf871 Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 20:20:33 +0900 Subject: [PATCH 10/15] =?UTF-8?q?fix:=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=EC=97=90=EC=84=9C=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20principalDetails=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/alarm/controller/AlarmController.java | 7 ++++--- .../familing/domain/chat/controller/ChatController.java | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java b/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java index 6db4e3a..a59cee8 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/controller/AlarmController.java @@ -3,6 +3,7 @@ import com.pinu.familing.domain.alarm.service.AlarmService; import com.pinu.familing.global.oauth.dto.CustomOAuth2User; +import com.pinu.familing.global.oauth.dto.PrincipalDetails; import com.pinu.familing.global.util.ApiUtils; import lombok.RequiredArgsConstructor; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -18,10 +19,10 @@ public class AlarmController { private final AlarmService alarmService; //나의 알람을 불러온다. - @GetMapping("alarm") - public ApiUtils.ApiResult getAlarm(@AuthenticationPrincipal CustomOAuth2User customOAuth2User) { + @GetMapping("alarms") + public ApiUtils.ApiResult getAlarm(@AuthenticationPrincipal PrincipalDetails principalDetails) { - return ApiUtils.success(alarmService.loadAlarm(customOAuth2User.getName())); + return ApiUtils.success(alarmService.loadAlarm(principalDetails.getUsername())); } } diff --git a/familing/src/main/java/com/pinu/familing/domain/chat/controller/ChatController.java b/familing/src/main/java/com/pinu/familing/domain/chat/controller/ChatController.java index e170f87..93d0cfd 100644 --- a/familing/src/main/java/com/pinu/familing/domain/chat/controller/ChatController.java +++ b/familing/src/main/java/com/pinu/familing/domain/chat/controller/ChatController.java @@ -4,6 +4,7 @@ import com.pinu.familing.domain.chat.entity.Message; import com.pinu.familing.domain.chat.service.ChatService; import com.pinu.familing.global.oauth.dto.CustomOAuth2User; +import com.pinu.familing.global.oauth.dto.PrincipalDetails; import com.pinu.familing.global.util.ApiUtils; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -27,15 +28,15 @@ public class ChatController { // 자기 단톡방 채팅내역 조회 @GetMapping("/chatroom/message") - public ResponseEntity chattingList(@AuthenticationPrincipal CustomOAuth2User principal) { - ChattingHistoryResponseDto chattingList = chatService.getChattingList(principal.getName()); + public ResponseEntity chattingList(@AuthenticationPrincipal PrincipalDetails principalDetails) { + ChattingHistoryResponseDto chattingList = chatService.getChattingList(principalDetails.getUsername()); return ResponseEntity.ok(chattingList); } // 자신의 채팅방 정보 조회 @GetMapping("/chatroom/user") - public ApiUtils.ApiResult chatRoomInfo(@AuthenticationPrincipal CustomOAuth2User principal) { - return ApiUtils.success(chatService.getChatRoomInfo(principal.getName())); + public ApiUtils.ApiResult chatRoomInfo(@AuthenticationPrincipal PrincipalDetails principalDetails) { + return ApiUtils.success(chatService.getChatRoomInfo(principalDetails.getUsername())); } // ws.send("/pub/message", {}, JSON.stringify("메시지"); 로들어오는 요청을 처리한다. From 4b03a3ce65b1551d3ae53dfe258e3b49ddf7ee3a Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 22:53:57 +0900 Subject: [PATCH 11/15] =?UTF-8?q?fix:=20=EC=95=8C=EB=A6=BC=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20,=EC=9D=BD=EC=9D=8C,=20=EC=95=88=EC=9D=BD=EC=9D=8C,?= =?UTF-8?q?=201=EC=9D=BC=EC=A0=84,=207=EC=9D=BC=EC=A0=84=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EA=B5=AC=EB=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/alarm/dto/AlarmResponseDto.java | 4 +++- .../alarm/repository/AlarmRepository.java | 11 +++++++++++ .../domain/alarm/service/AlarmService.java | 19 +++++++++++++++++++ .../alarm/service/AlarmServiceTest.java | 1 + 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmResponseDto.java b/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmResponseDto.java index 21d7b96..cc54937 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmResponseDto.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/dto/AlarmResponseDto.java @@ -7,6 +7,8 @@ @Builder public record AlarmResponseDto( List read, - List unread + List unread, + List yesterday, + List sevenday ) { } \ No newline at end of file diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java b/familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java index ecd59f6..daada34 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/repository/AlarmRepository.java @@ -3,7 +3,10 @@ import com.pinu.familing.domain.alarm.entity.Alarm; import com.pinu.familing.domain.user.entity.User; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import java.time.LocalDateTime; import java.util.List; public interface AlarmRepository extends JpaRepository { @@ -11,4 +14,12 @@ public interface AlarmRepository extends JpaRepository { List findByReceiverAndIsReadFalse(User receiver); List findByReceiverAndIsReadTrue(User receiver); + // isRead가 true이고, 24시간 이내에 생성된 알람을 조회 + @Query("SELECT a FROM Alarm a WHERE a.receiver = :receiver AND a.isRead = true AND a.createDateTime >= :since") + List findReadAlarmsWithin24Hours(@Param("receiver") User receiver, @Param("since") LocalDateTime since); + + // isRead가 true이고, 24시간 이상 7일 이내에 생성된 알람을 조회 + @Query("SELECT a FROM Alarm a WHERE a.receiver = :receiver AND a.isRead = true AND a.createDateTime < :until AND a.createDateTime >= :since") + List findReadAlarmsBetween24HoursAnd7Days(@Param("receiver") User receiver, @Param("since") LocalDateTime since, @Param("until") LocalDateTime until); + } diff --git a/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java b/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java index c32b1c1..e702fe9 100644 --- a/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java +++ b/familing/src/main/java/com/pinu/familing/domain/alarm/service/AlarmService.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; import java.util.List; import java.util.stream.Collectors; @@ -60,6 +61,18 @@ public AlarmResponseDto loadAlarm(String username){ .orElseThrow(() -> new CustomException(USER_NOT_FOUND)); List byReceiverAndIsReadFalse = alarmRepository.findByReceiverAndIsReadFalse(user); List byReceiverAndIsReadTrue = alarmRepository.findByReceiverAndIsReadTrue(user); + // 현재 시간 + LocalDateTime now = LocalDateTime.now(); + + // 24시간 전의 시간 계산 + LocalDateTime oneDayAgo = now.minusHours(24); + // 7일 전 시간 계산 + LocalDateTime sevenDaysAgo = now.minusDays(7); + + List alarmsWithin24Hours = alarmRepository.findReadAlarmsWithin24Hours(user, oneDayAgo); + + // 메서드 호출하여 24시간 이상 7일 이내의 알람 조회 + List alarmsBetween24HoursAnd7Days = alarmRepository.findReadAlarmsBetween24HoursAnd7Days(user, sevenDaysAgo, oneDayAgo); AlarmResponseDto alarmResponseDto = AlarmResponseDto.builder() .read(byReceiverAndIsReadTrue.stream() @@ -68,6 +81,12 @@ public AlarmResponseDto loadAlarm(String username){ .unread(byReceiverAndIsReadFalse.stream() .map(AlarmDto::fromEntity) .collect(Collectors.toList())) + .yesterday(alarmsWithin24Hours.stream() + .map(AlarmDto::fromEntity) + .collect(Collectors.toList())) + .sevenday(alarmsBetween24HoursAnd7Days.stream() + .map(AlarmDto::fromEntity) + .collect(Collectors.toList())) .build(); // 조회한 알림 읽음으로 처리 byReceiverAndIsReadFalse.forEach(alarm -> { diff --git a/familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java b/familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java index 273eb5e..f94277c 100644 --- a/familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java +++ b/familing/src/test/java/com/pinu/familing/domain/alarm/service/AlarmServiceTest.java @@ -19,6 +19,7 @@ import jakarta.transaction.Transactional; +import java.time.LocalDateTime; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; From 7bb43a59dbb6bc595eea0fb7897954967874d62b Mon Sep 17 00:00:00 2001 From: JinSeoHyun <15roa1121@gmail.com> Date: Wed, 28 Aug 2024 21:02:26 +0900 Subject: [PATCH 12/15] =?UTF-8?q?fix=20:=20=EC=BF=A0=ED=82=A4=EC=97=90=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pinu/familing/global/oauth/controller/KakaoController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/familing/src/main/java/com/pinu/familing/global/oauth/controller/KakaoController.java b/familing/src/main/java/com/pinu/familing/global/oauth/controller/KakaoController.java index b06e02d..a590c4e 100644 --- a/familing/src/main/java/com/pinu/familing/global/oauth/controller/KakaoController.java +++ b/familing/src/main/java/com/pinu/familing/global/oauth/controller/KakaoController.java @@ -48,6 +48,8 @@ private Cookie createCookie(String key, String value) { // js가 쿠키를 가져가지 못하게 cookie.setHttpOnly(true); + cookie.setDomain("3.39.254.198"); + return cookie; } } From e92f3057e42f5158d899aaff295ae72e2c667003 Mon Sep 17 00:00:00 2001 From: jinseohyun1228 <121755257+jinseohyun1228@users.noreply.github.com> Date: Wed, 28 Aug 2024 21:13:41 +0900 Subject: [PATCH 13/15] Update deploy.sh --- scripts/deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index ed8ec61..75ec06a 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -23,5 +23,5 @@ else sleep 5 fi -echo "> DEPLOY_JAR 배포" >> /home/ubuntu/action/deploy.log +echo "> DEPLOY_JAR 배포" >> home/ubuntu/action/deploy.log sudo nohup java -jar $DEPLOY_PATH$JAR_NAME >> /home/ubuntu/deploy.log 2>/home/ubuntu/action/deploy_err.log & From 45aaea904f30536e7d1ace9a0b198cb018d935dd Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 22:57:06 +0900 Subject: [PATCH 14/15] =?UTF-8?q?fix:=20=EB=8F=84=EB=A9=94=EC=9D=B8=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EB=B6=80=EB=B6=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pinu/familing/global/oauth/controller/KakaoController.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/familing/src/main/java/com/pinu/familing/global/oauth/controller/KakaoController.java b/familing/src/main/java/com/pinu/familing/global/oauth/controller/KakaoController.java index a590c4e..b06e02d 100644 --- a/familing/src/main/java/com/pinu/familing/global/oauth/controller/KakaoController.java +++ b/familing/src/main/java/com/pinu/familing/global/oauth/controller/KakaoController.java @@ -48,8 +48,6 @@ private Cookie createCookie(String key, String value) { // js가 쿠키를 가져가지 못하게 cookie.setHttpOnly(true); - cookie.setDomain("3.39.254.198"); - return cookie; } } From 1d9a8d6b29234f946fa93f2b0fd75b07d3b715b5 Mon Sep 17 00:00:00 2001 From: JunHyeong-99 <64734115+JunHyeong-99@users.noreply.github.com> Date: Wed, 28 Aug 2024 22:57:28 +0900 Subject: [PATCH 15/15] =?UTF-8?q?chore:=20=EB=B0=B0=ED=8F=AC=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=BD=ED=8A=B8=20deploy.sh=EC=9C=84=EC=B9=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appspec.yml | 2 +- scripts/deploy.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appspec.yml b/appspec.yml index 51d2c5b..dd41e28 100644 --- a/appspec.yml +++ b/appspec.yml @@ -13,6 +13,6 @@ permissions: hooks: ApplicationStart: - - location: /home/ubuntu/action/scripts/deploy.sh #최상위 디렉토리의 script 폴더 내의 shell script가 실행된다. + - location: scripts/deploy.sh #최상위 디렉토리의 script 폴더 내의 shell script가 실행된다. timeout: 60 runas: ubuntu diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 75ec06a..ed8ec61 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -23,5 +23,5 @@ else sleep 5 fi -echo "> DEPLOY_JAR 배포" >> home/ubuntu/action/deploy.log +echo "> DEPLOY_JAR 배포" >> /home/ubuntu/action/deploy.log sudo nohup java -jar $DEPLOY_PATH$JAR_NAME >> /home/ubuntu/deploy.log 2>/home/ubuntu/action/deploy_err.log &