Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat : 알림 api 생성 #16

Merged
merged 20 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f0fb02b
feat : 알림 기능을 위한 SSE 초기 세팅
allllfo Jun 17, 2024
2a6f71d
feat(WIP) : 알림 SSE 초기세팅 및 api 개발중
allllfo Jun 18, 2024
3e019ed
feat : mongoDB 사용을 위한 dependency 추가
allllfo Jun 18, 2024
3fc27a5
Feat : mongoDB를 위한 세팅
allllfo Jun 18, 2024
756dc12
refactor : mongoDB 오류 해결을 위한 패키지 이동(임시)
allllfo Jun 18, 2024
cb98447
feat : mongoDB 해결을 위한 어노테이션 추가
allllfo Jun 18, 2024
99f51f6
refactor : 기존의 apiUtils 추가
allllfo Jun 18, 2024
7000f13
feat : 알림 삭제, 알림 전체 삭제 api 완성
allllfo Jun 18, 2024
02aefe5
feat: 알람 전체 조회 api 생성
allllfo Jun 18, 2024
f864ed6
feat : Utils 폴더 생성 후 messageCode, messageHandler 생성
allllfo Jun 18, 2024
c91f8f2
refactor: Notification클래스안의 messageCode int를 message String으로 변경
allllfo Jun 18, 2024
e977a0e
refactor : notification폴더 global 안으로 이동, 레포지토리 이름 변경
allllfo Jun 18, 2024
3fbe938
refactor : notification폴더 global 안에서 다시 빼냄
allllfo Jun 18, 2024
9c54190
refactor : mongo, JPA 에서 Bean overriding 되는 것 해결!
allllfo Jun 19, 2024
192cfae
refactor : shinhan이름 변경, module server 이름들 변경
allllfo Jun 19, 2024
1502466
refactor : 불필요한부분 주석처리
allllfo Jun 19, 2024
414d7dc
refactor : mongodb 변경
allllfo Jun 19, 2024
ee0d622
refactor : mongo 관련 재변경
allllfo Jun 19, 2024
bb805a0
Merge branch 'feature/13-notification' of https://github.com/ii-sol/b…
allllfo Jun 19, 2024
ce70efa
git : cache 삭제
allllfo Jun 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed server2/.env
Empty file.
1 change: 1 addition & 0 deletions server2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ 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 파일로 하겠다는 의미
Expand Down
7 changes: 0 additions & 7 deletions server2/gradle/wrapper/gradle-wrapper.properties

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package sinhan.server1;

package shinhan.server_child;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import shinhan.server_common.ServerCommonApplication;

@SpringBootApplication(scanBasePackages = {"server-child", "server-parent"})
public class Server3Application {
@SpringBootApplication(scanBasePackages = {"shinhan.server_child", "shinhan.server_common"})
public class ServerChildApplication {

public static void main(String[] args) {
SpringApplication.run(Server3Application.class, args);
SpringApplication.run(ServerCommonApplication.class, args);
}

// @RabbitListener(queues = "hello")
// public void listen(String message) {
// System.out.println("Received: " + message);
// }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain;
package shinhan.server_child.domain;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
4 changes: 4 additions & 0 deletions server2/server-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package shinhan.server_common;


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 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 = {"shinhan.server_common.notification.mongo"})
public class ServerCommonApplication {

public static void main(String[] args) {
SpringApplication.run(ServerCommonApplication.class, args);
}

// @RabbitListener(queues = "hello")
// public void listen(String message) {
// System.out.println("Received: " + message);
// }
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package sinhan.server1.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.server1.domain.invest.dto.StockFindDetailResponseDTO;
import sinhan.server1.domain.invest.service.StockService;
import sinhan.server1.domain.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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package sinhan.server1.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.server1.domain.utils.ApiResult;
import shinhan.server_common.global.utils.ApiResult;

public class InvestController {
//투자 거래 내역 조회하기(부모)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.controller;
package shinhan.server_common.domain.invest.controller;


import lombok.extern.slf4j.Slf4j;
Expand All @@ -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.domain.utils.ApiResult;
import shinhan.server_common.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<Integer> stringApiResult = ApiResult.responseSuccess(childOrder);
return stringApiResult;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.controller;
package shinhan.server_common.domain.invest.controller;


import org.springframework.web.bind.annotation.DeleteMapping;
Expand All @@ -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.domain.utils.ApiResult;
import shinhan.server_common.domain.invest.service.StockService;
import shinhan.server_common.global.utils.ApiResult;

@RestController
public class StockController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.dto;
package shinhan.server_common.domain.invest.dto;

import java.util.List;
import lombok.AllArgsConstructor;
Expand All @@ -7,7 +7,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import sinhan.server1.domain.invest.entity.StockCartDate;
import shinhan.server_common.domain.invest.entity.StockCartDate;

@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.entity;
package shinhan.server_common.domain.invest.entity;

import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.entity;
package shinhan.server_common.domain.invest.entity;

import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.entity;
package shinhan.server_common.domain.invest.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.entity;
package shinhan.server_common.domain.invest.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.entity;
package shinhan.server_common.domain.invest.entity;


import com.fasterxml.jackson.databind.PropertyNamingStrategy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.entity;
package shinhan.server_common.domain.invest.entity;

import java.util.List;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.entity;
package shinhan.server_common.domain.invest.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.entity;
package shinhan.server_common.domain.invest.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.entity;
package shinhan.server_common.domain.invest.entity;

import com.fasterxml.jackson.databind.annotation.JsonNaming;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.repository;
package shinhan.server_common.domain.invest.repository;

import org.springframework.stereotype.Service;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.domain.invest.service;
package shinhan.server_common.domain.invest.service;

import java.net.URI;
import java.text.SimpleDateFormat;
Expand All @@ -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 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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package shinhan.server_common.domain.tempuser;

import jakarta.persistence.*;
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;

@Column(name = "serial_num", unique = true)
Long serialNumber;

String name;

@Builder
public TempUser( Long serialNumber, String name) {
this.serialNumber = serialNumber;
this.name = name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package shinhan.server_common.domain.tempuser;

import org.springframework.data.jpa.repository.JpaRepository;

public interface TempUserRepository extends JpaRepository<TempUser,Integer> {
TempUser findBySerialNumber(Long serialNumber);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sinhan.server1.global.config;
package shinhan.server_common.global.config;

import io.netty.channel.ChannelOption;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package shinhan.server_common.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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package shinhan.server_common.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<ErrorResponse> handleCustomException(CustomException e) {
return ErrorResponse.toResponseEntity(e);
}

// bean validation 관련 에러
@ExceptionHandler(MethodArgumentNotValidException.class)
protected ResponseEntity<ErrorResponse> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {

FieldError fieldError = e.getFieldError();

log.info(fieldError.toString());
return ErrorResponse.toResponseEntity(HttpStatus.BAD_REQUEST, fieldError);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package shinhan.server_common.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, "알람 보내기에 실패했습니다."),

NOT_FOUND_MESSAGECODE(HttpStatus.NOT_FOUND, "저장된 알림 메세지 형식을 찾을 수 없습니다.");

private final HttpStatus status;
private final String message;
}
Loading