diff --git a/.gitignore b/.gitignore
index 549e00a2..64703cb3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,33 +1,22 @@
-HELP.md
+*.class
+*.log
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+hs_err_pid*
+replay_pid*
+out/
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
-### STS ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-.sts4-cache
-
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
-
-### NetBeans ###
-/nbproject/private/
-/nbbuild/
-/dist/
-/nbdist/
-/.nb-gradle/
-build/
-!**/src/main/**/build/
-!**/src/test/**/build/
-
-### VS Code ###
-.vscode/
diff --git a/docker-compose.yml b/docker-compose.yml
index b387e1a6..9f5351c2 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,15 +1,45 @@
-version: '3.1'
services:
stats-server:
+ build:
+ context: stats/stats-server
+ dockerfile: Dockerfile
+ container_name: stats-server
ports:
- "9090:9090"
+ environment:
+ - SPRING_DATASOURCE_URL=jdbc:postgresql://stats-db:5432/ewm-stats
+ - SPRING_DATASOURCE_USERNAME=test
+ - SPRING_DATASOURCE_PASSWORD=test
+
stats-db:
- image: postgres:14-alpine
+ image: postgres:16.1
+ container_name: postgres-stats-ewm
+ ports:
+ - "6542:5432"
+ environment:
+ - POSTGRES_DB=ewm-stats
+ - POSTGRES_USER=test
+ - POSTGRES_PASSWORD=test
ewm-service:
+ build:
+ context: main-service/
+ dockerfile: Dockerfile
+ container_name: main-server
ports:
- "8080:8080"
+ environment:
+ - SPRING_DATASOURCE_URL=jdbc:postgresql://stats-db:5432/ewm-main
+ - SPRING_DATASOURCE_USERNAME=test
+ - SPRING_DATASOURCE_PASSWORD=test
ewm-db:
- image: postgres:14-alpine
+ image: postgres:16.1
+ container_name: postgres-main-ewm
+ ports:
+ - "6543:5432"
+ environment:
+ - POSTGRES_DB=ewm-main
+ - POSTGRES_USER=test
+ - POSTGRES_PASSWORD=test
\ No newline at end of file
diff --git a/ewm-main-service-spec.json b/ewm-main-service-spec.json
index 191bd9d4..f28d1413 100644
--- a/ewm-main-service-spec.json
+++ b/ewm-main-service-spec.json
@@ -1,7 +1,8 @@
{
"openapi": "3.0.1",
"info": {
- "title": "Main service API",
+ "description": "Documentation \"Explore With Me\" API v1.0",
+ "title": "\"Explore With Me\" API сервер",
"version": "1.0"
},
"servers": [
@@ -479,6 +480,7 @@
"name": "from",
"required": false,
"schema": {
+ "minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
@@ -634,6 +636,7 @@
"name": "from",
"required": false,
"schema": {
+ "minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
@@ -803,6 +806,7 @@
"name": "from",
"required": false,
"schema": {
+ "minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
@@ -943,6 +947,7 @@
"name": "from",
"required": false,
"schema": {
+ "minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
@@ -1074,6 +1079,8 @@
"name": "text",
"required": false,
"schema": {
+ "maxLength": 7000,
+ "minLength": 1,
"type": "string"
}
},
@@ -1146,6 +1153,7 @@
"name": "from",
"required": false,
"schema": {
+ "minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
@@ -1287,6 +1295,7 @@
"name": "from",
"required": false,
"schema": {
+ "minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
@@ -2098,6 +2107,8 @@
"example": 1
},
"name": {
+ "maxLength": 50,
+ "minLength": 1,
"type": "string",
"description": "Название категории",
"example": "Концерты"
@@ -2441,6 +2452,8 @@
"type": "object",
"properties": {
"name": {
+ "maxLength": 50,
+ "minLength": 1,
"type": "string",
"description": "Название категории",
"example": "Концерты"
@@ -2476,6 +2489,8 @@
"default": false
},
"title": {
+ "maxLength": 50,
+ "minLength": 1,
"type": "string",
"description": "Заголовок подборки",
"example": "Летние концерты"
@@ -2559,11 +2574,15 @@
"type": "object",
"properties": {
"email": {
+ "maxLength": 254,
+ "minLength": 6,
"type": "string",
"description": "Почтовый адрес",
"example": "ivan.petrov@practicummail.ru"
},
"name": {
+ "maxLength": 250,
+ "minLength": 2,
"type": "string",
"description": "Имя",
"example": "Иван Петров"
@@ -2624,6 +2643,8 @@
"example": true
},
"title": {
+ "maxLength": 50,
+ "minLength": 1,
"type": "string",
"description": "Заголовок подборки",
"example": "Необычные фотозоны"
diff --git a/main-service/Dockerfile b/main-service/Dockerfile
new file mode 100644
index 00000000..904a3487
--- /dev/null
+++ b/main-service/Dockerfile
@@ -0,0 +1,3 @@
+FROM amazoncorretto:21
+COPY target/*.jar main.jar
+ENTRYPOINT ["java","-jar","/main.jar"]
\ No newline at end of file
diff --git a/main-service/pom.xml b/main-service/pom.xml
new file mode 100644
index 00000000..9bd0623d
--- /dev/null
+++ b/main-service/pom.xml
@@ -0,0 +1,59 @@
+
+
+ 4.0.0
+
+ ru.practicum
+ explore-with-me
+ 0.0.1-SNAPSHOT
+
+
+ ru.practicum.yandex
+ main-service
+
+
+ 21
+ 21
+ UTF-8
+
+
+
+ ru.practicum.yandex
+ stats-client
+ 0.0.1-SNAPSHOT
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.0
+
+
+
+ true
+ ru.practicum.exploreWithMe.ExploreWithMeMain
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main-service/src/main/java/ru/practicum/exploreWithMe/ExploreWithMeMain.java b/main-service/src/main/java/ru/practicum/exploreWithMe/ExploreWithMeMain.java
new file mode 100644
index 00000000..44de9c87
--- /dev/null
+++ b/main-service/src/main/java/ru/practicum/exploreWithMe/ExploreWithMeMain.java
@@ -0,0 +1,11 @@
+package ru.practicum.exploreWithMe;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ExploreWithMeMain {
+ public static void main(String[] args) {
+ SpringApplication.run(ExploreWithMeMain.class, args);
+ }
+}
diff --git a/main-service/src/main/resources/application.properties b/main-service/src/main/resources/application.properties
new file mode 100644
index 00000000..7ca7a42b
--- /dev/null
+++ b/main-service/src/main/resources/application.properties
@@ -0,0 +1,3 @@
+server.port=8080
+
+stats-server.url=http://localhost:9090
diff --git a/pom.xml b/pom.xml
index ad386209..1d504498 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,16 +1,20 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
- 2.7.5
+ 3.3.2
Explore With Me
+
+ stats
+ main-service
+
ru.practicum
explore-with-me
@@ -18,7 +22,7 @@
pom
- 11
+ 21
UTF-8
@@ -63,7 +67,7 @@
com.github.spotbugs
spotbugs-maven-plugin
- 4.7.0.0
+ 4.8.5.0
Max
High
@@ -79,7 +83,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.8
+ 0.8.12
diff --git a/stats/pom.xml b/stats/pom.xml
new file mode 100644
index 00000000..4c84ecf3
--- /dev/null
+++ b/stats/pom.xml
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+
+ ru.practicum
+ explore-with-me
+ 0.0.1-SNAPSHOT
+
+
+ ru.practicum.yandex
+ stats
+ pom
+
+
+ stats-client
+ stats-dto
+ stats-server
+
+
+
+ 21
+ 21
+ UTF-8
+
+
+
\ No newline at end of file
diff --git a/stats/stats-client/pom.xml b/stats/stats-client/pom.xml
new file mode 100644
index 00000000..a9cf34eb
--- /dev/null
+++ b/stats/stats-client/pom.xml
@@ -0,0 +1,45 @@
+
+
+ 4.0.0
+
+ ru.practicum
+ explore-with-me
+ 0.0.1-SNAPSHOT
+ ../../pom.xml
+
+
+ ru.practicum.yandex
+ stats-client
+
+
+ 21
+ 21
+ UTF-8
+
+
+
+
+ ru.practicum.yandex
+ stats-dto
+ 0.0.1-SNAPSHOT
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+ org.apache.httpcomponents.client5
+ httpclient5
+
+
+
+
\ No newline at end of file
diff --git a/stats/stats-client/src/main/java/ru/practicum/exploreWithMe/client/BaseClient.java b/stats/stats-client/src/main/java/ru/practicum/exploreWithMe/client/BaseClient.java
new file mode 100644
index 00000000..4098da0f
--- /dev/null
+++ b/stats/stats-client/src/main/java/ru/practicum/exploreWithMe/client/BaseClient.java
@@ -0,0 +1,61 @@
+package ru.practicum.exploreWithMe.client;
+
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.lang.Nullable;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.List;
+
+public class BaseClient {
+ protected final RestTemplate rest;
+
+ public BaseClient(RestTemplate rest) {
+ this.rest = rest;
+ }
+
+ protected ResponseEntity