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

Stat svc #36

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 19 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
version: '3.1'
services:
stats-server:
ports:
- "9090:9090"

stats-db:
statistics-db:
image: postgres:14-alpine

ewm-service:
container_name: statistics_postgres_container
ports:
- "8080:8080"
- "6541:5432"
environment:
- POSTGRES_DB=statistics-db
- POSTGRES_USER=iamstatsroot
- POSTGRES_PASSWORD=iamstatsroot

ewm-db:
image: postgres:14-alpine
statistics-server:
build: statistics-service/statistics-server
image: statistics_server_image
container_name: statistics_server_container
ports:
- "9090:9090"
depends_on:
- statistics-db
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://statistics-db:5432/statistics-db
- SPRING_DATASOURCE_USERNAME=iamstatsroot
- SPRING_DATASOURCE_PASSWORD=iamstatsroot
3 changes: 3 additions & 0 deletions event-service/DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM amazoncorretto:11-alpine-jdk
COPY target/*.jar event-service.jar
ENTRYPOINT ["java","-jar","/event-service.jar"]
44 changes: 44 additions & 0 deletions event-service/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>explore-with-me</artifactId>
<groupId>ru.practicum</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>event-service</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>ru.practicum</groupId>
<artifactId>http-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
11 changes: 11 additions & 0 deletions event-service/src/main/java/ru/practicum/EventServiceApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ru.practicum;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class EventServiceApp {
public static void main(String[] args) {
SpringApplication.run(EventServiceApp.class, args);
}
}
26 changes: 26 additions & 0 deletions event-service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
server.port=8080
statistics-server.url=http://localhost:9090

spring.jpa.hibernate.ddl-auto=none
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL10Dialect
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.show_sql=true
spring.sql.init.mode=always

logging.level.org.springframework.orm.jpa=INFO
logging.level.org.springframework.transaction=INFO
logging.level.org.springframework.transaction.interceptor=TRACE
logging.level.org.springframework.orm.jpa.JpaTransactionManager=DEBUG

#---
spring.config.activate.on-profile=dev
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/event-db
spring.datasource.username=iameventroot
spring.datasource.password=iameventroot
#---
spring.config.activate.on-profile=ci,test
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:event-db
spring.datasource.username=test
spring.datasource.password=test
23 changes: 22 additions & 1 deletion ewm-main-service-spec.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -479,6 +480,7 @@
"name": "from",
"required": false,
"schema": {
"minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
Expand Down Expand Up @@ -634,6 +636,7 @@
"name": "from",
"required": false,
"schema": {
"minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
Expand Down Expand Up @@ -803,6 +806,7 @@
"name": "from",
"required": false,
"schema": {
"minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
Expand Down Expand Up @@ -943,6 +947,7 @@
"name": "from",
"required": false,
"schema": {
"minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
Expand Down Expand Up @@ -1074,6 +1079,8 @@
"name": "text",
"required": false,
"schema": {
"maxLength": 7000,
"minLength": 1,
"type": "string"
}
},
Expand Down Expand Up @@ -1146,6 +1153,7 @@
"name": "from",
"required": false,
"schema": {
"minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
Expand Down Expand Up @@ -1287,6 +1295,7 @@
"name": "from",
"required": false,
"schema": {
"minimum": 0,
"type": "integer",
"format": "int32",
"default": 0
Expand Down Expand Up @@ -2098,6 +2107,8 @@
"example": 1
},
"name": {
"maxLength": 50,
"minLength": 1,
"type": "string",
"description": "Название категории",
"example": "Концерты"
Expand Down Expand Up @@ -2441,6 +2452,8 @@
"type": "object",
"properties": {
"name": {
"maxLength": 50,
"minLength": 1,
"type": "string",
"description": "Название категории",
"example": "Концерты"
Expand Down Expand Up @@ -2476,6 +2489,8 @@
"default": false
},
"title": {
"maxLength": 50,
"minLength": 1,
"type": "string",
"description": "Заголовок подборки",
"example": "Летние концерты"
Expand Down Expand Up @@ -2559,11 +2574,15 @@
"type": "object",
"properties": {
"email": {
"maxLength": 254,
"minLength": 6,
"type": "string",
"description": "Почтовый адрес",
"example": "[email protected]"
},
"name": {
"maxLength": 250,
"minLength": 2,
"type": "string",
"description": "Имя",
"example": "Иван Петров"
Expand Down Expand Up @@ -2624,6 +2643,8 @@
"example": true
},
"title": {
"maxLength": 50,
"minLength": 1,
"type": "string",
"description": "Заголовок подборки",
"example": "Необычные фотозоны"
Expand Down
92 changes: 91 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<modules>
<module>event-service</module>
<module>statistics-service</module>
</modules>

<parent>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
Expand All @@ -17,6 +21,64 @@
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.5.5.Final</version>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
</dependencies>

<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -34,6 +96,34 @@
</systemPropertyVariables>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>11</source>
<target>11</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.5.5.Final</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down
Loading
Loading