From f0fb02bdcb9c25edc3fbe467b373c8a3cee75e2c Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 00:26:31 +0900 Subject: [PATCH 01/19] =?UTF-8?q?feat=20:=20=EC=95=8C=EB=A6=BC=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=EC=9D=84=20=EC=9C=84=ED=95=9C=20SSE=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/NotificationController.java | 17 +++++++++++++++++ .../notification/entity/Notification.java | 4 ++++ .../domain/notification/service/SSEService.java | 9 +++++++++ .../src/main/resources/application.properties | 8 +++++--- 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java create mode 100644 server2/server-common/src/main/java/sinhan/server1/domain/notification/entity/Notification.java create mode 100644 server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java b/server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java new file mode 100644 index 0000000..b33c4a4 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java @@ -0,0 +1,17 @@ +package sinhan.server1.domain.notification.controller; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import sinhan.server1.domain.notification.service.SSEService; + +@RestController +@Slf4j +@RequiredArgsConstructor +public class NotificationController { + + private final SSEService sseService; + + +} diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/notification/entity/Notification.java b/server2/server-common/src/main/java/sinhan/server1/domain/notification/entity/Notification.java new file mode 100644 index 0000000..2b36a89 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server1/domain/notification/entity/Notification.java @@ -0,0 +1,4 @@ +package sinhan.server1.domain.notification.entity; + +public class Notification { +} diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java b/server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java new file mode 100644 index 0000000..afe2f83 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java @@ -0,0 +1,9 @@ +package sinhan.server1.domain.notification.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class SSEService { +} diff --git a/server2/server-parent/src/main/resources/application.properties b/server2/server-parent/src/main/resources/application.properties index 3be7be8..4eb1acb 100644 --- a/server2/server-parent/src/main/resources/application.properties +++ b/server2/server-parent/src/main/resources/application.properties @@ -5,10 +5,12 @@ spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 spring.rabbitmq.username=guest spring.rabbitmq.password=guest -spring.datasource.diver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.url=jdbc:mysql://localhost:3306/testdb + +spring.datasource.url=jdbc:mysql://localhost:3306/parents_isol spring.datasource.username=root -spring.datasource.password=TestdbRoot +spring.datasource.password=Rlaalfo430, +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver + server.port=8081 From 2a6f71d3ad140c1309f1a9b378d8813f84b60a07 Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 10:59:17 +0900 Subject: [PATCH 02/19] =?UTF-8?q?feat(WIP)=20:=20=EC=95=8C=EB=A6=BC=20SSE?= =?UTF-8?q?=20=EC=B4=88=EA=B8=B0=EC=84=B8=ED=8C=85=20=EB=B0=8F=20api=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../invest/controller/DartController.java | 2 +- .../invest/controller/InvestController.java | 2 +- .../invest/controller/ProposalController.java | 2 +- .../invest/controller/StockController.java | 2 +- .../controller/NotificationController.java | 18 +++++- .../notification/entity/Notification.java | 35 ++++++++++++ .../notification/service/SSEService.java | 57 +++++++++++++++++++ .../server1/domain/tempuser/TempUser.java | 29 ++++++++++ .../domain/tempuser/TempUserRepository.java | 8 +++ .../global/exception/CustomException.java | 12 ++++ .../exception/CustomExceptionHandler.java | 31 ++++++++++ .../server1/global/exception/ErrorCode.java | 23 ++++++++ .../global/exception/ErrorResponse.java | 54 ++++++++++++++++++ .../{domain => global}/utils/ApiResult.java | 2 +- 14 files changed, 271 insertions(+), 6 deletions(-) create mode 100644 server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUser.java create mode 100644 server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUserRepository.java create mode 100644 server2/server-common/src/main/java/sinhan/server1/global/exception/CustomException.java create mode 100644 server2/server-common/src/main/java/sinhan/server1/global/exception/CustomExceptionHandler.java create mode 100644 server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorCode.java create mode 100644 server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorResponse.java rename server2/server-common/src/main/java/sinhan/server1/{domain => global}/utils/ApiResult.java (96%) diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/DartController.java b/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/DartController.java index 9413e17..7ef30d6 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/DartController.java +++ b/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/DartController.java @@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RestController; import sinhan.server1.domain.invest.dto.StockFindDetailResponseDTO; import sinhan.server1.domain.invest.service.StockService; -import sinhan.server1.domain.utils.ApiResult; +import sinhan.server1.global.utils.ApiResult; @RestController public class DartController { diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/InvestController.java b/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/InvestController.java index 39065af..dca92d8 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/InvestController.java +++ b/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/InvestController.java @@ -3,7 +3,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; -import sinhan.server1.domain.utils.ApiResult; +import sinhan.server1.global.utils.ApiResult; public class InvestController { //투자 거래 내역 조회하기(부모) diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/ProposalController.java b/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/ProposalController.java index d104a71..6000deb 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/ProposalController.java +++ b/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/ProposalController.java @@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import sinhan.server1.domain.utils.ApiResult; +import sinhan.server1.global.utils.ApiResult; @RestController @Slf4j diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/StockController.java b/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/StockController.java index 77fed22..4fdba0c 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/StockController.java +++ b/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/StockController.java @@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import sinhan.server1.domain.invest.service.StockService; -import sinhan.server1.domain.utils.ApiResult; +import sinhan.server1.global.utils.ApiResult; @RestController public class StockController { diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java b/server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java index b33c4a4..afeaf2f 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java +++ b/server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java @@ -2,16 +2,32 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import sinhan.server1.domain.notification.service.SSEService; +import sinhan.server1.domain.tempuser.TempUser; @RestController @Slf4j @RequiredArgsConstructor +@RequestMapping("/notifications") public class NotificationController { private final SSEService sseService; - + //SSE 구독하기 -> 프론트에서 로그인할때 부름 + @GetMapping("/subscribe") + public SseEmitter subscribeSSE(TempUser tempUser){ + return sseService.subscribe(tempUser.getSerialNumber()); + } + + //해당 사용자의 모든 알림 가져오기 + + //개별 알림 삭제하기 + + //알림 전체 삭제하기 + + } diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/notification/entity/Notification.java b/server2/server-common/src/main/java/sinhan/server1/domain/notification/entity/Notification.java index 2b36a89..95d70cd 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/notification/entity/Notification.java +++ b/server2/server-common/src/main/java/sinhan/server1/domain/notification/entity/Notification.java @@ -1,4 +1,39 @@ package sinhan.server1.domain.notification.entity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import sinhan.server1.domain.tempuser.TempUser; + +import java.time.LocalDateTime; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class Notification { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + int id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_serial_number", referencedColumnName = "serialNumber") + TempUser receiver; + + String sender; // 별명 + int messageCode; // 메세지 코드 + int functionCode; // 기능 + + LocalDateTime createDate; + + @Builder + public Notification(int messageCode, int functionCode, TempUser receiver, String sender, LocalDateTime createDate) { + this.messageCode = messageCode; + this.functionCode = functionCode; + this.receiver = receiver; + this.sender = sender; + this.createDate = createDate; + } } diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java b/server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java index afe2f83..765e00f 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java +++ b/server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java @@ -1,9 +1,66 @@ package sinhan.server1.domain.notification.service; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; +import sinhan.server1.domain.notification.entity.Notification; +import sinhan.server1.domain.tempuser.TempUser; +import sinhan.server1.domain.tempuser.TempUserRepository; +import sinhan.server1.global.exception.CustomException; +import sinhan.server1.global.exception.ErrorCode; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; @Service @RequiredArgsConstructor +@Slf4j +@Transactional public class SSEService { + private final Map sseEmitters = new ConcurrentHashMap<>(); + private final TempUserRepository tempUserRepository; + public SseEmitter subscribe(Long serialNumber) { + SseEmitter emitter = new SseEmitter(7200000L);// 2시간 타임아웃 + sseEmitters.put(serialNumber, emitter); + + emitter.onCompletion(()-> sseEmitters.remove(serialNumber)); + emitter.onTimeout(()->{ + sseEmitters.remove(serialNumber); + log.info("SSE 타임아웃" + serialNumber); + }); + + return emitter; + } + + public void sendNotification(Long serialNumber, String senderName, Integer functionCode, Integer messageCode){ + SseEmitter emitter = sseEmitters.get(serialNumber); + TempUser receiver = tempUserRepository.findBySerialNumber(serialNumber); +₩ + Notification notification = Notification.builder() + .receiver(receiver) + .sender(senderName) + .functionCode(functionCode) + .messageCode(messageCode) + .createDate(LocalDateTime.now()) + .build(); + + //notification 몽고 디비에 저장 + + try{ + emitter.send(SseEmitter.event().name("notification").data(notification)); + } catch (IOException e) { + + //몽고 디비에서 저장된거 삭제하기 + + + throw new CustomException(ErrorCode.FAILED_NOTIFICATION); + } + } + + } + } diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUser.java b/server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUser.java new file mode 100644 index 0000000..7b8bee3 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUser.java @@ -0,0 +1,29 @@ +package sinhan.server1.domain.tempuser; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class TempUser { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + int id; + + Long serialNumber; + + String name; + + @Builder + public TempUser( Long serialNumber, String name) { + this.serialNumber = serialNumber; + this.name = name; + } +} diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUserRepository.java b/server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUserRepository.java new file mode 100644 index 0000000..e6112dd --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUserRepository.java @@ -0,0 +1,8 @@ +package sinhan.server1.domain.tempuser; + +import org.springframework.data.jpa.repository.JpaRepository; +import sinhan.server1.domain.notification.entity.Notification; + +public interface TempUserRepository extends JpaRepository { + TempUser findBySerialNumber(Long serialNumber); +} diff --git a/server2/server-common/src/main/java/sinhan/server1/global/exception/CustomException.java b/server2/server-common/src/main/java/sinhan/server1/global/exception/CustomException.java new file mode 100644 index 0000000..a9c87a2 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server1/global/exception/CustomException.java @@ -0,0 +1,12 @@ +package sinhan.server1.global.exception; + +import lombok.Getter; + +@Getter +public class CustomException extends RuntimeException { + private final ErrorCode errorCode; + public CustomException(ErrorCode errorCode) { + super(errorCode.getMessage()); + this.errorCode = errorCode; + } +} diff --git a/server2/server-common/src/main/java/sinhan/server1/global/exception/CustomExceptionHandler.java b/server2/server-common/src/main/java/sinhan/server1/global/exception/CustomExceptionHandler.java new file mode 100644 index 0000000..fd75925 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server1/global/exception/CustomExceptionHandler.java @@ -0,0 +1,31 @@ +package sinhan.server1.global.exception; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.FieldError; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@Slf4j +@RestControllerAdvice +public class CustomExceptionHandler { + + @ExceptionHandler + protected ResponseEntity handleCustomException(CustomException e) { + return ErrorResponse.toResponseEntity(e); + } + + // bean validation 관련 에러 + @ExceptionHandler(MethodArgumentNotValidException.class) + protected ResponseEntity handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { + + FieldError fieldError = e.getFieldError(); + + log.info(fieldError.toString()); + return ErrorResponse.toResponseEntity(HttpStatus.BAD_REQUEST, fieldError); + } + + +} diff --git a/server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorCode.java b/server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorCode.java new file mode 100644 index 0000000..cb0a30c --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorCode.java @@ -0,0 +1,23 @@ +package sinhan.server1.global.exception; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@Getter +@AllArgsConstructor +public enum ErrorCode { + + //유저 예외 + NOT_FOUND_USER(HttpStatus.NOT_FOUND, "해당 유저를 찾을 수 없습니다."), + + //용돈 예외 + NOT_FOUND_TEMPORAL_ALLOWANCE(HttpStatus.NOT_FOUND, "해당되는 용돈 조르기가 없습니다."), + + //알람 예외 + FAILED_NOTIFICATION(HttpStatus.CONFLICT, "알람 보내기에 실패했습니다."); + + + private final HttpStatus status; + private final String message; +} diff --git a/server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorResponse.java b/server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorResponse.java new file mode 100644 index 0000000..ecb7e59 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorResponse.java @@ -0,0 +1,54 @@ +package sinhan.server1.global.exception; + +import lombok.Builder; +import lombok.Getter; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.FieldError; + +@Getter +@Builder +public class ErrorResponse { + private final String status; + private final String error; + + //CustomException 인 경우 + public static ResponseEntity toResponseEntity(CustomException e){ + ErrorCode errorCode = e.getErrorCode(); + + return ResponseEntity + .status(errorCode.getStatus()) + .body( + ErrorResponse.builder() + .status(errorCode.getStatus().name()) + .error(errorCode.getMessage()) + .build() + ); + + } + + //FieldError인 경우 + public static ResponseEntity toResponseEntity(HttpStatus status, FieldError fieldError){ + return ResponseEntity + .status(status) + .body( + ErrorResponse.builder() + .status(status.name()) + .error(fieldError.getDefaultMessage()) + .build() + ); + } + + //예외메세지 필요 없는 경우 + public static ResponseEntity toResponseEntity(HttpStatus status) { + return ResponseEntity + .status(status) + .body( + ErrorResponse.builder() + .status(status.name()) + .build() + ); + } + + +} diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/utils/ApiResult.java b/server2/server-common/src/main/java/sinhan/server1/global/utils/ApiResult.java similarity index 96% rename from server2/server-common/src/main/java/sinhan/server1/domain/utils/ApiResult.java rename to server2/server-common/src/main/java/sinhan/server1/global/utils/ApiResult.java index 06215d9..cd29d82 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/utils/ApiResult.java +++ b/server2/server-common/src/main/java/sinhan/server1/global/utils/ApiResult.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.utils; +package sinhan.server1.global.utils; import lombok.Getter; import org.springframework.http.HttpStatus; From 3e019edc19cd7e8049c303f7cf8b88dd7cc79a9a Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 13:37:49 +0900 Subject: [PATCH 03/19] =?UTF-8?q?feat=20:=20mongoDB=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=9C=20dependency=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server2/build.gradle | 3 +++ server2/server-common/build.gradle | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/server2/build.gradle b/server2/build.gradle index 0b5bb59..980b9b5 100644 --- a/server2/build.gradle +++ b/server2/build.gradle @@ -37,6 +37,9 @@ subprojects { // 각 모듈에 적용할 공통 설정 testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.amqp:spring-rabbit-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' + + } tasks.named('bootJar') { //빌드할 때 bootjar 파일로 하겠다는 의미 diff --git a/server2/server-common/build.gradle b/server2/server-common/build.gradle index 94bd55c..3034f4d 100644 --- a/server2/server-common/build.gradle +++ b/server2/server-common/build.gradle @@ -26,6 +26,10 @@ subprojects { // 각 모듈에 적용할 공통 설정 apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' + dependencies { + implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' + } + tasks.named('bootJar') { //빌드할 때 bootjar 파일로 하겠다는 의미 enabled = false } From 3fc27a5b61631c0a0940a4127ead1d0eac30bb8d Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 19:16:11 +0900 Subject: [PATCH 04/19] =?UTF-8?q?Feat=20:=20mongoDB=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server2/server-common/build.gradle | 6 +++--- .../server-parent/src/main/resources/application.properties | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server2/server-common/build.gradle b/server2/server-common/build.gradle index 3034f4d..a8234ac 100644 --- a/server2/server-common/build.gradle +++ b/server2/server-common/build.gradle @@ -26,9 +26,9 @@ subprojects { // 각 모듈에 적용할 공통 설정 apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' - dependencies { - implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' - } +// dependencies { +// implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' +// } tasks.named('bootJar') { //빌드할 때 bootjar 파일로 하겠다는 의미 enabled = false diff --git a/server2/server-parent/src/main/resources/application.properties b/server2/server-parent/src/main/resources/application.properties index 4eb1acb..96a726f 100644 --- a/server2/server-parent/src/main/resources/application.properties +++ b/server2/server-parent/src/main/resources/application.properties @@ -6,11 +6,12 @@ spring.rabbitmq.port=5672 spring.rabbitmq.username=guest spring.rabbitmq.password=guest -spring.datasource.url=jdbc:mysql://localhost:3306/parents_isol +spring.datasource.url=jdbc:mysql://localhost:3306/isol spring.datasource.username=root spring.datasource.password=Rlaalfo430, spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.data.mongodb.uri=mongodb+srv://mirae4292:rlaalfo430@cluster0.swp3udx.mongodb.net/isol?retryWrites=true&w=majority&appName=Cluster0 server.port=8081 From 756dc126b3d3dcd3ef5b06f9cf8e63788d63fb6d Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 19:18:02 +0900 Subject: [PATCH 05/19] =?UTF-8?q?refactor=20:=20mongoDB=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=ED=95=B4=EA=B2=B0=EC=9D=84=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=ED=8C=A8=ED=82=A4=EC=A7=80=20=EC=9D=B4=EB=8F=99(=EC=9E=84?= =?UTF-8?q?=EC=8B=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server2/build.gradle | 2 - .../sinhan/server1/Server2Application.java | 18 ---- .../server1/domain/AccountController.java | 13 --- .../controller/NotificationController.java | 33 ------- .../notification/service/SSEService.java | 66 ------------- .../Server3Application.java | 5 +- .../invest/controller/DartController.java | 8 +- .../invest/controller/InvestController.java | 4 +- .../invest/controller/ProposalController.java | 6 +- .../invest/controller/StockController.java | 6 +- .../dto/StockFindDetailResponseDTO.java | 4 +- .../domain/invest/entity/StockCartDate.java | 2 +- .../invest/entity/StockCurrentDetail.java | 2 +- .../entity/StockCurrentPriceOutput.java | 2 +- .../invest/entity/StockDivideDetail.java | 2 +- .../invest/entity/StockDivideOutput.java | 2 +- .../entity/StockDuraionPriceOutput.java | 2 +- .../invest/entity/StockDurationDetail.java | 2 +- .../invest/entity/StockFianceDetail.java | 2 +- .../entity/StockFianceResponseOutput.java | 2 +- .../invest/repository/StockRepository.java | 2 +- .../domain/invest/service/StockService.java | 12 +-- .../domain/tempuser/TempUser.java | 8 +- .../domain/tempuser/TempUserRepository.java | 3 +- .../global/config/WebClientCongif.java | 2 +- .../global/exception/CustomException.java | 2 +- .../exception/CustomExceptionHandler.java | 2 +- .../global/exception/ErrorCode.java | 2 +- .../global/exception/ErrorResponse.java | 2 +- .../global/utils/ApiResult.java | 2 +- .../controller/NotificationController.java | 54 ++++++++++ .../notification/entity/Notification.java | 18 ++-- .../mongo/newNotificationRepository.java | 10 ++ .../notification/service/SSEService.java | 99 +++++++++++++++++++ 34 files changed, 215 insertions(+), 186 deletions(-) delete mode 100644 server2/server-child/src/main/java/sinhan/server1/Server2Application.java delete mode 100644 server2/server-child/src/main/java/sinhan/server1/domain/AccountController.java delete mode 100644 server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java delete mode 100644 server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java rename server2/server-common/src/main/java/sinhan/{server1 => server2}/Server3Application.java (78%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/controller/DartController.java (79%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/controller/InvestController.java (91%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/controller/ProposalController.java (94%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/controller/StockController.java (91%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/dto/StockFindDetailResponseDTO.java (86%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/entity/StockCartDate.java (90%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/entity/StockCurrentDetail.java (87%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/entity/StockCurrentPriceOutput.java (90%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/entity/StockDivideDetail.java (90%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/entity/StockDivideOutput.java (88%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/entity/StockDuraionPriceOutput.java (83%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/entity/StockDurationDetail.java (94%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/entity/StockFianceDetail.java (88%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/entity/StockFianceResponseOutput.java (85%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/repository/StockRepository.java (65%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/invest/service/StockService.java (95%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/tempuser/TempUser.java (70%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/domain/tempuser/TempUserRepository.java (65%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/global/config/WebClientCongif.java (98%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/global/exception/CustomException.java (86%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/global/exception/CustomExceptionHandler.java (96%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/global/exception/ErrorCode.java (93%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/global/exception/ErrorResponse.java (97%) rename server2/server-common/src/main/java/sinhan/{server1 => server2}/global/utils/ApiResult.java (96%) create mode 100644 server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java rename server2/server-common/src/main/java/sinhan/{server1/domain => server2}/notification/entity/Notification.java (54%) create mode 100644 server2/server-common/src/main/java/sinhan/server2/notification/mongo/newNotificationRepository.java create mode 100644 server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java diff --git a/server2/build.gradle b/server2/build.gradle index 980b9b5..ceb91b9 100644 --- a/server2/build.gradle +++ b/server2/build.gradle @@ -38,8 +38,6 @@ subprojects { // 각 모듈에 적용할 공통 설정 testImplementation 'org.springframework.amqp:spring-rabbit-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' - - } tasks.named('bootJar') { //빌드할 때 bootjar 파일로 하겠다는 의미 diff --git a/server2/server-child/src/main/java/sinhan/server1/Server2Application.java b/server2/server-child/src/main/java/sinhan/server1/Server2Application.java deleted file mode 100644 index cadabf7..0000000 --- a/server2/server-child/src/main/java/sinhan/server1/Server2Application.java +++ /dev/null @@ -1,18 +0,0 @@ -package sinhan.server1; - - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Server2Application { - - public static void main(String[] args) { - SpringApplication.run(Server3Application.class, args); - } - -// @RabbitListener(queues = "hello") -// public void listen(String message) { -// System.out.println("Received: " + message); -// } -} \ No newline at end of file diff --git a/server2/server-child/src/main/java/sinhan/server1/domain/AccountController.java b/server2/server-child/src/main/java/sinhan/server1/domain/AccountController.java deleted file mode 100644 index db0aa0d..0000000 --- a/server2/server-child/src/main/java/sinhan/server1/domain/AccountController.java +++ /dev/null @@ -1,13 +0,0 @@ -package sinhan.server1.domain; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class AccountController { - @GetMapping("/temp") - public String getStock(){ - return "addff"; - } - -} diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java b/server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java deleted file mode 100644 index afeaf2f..0000000 --- a/server2/server-common/src/main/java/sinhan/server1/domain/notification/controller/NotificationController.java +++ /dev/null @@ -1,33 +0,0 @@ -package sinhan.server1.domain.notification.controller; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; -import sinhan.server1.domain.notification.service.SSEService; -import sinhan.server1.domain.tempuser.TempUser; - -@RestController -@Slf4j -@RequiredArgsConstructor -@RequestMapping("/notifications") -public class NotificationController { - - private final SSEService sseService; - - //SSE 구독하기 -> 프론트에서 로그인할때 부름 - @GetMapping("/subscribe") - public SseEmitter subscribeSSE(TempUser tempUser){ - return sseService.subscribe(tempUser.getSerialNumber()); - } - - //해당 사용자의 모든 알림 가져오기 - - //개별 알림 삭제하기 - - //알림 전체 삭제하기 - - -} diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java b/server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java deleted file mode 100644 index 765e00f..0000000 --- a/server2/server-common/src/main/java/sinhan/server1/domain/notification/service/SSEService.java +++ /dev/null @@ -1,66 +0,0 @@ -package sinhan.server1.domain.notification.service; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; -import sinhan.server1.domain.notification.entity.Notification; -import sinhan.server1.domain.tempuser.TempUser; -import sinhan.server1.domain.tempuser.TempUserRepository; -import sinhan.server1.global.exception.CustomException; -import sinhan.server1.global.exception.ErrorCode; - -import java.io.IOException; -import java.time.LocalDateTime; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -@Service -@RequiredArgsConstructor -@Slf4j -@Transactional -public class SSEService { - private final Map sseEmitters = new ConcurrentHashMap<>(); - private final TempUserRepository tempUserRepository; - public SseEmitter subscribe(Long serialNumber) { - SseEmitter emitter = new SseEmitter(7200000L);// 2시간 타임아웃 - sseEmitters.put(serialNumber, emitter); - - emitter.onCompletion(()-> sseEmitters.remove(serialNumber)); - emitter.onTimeout(()->{ - sseEmitters.remove(serialNumber); - log.info("SSE 타임아웃" + serialNumber); - }); - - return emitter; - } - - public void sendNotification(Long serialNumber, String senderName, Integer functionCode, Integer messageCode){ - SseEmitter emitter = sseEmitters.get(serialNumber); - TempUser receiver = tempUserRepository.findBySerialNumber(serialNumber); -₩ - Notification notification = Notification.builder() - .receiver(receiver) - .sender(senderName) - .functionCode(functionCode) - .messageCode(messageCode) - .createDate(LocalDateTime.now()) - .build(); - - //notification 몽고 디비에 저장 - - try{ - emitter.send(SseEmitter.event().name("notification").data(notification)); - } catch (IOException e) { - - //몽고 디비에서 저장된거 삭제하기 - - - throw new CustomException(ErrorCode.FAILED_NOTIFICATION); - } - } - - } - -} diff --git a/server2/server-common/src/main/java/sinhan/server1/Server3Application.java b/server2/server-common/src/main/java/sinhan/server2/Server3Application.java similarity index 78% rename from server2/server-common/src/main/java/sinhan/server1/Server3Application.java rename to server2/server-common/src/main/java/sinhan/server2/Server3Application.java index dd9f47e..5534c20 100644 --- a/server2/server-common/src/main/java/sinhan/server1/Server3Application.java +++ b/server2/server-common/src/main/java/sinhan/server2/Server3Application.java @@ -1,10 +1,11 @@ -package sinhan.server1; +package sinhan.server2; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication(scanBasePackages = {"server-child", "server-parent"}) +// common +@SpringBootApplication//(scanBasePackages = {"server-child", "server-parent"}) public class Server3Application { public static void main(String[] args) { diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/DartController.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/DartController.java similarity index 79% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/DartController.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/DartController.java index 7ef30d6..0b564f3 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/DartController.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/DartController.java @@ -1,12 +1,12 @@ -package sinhan.server1.domain.invest.controller; +package sinhan.server2.domain.invest.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; -import sinhan.server1.domain.invest.dto.StockFindDetailResponseDTO; -import sinhan.server1.domain.invest.service.StockService; -import sinhan.server1.global.utils.ApiResult; +import sinhan.server2.domain.invest.dto.StockFindDetailResponseDTO; +import sinhan.server2.domain.invest.service.StockService; +import sinhan.server2.global.utils.ApiResult; @RestController public class DartController { diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/InvestController.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/InvestController.java similarity index 91% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/InvestController.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/InvestController.java index dca92d8..8e3c9aa 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/InvestController.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/InvestController.java @@ -1,9 +1,9 @@ -package sinhan.server1.domain.invest.controller; +package sinhan.server2.domain.invest.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; -import sinhan.server1.global.utils.ApiResult; +import sinhan.server2.global.utils.ApiResult; public class InvestController { //투자 거래 내역 조회하기(부모) diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/ProposalController.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/ProposalController.java similarity index 94% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/ProposalController.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/ProposalController.java index 6000deb..9aa7bfc 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/ProposalController.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/ProposalController.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.controller; +package sinhan.server2.domain.invest.controller; import lombok.extern.slf4j.Slf4j; @@ -7,14 +7,14 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import sinhan.server1.global.utils.ApiResult; +import sinhan.server2.global.utils.ApiResult; @RestController @Slf4j public class ProposalController { //투자 제안 내역 달변 조회하기(부모) @GetMapping("/proposal/invest/history/{co}") - public ApiResult getChildInvestProposal(@RequestParam("year") int year,@RequestParam("month") int month,@PathVariable("co") int childOrder){ + public ApiResult getChildInvestProposal(@RequestParam("year") int year, @RequestParam("month") int month, @PathVariable("co") int childOrder){ ApiResult stringApiResult = ApiResult.responseSuccess(childOrder); return stringApiResult; } diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/StockController.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/StockController.java similarity index 91% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/StockController.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/StockController.java index 4fdba0c..e50baa1 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/controller/StockController.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/StockController.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.controller; +package sinhan.server2.domain.invest.controller; import org.springframework.web.bind.annotation.DeleteMapping; @@ -7,8 +7,8 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import sinhan.server1.domain.invest.service.StockService; -import sinhan.server1.global.utils.ApiResult; +import sinhan.server2.domain.invest.service.StockService; +import sinhan.server2.global.utils.ApiResult; @RestController public class StockController { diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/dto/StockFindDetailResponseDTO.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/dto/StockFindDetailResponseDTO.java similarity index 86% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/dto/StockFindDetailResponseDTO.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/dto/StockFindDetailResponseDTO.java index f72dd0c..8b61a66 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/dto/StockFindDetailResponseDTO.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/dto/StockFindDetailResponseDTO.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.dto; +package sinhan.server2.domain.invest.dto; import java.util.List; import lombok.AllArgsConstructor; @@ -7,7 +7,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import sinhan.server1.domain.invest.entity.StockCartDate; +import sinhan.server2.domain.invest.entity.StockCartDate; @Getter @Setter diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockCartDate.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCartDate.java similarity index 90% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockCartDate.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCartDate.java index 455b964..b85d455 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockCartDate.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCartDate.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.entity; +package sinhan.server2.domain.invest.entity; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockCurrentDetail.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentDetail.java similarity index 87% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockCurrentDetail.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentDetail.java index 1744acc..48e12fa 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockCurrentDetail.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentDetail.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.entity; +package sinhan.server2.domain.invest.entity; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockCurrentPriceOutput.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentPriceOutput.java similarity index 90% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockCurrentPriceOutput.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentPriceOutput.java index d434744..ba50d52 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockCurrentPriceOutput.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentPriceOutput.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.entity; +package sinhan.server2.domain.invest.entity; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.PropertyNamingStrategy; diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDivideDetail.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideDetail.java similarity index 90% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDivideDetail.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideDetail.java index 496e291..b6acb56 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDivideDetail.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideDetail.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.entity; +package sinhan.server2.domain.invest.entity; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.PropertyNamingStrategy; diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDivideOutput.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideOutput.java similarity index 88% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDivideOutput.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideOutput.java index d7707d2..5d94230 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDivideOutput.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideOutput.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.entity; +package sinhan.server2.domain.invest.entity; import com.fasterxml.jackson.databind.PropertyNamingStrategy; diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDuraionPriceOutput.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDuraionPriceOutput.java similarity index 83% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDuraionPriceOutput.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDuraionPriceOutput.java index 98d0728..e92cab6 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDuraionPriceOutput.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDuraionPriceOutput.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.entity; +package sinhan.server2.domain.invest.entity; import java.util.List; import lombok.Data; diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDurationDetail.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDurationDetail.java similarity index 94% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDurationDetail.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDurationDetail.java index 724f5c0..7fdc0ee 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockDurationDetail.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDurationDetail.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.entity; +package sinhan.server2.domain.invest.entity; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.PropertyNamingStrategy; diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockFianceDetail.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceDetail.java similarity index 88% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockFianceDetail.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceDetail.java index 784b3b4..18807ba 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockFianceDetail.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceDetail.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.entity; +package sinhan.server2.domain.invest.entity; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonNaming; diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockFianceResponseOutput.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceResponseOutput.java similarity index 85% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockFianceResponseOutput.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceResponseOutput.java index f2ea6bb..7eb1be0 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/entity/StockFianceResponseOutput.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceResponseOutput.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.entity; +package sinhan.server2.domain.invest.entity; import com.fasterxml.jackson.databind.annotation.JsonNaming; import java.util.List; diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/repository/StockRepository.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/repository/StockRepository.java similarity index 65% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/repository/StockRepository.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/repository/StockRepository.java index 96ffa14..d3df9f8 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/repository/StockRepository.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/repository/StockRepository.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.repository; +package sinhan.server2.domain.invest.repository; import org.springframework.stereotype.Service; diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/invest/service/StockService.java b/server2/server-common/src/main/java/sinhan/server2/domain/invest/service/StockService.java similarity index 95% rename from server2/server-common/src/main/java/sinhan/server1/domain/invest/service/StockService.java rename to server2/server-common/src/main/java/sinhan/server2/domain/invest/service/StockService.java index 8f68477..2393385 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/invest/service/StockService.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/invest/service/StockService.java @@ -1,4 +1,4 @@ -package sinhan.server1.domain.invest.service; +package sinhan.server2.domain.invest.service; import java.net.URI; import java.text.SimpleDateFormat; @@ -8,11 +8,11 @@ import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.util.UriBuilder; import reactor.core.publisher.Mono; -import sinhan.server1.domain.invest.dto.StockFindDetailResponseDTO; -import sinhan.server1.domain.invest.entity.StockDivideOutput; -import sinhan.server1.domain.invest.entity.StockDuraionPriceOutput; -import sinhan.server1.domain.invest.entity.StockFianceResponseOutput; -import sinhan.server1.domain.invest.repository.StockRepository; +import sinhan.server2.domain.invest.dto.StockFindDetailResponseDTO; +import sinhan.server2.domain.invest.entity.StockDivideOutput; +import sinhan.server2.domain.invest.entity.StockDuraionPriceOutput; +import sinhan.server2.domain.invest.entity.StockFianceResponseOutput; +import sinhan.server2.domain.invest.repository.StockRepository; @Service public class StockService { diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUser.java b/server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUser.java similarity index 70% rename from server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUser.java rename to server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUser.java index 7b8bee3..421ede3 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUser.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUser.java @@ -1,9 +1,6 @@ -package sinhan.server1.domain.tempuser; +package sinhan.server2.domain.tempuser; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -17,6 +14,7 @@ public class TempUser { @GeneratedValue(strategy = GenerationType.IDENTITY) int id; + @Column(name = "serial_num", unique = true) Long serialNumber; String name; diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUserRepository.java b/server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUserRepository.java similarity index 65% rename from server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUserRepository.java rename to server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUserRepository.java index e6112dd..363b82e 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/tempuser/TempUserRepository.java +++ b/server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUserRepository.java @@ -1,7 +1,6 @@ -package sinhan.server1.domain.tempuser; +package sinhan.server2.domain.tempuser; import org.springframework.data.jpa.repository.JpaRepository; -import sinhan.server1.domain.notification.entity.Notification; public interface TempUserRepository extends JpaRepository { TempUser findBySerialNumber(Long serialNumber); diff --git a/server2/server-common/src/main/java/sinhan/server1/global/config/WebClientCongif.java b/server2/server-common/src/main/java/sinhan/server2/global/config/WebClientCongif.java similarity index 98% rename from server2/server-common/src/main/java/sinhan/server1/global/config/WebClientCongif.java rename to server2/server-common/src/main/java/sinhan/server2/global/config/WebClientCongif.java index 2fb2b70..09f9898 100644 --- a/server2/server-common/src/main/java/sinhan/server1/global/config/WebClientCongif.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/config/WebClientCongif.java @@ -1,4 +1,4 @@ -package sinhan.server1.global.config; +package sinhan.server2.global.config; import io.netty.channel.ChannelOption; import org.springframework.beans.factory.annotation.Value; diff --git a/server2/server-common/src/main/java/sinhan/server1/global/exception/CustomException.java b/server2/server-common/src/main/java/sinhan/server2/global/exception/CustomException.java similarity index 86% rename from server2/server-common/src/main/java/sinhan/server1/global/exception/CustomException.java rename to server2/server-common/src/main/java/sinhan/server2/global/exception/CustomException.java index a9c87a2..9629467 100644 --- a/server2/server-common/src/main/java/sinhan/server1/global/exception/CustomException.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/exception/CustomException.java @@ -1,4 +1,4 @@ -package sinhan.server1.global.exception; +package sinhan.server2.global.exception; import lombok.Getter; diff --git a/server2/server-common/src/main/java/sinhan/server1/global/exception/CustomExceptionHandler.java b/server2/server-common/src/main/java/sinhan/server2/global/exception/CustomExceptionHandler.java similarity index 96% rename from server2/server-common/src/main/java/sinhan/server1/global/exception/CustomExceptionHandler.java rename to server2/server-common/src/main/java/sinhan/server2/global/exception/CustomExceptionHandler.java index fd75925..8a540b3 100644 --- a/server2/server-common/src/main/java/sinhan/server1/global/exception/CustomExceptionHandler.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/exception/CustomExceptionHandler.java @@ -1,4 +1,4 @@ -package sinhan.server1.global.exception; +package sinhan.server2.global.exception; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; diff --git a/server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorCode.java b/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorCode.java similarity index 93% rename from server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorCode.java rename to server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorCode.java index cb0a30c..1fb37f1 100644 --- a/server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorCode.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorCode.java @@ -1,4 +1,4 @@ -package sinhan.server1.global.exception; +package sinhan.server2.global.exception; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorResponse.java b/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorResponse.java similarity index 97% rename from server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorResponse.java rename to server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorResponse.java index ecb7e59..c03af43 100644 --- a/server2/server-common/src/main/java/sinhan/server1/global/exception/ErrorResponse.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorResponse.java @@ -1,4 +1,4 @@ -package sinhan.server1.global.exception; +package sinhan.server2.global.exception; import lombok.Builder; import lombok.Getter; diff --git a/server2/server-common/src/main/java/sinhan/server1/global/utils/ApiResult.java b/server2/server-common/src/main/java/sinhan/server2/global/utils/ApiResult.java similarity index 96% rename from server2/server-common/src/main/java/sinhan/server1/global/utils/ApiResult.java rename to server2/server-common/src/main/java/sinhan/server2/global/utils/ApiResult.java index cd29d82..37817b8 100644 --- a/server2/server-common/src/main/java/sinhan/server1/global/utils/ApiResult.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/utils/ApiResult.java @@ -1,4 +1,4 @@ -package sinhan.server1.global.utils; +package sinhan.server2.global.utils; import lombok.Getter; import org.springframework.http.HttpStatus; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java b/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java new file mode 100644 index 0000000..503c587 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java @@ -0,0 +1,54 @@ +package sinhan.server2.notification.controller; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; +import sinhan.server2.domain.tempuser.TempUser; +import sinhan.server2.global.utils.ApiResult; +import sinhan.server2.global.utils.ApiUtils; +import sinhan.server2.notification.service.SSEService; + +import static sinhan.server2.global.utils.ApiUtils.success; + +@RestController +@Slf4j +@RequiredArgsConstructor +@RequestMapping("/notifications") +public class NotificationController { + + private final SSEService sseService; + + //SSE 구독하기 -> 프론트에서 로그인할때 부름 +// @GetMapping("/subscribe/{}") +// public SseEmitter subscribeSSE(TempUser tempUser){ +// +// return sseService.subscribe(tempUser.getSerialNumber()); +// } + + + @GetMapping("/subscribe/{usn}") + public SseEmitter subscribeSSE(@PathVariable("usn") Long usn){ + + return sseService.subscribe(usn); + } + + //해당 사용자의 모든 알림 가져오기 +// @GetMapping("/{usn}") + + //개별 알림 삭제하기 + @DeleteMapping("/{nsn}") + public ApiUtils.ApiResult deleteNotification(TempUser tempUser, @PathVariable("nsn") String nsn){ + sseService.deleteNotification(nsn); + return success(null); + } + + //알림 전체 삭제하기 + @DeleteMapping("/{rsn}") + public ApiUtils.ApiResult deleteNotification(@PathVariable("rsn") Long rsn){ + sseService.deleteAllNotifications(rsn); + return success(null); + } + + +} diff --git a/server2/server-common/src/main/java/sinhan/server1/domain/notification/entity/Notification.java b/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java similarity index 54% rename from server2/server-common/src/main/java/sinhan/server1/domain/notification/entity/Notification.java rename to server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java index 95d70cd..ab9ce5d 100644 --- a/server2/server-common/src/main/java/sinhan/server1/domain/notification/entity/Notification.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java @@ -1,13 +1,14 @@ -package sinhan.server1.domain.notification.entity; +package sinhan.server2.notification.entity; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import sinhan.server1.domain.tempuser.TempUser; +import sinhan.server2.domain.tempuser.TempUser; import java.time.LocalDateTime; +import java.util.UUID; @Entity @Getter @@ -15,12 +16,10 @@ public class Notification { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - int id; + @Column(unique = true, nullable = false) + String notificationSerialNumber; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_serial_number", referencedColumnName = "serialNumber") - TempUser receiver; + Long receiverSerialNumber; String sender; // 별명 int messageCode; // 메세지 코드 @@ -29,10 +28,11 @@ public class Notification { LocalDateTime createDate; @Builder - public Notification(int messageCode, int functionCode, TempUser receiver, String sender, LocalDateTime createDate) { + public Notification(int messageCode, int functionCode, Long receiverSerialNumber, String sender, LocalDateTime createDate) { + this.notificationSerialNumber = UUID.randomUUID().toString(); this.messageCode = messageCode; this.functionCode = functionCode; - this.receiver = receiver; + this.receiverSerialNumber = receiverSerialNumber; this.sender = sender; this.createDate = createDate; } diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/mongo/newNotificationRepository.java b/server2/server-common/src/main/java/sinhan/server2/notification/mongo/newNotificationRepository.java new file mode 100644 index 0000000..8418c44 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server2/notification/mongo/newNotificationRepository.java @@ -0,0 +1,10 @@ +package sinhan.server2.notification.mongo; + +import org.springframework.data.mongodb.repository.MongoRepository; +import sinhan.server2.notification.entity.Notification; + +public interface newNotificationRepository extends MongoRepository { + public void deleteByNotificationSerialNumber(String notificationSerialNumber); + + public void deleteByReceiverSerialNumber(Long receiverSerialNumber); +} diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java b/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java new file mode 100644 index 0000000..17732f0 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java @@ -0,0 +1,99 @@ +package sinhan.server2.notification.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; +import sinhan.server2.notification.entity.Notification; +import sinhan.server2.domain.tempuser.TempUser; +import sinhan.server2.domain.tempuser.TempUserRepository; +import sinhan.server2.global.exception.CustomException; +import sinhan.server2.global.exception.ErrorCode; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +@Service +@RequiredArgsConstructor +@Slf4j +@Transactional +public class SSEService { + private final Map sseEmitters = new ConcurrentHashMap<>(); + private final TempUserRepository tempUserRepository; + private final sinhan.server2.notification.mongo.newNotificationRepository newNotificationRepository; + + //SSE에 등록 + public SseEmitter subscribe(Long serialNumber) { + SseEmitter emitter = new SseEmitter(7200000L);// 2시간 타임아웃 + sseEmitters.put(serialNumber, emitter); + + //이부분은 원래 없음 + sendNotification(serialNumber, "alfo", 1, 1); + + emitter.onCompletion(()-> sseEmitters.remove(serialNumber)); + emitter.onTimeout(()->{ + sseEmitters.remove(serialNumber); + log.info("SSE 타임아웃" + serialNumber); + }); + emitter.onError((e)->{ + sseEmitters.remove(serialNumber); + log.info("SSE 에러 발생"+serialNumber); + }); + + return emitter; + } + + //알람 보내기 + public void sendNotification(Long serialNumber, String senderName, Integer functionCode, Integer messageCode){ + SseEmitter emitter = sseEmitters.get(serialNumber); + Notification savedNotification = saveNotification(serialNumber, senderName, functionCode, messageCode); + //emitter가 null인 경우 + try{ + emitter.send(SseEmitter.event().name("notification").data(savedNotification)); + } catch (IOException e) { + + //몽고 디비에서 저장된거 삭제하기 + newNotificationRepository.deleteByNotificationSerialNumber(savedNotification.getNotificationSerialNumber()); + //emitter를 삭제해야하나? => 재시도 로직을 넣어야 하나? => 재시도 횟수 + sseEmitters.remove(serialNumber); + + throw new CustomException(ErrorCode.FAILED_NOTIFICATION); + } + + } + + + //private : 알림 저장하기 + private Notification saveNotification(Long serialNumber, String senderName, Integer functionCode, Integer messageCode){ + TempUser receiver = tempUserRepository.findBySerialNumber(serialNumber); + + System.out.println(receiver.getSerialNumber()); + + Notification notification = Notification.builder() + .receiverSerialNumber(serialNumber) + .sender(senderName) + .functionCode(functionCode) + .messageCode(messageCode) + .createDate(LocalDateTime.now()) + .build(); + + //notification 몽고 디비에 저장 + newNotificationRepository.save(notification); + + return notification; + + } + + //알람 개별 삭제 + public void deleteNotification(String notificationSerailNumber) { + newNotificationRepository.deleteByNotificationSerialNumber(notificationSerailNumber); + } + + //알람 전체 삭제 + public void deleteAllNotifications(Long receiverSerialNumber){ + newNotificationRepository.deleteByReceiverSerialNumber(receiverSerialNumber); + } +} From cb9844769d437263e2c3d82c38957c406f44b20a Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 19:19:17 +0900 Subject: [PATCH 06/19] =?UTF-8?q?feat=20:=20mongoDB=20=ED=95=B4=EA=B2=B0?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=96=B4=EB=85=B8=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sinhan/server3/Server2Application.java | 19 +++++++++++++++++++ .../sinhan/server1/Server1Application.java | 14 ++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 server2/server-child/src/main/java/sinhan/server3/Server2Application.java diff --git a/server2/server-child/src/main/java/sinhan/server3/Server2Application.java b/server2/server-child/src/main/java/sinhan/server3/Server2Application.java new file mode 100644 index 0000000..9e35e63 --- /dev/null +++ b/server2/server-child/src/main/java/sinhan/server3/Server2Application.java @@ -0,0 +1,19 @@ +package sinhan.server1; + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import sinhan.server2.Server3Application; + +@SpringBootApplication +public class Server2Application { + + public static void main(String[] args) { + SpringApplication.run(Server3Application.class, args); + } + +// @RabbitListener(queues = "hello") +// public void listen(String message) { +// System.out.println("Received: " + message); +// } +} \ No newline at end of file diff --git a/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java b/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java index 2554aa7..6719b89 100644 --- a/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java +++ b/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java @@ -1,16 +1,14 @@ package sinhan.server1; -import org.springframework.amqp.core.Queue; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; + +@SpringBootApplication(scanBasePackages = {"sinhan.server2"}) +@EnableJpaRepositories(basePackages = {"sinhan.server2.domain"}) +@EnableMongoRepositories(basePackages = {"sinhan.server2.notification.mongo"}) -@SpringBootApplication -// (scanBasePackages = "server2") public class Server1Application { public static void main(String[] args) { From 99f51f6a0de6cc1b53cf4d7b201852864f2b04e3 Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 19:19:35 +0900 Subject: [PATCH 07/19] =?UTF-8?q?refactor=20:=20=EA=B8=B0=EC=A1=B4?= =?UTF-8?q?=EC=9D=98=20apiUtils=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sinhan/server2/global/utils/ApiUtils.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 server2/server-common/src/main/java/sinhan/server2/global/utils/ApiUtils.java diff --git a/server2/server-common/src/main/java/sinhan/server2/global/utils/ApiUtils.java b/server2/server-common/src/main/java/sinhan/server2/global/utils/ApiUtils.java new file mode 100644 index 0000000..527f10d --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server2/global/utils/ApiUtils.java @@ -0,0 +1,33 @@ +package sinhan.server2.global.utils; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +public class ApiUtils { + + public static ApiResult success(T data) { + return new ApiResult(true, data, null); + } + + public static ApiResult error(T message, HttpStatus httpStatus) { + return new ApiResult(false, null, new ApiError(message, httpStatus)); + } + + @Getter + @AllArgsConstructor + public static class ApiResult { + + private boolean success; + private T response; + private ApiError error; + } + + @Getter + @AllArgsConstructor + static class ApiError { + + private T message; + private HttpStatus httpStatus; + } +} \ No newline at end of file From 7000f1321744606470be48cd6e926c20932776c4 Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 19:30:26 +0900 Subject: [PATCH 08/19] =?UTF-8?q?feat=20:=20=EC=95=8C=EB=A6=BC=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C,=20=EC=95=8C=EB=A6=BC=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20api=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sinhan/server3/domain/AccountController.java | 13 +++++++++++++ .../controller/NotificationController.java | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 server2/server-child/src/main/java/sinhan/server3/domain/AccountController.java diff --git a/server2/server-child/src/main/java/sinhan/server3/domain/AccountController.java b/server2/server-child/src/main/java/sinhan/server3/domain/AccountController.java new file mode 100644 index 0000000..c1f09ef --- /dev/null +++ b/server2/server-child/src/main/java/sinhan/server3/domain/AccountController.java @@ -0,0 +1,13 @@ +package sinhan.server3.domain; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class AccountController { + @GetMapping("/temp") + public String getStock(){ + return "addff"; + } + +} diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java b/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java index 503c587..f2de39e 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java @@ -38,13 +38,13 @@ public SseEmitter subscribeSSE(@PathVariable("usn") Long usn){ //개별 알림 삭제하기 @DeleteMapping("/{nsn}") - public ApiUtils.ApiResult deleteNotification(TempUser tempUser, @PathVariable("nsn") String nsn){ + public ApiUtils.ApiResult deleteNotification( @PathVariable("nsn") String nsn){ sseService.deleteNotification(nsn); return success(null); } //알림 전체 삭제하기 - @DeleteMapping("/{rsn}") + @DeleteMapping("/all/{rsn}") public ApiUtils.ApiResult deleteNotification(@PathVariable("rsn") Long rsn){ sseService.deleteAllNotifications(rsn); return success(null); From 02aefe5ea3e1e00cec83071ea1251fe5b5ca7218 Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 22:49:10 +0900 Subject: [PATCH 09/19] =?UTF-8?q?feat:=20=EC=95=8C=EB=9E=8C=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=20api=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/NotificationController.java | 7 ++++- .../dto/NotificationFindAllResponse.java | 29 +++++++++++++++++++ .../mongo/newNotificationRepository.java | 4 +++ .../notification/service/SSEService.java | 12 ++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java b/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java index f2de39e..ff2b347 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java @@ -7,6 +7,7 @@ import sinhan.server2.domain.tempuser.TempUser; import sinhan.server2.global.utils.ApiResult; import sinhan.server2.global.utils.ApiUtils; +import sinhan.server2.notification.dto.NotificationFindAllResponse; import sinhan.server2.notification.service.SSEService; import static sinhan.server2.global.utils.ApiUtils.success; @@ -34,7 +35,11 @@ public SseEmitter subscribeSSE(@PathVariable("usn") Long usn){ } //해당 사용자의 모든 알림 가져오기 -// @GetMapping("/{usn}") + @GetMapping("/{usn}") + public ApiUtils.ApiResult findAllNotifications(@PathVariable("usn") Long usn){ + NotificationFindAllResponse response = sseService.findAllNotifications(usn); + return success(response); + } //개별 알림 삭제하기 @DeleteMapping("/{nsn}") diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java b/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java new file mode 100644 index 0000000..b23bd68 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java @@ -0,0 +1,29 @@ +package sinhan.server2.notification.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import sinhan.server2.notification.entity.Notification; + +import java.time.LocalDateTime; + +@Builder +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class NotificationFindAllResponse { + private int functionCode; // 기능 + private int messageCode; + private String sender; // 별명 + LocalDateTime createDate; + + public static NotificationFindAllResponse from(Notification notification){ + return NotificationFindAllResponse.builder() + .functionCode(notification.getFunctionCode()) + .messageCode(notification.getMessageCode()) + .sender(notification.getSender()) + .createDate(notification.getCreateDate()) + .build(); + } +} diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/mongo/newNotificationRepository.java b/server2/server-common/src/main/java/sinhan/server2/notification/mongo/newNotificationRepository.java index 8418c44..ca5f330 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/mongo/newNotificationRepository.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/mongo/newNotificationRepository.java @@ -3,8 +3,12 @@ import org.springframework.data.mongodb.repository.MongoRepository; import sinhan.server2.notification.entity.Notification; +import java.util.List; + public interface newNotificationRepository extends MongoRepository { public void deleteByNotificationSerialNumber(String notificationSerialNumber); public void deleteByReceiverSerialNumber(Long receiverSerialNumber); + + public List findAllByReceiverSerialNumber(Long receiverSerialNumber); } diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java b/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java index 17732f0..30f3034 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java @@ -5,6 +5,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; +import sinhan.server2.notification.dto.NotificationFindAllResponse; import sinhan.server2.notification.entity.Notification; import sinhan.server2.domain.tempuser.TempUser; import sinhan.server2.domain.tempuser.TempUserRepository; @@ -13,6 +14,7 @@ import java.io.IOException; import java.time.LocalDateTime; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -87,6 +89,15 @@ private Notification saveNotification(Long serialNumber, String senderName, Inte } + //알람 전체 조회 + public List findAllNotifications(Long receiverSerialNumber) { + return newNotificationRepository.findAllByReceiverSerialNumber(receiverSerialNumber) + .stream().map(notification -> { + return NotificationFindAllResponse.from(notification); + }) + .toList(); + } + //알람 개별 삭제 public void deleteNotification(String notificationSerailNumber) { newNotificationRepository.deleteByNotificationSerialNumber(notificationSerailNumber); @@ -96,4 +107,5 @@ public void deleteNotification(String notificationSerailNumber) { public void deleteAllNotifications(Long receiverSerialNumber){ newNotificationRepository.deleteByReceiverSerialNumber(receiverSerialNumber); } + } From f864ed6b9e8f3bf544249cd45c65759a4b569aa4 Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 23:31:25 +0900 Subject: [PATCH 10/19] =?UTF-8?q?feat=20:=20Utils=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=ED=9B=84=20messageCode,=20messageHandler?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server2/global/exception/ErrorCode.java | 3 +- .../controller/NotificationController.java | 4 +- .../notification/utils/MessageCode.java | 72 +++++++++++++++++++ .../notification/utils/MessageHandler.java | 15 ++++ 4 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java create mode 100644 server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java diff --git a/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorCode.java b/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorCode.java index 1fb37f1..4ece5de 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorCode.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorCode.java @@ -15,8 +15,9 @@ public enum ErrorCode { NOT_FOUND_TEMPORAL_ALLOWANCE(HttpStatus.NOT_FOUND, "해당되는 용돈 조르기가 없습니다."), //알람 예외 - FAILED_NOTIFICATION(HttpStatus.CONFLICT, "알람 보내기에 실패했습니다."); + FAILED_NOTIFICATION(HttpStatus.CONFLICT, "알람 보내기에 실패했습니다."), + NOT_FOUND_MESSAGECODE(HttpStatus.NOT_FOUND, "저장된 알림 메세지 형식을 찾을 수 없습니다."); private final HttpStatus status; private final String message; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java b/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java index ff2b347..bddedb8 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java @@ -10,6 +10,8 @@ import sinhan.server2.notification.dto.NotificationFindAllResponse; import sinhan.server2.notification.service.SSEService; +import java.util.List; + import static sinhan.server2.global.utils.ApiUtils.success; @RestController @@ -37,7 +39,7 @@ public SseEmitter subscribeSSE(@PathVariable("usn") Long usn){ //해당 사용자의 모든 알림 가져오기 @GetMapping("/{usn}") public ApiUtils.ApiResult findAllNotifications(@PathVariable("usn") Long usn){ - NotificationFindAllResponse response = sseService.findAllNotifications(usn); + List response = sseService.findAllNotifications(usn); return success(response); } diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java b/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java new file mode 100644 index 0000000..39c45a5 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java @@ -0,0 +1,72 @@ +package sinhan.server2.notification.utils; + +import java.util.HashMap; +import java.util.Map; + +public class MessageCode { + private static final Map messageCodes = new HashMap<>(); + + static { + messageCodes.put(0, "%s님이 아이 등록을 요청했어요."); + messageCodes.put(1, "%s님이 부모 등록을 요청했어요."); + messageCodes.put(101, "%s님이 %d원을 송금하였습니다."); + messageCodes.put(200, "%s님으로부터 정기 용돈이 시작돼요."); + messageCodes.put(201, "%s님에게 정기 용돈 %d원을 보냈어요."); + messageCodes.put(202, "%s님으로부터 정기 용돈 %d원이 들어왔어요."); + messageCodes.put(210, "%s님이 용돈 조르기를 요청했어요."); + messageCodes.put(211, "%s님이 용돈 조르기를 거절했어요."); + messageCodes.put(212, "%s님이 용돈 조르기를 수락했어요."); + messageCodes.put(220, "%s님으로부터 용돈 %d원이 들어왔어요."); + messageCodes.put(230, "용돈 조르기를 사용하여 신뢰도가 -1 되었어요."); + messageCodes.put(300, "%s님이 미션 완료를 요청했어요."); + messageCodes.put(301, "%s님이 미션 완료(%s)를 확인했어요. %d원이 들어왔어요."); + messageCodes.put(310, "%s님이 미션을 요청했어요."); + messageCodes.put(311, "%s님이 미션을 포기했어요."); + messageCodes.put(312, "%s님이 미션을 수락했어요."); + messageCodes.put(320, "%s님이 미션을 요청했어요."); + messageCodes.put(321, "%s님이 미션을 거절했어요."); + messageCodes.put(322, "%s님이 미션을 수락했어요."); + messageCodes.put(330, "미션을 수행하여 신뢰도가 +1 되었어요."); + messageCodes.put(401, "%s님이 %d원 %d개월 대출을 신청했어요."); + messageCodes.put(402, "%s님이 %d원 %d개월 대출을 수락했어요."); + messageCodes.put(403, "%s님이 %d원 %d개월 대출을 거절했어요."); + messageCodes.put(411, "%s님이 %d원을 상환했어요."); + messageCodes.put(412, "%s님에게 %d원을 상환했어요."); + messageCodes.put(413, "%s님이 잔고 부족으로 대출 상환을 실패했어요."); + messageCodes.put(414, "%s님에게 잔고 부족으로 대출 상환을 못했어요."); + messageCodes.put(420, "대출을 상환하여 신뢰도가 +5 되었어요."); + messageCodes.put(421, "대출을 연체하여 신뢰도가 -1 되었어요."); + messageCodes.put(431, "신뢰가 쌓여 신뢰도가 매우 높음이 되었어요."); + messageCodes.put(432, "신뢰가 쌓여 신뢰도가 높음이 되었어요."); + messageCodes.put(433, "신뢰도가 쌓여 신뢰도가 보통이 되었어요."); + messageCodes.put(434, "신뢰도가 쌓여 신뢰도가 낮음이 되었어요."); + messageCodes.put(435, "신뢰가 사라져 신뢰도가 높음이 되었어요."); + messageCodes.put(436, "신뢰가 사라져 신뢰도가 보통이 되었어요."); + messageCodes.put(437, "신뢰가 사라져 신뢰도가 낮음이 되었어요."); + messageCodes.put(438, "신뢰가 사라져 신뢰도가 매우 낮음이 되었어요."); + messageCodes.put(441, "%s님이 신뢰가 쌓여 신뢰도가 매우 높음이 되었어요."); + messageCodes.put(442, "%s님이 신뢰가 쌓여 신뢰도가 높음이 되었어요."); + messageCodes.put(443, "%s님이 신뢰도가 쌓여 신뢰도가 보통이 되었어요."); + messageCodes.put(444, "%s님이 신뢰도가 쌓여 신뢰도가 낮음이 되었어요."); + messageCodes.put(445, "%s님이 신뢰가 사라져 신뢰도가 높음이 되었어요."); + messageCodes.put(446, "%s님이 신뢰가 사라져 신뢰도가 보통이 되었어요."); + messageCodes.put(447, "%s님이 신뢰가 사라져 신뢰도가 낮음이 되었어요."); + messageCodes.put(448, "%s님이 신뢰가 사라져 신뢰도가 매우 낮음이 되었어요."); + messageCodes.put(501, "%s님이 보유하신 %s종목이 10프로 떨어졌어요."); + messageCodes.put(502, "%s님이 보유하신 %s종목이 30프로 떨어졌어요."); + messageCodes.put(503, "%s님이 보유하신 %s종목이 50프로 떨어졌어요."); + messageCodes.put(511, "%s님이 종목 리스트에 %s을 제안했어요!"); + messageCodes.put(512, "%s님이 종목 리스트에 %s 제안을 수락했어요."); + messageCodes.put(513, "%s님이 종목 리스트에 %s 제안을 거절했어요."); + messageCodes.put(514, "%s님이 %s을 0주 %s 제안했어요!"); + messageCodes.put(515, "%s님이 %s을 0주 %s 제안을 수락했어요."); + messageCodes.put(516, "%s님이 %s을 0주 %s 제안을 거절했어요."); + messageCodes.put(517, "%s님이 종목리스트에 %s을 추가했어요."); + messageCodes.put(520, "투자 수익이 10%% 이상이어서 신뢰도가 +5 되었어요."); + messageCodes.put(521, "투자 손실이 10%% 이상이어서 신뢰도가 -5 되었어요."); + } + + public static String getMessage(Integer code) { + return messageCodes.get(code); + } +} diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java b/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java new file mode 100644 index 0000000..788f875 --- /dev/null +++ b/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java @@ -0,0 +1,15 @@ +package sinhan.server2.notification.utils; + +import sinhan.server2.global.exception.CustomException; +import sinhan.server2.global.exception.ErrorCode; + +public class MessageHandler { + public static String getMessage(Integer code, Object... args) { + String message = MessageCode.getMessage(code); + if (message == null) { + throw new CustomException(ErrorCode.NOT_FOUND_MESSAGECODE); + } + return String.format(message, args); + } + +} From c91f8f223ece732de336eafeda6a42c1064a5992 Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 23:45:10 +0900 Subject: [PATCH 11/19] =?UTF-8?q?refactor:=20Notification=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=EC=95=88=EC=9D=98=20messageCode=20int?= =?UTF-8?q?=EB=A5=BC=20message=20String=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/NotificationFindAllResponse.java | 4 ++-- .../notification/entity/Notification.java | 6 +++--- .../notification/service/SSEService.java | 19 ++++++++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java b/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java index b23bd68..1fb944a 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java @@ -14,14 +14,14 @@ @AllArgsConstructor public class NotificationFindAllResponse { private int functionCode; // 기능 - private int messageCode; + private String messageCode; private String sender; // 별명 LocalDateTime createDate; public static NotificationFindAllResponse from(Notification notification){ return NotificationFindAllResponse.builder() .functionCode(notification.getFunctionCode()) - .messageCode(notification.getMessageCode()) + .messageCode(notification.getMessage()) .sender(notification.getSender()) .createDate(notification.getCreateDate()) .build(); diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java b/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java index ab9ce5d..639463b 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java @@ -22,15 +22,15 @@ public class Notification { Long receiverSerialNumber; String sender; // 별명 - int messageCode; // 메세지 코드 + String message; // 메세지 코드 int functionCode; // 기능 LocalDateTime createDate; @Builder - public Notification(int messageCode, int functionCode, Long receiverSerialNumber, String sender, LocalDateTime createDate) { + public Notification(String message, int functionCode, Long receiverSerialNumber, String sender, LocalDateTime createDate) { this.notificationSerialNumber = UUID.randomUUID().toString(); - this.messageCode = messageCode; + this.message = message; this.functionCode = functionCode; this.receiverSerialNumber = receiverSerialNumber; this.sender = sender; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java b/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java index 30f3034..cf3ce5e 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java @@ -11,9 +11,12 @@ import sinhan.server2.domain.tempuser.TempUserRepository; import sinhan.server2.global.exception.CustomException; import sinhan.server2.global.exception.ErrorCode; +import sinhan.server2.notification.utils.MessageHandler; import java.io.IOException; import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -33,7 +36,9 @@ public SseEmitter subscribe(Long serialNumber) { sseEmitters.put(serialNumber, emitter); //이부분은 원래 없음 - sendNotification(serialNumber, "alfo", 1, 1); + String newMesssage= MessageHandler.getMessage(0,"알파코"); + sendNotification(serialNumber, "alfo", 1, newMesssage); + //여기까지 원래 없음 emitter.onCompletion(()-> sseEmitters.remove(serialNumber)); emitter.onTimeout(()->{ @@ -48,10 +53,10 @@ public SseEmitter subscribe(Long serialNumber) { return emitter; } - //알람 보내기 - public void sendNotification(Long serialNumber, String senderName, Integer functionCode, Integer messageCode){ + //알람 보내기 => message는 각자 자기 도메인에서 MessageHandler.getMessage(여러 인수들); 해서 나온거 가져오기 + public void sendNotification(Long serialNumber, String senderName, Integer functionCode, String message){ SseEmitter emitter = sseEmitters.get(serialNumber); - Notification savedNotification = saveNotification(serialNumber, senderName, functionCode, messageCode); + Notification savedNotification = saveNotification(serialNumber, senderName, functionCode, message); //emitter가 null인 경우 try{ emitter.send(SseEmitter.event().name("notification").data(savedNotification)); @@ -69,7 +74,7 @@ public void sendNotification(Long serialNumber, String senderName, Integer funct //private : 알림 저장하기 - private Notification saveNotification(Long serialNumber, String senderName, Integer functionCode, Integer messageCode){ + private Notification saveNotification(Long serialNumber, String senderName, Integer functionCode, String message){ TempUser receiver = tempUserRepository.findBySerialNumber(serialNumber); System.out.println(receiver.getSerialNumber()); @@ -78,8 +83,8 @@ private Notification saveNotification(Long serialNumber, String senderName, Inte .receiverSerialNumber(serialNumber) .sender(senderName) .functionCode(functionCode) - .messageCode(messageCode) - .createDate(LocalDateTime.now()) + .message(message) + .createDate(ZonedDateTime.now(ZoneId.of("Asia/Seoul")).toLocalDateTime()) .build(); //notification 몽고 디비에 저장 From e977a0e657d4c37c07eccf41e5b3f283ef33c9ce Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 23:50:18 +0900 Subject: [PATCH 12/19] =?UTF-8?q?refactor=20:=20notification=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20global=20=EC=95=88=EC=9C=BC=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99,=20=EB=A0=88=ED=8F=AC=EC=A7=80=ED=86=A0=EB=A6=AC=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/NotificationController.java | 8 +++---- .../dto/NotificationFindAllResponse.java | 4 ++-- .../notification/entity/Notification.java | 2 +- .../mongo/NotificationRepository.java} | 6 ++--- .../notification/service/SSEService.java | 22 +++++++++---------- .../notification/utils/MessageCode.java | 2 +- .../notification/utils/MessageHandler.java | 2 +- .../sinhan/server1/Server1Application.java | 2 +- 8 files changed, 23 insertions(+), 25 deletions(-) rename server2/server-common/src/main/java/sinhan/server2/{ => global}/notification/controller/NotificationController.java (86%) rename server2/server-common/src/main/java/sinhan/server2/{ => global}/notification/dto/NotificationFindAllResponse.java (87%) rename server2/server-common/src/main/java/sinhan/server2/{ => global}/notification/entity/Notification.java (95%) rename server2/server-common/src/main/java/sinhan/server2/{notification/mongo/newNotificationRepository.java => global/notification/mongo/NotificationRepository.java} (62%) rename server2/server-common/src/main/java/sinhan/server2/{ => global}/notification/service/SSEService.java (82%) rename server2/server-common/src/main/java/sinhan/server2/{ => global}/notification/utils/MessageCode.java (99%) rename server2/server-common/src/main/java/sinhan/server2/{ => global}/notification/utils/MessageHandler.java (89%) diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java b/server2/server-common/src/main/java/sinhan/server2/global/notification/controller/NotificationController.java similarity index 86% rename from server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java rename to server2/server-common/src/main/java/sinhan/server2/global/notification/controller/NotificationController.java index bddedb8..8125850 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/notification/controller/NotificationController.java @@ -1,14 +1,12 @@ -package sinhan.server2.notification.controller; +package sinhan.server2.global.notification.controller; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; -import sinhan.server2.domain.tempuser.TempUser; -import sinhan.server2.global.utils.ApiResult; +import sinhan.server2.global.notification.dto.NotificationFindAllResponse; import sinhan.server2.global.utils.ApiUtils; -import sinhan.server2.notification.dto.NotificationFindAllResponse; -import sinhan.server2.notification.service.SSEService; +import sinhan.server2.global.notification.service.SSEService; import java.util.List; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java b/server2/server-common/src/main/java/sinhan/server2/global/notification/dto/NotificationFindAllResponse.java similarity index 87% rename from server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java rename to server2/server-common/src/main/java/sinhan/server2/global/notification/dto/NotificationFindAllResponse.java index 1fb944a..fb22da5 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/notification/dto/NotificationFindAllResponse.java @@ -1,10 +1,10 @@ -package sinhan.server2.notification.dto; +package sinhan.server2.global.notification.dto; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import sinhan.server2.notification.entity.Notification; +import sinhan.server2.global.notification.entity.Notification; import java.time.LocalDateTime; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java b/server2/server-common/src/main/java/sinhan/server2/global/notification/entity/Notification.java similarity index 95% rename from server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java rename to server2/server-common/src/main/java/sinhan/server2/global/notification/entity/Notification.java index 639463b..e3b9857 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/notification/entity/Notification.java @@ -1,4 +1,4 @@ -package sinhan.server2.notification.entity; +package sinhan.server2.global.notification.entity; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/mongo/newNotificationRepository.java b/server2/server-common/src/main/java/sinhan/server2/global/notification/mongo/NotificationRepository.java similarity index 62% rename from server2/server-common/src/main/java/sinhan/server2/notification/mongo/newNotificationRepository.java rename to server2/server-common/src/main/java/sinhan/server2/global/notification/mongo/NotificationRepository.java index ca5f330..acc8889 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/mongo/newNotificationRepository.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/notification/mongo/NotificationRepository.java @@ -1,11 +1,11 @@ -package sinhan.server2.notification.mongo; +package sinhan.server2.global.notification.mongo; import org.springframework.data.mongodb.repository.MongoRepository; -import sinhan.server2.notification.entity.Notification; +import sinhan.server2.global.notification.entity.Notification; import java.util.List; -public interface newNotificationRepository extends MongoRepository { +public interface NotificationRepository extends MongoRepository { public void deleteByNotificationSerialNumber(String notificationSerialNumber); public void deleteByReceiverSerialNumber(Long receiverSerialNumber); diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java b/server2/server-common/src/main/java/sinhan/server2/global/notification/service/SSEService.java similarity index 82% rename from server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java rename to server2/server-common/src/main/java/sinhan/server2/global/notification/service/SSEService.java index cf3ce5e..5d9a583 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/notification/service/SSEService.java @@ -1,20 +1,20 @@ -package sinhan.server2.notification.service; +package sinhan.server2.global.notification.service; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; -import sinhan.server2.notification.dto.NotificationFindAllResponse; -import sinhan.server2.notification.entity.Notification; +import sinhan.server2.global.notification.dto.NotificationFindAllResponse; +import sinhan.server2.global.notification.entity.Notification; import sinhan.server2.domain.tempuser.TempUser; import sinhan.server2.domain.tempuser.TempUserRepository; import sinhan.server2.global.exception.CustomException; import sinhan.server2.global.exception.ErrorCode; -import sinhan.server2.notification.utils.MessageHandler; +import sinhan.server2.global.notification.mongo.NotificationRepository; +import sinhan.server2.global.notification.utils.MessageHandler; import java.io.IOException; -import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.List; @@ -28,7 +28,7 @@ public class SSEService { private final Map sseEmitters = new ConcurrentHashMap<>(); private final TempUserRepository tempUserRepository; - private final sinhan.server2.notification.mongo.newNotificationRepository newNotificationRepository; + private final NotificationRepository NotificationRepository; //SSE에 등록 public SseEmitter subscribe(Long serialNumber) { @@ -63,7 +63,7 @@ public void sendNotification(Long serialNumber, String senderName, Integer funct } catch (IOException e) { //몽고 디비에서 저장된거 삭제하기 - newNotificationRepository.deleteByNotificationSerialNumber(savedNotification.getNotificationSerialNumber()); + NotificationRepository.deleteByNotificationSerialNumber(savedNotification.getNotificationSerialNumber()); //emitter를 삭제해야하나? => 재시도 로직을 넣어야 하나? => 재시도 횟수 sseEmitters.remove(serialNumber); @@ -88,7 +88,7 @@ private Notification saveNotification(Long serialNumber, String senderName, Inte .build(); //notification 몽고 디비에 저장 - newNotificationRepository.save(notification); + NotificationRepository.save(notification); return notification; @@ -96,7 +96,7 @@ private Notification saveNotification(Long serialNumber, String senderName, Inte //알람 전체 조회 public List findAllNotifications(Long receiverSerialNumber) { - return newNotificationRepository.findAllByReceiverSerialNumber(receiverSerialNumber) + return NotificationRepository.findAllByReceiverSerialNumber(receiverSerialNumber) .stream().map(notification -> { return NotificationFindAllResponse.from(notification); }) @@ -105,12 +105,12 @@ public List findAllNotifications(Long receiverSeria //알람 개별 삭제 public void deleteNotification(String notificationSerailNumber) { - newNotificationRepository.deleteByNotificationSerialNumber(notificationSerailNumber); + NotificationRepository.deleteByNotificationSerialNumber(notificationSerailNumber); } //알람 전체 삭제 public void deleteAllNotifications(Long receiverSerialNumber){ - newNotificationRepository.deleteByReceiverSerialNumber(receiverSerialNumber); + NotificationRepository.deleteByReceiverSerialNumber(receiverSerialNumber); } } diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java b/server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageCode.java similarity index 99% rename from server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java rename to server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageCode.java index 39c45a5..41ebefb 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageCode.java @@ -1,4 +1,4 @@ -package sinhan.server2.notification.utils; +package sinhan.server2.global.notification.utils; import java.util.HashMap; import java.util.Map; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java b/server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageHandler.java similarity index 89% rename from server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java rename to server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageHandler.java index 788f875..2394f89 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java +++ b/server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageHandler.java @@ -1,4 +1,4 @@ -package sinhan.server2.notification.utils; +package sinhan.server2.global.notification.utils; import sinhan.server2.global.exception.CustomException; import sinhan.server2.global.exception.ErrorCode; diff --git a/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java b/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java index 6719b89..9f54c5a 100644 --- a/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java +++ b/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java @@ -7,7 +7,7 @@ @SpringBootApplication(scanBasePackages = {"sinhan.server2"}) @EnableJpaRepositories(basePackages = {"sinhan.server2.domain"}) -@EnableMongoRepositories(basePackages = {"sinhan.server2.notification.mongo"}) +@EnableMongoRepositories(basePackages = {"sinhan.server2.global.notification.mongo"}) public class Server1Application { From 3fbe938e2c365c4771db57aa06822dc5a82c6d3a Mon Sep 17 00:00:00 2001 From: allllfo Date: Tue, 18 Jun 2024 23:59:38 +0900 Subject: [PATCH 13/19] =?UTF-8?q?refactor=20:=20notification=ED=8F=B4?= =?UTF-8?q?=EB=8D=94=20global=20=EC=95=88=EC=97=90=EC=84=9C=20=EB=8B=A4?= =?UTF-8?q?=EC=8B=9C=20=EB=B9=BC=EB=83=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parent에서는 작동하는데 child에서 작동안함 --- .../main/java/sinhan/server3/Server2Application.java | 8 ++++++-- .../controller/NotificationController.java | 6 +++--- .../notification/dto/NotificationFindAllResponse.java | 4 ++-- .../notification/entity/Notification.java | 2 +- .../notification/mongo/NotificationRepository.java | 4 ++-- .../{global => }/notification/service/SSEService.java | 11 +++++------ .../{global => }/notification/utils/MessageCode.java | 2 +- .../notification/utils/MessageHandler.java | 2 +- .../main/java/sinhan/server1/Server1Application.java | 2 +- 9 files changed, 22 insertions(+), 19 deletions(-) rename server2/server-common/src/main/java/sinhan/server2/{global => }/notification/controller/NotificationController.java (89%) rename server2/server-common/src/main/java/sinhan/server2/{global => }/notification/dto/NotificationFindAllResponse.java (87%) rename server2/server-common/src/main/java/sinhan/server2/{global => }/notification/entity/Notification.java (95%) rename server2/server-common/src/main/java/sinhan/server2/{global => }/notification/mongo/NotificationRepository.java (79%) rename server2/server-common/src/main/java/sinhan/server2/{global => }/notification/service/SSEService.java (91%) rename server2/server-common/src/main/java/sinhan/server2/{global => }/notification/utils/MessageCode.java (99%) rename server2/server-common/src/main/java/sinhan/server2/{global => }/notification/utils/MessageHandler.java (89%) diff --git a/server2/server-child/src/main/java/sinhan/server3/Server2Application.java b/server2/server-child/src/main/java/sinhan/server3/Server2Application.java index 9e35e63..f82de5e 100644 --- a/server2/server-child/src/main/java/sinhan/server3/Server2Application.java +++ b/server2/server-child/src/main/java/sinhan/server3/Server2Application.java @@ -1,11 +1,15 @@ -package sinhan.server1; +package sinhan.server3; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; import sinhan.server2.Server3Application; -@SpringBootApplication +@SpringBootApplication(scanBasePackages = {"sinhan.server2"}) +@EnableJpaRepositories(basePackages = {"sinhan.server2.domain"}) +@EnableMongoRepositories(basePackages = {"sinhan.server2.notification.mongo"}) public class Server2Application { public static void main(String[] args) { diff --git a/server2/server-common/src/main/java/sinhan/server2/global/notification/controller/NotificationController.java b/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java similarity index 89% rename from server2/server-common/src/main/java/sinhan/server2/global/notification/controller/NotificationController.java rename to server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java index 8125850..434053e 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/notification/controller/NotificationController.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java @@ -1,12 +1,12 @@ -package sinhan.server2.global.notification.controller; +package sinhan.server2.notification.controller; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; -import sinhan.server2.global.notification.dto.NotificationFindAllResponse; +import sinhan.server2.notification.dto.NotificationFindAllResponse; import sinhan.server2.global.utils.ApiUtils; -import sinhan.server2.global.notification.service.SSEService; +import sinhan.server2.notification.service.SSEService; import java.util.List; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/notification/dto/NotificationFindAllResponse.java b/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java similarity index 87% rename from server2/server-common/src/main/java/sinhan/server2/global/notification/dto/NotificationFindAllResponse.java rename to server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java index fb22da5..1fb944a 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/notification/dto/NotificationFindAllResponse.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java @@ -1,10 +1,10 @@ -package sinhan.server2.global.notification.dto; +package sinhan.server2.notification.dto; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import sinhan.server2.global.notification.entity.Notification; +import sinhan.server2.notification.entity.Notification; import java.time.LocalDateTime; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/notification/entity/Notification.java b/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java similarity index 95% rename from server2/server-common/src/main/java/sinhan/server2/global/notification/entity/Notification.java rename to server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java index e3b9857..639463b 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/notification/entity/Notification.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java @@ -1,4 +1,4 @@ -package sinhan.server2.global.notification.entity; +package sinhan.server2.notification.entity; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/notification/mongo/NotificationRepository.java b/server2/server-common/src/main/java/sinhan/server2/notification/mongo/NotificationRepository.java similarity index 79% rename from server2/server-common/src/main/java/sinhan/server2/global/notification/mongo/NotificationRepository.java rename to server2/server-common/src/main/java/sinhan/server2/notification/mongo/NotificationRepository.java index acc8889..858f652 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/notification/mongo/NotificationRepository.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/mongo/NotificationRepository.java @@ -1,7 +1,7 @@ -package sinhan.server2.global.notification.mongo; +package sinhan.server2.notification.mongo; import org.springframework.data.mongodb.repository.MongoRepository; -import sinhan.server2.global.notification.entity.Notification; +import sinhan.server2.notification.entity.Notification; import java.util.List; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/notification/service/SSEService.java b/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java similarity index 91% rename from server2/server-common/src/main/java/sinhan/server2/global/notification/service/SSEService.java rename to server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java index 5d9a583..38bf580 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/notification/service/SSEService.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java @@ -1,18 +1,17 @@ -package sinhan.server2.global.notification.service; +package sinhan.server2.notification.service; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; -import sinhan.server2.global.notification.dto.NotificationFindAllResponse; -import sinhan.server2.global.notification.entity.Notification; +import sinhan.server2.notification.dto.NotificationFindAllResponse; +import sinhan.server2.notification.entity.Notification; import sinhan.server2.domain.tempuser.TempUser; import sinhan.server2.domain.tempuser.TempUserRepository; import sinhan.server2.global.exception.CustomException; import sinhan.server2.global.exception.ErrorCode; -import sinhan.server2.global.notification.mongo.NotificationRepository; -import sinhan.server2.global.notification.utils.MessageHandler; +import sinhan.server2.notification.utils.MessageHandler; import java.io.IOException; import java.time.ZoneId; @@ -28,7 +27,7 @@ public class SSEService { private final Map sseEmitters = new ConcurrentHashMap<>(); private final TempUserRepository tempUserRepository; - private final NotificationRepository NotificationRepository; + private final sinhan.server2.notification.mongo.NotificationRepository NotificationRepository; //SSE에 등록 public SseEmitter subscribe(Long serialNumber) { diff --git a/server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageCode.java b/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java similarity index 99% rename from server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageCode.java rename to server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java index 41ebefb..39c45a5 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageCode.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java @@ -1,4 +1,4 @@ -package sinhan.server2.global.notification.utils; +package sinhan.server2.notification.utils; import java.util.HashMap; import java.util.Map; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageHandler.java b/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java similarity index 89% rename from server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageHandler.java rename to server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java index 2394f89..788f875 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/notification/utils/MessageHandler.java +++ b/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java @@ -1,4 +1,4 @@ -package sinhan.server2.global.notification.utils; +package sinhan.server2.notification.utils; import sinhan.server2.global.exception.CustomException; import sinhan.server2.global.exception.ErrorCode; diff --git a/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java b/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java index 9f54c5a..6719b89 100644 --- a/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java +++ b/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java @@ -7,7 +7,7 @@ @SpringBootApplication(scanBasePackages = {"sinhan.server2"}) @EnableJpaRepositories(basePackages = {"sinhan.server2.domain"}) -@EnableMongoRepositories(basePackages = {"sinhan.server2.global.notification.mongo"}) +@EnableMongoRepositories(basePackages = {"sinhan.server2.notification.mongo"}) public class Server1Application { From 9c541905940d9c7a025436f6cab5cb91120898f9 Mon Sep 17 00:00:00 2001 From: allllfo Date: Wed, 19 Jun 2024 09:34:35 +0900 Subject: [PATCH 14/19] =?UTF-8?q?refactor=20:=20mongo,=20JPA=20=EC=97=90?= =?UTF-8?q?=EC=84=9C=20Bean=20overriding=20=EB=90=98=EB=8A=94=20=EA=B2=83?= =?UTF-8?q?=20=ED=95=B4=EA=B2=B0!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/sinhan/server3/Server2Application.java | 8 ++++---- .../src/main/java/sinhan/server2/Server3Application.java | 9 +++++++++ .../src/main/java/sinhan/server1/Server1Application.java | 5 +---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/server2/server-child/src/main/java/sinhan/server3/Server2Application.java b/server2/server-child/src/main/java/sinhan/server3/Server2Application.java index f82de5e..0d955dd 100644 --- a/server2/server-child/src/main/java/sinhan/server3/Server2Application.java +++ b/server2/server-child/src/main/java/sinhan/server3/Server2Application.java @@ -1,15 +1,15 @@ package sinhan.server3; - import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; import sinhan.server2.Server3Application; +import sinhan.server2.notification.mongo.NotificationRepository; -@SpringBootApplication(scanBasePackages = {"sinhan.server2"}) -@EnableJpaRepositories(basePackages = {"sinhan.server2.domain"}) -@EnableMongoRepositories(basePackages = {"sinhan.server2.notification.mongo"}) +@SpringBootApplication(scanBasePackages = {"sinhan.server3", "sinhan.server2"}) public class Server2Application { public static void main(String[] args) { diff --git a/server2/server-common/src/main/java/sinhan/server2/Server3Application.java b/server2/server-common/src/main/java/sinhan/server2/Server3Application.java index 5534c20..91de36c 100644 --- a/server2/server-common/src/main/java/sinhan/server2/Server3Application.java +++ b/server2/server-common/src/main/java/sinhan/server2/Server3Application.java @@ -3,9 +3,18 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; +import sinhan.server2.notification.mongo.NotificationRepository; // common @SpringBootApplication//(scanBasePackages = {"server-child", "server-parent"}) +@EnableJpaRepositories(excludeFilters = @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = NotificationRepository.class)) +@EnableMongoRepositories(basePackages = {"sinhan.server2.notification.mongo"}) public class Server3Application { public static void main(String[] args) { diff --git a/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java b/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java index 6719b89..6775476 100644 --- a/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java +++ b/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java @@ -5,10 +5,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; -@SpringBootApplication(scanBasePackages = {"sinhan.server2"}) -@EnableJpaRepositories(basePackages = {"sinhan.server2.domain"}) -@EnableMongoRepositories(basePackages = {"sinhan.server2.notification.mongo"}) - +@SpringBootApplication(scanBasePackages = {"sinhan.server2", "sinhan.server1"}) public class Server1Application { public static void main(String[] args) { From 192cfae0e3f4ba4e97683570c949917f790b41a7 Mon Sep 17 00:00:00 2001 From: allllfo Date: Wed, 19 Jun 2024 09:48:25 +0900 Subject: [PATCH 15/19] =?UTF-8?q?refactor=20:=20shinhan=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD,=20module=20server=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=EB=93=A4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server_child/ServerChildApplication.java | 18 +++++++++++++++ .../domain/AccountController.java | 2 +- .../sinhan/server3/Server2Application.java | 23 ------------------- .../ServerCommonApplicationTests.java} | 4 ++-- .../ServerCommonApplication.java} | 10 ++++---- .../invest/controller/DartController.java | 8 +++---- .../invest/controller/InvestController.java | 4 ++-- .../invest/controller/ProposalController.java | 4 ++-- .../invest/controller/StockController.java | 6 ++--- .../dto/StockFindDetailResponseDTO.java | 4 ++-- .../domain/invest/entity/StockCartDate.java | 2 +- .../invest/entity/StockCurrentDetail.java | 2 +- .../entity/StockCurrentPriceOutput.java | 2 +- .../invest/entity/StockDivideDetail.java | 2 +- .../invest/entity/StockDivideOutput.java | 2 +- .../entity/StockDuraionPriceOutput.java | 2 +- .../invest/entity/StockDurationDetail.java | 2 +- .../invest/entity/StockFianceDetail.java | 2 +- .../entity/StockFianceResponseOutput.java | 2 +- .../invest/repository/StockRepository.java | 2 +- .../domain/invest/service/StockService.java | 12 +++++----- .../domain/tempuser/TempUser.java | 2 +- .../domain/tempuser/TempUserRepository.java | 2 +- .../global/config/WebClientCongif.java | 2 +- .../global/exception/CustomException.java | 2 +- .../exception/CustomExceptionHandler.java | 2 +- .../global/exception/ErrorCode.java | 2 +- .../global/exception/ErrorResponse.java | 2 +- .../global/utils/ApiResult.java | 2 +- .../server_common}/global/utils/ApiUtils.java | 2 +- .../controller/NotificationController.java | 10 ++++---- .../dto/NotificationFindAllResponse.java | 4 ++-- .../notification/entity/Notification.java | 3 +-- .../mongo/NotificationRepository.java | 4 ++-- .../notification/service/SSEService.java | 18 +++++++-------- .../notification/utils/MessageCode.java | 2 +- .../notification/utils/MessageHandler.java | 6 ++--- .../ServerCommonApplicationTests.java} | 4 ++-- .../ServerParentApplication.java | 17 ++++++++++++++ .../account/controller/AccountController.java | 3 +-- .../domain/account/entity/Account.java | 4 ++++ .../server_parent}/global/utils/ApiUtils.java | 2 +- .../global/utils/Validator.java | 2 +- .../sinhan/server1/Server1Application.java | 19 --------------- .../domain/account/entity/Account.java | 4 ---- .../ServerParentApplicationTests.java} | 4 ++-- 46 files changed, 115 insertions(+), 124 deletions(-) create mode 100644 server2/server-child/src/main/java/shinhan/server_child/ServerChildApplication.java rename server2/server-child/src/main/java/{sinhan/server3 => shinhan/server_child}/domain/AccountController.java (87%) delete mode 100644 server2/server-child/src/main/java/sinhan/server3/Server2Application.java rename server2/server-child/src/test/java/{sinhan/server1/Server3ApplicationTests.java => shinhan/server1/ServerCommonApplicationTests.java} (79%) rename server2/server-common/src/main/java/{sinhan/server2/Server3Application.java => shinhan/server_common/ServerCommonApplication.java} (74%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/controller/DartController.java (77%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/controller/InvestController.java (90%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/controller/ProposalController.java (96%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/controller/StockController.java (90%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/dto/StockFindDetailResponseDTO.java (85%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/entity/StockCartDate.java (89%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/entity/StockCurrentDetail.java (85%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/entity/StockCurrentPriceOutput.java (88%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/entity/StockDivideDetail.java (88%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/entity/StockDivideOutput.java (87%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/entity/StockDuraionPriceOutput.java (81%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/entity/StockDurationDetail.java (93%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/entity/StockFianceDetail.java (86%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/entity/StockFianceResponseOutput.java (83%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/repository/StockRepository.java (61%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/invest/service/StockService.java (94%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/tempuser/TempUser.java (91%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/domain/tempuser/TempUserRepository.java (80%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/global/config/WebClientCongif.java (97%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/global/exception/CustomException.java (84%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/global/exception/CustomExceptionHandler.java (95%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/global/exception/ErrorCode.java (93%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/global/exception/ErrorResponse.java (97%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/global/utils/ApiResult.java (95%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/global/utils/ApiUtils.java (94%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/notification/controller/NotificationController.java (83%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/notification/dto/NotificationFindAllResponse.java (87%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/notification/entity/Notification.java (91%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/notification/mongo/NotificationRepository.java (79%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/notification/service/SSEService.java (86%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/notification/utils/MessageCode.java (99%) rename server2/server-common/src/main/java/{sinhan/server2 => shinhan/server_common}/notification/utils/MessageHandler.java (65%) rename server2/server-common/src/test/java/{sinhan/server1/Server3ApplicationTests.java => shinhan/server1/ServerCommonApplicationTests.java} (79%) create mode 100644 server2/server-parent/src/main/java/shinhan/server_parent/ServerParentApplication.java rename server2/server-parent/src/main/java/{sinhan/server1 => shinhan/server_parent}/domain/account/controller/AccountController.java (70%) create mode 100644 server2/server-parent/src/main/java/shinhan/server_parent/domain/account/entity/Account.java rename server2/server-parent/src/main/java/{sinhan/server1 => shinhan/server_parent}/global/utils/ApiUtils.java (94%) rename server2/server-parent/src/main/java/{sinhan/server1 => shinhan/server_parent}/global/utils/Validator.java (86%) delete mode 100644 server2/server-parent/src/main/java/sinhan/server1/Server1Application.java delete mode 100644 server2/server-parent/src/main/java/sinhan/server1/domain/account/entity/Account.java rename server2/server-parent/src/test/java/{sinhan/server1/Server1ApplicationTests.java => shinhan/server1/ServerParentApplicationTests.java} (72%) diff --git a/server2/server-child/src/main/java/shinhan/server_child/ServerChildApplication.java b/server2/server-child/src/main/java/shinhan/server_child/ServerChildApplication.java new file mode 100644 index 0000000..dd2a670 --- /dev/null +++ b/server2/server-child/src/main/java/shinhan/server_child/ServerChildApplication.java @@ -0,0 +1,18 @@ +package shinhan.server_child; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import shinhan.server_common.ServerCommonApplication; + +@SpringBootApplication(scanBasePackages = {"shinhan.server_child", "shinhan.server_common"}) +public class ServerChildApplication { + + public static void main(String[] args) { + SpringApplication.run(ServerCommonApplication.class, args); + } + +// @RabbitListener(queues = "hello") +// public void listen(String message) { +// System.out.println("Received: " + message); +// } +} \ No newline at end of file diff --git a/server2/server-child/src/main/java/sinhan/server3/domain/AccountController.java b/server2/server-child/src/main/java/shinhan/server_child/domain/AccountController.java similarity index 87% rename from server2/server-child/src/main/java/sinhan/server3/domain/AccountController.java rename to server2/server-child/src/main/java/shinhan/server_child/domain/AccountController.java index c1f09ef..d508eb1 100644 --- a/server2/server-child/src/main/java/sinhan/server3/domain/AccountController.java +++ b/server2/server-child/src/main/java/shinhan/server_child/domain/AccountController.java @@ -1,4 +1,4 @@ -package sinhan.server3.domain; +package shinhan.server_child.domain; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/server2/server-child/src/main/java/sinhan/server3/Server2Application.java b/server2/server-child/src/main/java/sinhan/server3/Server2Application.java deleted file mode 100644 index 0d955dd..0000000 --- a/server2/server-child/src/main/java/sinhan/server3/Server2Application.java +++ /dev/null @@ -1,23 +0,0 @@ -package sinhan.server3; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.FilterType; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; -import sinhan.server2.Server3Application; -import sinhan.server2.notification.mongo.NotificationRepository; - -@SpringBootApplication(scanBasePackages = {"sinhan.server3", "sinhan.server2"}) -public class Server2Application { - - public static void main(String[] args) { - SpringApplication.run(Server3Application.class, args); - } - -// @RabbitListener(queues = "hello") -// public void listen(String message) { -// System.out.println("Received: " + message); -// } -} \ No newline at end of file diff --git a/server2/server-child/src/test/java/sinhan/server1/Server3ApplicationTests.java b/server2/server-child/src/test/java/shinhan/server1/ServerCommonApplicationTests.java similarity index 79% rename from server2/server-child/src/test/java/sinhan/server1/Server3ApplicationTests.java rename to server2/server-child/src/test/java/shinhan/server1/ServerCommonApplicationTests.java index 8bb2e2a..19068ee 100644 --- a/server2/server-child/src/test/java/sinhan/server1/Server3ApplicationTests.java +++ b/server2/server-child/src/test/java/shinhan/server1/ServerCommonApplicationTests.java @@ -1,10 +1,10 @@ -package sinhan.server1; +package shinhan.server1; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -class Server3ApplicationTests { +class ServerCommonApplicationTests { @Test void contextLoads() { diff --git a/server2/server-common/src/main/java/sinhan/server2/Server3Application.java b/server2/server-common/src/main/java/shinhan/server_common/ServerCommonApplication.java similarity index 74% rename from server2/server-common/src/main/java/sinhan/server2/Server3Application.java rename to server2/server-common/src/main/java/shinhan/server_common/ServerCommonApplication.java index 91de36c..ea06c45 100644 --- a/server2/server-common/src/main/java/sinhan/server2/Server3Application.java +++ b/server2/server-common/src/main/java/shinhan/server_common/ServerCommonApplication.java @@ -1,4 +1,4 @@ -package sinhan.server2; +package shinhan.server_common; import org.springframework.boot.SpringApplication; @@ -7,18 +7,18 @@ import org.springframework.context.annotation.FilterType; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; -import sinhan.server2.notification.mongo.NotificationRepository; +import shinhan.server_common.notification.mongo.NotificationRepository; // common @SpringBootApplication//(scanBasePackages = {"server-child", "server-parent"}) @EnableJpaRepositories(excludeFilters = @ComponentScan.Filter( type = FilterType.ASSIGNABLE_TYPE, classes = NotificationRepository.class)) -@EnableMongoRepositories(basePackages = {"sinhan.server2.notification.mongo"}) -public class Server3Application { +@EnableMongoRepositories(basePackages = {"shinhan.server_common.notification.mongo"}) +public class ServerCommonApplication { public static void main(String[] args) { - SpringApplication.run(Server3Application.class, args); + SpringApplication.run(ServerCommonApplication.class, args); } // @RabbitListener(queues = "hello") diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/DartController.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/DartController.java similarity index 77% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/DartController.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/DartController.java index 0b564f3..c0390cb 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/DartController.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/DartController.java @@ -1,12 +1,12 @@ -package sinhan.server2.domain.invest.controller; +package shinhan.server_common.domain.invest.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; -import sinhan.server2.domain.invest.dto.StockFindDetailResponseDTO; -import sinhan.server2.domain.invest.service.StockService; -import sinhan.server2.global.utils.ApiResult; +import shinhan.server_common.domain.invest.dto.StockFindDetailResponseDTO; +import shinhan.server_common.domain.invest.service.StockService; +import shinhan.server_common.global.utils.ApiResult; @RestController public class DartController { diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/InvestController.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/InvestController.java similarity index 90% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/InvestController.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/InvestController.java index 8e3c9aa..331a15c 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/InvestController.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/InvestController.java @@ -1,9 +1,9 @@ -package sinhan.server2.domain.invest.controller; +package shinhan.server_common.domain.invest.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; -import sinhan.server2.global.utils.ApiResult; +import shinhan.server_common.global.utils.ApiResult; public class InvestController { //투자 거래 내역 조회하기(부모) diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/ProposalController.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/ProposalController.java similarity index 96% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/ProposalController.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/ProposalController.java index 9aa7bfc..23ed350 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/ProposalController.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/ProposalController.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.controller; +package shinhan.server_common.domain.invest.controller; import lombok.extern.slf4j.Slf4j; @@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import sinhan.server2.global.utils.ApiResult; +import shinhan.server_common.global.utils.ApiResult; @RestController @Slf4j diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/StockController.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/StockController.java similarity index 90% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/StockController.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/StockController.java index e50baa1..e9aac8b 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/controller/StockController.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/controller/StockController.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.controller; +package shinhan.server_common.domain.invest.controller; import org.springframework.web.bind.annotation.DeleteMapping; @@ -7,8 +7,8 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import sinhan.server2.domain.invest.service.StockService; -import sinhan.server2.global.utils.ApiResult; +import shinhan.server_common.domain.invest.service.StockService; +import shinhan.server_common.global.utils.ApiResult; @RestController public class StockController { diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/dto/StockFindDetailResponseDTO.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/dto/StockFindDetailResponseDTO.java similarity index 85% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/dto/StockFindDetailResponseDTO.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/dto/StockFindDetailResponseDTO.java index 8b61a66..c194244 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/dto/StockFindDetailResponseDTO.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/dto/StockFindDetailResponseDTO.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.dto; +package shinhan.server_common.domain.invest.dto; import java.util.List; import lombok.AllArgsConstructor; @@ -7,7 +7,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import sinhan.server2.domain.invest.entity.StockCartDate; +import shinhan.server_common.domain.invest.entity.StockCartDate; @Getter @Setter diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCartDate.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockCartDate.java similarity index 89% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCartDate.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockCartDate.java index b85d455..a7c70cb 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCartDate.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockCartDate.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.entity; +package shinhan.server_common.domain.invest.entity; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentDetail.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockCurrentDetail.java similarity index 85% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentDetail.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockCurrentDetail.java index 48e12fa..4aad01b 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentDetail.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockCurrentDetail.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.entity; +package shinhan.server_common.domain.invest.entity; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentPriceOutput.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockCurrentPriceOutput.java similarity index 88% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentPriceOutput.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockCurrentPriceOutput.java index ba50d52..bdd9c6d 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockCurrentPriceOutput.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockCurrentPriceOutput.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.entity; +package shinhan.server_common.domain.invest.entity; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.PropertyNamingStrategy; diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideDetail.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDivideDetail.java similarity index 88% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideDetail.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDivideDetail.java index b6acb56..eec6ae8 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideDetail.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDivideDetail.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.entity; +package shinhan.server_common.domain.invest.entity; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.PropertyNamingStrategy; diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideOutput.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDivideOutput.java similarity index 87% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideOutput.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDivideOutput.java index 5d94230..5a9919a 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDivideOutput.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDivideOutput.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.entity; +package shinhan.server_common.domain.invest.entity; import com.fasterxml.jackson.databind.PropertyNamingStrategy; diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDuraionPriceOutput.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDuraionPriceOutput.java similarity index 81% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDuraionPriceOutput.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDuraionPriceOutput.java index e92cab6..5be3e31 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDuraionPriceOutput.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDuraionPriceOutput.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.entity; +package shinhan.server_common.domain.invest.entity; import java.util.List; import lombok.Data; diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDurationDetail.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDurationDetail.java similarity index 93% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDurationDetail.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDurationDetail.java index 7fdc0ee..703c8f2 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockDurationDetail.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockDurationDetail.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.entity; +package shinhan.server_common.domain.invest.entity; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.PropertyNamingStrategy; diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceDetail.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockFianceDetail.java similarity index 86% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceDetail.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockFianceDetail.java index 18807ba..96202f8 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceDetail.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockFianceDetail.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.entity; +package shinhan.server_common.domain.invest.entity; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonNaming; diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceResponseOutput.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockFianceResponseOutput.java similarity index 83% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceResponseOutput.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockFianceResponseOutput.java index 7eb1be0..82b117a 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/entity/StockFianceResponseOutput.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/entity/StockFianceResponseOutput.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.entity; +package shinhan.server_common.domain.invest.entity; import com.fasterxml.jackson.databind.annotation.JsonNaming; import java.util.List; diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/repository/StockRepository.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/repository/StockRepository.java similarity index 61% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/repository/StockRepository.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/repository/StockRepository.java index d3df9f8..42259be 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/repository/StockRepository.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/repository/StockRepository.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.repository; +package shinhan.server_common.domain.invest.repository; import org.springframework.stereotype.Service; diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/invest/service/StockService.java b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/service/StockService.java similarity index 94% rename from server2/server-common/src/main/java/sinhan/server2/domain/invest/service/StockService.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/invest/service/StockService.java index 2393385..e912bab 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/invest/service/StockService.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/invest/service/StockService.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.invest.service; +package shinhan.server_common.domain.invest.service; import java.net.URI; import java.text.SimpleDateFormat; @@ -8,11 +8,11 @@ import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.util.UriBuilder; import reactor.core.publisher.Mono; -import sinhan.server2.domain.invest.dto.StockFindDetailResponseDTO; -import sinhan.server2.domain.invest.entity.StockDivideOutput; -import sinhan.server2.domain.invest.entity.StockDuraionPriceOutput; -import sinhan.server2.domain.invest.entity.StockFianceResponseOutput; -import sinhan.server2.domain.invest.repository.StockRepository; +import shinhan.server_common.domain.invest.dto.StockFindDetailResponseDTO; +import shinhan.server_common.domain.invest.entity.StockDivideOutput; +import shinhan.server_common.domain.invest.entity.StockDuraionPriceOutput; +import shinhan.server_common.domain.invest.entity.StockFianceResponseOutput; +import shinhan.server_common.domain.invest.repository.StockRepository; @Service public class StockService { diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUser.java b/server2/server-common/src/main/java/shinhan/server_common/domain/tempuser/TempUser.java similarity index 91% rename from server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUser.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/tempuser/TempUser.java index 421ede3..3538bad 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUser.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/tempuser/TempUser.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.tempuser; +package shinhan.server_common.domain.tempuser; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUserRepository.java b/server2/server-common/src/main/java/shinhan/server_common/domain/tempuser/TempUserRepository.java similarity index 80% rename from server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUserRepository.java rename to server2/server-common/src/main/java/shinhan/server_common/domain/tempuser/TempUserRepository.java index 363b82e..d7de91d 100644 --- a/server2/server-common/src/main/java/sinhan/server2/domain/tempuser/TempUserRepository.java +++ b/server2/server-common/src/main/java/shinhan/server_common/domain/tempuser/TempUserRepository.java @@ -1,4 +1,4 @@ -package sinhan.server2.domain.tempuser; +package shinhan.server_common.domain.tempuser; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/config/WebClientCongif.java b/server2/server-common/src/main/java/shinhan/server_common/global/config/WebClientCongif.java similarity index 97% rename from server2/server-common/src/main/java/sinhan/server2/global/config/WebClientCongif.java rename to server2/server-common/src/main/java/shinhan/server_common/global/config/WebClientCongif.java index 09f9898..e490e1c 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/config/WebClientCongif.java +++ b/server2/server-common/src/main/java/shinhan/server_common/global/config/WebClientCongif.java @@ -1,4 +1,4 @@ -package sinhan.server2.global.config; +package shinhan.server_common.global.config; import io.netty.channel.ChannelOption; import org.springframework.beans.factory.annotation.Value; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/exception/CustomException.java b/server2/server-common/src/main/java/shinhan/server_common/global/exception/CustomException.java similarity index 84% rename from server2/server-common/src/main/java/sinhan/server2/global/exception/CustomException.java rename to server2/server-common/src/main/java/shinhan/server_common/global/exception/CustomException.java index 9629467..1dd6ca6 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/exception/CustomException.java +++ b/server2/server-common/src/main/java/shinhan/server_common/global/exception/CustomException.java @@ -1,4 +1,4 @@ -package sinhan.server2.global.exception; +package shinhan.server_common.global.exception; import lombok.Getter; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/exception/CustomExceptionHandler.java b/server2/server-common/src/main/java/shinhan/server_common/global/exception/CustomExceptionHandler.java similarity index 95% rename from server2/server-common/src/main/java/sinhan/server2/global/exception/CustomExceptionHandler.java rename to server2/server-common/src/main/java/shinhan/server_common/global/exception/CustomExceptionHandler.java index 8a540b3..86de799 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/exception/CustomExceptionHandler.java +++ b/server2/server-common/src/main/java/shinhan/server_common/global/exception/CustomExceptionHandler.java @@ -1,4 +1,4 @@ -package sinhan.server2.global.exception; +package shinhan.server_common.global.exception; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorCode.java b/server2/server-common/src/main/java/shinhan/server_common/global/exception/ErrorCode.java similarity index 93% rename from server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorCode.java rename to server2/server-common/src/main/java/shinhan/server_common/global/exception/ErrorCode.java index 4ece5de..6276dd9 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorCode.java +++ b/server2/server-common/src/main/java/shinhan/server_common/global/exception/ErrorCode.java @@ -1,4 +1,4 @@ -package sinhan.server2.global.exception; +package shinhan.server_common.global.exception; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorResponse.java b/server2/server-common/src/main/java/shinhan/server_common/global/exception/ErrorResponse.java similarity index 97% rename from server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorResponse.java rename to server2/server-common/src/main/java/shinhan/server_common/global/exception/ErrorResponse.java index c03af43..6160e0f 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/exception/ErrorResponse.java +++ b/server2/server-common/src/main/java/shinhan/server_common/global/exception/ErrorResponse.java @@ -1,4 +1,4 @@ -package sinhan.server2.global.exception; +package shinhan.server_common.global.exception; import lombok.Builder; import lombok.Getter; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/utils/ApiResult.java b/server2/server-common/src/main/java/shinhan/server_common/global/utils/ApiResult.java similarity index 95% rename from server2/server-common/src/main/java/sinhan/server2/global/utils/ApiResult.java rename to server2/server-common/src/main/java/shinhan/server_common/global/utils/ApiResult.java index 37817b8..bd2969d 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/utils/ApiResult.java +++ b/server2/server-common/src/main/java/shinhan/server_common/global/utils/ApiResult.java @@ -1,4 +1,4 @@ -package sinhan.server2.global.utils; +package shinhan.server_common.global.utils; import lombok.Getter; import org.springframework.http.HttpStatus; diff --git a/server2/server-common/src/main/java/sinhan/server2/global/utils/ApiUtils.java b/server2/server-common/src/main/java/shinhan/server_common/global/utils/ApiUtils.java similarity index 94% rename from server2/server-common/src/main/java/sinhan/server2/global/utils/ApiUtils.java rename to server2/server-common/src/main/java/shinhan/server_common/global/utils/ApiUtils.java index 527f10d..cf1d8a5 100644 --- a/server2/server-common/src/main/java/sinhan/server2/global/utils/ApiUtils.java +++ b/server2/server-common/src/main/java/shinhan/server_common/global/utils/ApiUtils.java @@ -1,4 +1,4 @@ -package sinhan.server2.global.utils; +package shinhan.server_common.global.utils; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java b/server2/server-common/src/main/java/shinhan/server_common/notification/controller/NotificationController.java similarity index 83% rename from server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java rename to server2/server-common/src/main/java/shinhan/server_common/notification/controller/NotificationController.java index 434053e..0744ef7 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/controller/NotificationController.java +++ b/server2/server-common/src/main/java/shinhan/server_common/notification/controller/NotificationController.java @@ -1,16 +1,16 @@ -package sinhan.server2.notification.controller; +package shinhan.server_common.notification.controller; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; -import sinhan.server2.notification.dto.NotificationFindAllResponse; -import sinhan.server2.global.utils.ApiUtils; -import sinhan.server2.notification.service.SSEService; +import shinhan.server_common.notification.dto.NotificationFindAllResponse; +import shinhan.server_common.global.utils.ApiUtils; +import shinhan.server_common.notification.service.SSEService; import java.util.List; -import static sinhan.server2.global.utils.ApiUtils.success; +import static shinhan.server_common.global.utils.ApiUtils.success; @RestController @Slf4j diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java b/server2/server-common/src/main/java/shinhan/server_common/notification/dto/NotificationFindAllResponse.java similarity index 87% rename from server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java rename to server2/server-common/src/main/java/shinhan/server_common/notification/dto/NotificationFindAllResponse.java index 1fb944a..fec0295 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/dto/NotificationFindAllResponse.java +++ b/server2/server-common/src/main/java/shinhan/server_common/notification/dto/NotificationFindAllResponse.java @@ -1,10 +1,10 @@ -package sinhan.server2.notification.dto; +package shinhan.server_common.notification.dto; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import sinhan.server2.notification.entity.Notification; +import shinhan.server_common.notification.entity.Notification; import java.time.LocalDateTime; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java b/server2/server-common/src/main/java/shinhan/server_common/notification/entity/Notification.java similarity index 91% rename from server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java rename to server2/server-common/src/main/java/shinhan/server_common/notification/entity/Notification.java index 639463b..06971ee 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/entity/Notification.java +++ b/server2/server-common/src/main/java/shinhan/server_common/notification/entity/Notification.java @@ -1,11 +1,10 @@ -package sinhan.server2.notification.entity; +package shinhan.server_common.notification.entity; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import sinhan.server2.domain.tempuser.TempUser; import java.time.LocalDateTime; import java.util.UUID; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/mongo/NotificationRepository.java b/server2/server-common/src/main/java/shinhan/server_common/notification/mongo/NotificationRepository.java similarity index 79% rename from server2/server-common/src/main/java/sinhan/server2/notification/mongo/NotificationRepository.java rename to server2/server-common/src/main/java/shinhan/server_common/notification/mongo/NotificationRepository.java index 858f652..81a7dee 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/mongo/NotificationRepository.java +++ b/server2/server-common/src/main/java/shinhan/server_common/notification/mongo/NotificationRepository.java @@ -1,7 +1,7 @@ -package sinhan.server2.notification.mongo; +package shinhan.server_common.notification.mongo; import org.springframework.data.mongodb.repository.MongoRepository; -import sinhan.server2.notification.entity.Notification; +import shinhan.server_common.notification.entity.Notification; import java.util.List; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java b/server2/server-common/src/main/java/shinhan/server_common/notification/service/SSEService.java similarity index 86% rename from server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java rename to server2/server-common/src/main/java/shinhan/server_common/notification/service/SSEService.java index 38bf580..911ca72 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/service/SSEService.java +++ b/server2/server-common/src/main/java/shinhan/server_common/notification/service/SSEService.java @@ -1,17 +1,17 @@ -package sinhan.server2.notification.service; +package shinhan.server_common.notification.service; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; -import sinhan.server2.notification.dto.NotificationFindAllResponse; -import sinhan.server2.notification.entity.Notification; -import sinhan.server2.domain.tempuser.TempUser; -import sinhan.server2.domain.tempuser.TempUserRepository; -import sinhan.server2.global.exception.CustomException; -import sinhan.server2.global.exception.ErrorCode; -import sinhan.server2.notification.utils.MessageHandler; +import shinhan.server_common.notification.dto.NotificationFindAllResponse; +import shinhan.server_common.notification.entity.Notification; +import shinhan.server_common.domain.tempuser.TempUser; +import shinhan.server_common.domain.tempuser.TempUserRepository; +import shinhan.server_common.global.exception.CustomException; +import shinhan.server_common.global.exception.ErrorCode; +import shinhan.server_common.notification.utils.MessageHandler; import java.io.IOException; import java.time.ZoneId; @@ -27,7 +27,7 @@ public class SSEService { private final Map sseEmitters = new ConcurrentHashMap<>(); private final TempUserRepository tempUserRepository; - private final sinhan.server2.notification.mongo.NotificationRepository NotificationRepository; + private final shinhan.server_common.notification.mongo.NotificationRepository NotificationRepository; //SSE에 등록 public SseEmitter subscribe(Long serialNumber) { diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java b/server2/server-common/src/main/java/shinhan/server_common/notification/utils/MessageCode.java similarity index 99% rename from server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java rename to server2/server-common/src/main/java/shinhan/server_common/notification/utils/MessageCode.java index 39c45a5..901a56c 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageCode.java +++ b/server2/server-common/src/main/java/shinhan/server_common/notification/utils/MessageCode.java @@ -1,4 +1,4 @@ -package sinhan.server2.notification.utils; +package shinhan.server_common.notification.utils; import java.util.HashMap; import java.util.Map; diff --git a/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java b/server2/server-common/src/main/java/shinhan/server_common/notification/utils/MessageHandler.java similarity index 65% rename from server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java rename to server2/server-common/src/main/java/shinhan/server_common/notification/utils/MessageHandler.java index 788f875..de13f45 100644 --- a/server2/server-common/src/main/java/sinhan/server2/notification/utils/MessageHandler.java +++ b/server2/server-common/src/main/java/shinhan/server_common/notification/utils/MessageHandler.java @@ -1,7 +1,7 @@ -package sinhan.server2.notification.utils; +package shinhan.server_common.notification.utils; -import sinhan.server2.global.exception.CustomException; -import sinhan.server2.global.exception.ErrorCode; +import shinhan.server_common.global.exception.CustomException; +import shinhan.server_common.global.exception.ErrorCode; public class MessageHandler { public static String getMessage(Integer code, Object... args) { diff --git a/server2/server-common/src/test/java/sinhan/server1/Server3ApplicationTests.java b/server2/server-common/src/test/java/shinhan/server1/ServerCommonApplicationTests.java similarity index 79% rename from server2/server-common/src/test/java/sinhan/server1/Server3ApplicationTests.java rename to server2/server-common/src/test/java/shinhan/server1/ServerCommonApplicationTests.java index 8bb2e2a..19068ee 100644 --- a/server2/server-common/src/test/java/sinhan/server1/Server3ApplicationTests.java +++ b/server2/server-common/src/test/java/shinhan/server1/ServerCommonApplicationTests.java @@ -1,10 +1,10 @@ -package sinhan.server1; +package shinhan.server1; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -class Server3ApplicationTests { +class ServerCommonApplicationTests { @Test void contextLoads() { diff --git a/server2/server-parent/src/main/java/shinhan/server_parent/ServerParentApplication.java b/server2/server-parent/src/main/java/shinhan/server_parent/ServerParentApplication.java new file mode 100644 index 0000000..e5f1ed7 --- /dev/null +++ b/server2/server-parent/src/main/java/shinhan/server_parent/ServerParentApplication.java @@ -0,0 +1,17 @@ +package shinhan.server_parent; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication(scanBasePackages = {"shinhan.server_parent", "shinhan.server_common"}) +public class ServerParentApplication { + + public static void main(String[] args) { + SpringApplication.run(ServerParentApplication.class, args); + } + +// @RabbitListener(queues = "hello") +// public void listen(String message) { +// System.out.println("Received: " + message); +// } +} \ No newline at end of file diff --git a/server2/server-parent/src/main/java/sinhan/server1/domain/account/controller/AccountController.java b/server2/server-parent/src/main/java/shinhan/server_parent/domain/account/controller/AccountController.java similarity index 70% rename from server2/server-parent/src/main/java/sinhan/server1/domain/account/controller/AccountController.java rename to server2/server-parent/src/main/java/shinhan/server_parent/domain/account/controller/AccountController.java index 98af38b..01414cc 100644 --- a/server2/server-parent/src/main/java/sinhan/server1/domain/account/controller/AccountController.java +++ b/server2/server-parent/src/main/java/shinhan/server_parent/domain/account/controller/AccountController.java @@ -1,7 +1,6 @@ -package sinhan.server1.domain.account.controller; +package shinhan.server_parent.domain.account.controller; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; @RestController diff --git a/server2/server-parent/src/main/java/shinhan/server_parent/domain/account/entity/Account.java b/server2/server-parent/src/main/java/shinhan/server_parent/domain/account/entity/Account.java new file mode 100644 index 0000000..37fc280 --- /dev/null +++ b/server2/server-parent/src/main/java/shinhan/server_parent/domain/account/entity/Account.java @@ -0,0 +1,4 @@ +package shinhan.server_parent.domain.account.entity; + +public class Account { +} diff --git a/server2/server-parent/src/main/java/sinhan/server1/global/utils/ApiUtils.java b/server2/server-parent/src/main/java/shinhan/server_parent/global/utils/ApiUtils.java similarity index 94% rename from server2/server-parent/src/main/java/sinhan/server1/global/utils/ApiUtils.java rename to server2/server-parent/src/main/java/shinhan/server_parent/global/utils/ApiUtils.java index 22a665d..aab872f 100644 --- a/server2/server-parent/src/main/java/sinhan/server1/global/utils/ApiUtils.java +++ b/server2/server-parent/src/main/java/shinhan/server_parent/global/utils/ApiUtils.java @@ -1,4 +1,4 @@ -package sinhan.server1.global.utils; +package shinhan.server_parent.global.utils; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/server2/server-parent/src/main/java/sinhan/server1/global/utils/Validator.java b/server2/server-parent/src/main/java/shinhan/server_parent/global/utils/Validator.java similarity index 86% rename from server2/server-parent/src/main/java/sinhan/server1/global/utils/Validator.java rename to server2/server-parent/src/main/java/shinhan/server_parent/global/utils/Validator.java index a6164dd..c629cd7 100644 --- a/server2/server-parent/src/main/java/sinhan/server1/global/utils/Validator.java +++ b/server2/server-parent/src/main/java/shinhan/server_parent/global/utils/Validator.java @@ -1,4 +1,4 @@ -package sinhan.server1.global.utils; +package shinhan.server_parent.global.utils; import java.util.regex.Pattern; diff --git a/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java b/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java deleted file mode 100644 index 6775476..0000000 --- a/server2/server-parent/src/main/java/sinhan/server1/Server1Application.java +++ /dev/null @@ -1,19 +0,0 @@ -package sinhan.server1; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; - -@SpringBootApplication(scanBasePackages = {"sinhan.server2", "sinhan.server1"}) -public class Server1Application { - - public static void main(String[] args) { - SpringApplication.run(Server1Application.class, args); - } - -// @RabbitListener(queues = "hello") -// public void listen(String message) { -// System.out.println("Received: " + message); -// } -} \ No newline at end of file diff --git a/server2/server-parent/src/main/java/sinhan/server1/domain/account/entity/Account.java b/server2/server-parent/src/main/java/sinhan/server1/domain/account/entity/Account.java deleted file mode 100644 index 5eeff81..0000000 --- a/server2/server-parent/src/main/java/sinhan/server1/domain/account/entity/Account.java +++ /dev/null @@ -1,4 +0,0 @@ -package sinhan.server1.domain.account.entity; - -public class Account { -} diff --git a/server2/server-parent/src/test/java/sinhan/server1/Server1ApplicationTests.java b/server2/server-parent/src/test/java/shinhan/server1/ServerParentApplicationTests.java similarity index 72% rename from server2/server-parent/src/test/java/sinhan/server1/Server1ApplicationTests.java rename to server2/server-parent/src/test/java/shinhan/server1/ServerParentApplicationTests.java index 1444ee1..3fbad8f 100644 --- a/server2/server-parent/src/test/java/sinhan/server1/Server1ApplicationTests.java +++ b/server2/server-parent/src/test/java/shinhan/server1/ServerParentApplicationTests.java @@ -1,10 +1,10 @@ -package sinhan.server1; +package shinhan.server1; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -class Server1ApplicationTests { +class ServerParentApplicationTests { @Test void contextLoads() { From 15024662ec1118fc660c439fc873ac37c9114e9c Mon Sep 17 00:00:00 2001 From: allllfo Date: Wed, 19 Jun 2024 09:55:31 +0900 Subject: [PATCH 16/19] =?UTF-8?q?refactor=20:=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=EB=B6=80=EB=B6=84=20=EC=A3=BC=EC=84=9D?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/NotificationController.java | 7 ++++--- .../server_common/notification/service/SSEService.java | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/server2/server-common/src/main/java/shinhan/server_common/notification/controller/NotificationController.java b/server2/server-common/src/main/java/shinhan/server_common/notification/controller/NotificationController.java index 0744ef7..6df2664 100644 --- a/server2/server-common/src/main/java/shinhan/server_common/notification/controller/NotificationController.java +++ b/server2/server-common/src/main/java/shinhan/server_common/notification/controller/NotificationController.java @@ -28,27 +28,28 @@ public class NotificationController { // } + //SSE 연결하기 userSerialNumber -> User 들어오면 바뀔 예정 @GetMapping("/subscribe/{usn}") public SseEmitter subscribeSSE(@PathVariable("usn") Long usn){ return sseService.subscribe(usn); } - //해당 사용자의 모든 알림 가져오기 + //해당 사용자의 모든 알림 가져오기 userSerialNumber -> User 들어오면 바뀔 예정 @GetMapping("/{usn}") public ApiUtils.ApiResult findAllNotifications(@PathVariable("usn") Long usn){ List response = sseService.findAllNotifications(usn); return success(response); } - //개별 알림 삭제하기 + //개별 알림 삭제하기 notificationSerialNumber @DeleteMapping("/{nsn}") public ApiUtils.ApiResult deleteNotification( @PathVariable("nsn") String nsn){ sseService.deleteNotification(nsn); return success(null); } - //알림 전체 삭제하기 + //알림 전체 삭제하기 - rsn : receiverSerialNumber @DeleteMapping("/all/{rsn}") public ApiUtils.ApiResult deleteNotification(@PathVariable("rsn") Long rsn){ sseService.deleteAllNotifications(rsn); diff --git a/server2/server-common/src/main/java/shinhan/server_common/notification/service/SSEService.java b/server2/server-common/src/main/java/shinhan/server_common/notification/service/SSEService.java index 911ca72..5dcd72a 100644 --- a/server2/server-common/src/main/java/shinhan/server_common/notification/service/SSEService.java +++ b/server2/server-common/src/main/java/shinhan/server_common/notification/service/SSEService.java @@ -33,11 +33,11 @@ public class SSEService { public SseEmitter subscribe(Long serialNumber) { SseEmitter emitter = new SseEmitter(7200000L);// 2시간 타임아웃 sseEmitters.put(serialNumber, emitter); - - //이부분은 원래 없음 - String newMesssage= MessageHandler.getMessage(0,"알파코"); - sendNotification(serialNumber, "alfo", 1, newMesssage); - //여기까지 원래 없음 +// +// //이부분은 원래 없음 +// String newMesssage= MessageHandler.getMessage(0,"알파코"); +// sendNotification(serialNumber, "alfo", 1, newMesssage); +// //여기까지 원래 없음 emitter.onCompletion(()-> sseEmitters.remove(serialNumber)); emitter.onTimeout(()->{ From 414d7dc333ad65d69afc1dd5f9df33d0cc945790 Mon Sep 17 00:00:00 2001 From: Future <86925185+allllfo@users.noreply.github.com> Date: Wed, 19 Jun 2024 10:22:27 +0900 Subject: [PATCH 17/19] =?UTF-8?q?refactor=20:=20mongodb=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.properties | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 server2/server-parent/src/main/resources/application.properties diff --git a/server2/server-parent/src/main/resources/application.properties b/server2/server-parent/src/main/resources/application.properties deleted file mode 100644 index 96a726f..0000000 --- a/server2/server-parent/src/main/resources/application.properties +++ /dev/null @@ -1,17 +0,0 @@ -spring.application.name=server_parent - - -spring.rabbitmq.host=localhost -spring.rabbitmq.port=5672 -spring.rabbitmq.username=guest -spring.rabbitmq.password=guest - -spring.datasource.url=jdbc:mysql://localhost:3306/isol -spring.datasource.username=root -spring.datasource.password=Rlaalfo430, -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver - -spring.data.mongodb.uri=mongodb+srv://mirae4292:rlaalfo430@cluster0.swp3udx.mongodb.net/isol?retryWrites=true&w=majority&appName=Cluster0 - -server.port=8081 - From ee0d62299c9ebe115556c3cce4439c7b4625731e Mon Sep 17 00:00:00 2001 From: allllfo Date: Wed, 19 Jun 2024 10:23:15 +0900 Subject: [PATCH 18/19] =?UTF-8?q?refactor=20:=20mongo=20=EA=B4=80=EB=A0=A8?= =?UTF-8?q?=20=EC=9E=AC=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.properties | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 server2/server-parent/src/main/resources/application.properties diff --git a/server2/server-parent/src/main/resources/application.properties b/server2/server-parent/src/main/resources/application.properties deleted file mode 100644 index 96a726f..0000000 --- a/server2/server-parent/src/main/resources/application.properties +++ /dev/null @@ -1,17 +0,0 @@ -spring.application.name=server_parent - - -spring.rabbitmq.host=localhost -spring.rabbitmq.port=5672 -spring.rabbitmq.username=guest -spring.rabbitmq.password=guest - -spring.datasource.url=jdbc:mysql://localhost:3306/isol -spring.datasource.username=root -spring.datasource.password=Rlaalfo430, -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver - -spring.data.mongodb.uri=mongodb+srv://mirae4292:rlaalfo430@cluster0.swp3udx.mongodb.net/isol?retryWrites=true&w=majority&appName=Cluster0 - -server.port=8081 - From ce70efa2888f43bc825a0ea20759b52a7bc4c7ac Mon Sep 17 00:00:00 2001 From: allllfo Date: Wed, 19 Jun 2024 10:26:25 +0900 Subject: [PATCH 19/19] =?UTF-8?q?git=20:=20cache=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server2/.env | 0 server2/gradle/wrapper/gradle-wrapper.properties | 7 ------- 2 files changed, 7 deletions(-) delete mode 100644 server2/.env delete mode 100644 server2/gradle/wrapper/gradle-wrapper.properties diff --git a/server2/.env b/server2/.env deleted file mode 100644 index e69de29..0000000 diff --git a/server2/gradle/wrapper/gradle-wrapper.properties b/server2/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index a441313..0000000 --- a/server2/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists