Skip to content

Commit 4512010

Browse files
committed
Spring Application v4
1 parent e6328a9 commit 4512010

44 files changed

Lines changed: 1106 additions & 753 deletions

Some content is hidden

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

heroes/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/pg

heroes/docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
db:
3+
image: postgres:latest
4+
container_name: heroes-db
5+
restart: always
6+
environment:
7+
POSTGRES_DB: postgres
8+
POSTGRES_USER: postgres
9+
POSTGRES_PASSWORD: postgres
10+
ports:
11+
- "25432:5432"
12+
volumes:
13+
- ./pg:/var/lib/postgresql/data
14+
healthcheck:
15+
test: [ "CMD-SHELL", "pg_isready -U postgres -d postgres" ]
16+
interval: 5s
17+
timeout: 5s
18+
retries: 5

heroes/pom.xml

Lines changed: 152 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,159 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4-
<modelVersion>4.0.0</modelVersion>
5-
<parent>
6-
<groupId>ru.mifi.practice</groupId>
7-
<artifactId>AaDS</artifactId>
8-
<version>${revision}</version>
9-
<relativePath>../pom.xml</relativePath>
10-
</parent>
11-
<artifactId>heroes</artifactId>
12-
<name>heroes</name>
13-
<description>Модуль heroes с поддержкой LongPolling и SSE.</description>
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>ru.mifi.practice</groupId>
7+
<artifactId>AaDS</artifactId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>heroes</artifactId>
12+
<name>heroes</name>
13+
<description>Модуль heroes с поддержкой LongPolling и SSE.</description>
14+
15+
<dependencyManagement>
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-dependencies</artifactId>
20+
<version>4.0.1</version>
21+
<type>pom</type>
22+
<scope>import</scope>
23+
</dependency>
24+
</dependencies>
25+
</dependencyManagement>
1426

15-
<dependencyManagement>
1627
<dependencies>
17-
<dependency>
18-
<groupId>org.springframework.boot</groupId>
19-
<artifactId>spring-boot-dependencies</artifactId>
20-
<version>4.0.1</version>
21-
<type>pom</type>
22-
<scope>import</scope>
23-
</dependency>
24-
</dependencies>
25-
</dependencyManagement>
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-web</artifactId>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter-actuator</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter-security</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-starter-data-jpa</artifactId>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.springframework.boot</groupId>
46+
<artifactId>spring-boot-starter-validation</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.springframework.session</groupId>
50+
<artifactId>spring-session-core</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.springdoc</groupId>
54+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
55+
<version>2.2.0</version>
56+
</dependency>
57+
<dependency>
58+
<groupId>com.google.guava</groupId>
59+
<artifactId>guava</artifactId>
60+
</dependency>
61+
<dependency>
62+
<groupId>com.fasterxml.jackson.core</groupId>
63+
<artifactId>jackson-databind</artifactId>
64+
</dependency>
65+
<dependency>
66+
<groupId>com.fasterxml.jackson.datatype</groupId>
67+
<artifactId>jackson-datatype-jsr310</artifactId>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.slf4j</groupId>
71+
<artifactId>slf4j-api</artifactId>
72+
</dependency>
73+
<dependency>
74+
<groupId>ch.qos.logback</groupId>
75+
<artifactId>logback-classic</artifactId>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.telegram</groupId>
79+
<artifactId>telegrambots-spring-boot-starter</artifactId>
80+
<version>6.9.7.1</version>
81+
</dependency>
82+
<dependency>
83+
<groupId>org.telegram</groupId>
84+
<artifactId>telegrambots-abilities</artifactId>
85+
<version>9.2.0</version>
86+
</dependency>
87+
<dependency>
88+
<groupId>io.micrometer</groupId>
89+
<artifactId>micrometer-core</artifactId>
90+
</dependency>
91+
<dependency>
92+
<groupId>io.micrometer</groupId>
93+
<artifactId>micrometer-registry-prometheus</artifactId>
94+
<scope>runtime</scope>
95+
</dependency>
96+
<dependency>
97+
<groupId>org.mapstruct</groupId>
98+
<artifactId>mapstruct</artifactId>
99+
<version>1.6.2</version>
100+
</dependency>
101+
<dependency>
102+
<groupId>io.jsonwebtoken</groupId>
103+
<artifactId>jjwt-api</artifactId>
104+
<version>0.12.3</version>
105+
</dependency>
106+
<dependency>
107+
<groupId>io.jsonwebtoken</groupId>
108+
<artifactId>jjwt-jackson</artifactId>
109+
<version>0.12.3</version>
110+
</dependency>
111+
<dependency>
112+
<groupId>io.jsonwebtoken</groupId>
113+
<artifactId>jjwt-impl</artifactId>
114+
<version>0.12.3</version>
115+
</dependency>
26116

