Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
When performing a code review, respond in Russian.
When performing a code review, respond in Russian!
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ target/
*.iws
*.iml
*.ipr
/.run/
18 changes: 9 additions & 9 deletions .run/Deployment compose-local.run.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Deployment compose-local" type="docker-deploy" factoryName="docker-compose.yml"
server-name="Docker">
<deployment type="docker-compose.yml">
<settings>
<option name="sourceFilePath" value="compose-local.yaml"/>
</settings>
</deployment>
<method v="2"/>
</configuration>
<configuration default="false" name="Deployment compose-local" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
<deployment type="docker-compose.yml">
<settings>
<option name="envFilePath" value="" />
<option name="sourceFilePath" value="compose-local.yaml" />
</settings>
</deployment>
<method v="2" />
</configuration>
Comment thread
Naz1anmak marked this conversation as resolved.
</component>
2 changes: 1 addition & 1 deletion .run/MainApplication (local).run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MainApplication (local)" type="Application" factoryName="Application">
<option name="ALTERNATIVE_JRE_PATH" value="23"/>
<option name="ALTERNATIVE_JRE_PATH" value="21"/>
Comment thread
Naz1anmak marked this conversation as resolved.
<option name="MAIN_CLASS_NAME" value="ru.practicum.MainApplication"/>
<module name="main-service"/>
<option name="VM_PARAMETERS" value="-Dspring.profiles.active=local"/>
Expand Down
10 changes: 10 additions & 0 deletions .run/MainApplication.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MainApplication" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="ru.practicum.MainApplication" />
<module name="main-service" />
<option name="VM_PARAMETERS" value="-Dspring.profiles.active=test" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
2 changes: 1 addition & 1 deletion .run/StatApplication (local).run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="StatApplication (local)" type="Application" factoryName="Application">
<option name="ALTERNATIVE_JRE_PATH" value="23"/>
<option name="ALTERNATIVE_JRE_PATH" value="21"/>
Comment thread
Naz1anmak marked this conversation as resolved.
<option name="MAIN_CLASS_NAME" value="ru.practicum.StatApplication"/>
<module name="stats-server"/>
<option name="VM_PARAMETERS" value="-Dspring.profiles.active=local"/>
Expand Down
2 changes: 1 addition & 1 deletion .run/StatApplication.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="StatApplication" type="Application" factoryName="Application">
<option name="ALTERNATIVE_JRE_PATH" value="23"/>
<option name="ALTERNATIVE_JRE_PATH" value="21"/>
<option name="MAIN_CLASS_NAME" value="ru.practicum.StatApplication"/>
<module name="stats-server"/>
<option name="VM_PARAMETERS" value="-Dspring.profiles.active=test"/>
Expand Down
28 changes: 15 additions & 13 deletions main-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,48 @@
<name>Main Service</name>

<dependencies>
<dependency>
<groupId>ru.practicum</groupId>
<artifactId>stats-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

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

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

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

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

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

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
Comment thread
Naz1anmak marked this conversation as resolved.
</dependencies>

<build>
Expand All @@ -67,6 +65,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
Comment thread
Naz1anmak marked this conversation as resolved.
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.practicum.category.controller;

public class AdminCategoryController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.practicum.category.controller;

