Skip to content

Commit 22f7be8

Browse files
authored
Release v1.0
Release v1.0
2 parents 03a6d8d + 2f47967 commit 22f7be8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+783
-117
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ build/
3333
.vscode/
3434

3535
data
36+
37+
logs

lombok.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copy the Qualifier and Value annotations from the instance variables to the constructor
2+
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier
3+
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Value

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@
116116
<version>3.3.0</version>
117117
</dependency>
118118

119+
<dependency>
120+
<groupId>org.springframework.boot</groupId>
121+
<artifactId>spring-boot-starter-mail</artifactId>
122+
<version>3.3.4</version>
123+
</dependency>
119124
</dependencies>
120125

121126
<build>

src/main/java/com/example/ecm/DemoApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import io.swagger.v3.oas.annotations.responses.ApiResponse;
44
import org.springframework.boot.SpringApplication;
55
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.scheduling.annotation.EnableScheduling;
67

78
@ApiResponse(responseCode = "200", description = "Hello World")
9+
@EnableScheduling
810
@SpringBootApplication
911
public class DemoApplication {
1012

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.example.ecm.aop;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import lombok.extern.slf4j.Slf4j;
5+
import org.aspectj.lang.ProceedingJoinPoint;
6+
import org.aspectj.lang.annotation.Around;
7+
import org.aspectj.lang.annotation.Aspect;
8+
import org.aspectj.lang.annotation.Pointcut;
9+
import org.springframework.stereotype.Component;
10+
11+
@Slf4j
12+
@Aspect
13+
@Component
14+
public class Log {
15+
16+
@Pointcut("@annotation(Loggable)")
17+
public void logExecutionTimeMethod() {
18+
}
19+
20+
@Pointcut("@within(Loggable)")
21+
public void logExecutionTimeClass() {
22+
}
23+
24+
@Around("logExecutionTimeMethod() || logExecutionTimeClass()")
25+
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
26+
long start = System.currentTimeMillis();
27+
28+
Object proceed = joinPoint.proceed();
29+
ObjectMapper objectMapper = new ObjectMapper();
30+
31+
long executionTime = System.currentTimeMillis() - start;
32+
33+
log.info("Method {} in class {} executed in {} ms with args {}",
34+
joinPoint.getSignature().getName(),
35+
joinPoint.getTarget().getClass().getSimpleName(),
36+
executionTime,
37+
objectMapper.writeValueAsString(joinPoint.getArgs()));
38+
39+
return proceed;
40+
}
41+
}
42+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.example.ecm.aop;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
@Target({ElementType.METHOD, ElementType.TYPE})
9+
@Retention(RetentionPolicy.RUNTIME)
10+
public @interface Loggable {
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.example.ecm.config;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.scheduling.annotation.EnableAsync;
5+
6+
@Configuration
7+
@EnableAsync
8+
public class AsyncConfig {
9+
}
10+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.example.ecm.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
import java.util.concurrent.Executors;
7+
import java.util.concurrent.ScheduledExecutorService;
8+
9+
@Configuration
10+
public class VotingConfig {
11+
12+
@Bean("votingFinisherScheduler")
13+
public ScheduledExecutorService scheduledExecutorService() {
14+
return Executors.newScheduledThreadPool(10);
15+
}
16+
}

src/main/java/com/example/ecm/controller/AttributeController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.example.ecm.controller;
22

3+
import com.example.ecm.aop.Loggable;
34
import com.example.ecm.dto.requests.CreateAttributeRequest;
45
import com.example.ecm.dto.responses.CreateAttributeResponse;
56
import com.example.ecm.service.AttributeService;
@@ -18,6 +19,7 @@
1819
@RestController
1920
@RequestMapping("/attributes")
2021
@RequiredArgsConstructor
22+
@Loggable
2123
public class AttributeController {
2224

2325
private final AttributeService attributeService;

src/main/java/com/example/ecm/controller/AuthController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.example.ecm.controller;
22

3+
import com.example.ecm.aop.Loggable;
34
import com.example.ecm.dto.requests.LoginRequest;
45
import com.example.ecm.dto.responses.LoginResponse;
56
import com.example.ecm.service.AuthService;
@@ -13,6 +14,7 @@
1314
@RestController
1415
@RequiredArgsConstructor
1516
@RequestMapping("/auth")
17+
@Loggable
1618
public class AuthController {
1719

1820
private final AuthService serviceAuth;

0 commit comments

Comments
 (0)