Skip to content

Commit ede6158

Browse files
committed
release 1.0.0 버전
1 parent 0827a9a commit ede6158

21 files changed

+359
-182
lines changed
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
package me.gijung.DMforU.AOP;
2-
3-
import lombok.extern.slf4j.Slf4j;
4-
import org.aspectj.lang.JoinPoint;
5-
import org.aspectj.lang.ProceedingJoinPoint;
6-
import org.aspectj.lang.annotation.*;
7-
import org.aspectj.lang.reflect.MethodSignature;
8-
import org.springframework.stereotype.Component;
9-
import org.springframework.util.StopWatch;
10-
import org.springframework.web.context.request.RequestContextHolder;
11-
import org.springframework.web.context.request.ServletRequestAttributes;
12-
13-
14-
import java.lang.reflect.Method;
15-
16-
@Component
17-
@Slf4j
18-
@Aspect
19-
public class ControllerAOP {
20-
21-
22-
@Pointcut("execution(* me.gijung.DMforU.controller..*.*(..))")
23-
public void pointCut() {
24-
}
25-
26-
// //Controller 시간
27-
// @Around("pointcut()")
28-
// public void time_lapse(ProceedingJoinPoint joinPoint) throws Throwable {
29-
// StopWatch stopWatch = new StopWatch();
30-
// stopWatch.start();
31-
// joinPoint.proceed();
32-
// stopWatch.stop();
33-
// log.info(stopWatch.prettyPrint());
34-
// log.info(String.valueOf(stopWatch.getTotalTimeSeconds()));
1+
package me.gijung.DMforU.AOP;//package me.gijung.DMforU.AOP;
2+
//
3+
//import lombok.extern.slf4j.Slf4j;
4+
//import org.aspectj.lang.JoinPoint;
5+
//import org.aspectj.lang.ProceedingJoinPoint;
6+
//import org.aspectj.lang.annotation.*;
7+
//import org.aspectj.lang.reflect.MethodSignature;
8+
//import org.springframework.stereotype.Component;
9+
//import org.springframework.util.StopWatch;
10+
//import org.springframework.web.context.request.RequestContextHolder;
11+
//import org.springframework.web.context.request.ServletRequestAttributes;
12+
//
13+
//
14+
//import java.lang.reflect.Method;
15+
//
16+
//@Component
17+
//@Slf4j
18+
//@Aspect
19+
//public class ControllerAOP {
20+
//
21+
//
22+
// @Pointcut("execution(* me.gijung.DMforU.controller..*.*(..))")
23+
// public void pointCut() {
3524
// }
36-
37-
// Controller 메소드 수행이 성공하면 , Method이름 경로 기록
38-
@AfterReturning("pointCut()")
39-
public void controllerLog(JoinPoint joinPoint) {
40-
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
41-
Method method = signature.getMethod();
42-
ServletRequestAttributes attribute = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
43-
log.info("Method_Name :: {} || URL :: {}",method.getName(),attribute.getRequest().getRequestURI());
44-
}
45-
46-
}
25+
//
26+
//// //Controller 시간
27+
//// @Around("pointcut()")
28+
//// public void time_lapse(ProceedingJoinPoint joinPoint) throws Throwable {
29+
//// StopWatch stopWatch = new StopWatch();
30+
//// stopWatch.start();
31+
//// joinPoint.proceed();
32+
//// stopWatch.stop();
33+
//// log.info(stopWatch.prettyPrint());
34+
//// log.info(String.valueOf(stopWatch.getTotalTimeSeconds()));
35+
//// }
36+
//
37+
// // Controller 메소드 수행이 성공하면 , Method이름 경로 기록
38+
// @AfterReturning("pointCut()")
39+
// public void controllerLog(JoinPoint joinPoint) {
40+
// MethodSignature signature = (MethodSignature) joinPoint.getSignature();
41+
// Method method = signature.getMethod();
42+
// ServletRequestAttributes attribute = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
43+
// log.info("Method_Name :: {} || URL :: {}",method.getName(),attribute.getRequest().getRequestURI());
44+
// }
45+
//
46+
//}
Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
package me.gijung.DMforU.AOP;
2-
3-
import lombok.extern.slf4j.Slf4j;
4-
import org.aspectj.lang.ProceedingJoinPoint;
5-
import org.aspectj.lang.annotation.Around;
6-
import org.aspectj.lang.annotation.Aspect;
7-
import org.aspectj.lang.annotation.Pointcut;
8-
import org.aspectj.lang.reflect.MethodSignature;
9-
import org.springframework.stereotype.Component;
10-
import org.springframework.util.StopWatch;
11-
12-
import java.lang.reflect.Method;
13-
14-
@Aspect
15-
@Component
16-
@Slf4j
17-
public class ServiceAOP {
18-
@Pointcut("execution(* me.gijung.DMforU.service.token..*.*(..))")
19-
public void pointcut() {
20-
}
21-
22-
//Service 로직 시간 측정
23-
@Around("pointcut()")
24-
public void timeLapse(ProceedingJoinPoint joinPoint) throws Throwable {
25-
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
26-
Method method = signature.getMethod();
27-
Class<?> declaringClass = method.getDeclaringClass();
28-
StopWatch stopWatch = new StopWatch();
29-
stopWatch.start();
30-
joinPoint.proceed();
31-
stopWatch.stop();
32-
log.info(declaringClass.getSimpleName());
33-
log.info(stopWatch.prettyPrint());
34-
log.info(String.valueOf(stopWatch.getTotalTimeSeconds()));
35-
log.info(String.valueOf(Thread.currentThread()));
36-
}
37-
}
1+
package me.gijung.DMforU.AOP;//package me.gijung.DMforU.AOP;
2+
//
3+
//import lombok.extern.slf4j.Slf4j;
4+
//import org.aspectj.lang.ProceedingJoinPoint;
5+
//import org.aspectj.lang.annotation.Around;
6+
//import org.aspectj.lang.annotation.Aspect;
7+
//import org.aspectj.lang.annotation.Pointcut;
8+
//import org.aspectj.lang.reflect.MethodSignature;
9+
//import org.springframework.stereotype.Component;
10+
//import org.springframework.util.StopWatch;
11+
//
12+
//import java.lang.reflect.Method;
13+
//
14+
//@Aspect
15+
//@Component
16+
//@Slf4j
17+
//public class ServiceAOP {
18+
// @Pointcut("execution(* me.gijung.DMforU.service..*.*(..))")
19+
// public void pointcut() {
20+
// }
21+
//
22+
// //Service 로직 시간 측정
23+
// @Around("pointcut()")
24+
// public void timeLapse(ProceedingJoinPoint joinPoint) throws Throwable {
25+
// MethodSignature signature = (MethodSignature) joinPoint.getSignature();
26+
// Method method = signature.getMethod();
27+
// Class<?> declaringClass = method.getDeclaringClass();
28+
// StopWatch stopWatch = new StopWatch();
29+
// stopWatch.start();
30+
// joinPoint.proceed();
31+
// stopWatch.stop();
32+
// log.info(declaringClass.getSimpleName());
33+
// log.info(stopWatch.prettyPrint());
34+
// log.info(String.valueOf(stopWatch.getTotalTimeSeconds()));
35+
// }
36+
//}

src/main/java/me/gijung/DMforU/config/RedisConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.google.firebase.messaging.FirebaseMessaging;
44
import com.google.firebase.messaging.FirebaseMessagingException;
55
import lombok.RequiredArgsConstructor;
6-
76
import me.gijung.DMforU.model.dto.TokensDto;
7+
88
import org.springframework.context.annotation.Bean;
99
import org.springframework.context.annotation.Configuration;
1010
import org.springframework.data.redis.connection.Message;
@@ -48,7 +48,7 @@ public void onMessage(Message message, byte[] pattern) {
4848
String expiredKey = new String(message.getBody());
4949
TokensDto tokensDto = TokensDto
5050
.builder()
51-
.token(expiredKey)
51+
.tokens(Collections.singletonList(expiredKey))
5252
.build();
5353
try {
5454
AllDeleteTopic(tokensDto);
@@ -75,7 +75,7 @@ private void AllDeleteTopic(TokensDto tokensDto) throws FirebaseMessagingExcepti
7575
.getInstance();
7676
EnumSet<Topic> topics = EnumSet.allOf(Topic.class);
7777
for (Topic topic : topics) {
78-
instance.unsubscribeFromTopic(Collections.singletonList(tokensDto.getToken()), String.valueOf(topic));
78+
instance.unsubscribeFromTopic(tokensDto.getTokens(), String.valueOf(topic));
7979
}
8080
}
8181
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package me.gijung.DMforU.config;//package me.gijung.DMforU.config;
2+
//
3+
//import org.springframework.context.annotation.Bean;
4+
//import org.springframework.context.annotation.Configuration;
5+
//import org.springframework.web.servlet.config.annotation.EnableWebMvc;
6+
//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
7+
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
8+
//import springfox.documentation.builders.ApiInfoBuilder;
9+
//import springfox.documentation.builders.PathSelectors;
10+
//import springfox.documentation.builders.RequestHandlerSelectors;
11+
//import springfox.documentation.service.ApiInfo;
12+
//import springfox.documentation.spi.DocumentationType;
13+
//import springfox.documentation.spring.web.plugins.Docket;
14+
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
15+
//
16+
//@Configuration
17+
//@EnableWebMvc
18+
//@EnableSwagger2
19+
//public class SwaggerConfig implements WebMvcConfigurer {
20+
//
21+
// /*
22+
// Docket: Swagger 설정의 핵심이 되는 Bean
23+
// useDefaultResponseMessages: Swagger 에서 제공해주는 기본 응답 코드 (200, 401, 403, 404). false 로 설정하면 기본 응답 코드를 노출하지 않음
24+
// apis: api 스펙이 작성되어 있는 패키지 (Controller) 를 지정
25+
// paths: apis 에 있는 API 중 특정 path 를 선택
26+
// apiInfo:Swagger UI 로 노출할 정보
27+
// */
28+
//
29+
// private static final String SERVICE_NAME = "Make Project";
30+
// private static final String API_VERSION = "V1";
31+
// private static final String API_DESCRIPTION = "MakeProject API TEST";
32+
// private static final String API_URL = "http://localhost:8080/";
33+
//
34+
// @Bean
35+
// public Docket api() {
36+
// return new Docket(DocumentationType.SWAGGER_2)
37+
// .apiInfo(apiInfo())
38+
// .select()
39+
// .apis(RequestHandlerSelectors.any()) // RequestMapping의 모든 URL LIST
40+
// .paths(PathSelectors.any()) // .any() -> ant(/api/**") /api/**인 URL만 표시
41+
// .build();
42+
// }
43+
//
44+
// private ApiInfo apiInfo() {
45+
// return new ApiInfoBuilder().title(SERVICE_NAME) // 서비스명
46+
// .version(API_VERSION) // API 버전
47+
// .description(API_DESCRIPTION) // API 설명
48+
// .termsOfServiceUrl(API_URL) // 서비스 url
49+
// .licenseUrl("라이센스 표시할 url")
50+
// .build();
51+
//
52+
// }// API INFO
53+
//
54+
// // 아래 부분은 WebMvcConfigure 를 상속받아서 설정하는 Mehtod
55+
// @Override
56+
// public void addResourceHandlers(ResourceHandlerRegistry registry) {
57+
// registry.addResourceHandler("/swagger-ui.html")
58+
// .addResourceLocations("classpath:/META-INF/resources/");
59+
//
60+
// registry.addResourceHandler("/webjars/**")
61+
// .addResourceLocations("classpath:/META-INF/resources/webjars/");
62+
// // -- Static resources
63+
// registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
64+
//
65+
// }
66+
//}

src/main/java/me/gijung/DMforU/controller/DepartmentController.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,39 @@
22

33
import lombok.RequiredArgsConstructor;
44
import me.gijung.DMforU.model.dto.DepartmentDto;
5-
import me.gijung.DMforU.service.redis.Department;
5+
import me.gijung.DMforU.model.dto.DepartmentRequestDto;
6+
import me.gijung.DMforU.model.dto.TokenRequestDto;
7+
import me.gijung.DMforU.service.DepartmentService;
68
import org.springframework.web.bind.annotation.PostMapping;
79
import org.springframework.web.bind.annotation.RequestBody;
810
import org.springframework.web.bind.annotation.RequestMapping;
911
import org.springframework.web.bind.annotation.RestController;
1012

13+
import java.util.Arrays;
14+
1115
@RestController
1216
@RequestMapping("/department/v1/dmu")
1317
@RequiredArgsConstructor
1418
public class DepartmentController {
1519

16-
private final Department departmentService;
20+
private final DepartmentService departmentService;
21+
22+
@PostMapping("/createDepartment")
23+
public void createDepartment(@RequestBody DepartmentRequestDto departmentRequestDto) {
24+
departmentService.createDepartment(
25+
new DepartmentDto(Arrays.asList(departmentRequestDto.getToken()), departmentRequestDto.getDepartment())
26+
);
27+
}
1728

1829
@PostMapping("/updateDepartment")
19-
public void updateDepartment(@RequestBody DepartmentDto departmentDto) {
20-
departmentService.updateDepartment(departmentDto);
30+
public void updateDepartment(@RequestBody DepartmentRequestDto departmentRequestDto) {
31+
departmentService.updateDepartment(
32+
new DepartmentDto(Arrays.asList(departmentRequestDto.getToken()), departmentRequestDto.getDepartment())
33+
);
2134
}
2235

2336
@PostMapping("/deleteDepartment")
24-
public void deleteDepartment(@RequestBody DepartmentDto departmentDto) {
25-
departmentService.deleteDepartment(departmentDto);
37+
public void deleteDepartment(@RequestBody TokenRequestDto tokenRequestDto) {
38+
departmentService.deleteDepartment(tokenRequestDto.getToken());
2639
}
2740
}

src/main/java/me/gijung/DMforU/controller/TokenController.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
import com.google.firebase.messaging.FirebaseMessagingException;
44
import lombok.AllArgsConstructor;
5-
import me.gijung.DMforU.model.dto.RequestTokenDto;
5+
import me.gijung.DMforU.model.dto.TokenRequestDto;
6+
import me.gijung.DMforU.model.dto.TokensDto;
7+
import me.gijung.DMforU.model.dto.TopicRequestDto;
68
import me.gijung.DMforU.service.TokenService;
79
import org.springframework.web.bind.annotation.*;
810

11+
import java.util.Arrays;
912
import java.util.concurrent.ExecutionException;
1013

1114
@RestController
@@ -15,22 +18,34 @@ public class TokenController {
1518

1619
private final TokenService tokenService;
1720

21+
1822
//기존 Token TTL Refresh
1923
@PostMapping("/refreshToken")
20-
public void refreshTopic(@RequestBody RequestTokenDto tokensDto){
21-
tokenService.refreshToken(tokensDto);
24+
public void refreshTopic(@RequestBody TokenRequestDto tokenRequestDto){
25+
tokenService.refreshToken(tokenRequestDto.getToken());
26+
}
27+
28+
//신규 Token 생성 URL
29+
@PostMapping("/createTopic")
30+
public void createTopic(@RequestBody TopicRequestDto tokenDto){
31+
tokenService.createToken(
32+
new TokensDto(Arrays.asList(tokenDto.getToken()), tokenDto.getTopics())
33+
);
2234
}
2335

2436
//redisService.updateToken = Token 유효시간 갱신 및 Token Redis Server에 등록
2537
//messageService.updateToken = Google FCM token & Topic 등록
2638
@PostMapping("/updateTopic")
27-
public void updateTopic(@RequestBody RequestTokenDto tokensDto) throws FirebaseMessagingException, ExecutionException, InterruptedException {
28-
tokenService.updateTopic(tokensDto);
39+
public void updateTopic(@RequestBody TopicRequestDto tokenDto) throws ExecutionException, FirebaseMessagingException, InterruptedException {
40+
tokenService.updateToken(
41+
new TokensDto(Arrays.asList(tokenDto.getToken()), tokenDto.getTopics())
42+
);
2943
}
3044

3145
//Topic 구독 취소, 추후에 무결성 검증 로직 추가
46+
3247
@PostMapping("/deleteTopic")
33-
public void deleteTopic(@RequestBody RequestTokenDto tokensDto) {
34-
tokenService.deleteTopic(tokensDto);
48+
public void deleteTopic(@RequestBody TokenRequestDto tokenRequestDto) {
49+
tokenService.deleteToken(tokenRequestDto.getToken());
3550
}
3651
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package me.gijung.DMforU.controller;
2+
3+
import lombok.RequiredArgsConstructor;
4+
import me.gijung.DMforU.model.dto.DepartmentDto;
5+
import me.gijung.DMforU.model.dto.InitRequestDto;
6+
import me.gijung.DMforU.model.dto.TokensDto;
7+
import me.gijung.DMforU.service.DepartmentService;
8+
import me.gijung.DMforU.service.TokenService;
9+
import org.springframework.web.bind.annotation.PostMapping;
10+
import org.springframework.web.bind.annotation.RequestBody;
11+
import org.springframework.web.bind.annotation.RequestMapping;
12+
import org.springframework.web.bind.annotation.RestController;
13+
14+
import java.util.Arrays;
15+
16+
@RestController
17+
@RequiredArgsConstructor
18+
@RequestMapping("/token/v1/dmu")
19+
public class initController {
20+
21+
private final TokenService tokenService;
22+
private final DepartmentService departmentService;
23+
24+
@PostMapping("/initToken")
25+
public void createTopic(@RequestBody InitRequestDto initRequestDto){
26+
27+
tokenService.createToken(
28+
new TokensDto(Arrays.asList(initRequestDto.getToken()), initRequestDto.getTopics())
29+
);
30+
departmentService.createDepartment(
31+
new DepartmentDto(Arrays.asList(initRequestDto.getToken()), initRequestDto.getDepartment())
32+
);
33+
}
34+
}

0 commit comments

Comments
 (0)