27-
<dependencies>
28-
<dependency>
29-
<groupId>org.springframework.boot</groupId>
30-
<artifactId>spring-boot-starter-webflux</artifactId>
31-
</dependency>
32-
<dependency>
33-
<groupId>org.springframework.session</groupId>
34-
<artifactId>spring-session-core</artifactId>
35-
</dependency>
36-
<dependency>
37-
<groupId>com.google.guava</groupId>
38-
<artifactId>guava</artifactId>
39-
</dependency>
40-
<dependency>
41-
<groupId>io.projectreactor</groupId>
42-
<artifactId>reactor-core</artifactId>
43-
<version>3.7.12</version>
44-
</dependency>
45-
<dependency>
46-
<groupId>io.projectreactor.netty</groupId>
47-
<artifactId>reactor-netty-http</artifactId>
48-
<version>1.2.2</version>
49-
</dependency>
50-
<dependency>
51-
<groupId>com.fasterxml.jackson.core</groupId>
52-
<artifactId>jackson-databind</artifactId>
53-
<version>2.17.2</version>
54-
</dependency>
55-
<dependency>
56-
<groupId>com.fasterxml.jackson.datatype</groupId>
57-
<artifactId>jackson-datatype-jsr310</artifactId>
58-
<version>2.19.2</version>
59-
</dependency>
60-
<dependency>
61-
<groupId>org.slf4j</groupId>
62-
<artifactId>slf4j-api</artifactId>
63-
<version>2.0.16</version>
64-
</dependency>
65-
<dependency>
66-
<groupId>ch.qos.logback</groupId>
67-
<artifactId>logback-classic</artifactId>
68-
<version>1.5.16</version>
69-
</dependency>
70-
<dependency>
71-
<groupId>org.telegram</groupId>
72-
<artifactId>telegrambots-spring-boot-starter</artifactId>
73-
<version>6.9.7.1</version>
74-
</dependency>
75-
<dependency>
76-
<groupId>org.telegram</groupId>
77-
<artifactId>telegrambots-abilities</artifactId>
78-
<version>9.2.0</version>
79-
</dependency>
80-
<dependency>
81-
<groupId>io.projectreactor</groupId>
82-
<artifactId>reactor-test</artifactId>
83-
<version>3.7.9</version>
84-
<scope>test</scope>
85-
</dependency>
86-
</dependencies>
117+
<dependency>
118+
<groupId>org.postgresql</groupId>
119+
<artifactId>postgresql</artifactId>
120+
<scope>runtime</scope>
121+
</dependency>
122+
<dependency>
123+
<groupId>org.projectlombok</groupId>
124+
<artifactId>lombok</artifactId>
125+
<optional>true</optional>
126+
</dependency>
127+
<dependency>
128+
<groupId>org.springframework.boot</groupId>
129+
<artifactId>spring-boot-starter-test</artifactId>
130+
<scope>test</scope>
131+
</dependency>
132+
<dependency>
133+
<groupId>org.junit.jupiter</groupId>
134+
<artifactId>junit-jupiter-api</artifactId>
135+
<scope>test</scope>
136+
</dependency>
137+
<dependency>
138+
<groupId>org.junit.jupiter</groupId>
139+
<artifactId>junit-jupiter-engine</artifactId>
140+
<scope>test</scope>
141+
</dependency>
142+
</dependencies>
143+
<build>
144+
<plugins>
145+
<plugin>
146+
<groupId>org.springframework.boot</groupId>
147+
<artifactId>spring-boot-maven-plugin</artifactId>
148+
<configuration>
149+
<excludes>
150+
<exclude>
151+
<groupId>org.projectlombok</groupId>
152+
<artifactId>lombok</artifactId>
153+
</exclude>
154+
</excludes>
155+
</configuration>
156+
</plugin>
157+
</plugins>
158+
</build>
87159
</project>

heroes/src/main/java/ru/mifi/practice/voln/api/TelegramHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
public interface TelegramHandler {
77

88
void received(TelegramLongPollingBot bot, Update update);
9+
10+
void send(Long telegramId, String message);
911
}
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
package ru.mifi.practice.voln.configuration;
22

3+
import io.micrometer.core.instrument.binder.logging.LogbackMetrics;
4+
import org.springframework.context.annotation.Bean;
35
import org.springframework.context.annotation.ComponentScan;
46
import org.springframework.context.annotation.Configuration;
7+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
58

69
@Configuration
7-
@ComponentScan(basePackages = {"ru.mifi.practice.voln.service", "ru.mifi.practice.voln.repository.implementation"})
10+
@EnableWebMvc
11+
@ComponentScan(basePackages = "ru.mifi.practice.voln.service")
812
public class ApplicationConfiguration {
13+
@Bean
14+
public LogbackMetrics logbackMetrics() {
15+
return new LogbackMetrics();
16+
}
917
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package ru.mifi.practice.voln.configuration;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
6+
import org.springframework.security.core.userdetails.User;
7+
import org.springframework.security.crypto.password.PasswordEncoder;
8+
9+
import javax.sql.DataSource;
10+
11+
@Configuration
12+
public class AuthenticationConfiguration2 {
13+
@Autowired
14+
public void configureGlobal(AuthenticationManagerBuilder auth, DataSource dataSource, PasswordEncoder encoder) {
15+
auth.jdbcAuthentication().dataSource(dataSource)
16+
.usersByUsernameQuery("SELECT username, password, enabled FROM users WHERE username=?")
17+
.authoritiesByUsernameQuery("SELECT username, authority FROM authorities WHERE username=?")
18+
.withUser(User.withUsername("admin").password(encoder.encode("admin")).roles("ADMIN"));
19+
}
20+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ru.mifi.practice.voln.configuration;
2+
3+
import org.springframework.boot.persistence.autoconfigure.EntityScan;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
6+
7+
@Configuration
8+
@EntityScan(basePackages = "ru.mifi.practice.voln.domain.entity")
9+
@EnableJpaRepositories(basePackages = "ru.mifi.practice.voln.repository")
10+
public class DatabaseConfiguration {
11+
}

0 commit comments

Comments
 (0)