public class PublicCategoryController {
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package ru.practicum.category.dto;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

public record CategoryDto(
Long id,
Comment thread
Naz1anmak marked this conversation as resolved.

@NotBlank(message = "Название категории не может быть пустым")
@Size(min = 1, max = 50, message = "Название категории должно содержать от {min} до {max} символов")
String name
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import jakarta.validation.constraints.Size;

public record NewCategoryDto(
@NotBlank(message = "Название категории не может быть пустой")
@Size(min = 1, max = 50, message = "Название категории должно содержать от 3 до 50 символов")
@NotBlank(message = "Название категории не может быть пустым")
@Size(min = 1, max = 50, message = "Название категории должно содержать от {min} до {max} символов")
String name
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ru.practicum.category.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import ru.practicum.category.dto.CategoryDto;
import ru.practicum.category.dto.NewCategoryDto;
import ru.practicum.category.model.Category;

@Mapper(componentModel = "spring")
public interface CategoryMapper {

@Mapping(target = "id", ignore = true)
Category toEntity(NewCategoryDto dto);

CategoryDto toDto(Category category);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ru.practicum.category.model;

import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Entity
Comment thread
Naz1anmak marked this conversation as resolved.
@Table(name = "categories")
@Getter
@Setter(AccessLevel.PROTECTED)
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class Category {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@EqualsAndHashCode.Include
private Long id;

@Column(name = "name", unique = true, nullable = false, length = 50)
private String name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.practicum.category.repository;

public class CategoryRepository {
Comment thread
Naz1anmak marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.practicum.category.service;

public interface CategoryService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.practicum.category.service;

public class CategoryServiceImpl implements CategoryService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.practicum.compilation.controller;

public class AdminCompilationController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.practicum.compilation.controller;

public class PublicCompilationController {
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public record NewCompilationDto(
boolean pinned,

@NotBlank(message = "Заголовок подборки не может быть пустым")
@Size(min = 1, max = 50, message = "Заголовок должен содержать от 1 до 50 символов")
@Size(min = 1, max = 50, message = "Заголовок должен содержать от {min} до {max} символов")
String title
) {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ru.practicum.compilation.dto;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

import java.util.Set;
Expand All @@ -9,7 +10,8 @@ public record UpdateCompilationRequest(

boolean pinned,

@Size(min = 1, max = 50, message = "Заголовок должен содержать от 1 до 50 символов")
@NotBlank(message = "Заголовок подборки не может быть пустым")
@Size(min = 1, max = 50, message = "Заголовок должен содержать от {min} до {max} символов")
String title
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.practicum.compilation.mapper;

public class CompilationMapper {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ru.practicum.compilation.model;

import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import ru.practicum.event.model.Event;

import java.util.Set;

@Entity
@Table(name = "compilations")
@Getter
@Setter(AccessLevel.PROTECTED)
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class Compilation {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@EqualsAndHashCode.Include
private Long id;
Comment thread
Naz1anmak marked this conversation as resolved.

@Column(nullable = false, length = 50)
private String title;

@Column(nullable = false)
private boolean pinned = false;

@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
name = "compilation_events",
joinColumns = @JoinColumn(name = "compilation_id"),
inverseJoinColumns = @JoinColumn(name = "event_id")
)
private Set<Event> events;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ru.practicum.compilation.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import ru.practicum.compilation.model.Compilation;

public interface CompilationRepository extends JpaRepository<Compilation, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.practicum.compilation.service;

public interface CompilationService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.practicum.compilation.service;

public class CompilationServiceImpl implements CompilationService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package ru.practicum.event.controller;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;
import ru.practicum.event.dto.EventFullDto;
import ru.practicum.event.dto.SearchEventAdminRequest;
import ru.practicum.event.dto.UpdateEventAdminRequest;
import ru.practicum.event.service.EventService;

import java.util.List;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/events")
public class AdminEventController {
private final EventService eventService;

@GetMapping
public List<EventFullDto> getEventsAdmin(@ModelAttribute @Valid SearchEventAdminRequest request) {
int size = (request.size() != null && request.size() > 0) ? request.size() : 10;
int from = request.from() != null ? request.from() : 0;
PageRequest pageRequest = PageRequest.of(from / size, size);
log.debug("Controller: getEventAdmin with filters {}", request);
return eventService.getEventsAdmin(request, pageRequest);
}

@PatchMapping("/{eventId}")
public EventFullDto updateEventAdmin(
@PathVariable Long eventId,
@RequestBody @Valid UpdateEventAdminRequest request
) {
log.debug("Controller: updateEventAdmin with id={} with data {}", eventId, request);
return eventService.updateEventAdmin(eventId, request);
}
}
Loading
Loading