-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
761 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
event-service/src/main/java/ru/practicum/EventServiceApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?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>statistics-service</artifactId> | ||
<groupId>ru.practicum</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>dto-service</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<pluginManagement> | ||
<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> | ||
</pluginManagement> | ||
</build> | ||
|
||
</project> |
22 changes: 22 additions & 0 deletions
22
statistics-service/dto-service/src/main/java/ru/practicum/dto/InputEventDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ru.practicum.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Setter | ||
@Builder | ||
public class InputEventDto { | ||
private long id; | ||
private String app; | ||
private String uri; | ||
private String ip; | ||
private LocalDateTime requestDate; | ||
} |
18 changes: 18 additions & 0 deletions
18
statistics-service/dto-service/src/main/java/ru/practicum/dto/OutputStatsDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ru.practicum.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Getter | ||
@Setter | ||
public class OutputStatsDto { | ||
private String app; | ||
private String uri; | ||
private long hits; | ||
} |
9 changes: 9 additions & 0 deletions
9
...ics-service/dto-service/src/main/java/ru/practicum/exception/EntityNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ru.practicum.exception; | ||
|
||
public class EntityNotFoundException extends RuntimeException { | ||
|
||
public EntityNotFoundException(String message) { | ||
super(message); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...s-service/dto-service/src/main/java/ru/practicum/exception/EntityValidationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ru.practicum.exception; | ||
|
||
public class EntityValidationException extends RuntimeException { | ||
|
||
public EntityValidationException(String message) { | ||
super(message); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
statistics-service/dto-service/src/main/java/ru/practicum/exception/ErrorHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package ru.practicum.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; | ||
import ru.practicum.exception.model.ErrorResponse; | ||
|
||
@RestControllerAdvice | ||
public class ErrorHandler extends ResponseEntityExceptionHandler { | ||
|
||
@ExceptionHandler | ||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
public ErrorResponse handleEntityInvalidException(final EntityValidationException e) { | ||
return new ErrorResponse( | ||
e.getMessage() | ||
); | ||
} | ||
|
||
@ExceptionHandler | ||
@ResponseStatus(HttpStatus.NOT_FOUND) | ||
public ErrorResponse handleEntityNotFoundException(final EntityNotFoundException e) { | ||
return new ErrorResponse( | ||
e.getMessage() | ||
); | ||
} | ||
|
||
@ExceptionHandler | ||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) | ||
public ErrorResponse handleUnexpectedException(final Throwable e) { | ||
return new ErrorResponse( | ||
"Произошла непредвиденная ошибка." | ||
); | ||
} | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
statistics-service/dto-service/src/main/java/ru/practicum/exception/model/ErrorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package ru.practicum.exception.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
public class ErrorResponse { | ||
private final String error; | ||
} |
Oops, something went wrong.