Skip to content
Open
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
22 changes: 18 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.7'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.openapi.generator' version '7.18.0'
id 'org.springframework.boot' version "${springBootVersion}"
id 'io.spring.dependency-management' version "${dependencyManagementVersion}"
id 'org.openapi.generator' version "${openapiGeneratorVersion}"
}

group = 'ru.practicum'
Expand All @@ -15,6 +15,10 @@ java {
}
}

ext {
set('springCloudVersion', "2024.0.0")
}

configurations {
compileOnly {
extendsFrom annotationProcessor
Expand All @@ -30,8 +34,11 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j'
implementation "org.mapstruct:mapstruct:${mapstructVersion}"
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-database-postgresql'
implementation "io.swagger.core.v3:swagger-annotations:${swaggerVersion}"
compileOnly 'org.projectlombok:lombok'
Expand All @@ -45,6 +52,12 @@ dependencies {
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

openApiGenerate {
generatorName = "spring"
inputSpec = "$rootDir/src/main/resources/openapi/openapi.yml"
Expand Down Expand Up @@ -76,6 +89,7 @@ openApiGenerate {
"TagCreateDto" : "ru.practicum.eventhub.api.dto.request.TagCreateDto",
"TagUpdateDto" : "ru.practicum.eventhub.api.dto.request.TagUpdateDto",
"TagDto" : "ru.practicum.eventhub.api.dto.response.TagDto",
"TagWithStatsDto": "ru.practicum.eventhub.api.dto.response.TagWithStatsDto",

"ErrorResponse" : "ru.practicum.eventhub.api.exception.ErrorResponse"
]
Expand Down
10 changes: 8 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ version: '3.7'
services:
postgres:
image: postgres:14
container_name: event-hub-db
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123456
ports:
- "5432:5432"
- "5432:5432"

redis:
image: redis:8.4.0
ports:
- "6379:6379"
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
springBootVersion=3.4.2
dependencyManagementVersion=1.1.7
openapiGeneratorVersion=7.10.0

mapstructVersion=1.6.3
swaggerVersion=2.2.38
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/ru/practicum/eventhub/EventHubApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableTransactionManagement
@EnableCaching
@EnableFeignClients
@EnableScheduling
public class EventHubApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public record CategoryDto(
OffsetDateTime updatedAt,
List<ProjectShortDto> projects
) {
public record ProjectShortDto(UUID id, String name) {
public record ProjectShortDto(UUID id) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public record EventDto(
OffsetDateTime updatedAt,
List<TagShortDto> tags
) {
public record TagShortDto(UUID id, String name) {
public record TagShortDto(UUID id) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public record ProjectDto(
OffsetDateTime updatedAt,
CategoryShortDto category
) {
public record CategoryShortDto(UUID id, String name) {
public record CategoryShortDto(UUID id) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public record TagDto(
String description,
List<EventShortDto> events
) {
public record EventShortDto(UUID id, String title) {
public record EventShortDto(UUID id) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ru.practicum.eventhub.api.dto.response;

import java.time.OffsetDateTime;

public record TagStatsDto(
long usageCount,
OffsetDateTime createdAt,
OffsetDateTime updatedAt
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ru.practicum.eventhub.api.dto.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import ru.practicum.eventhub.api.model.EventShortDto;

import java.util.List;
import java.util.UUID;

@JsonInclude(JsonInclude.Include.NON_NULL)
public record TagWithStatsDto(
UUID id,
String name,
String description,
List<EventShortDto> events,
TagStatsDto stats
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public record UserMetadataDto(
OffsetDateTime createdAt,
OffsetDateTime updatedAt
) {
public record UserShortDto(UUID id, String username, String email) {
public record UserShortDto(UUID id) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import ru.practicum.eventhub.api.dto.request.CategoryUpdateDto;
import ru.practicum.eventhub.api.dto.request.ProjectCreateDto;
import ru.practicum.eventhub.api.dto.response.CategoryDto;
import ru.practicum.eventhub.domain.model.Category;
import ru.practicum.eventhub.domain.model.Project;
import ru.practicum.eventhub.model.Category;
import ru.practicum.eventhub.model.Project;

import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import ru.practicum.eventhub.api.dto.request.EventUpdateDto;
import ru.practicum.eventhub.api.dto.request.TagCreateDto;
import ru.practicum.eventhub.api.dto.response.EventDto;
import ru.practicum.eventhub.domain.model.Event;
import ru.practicum.eventhub.domain.model.Tag;
import ru.practicum.eventhub.model.Event;
import ru.practicum.eventhub.model.Tag;

import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.mapstruct.MappingTarget;
import ru.practicum.eventhub.api.dto.request.ProjectUpdateDto;
import ru.practicum.eventhub.api.dto.response.ProjectDto;
import ru.practicum.eventhub.domain.model.Project;
import ru.practicum.eventhub.model.Project;

import static org.mapstruct.MappingConstants.ComponentModel.SPRING;
import static org.mapstruct.NullValuePropertyMappingStrategy.IGNORE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import ru.practicum.eventhub.api.dto.request.TagCreateDto;
import ru.practicum.eventhub.api.dto.request.TagUpdateDto;
import ru.practicum.eventhub.api.dto.response.TagDto;
import ru.practicum.eventhub.domain.model.Tag;
import ru.practicum.eventhub.api.dto.response.TagStatsDto;
import ru.practicum.eventhub.api.dto.response.TagWithStatsDto;
import ru.practicum.eventhub.model.Tag;

import static org.mapstruct.MappingConstants.ComponentModel.SPRING;
import static org.mapstruct.NullValuePropertyMappingStrategy.IGNORE;
Expand All @@ -16,6 +18,8 @@
public interface TagMapper {
TagDto toDto(Tag tag);

TagWithStatsDto toDtoWithStats(Tag tag, TagStatsDto stats);

@Mapping(target = "id", ignore = true)
@Mapping(target = "version", ignore = true)
@Mapping(target = "createdAt", ignore = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import ru.practicum.eventhub.api.dto.request.UserMetadataUpdateDto;
import ru.practicum.eventhub.api.dto.request.UserUpdateDto;
import ru.practicum.eventhub.api.dto.response.UserDto;
import ru.practicum.eventhub.domain.model.User;
import ru.practicum.eventhub.domain.model.UserMetadata;
import ru.practicum.eventhub.model.User;
import ru.practicum.eventhub.model.UserMetadata;

import static org.mapstruct.MappingConstants.ComponentModel.SPRING;
import static org.mapstruct.NullValuePropertyMappingStrategy.IGNORE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.mapstruct.Mapper;
import ru.practicum.eventhub.api.dto.response.UserMetadataDto;
import ru.practicum.eventhub.domain.model.UserMetadata;
import ru.practicum.eventhub.model.UserMetadata;

import static org.mapstruct.MappingConstants.ComponentModel.SPRING;

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading