-
Notifications
You must be signed in to change notification settings - Fork 0
Sprint Sections 17 Stage 2 Events & Users #7
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1bfbbb4
Update application properties for environment variables and enhance l…
Naz1anmak 8e8aef6
Merge remote-tracking branch 'origin/main_svc' into main_svc
6b86d3d
The sections of the final task 17 of the second part have been comple…
8c27b64
Edits made after the review
dd57998
Enhance logging, refactor exception handling, and update application …
Naz1anmak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 +1 @@ | ||
| When performing a code review, respond in Russian. | ||
| When performing a code review, respond in Russian! |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -20,3 +20,4 @@ target/ | |
| *.iws | ||
| *.iml | ||
| *.ipr | ||
| /.run/ | ||
This file contains hidden or 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,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> | ||
| </component> | ||
This file contains hidden or 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 hidden or 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 @@ | ||
| <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> |
This file contains hidden or 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 hidden or 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 hidden or 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
4 changes: 4 additions & 0 deletions
4
main-service/src/main/java/ru/practicum/category/controller/AdminCategoryController.java
This file contains hidden or 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,4 @@ | ||
| package ru.practicum.category.controller; | ||
|
|
||
| public class AdminCategoryController { | ||
| } |
4 changes: 4 additions & 0 deletions
4
main-service/src/main/java/ru/practicum/category/controller/PublicCategoryController.java
This file contains hidden or 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,4 @@ | ||
| package ru.practicum.category.controller; | ||
|
|
||
| public class PublicCategoryController { | ||
| } |
6 changes: 6 additions & 0 deletions
6
main-service/src/main/java/ru/practicum/category/dto/CategoryDto.java
This file contains hidden or 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,7 +1,13 @@ | ||
| package ru.practicum.category.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Size; | ||
|
|
||
| public record CategoryDto( | ||
| Long id, | ||
|
Naz1anmak marked this conversation as resolved.
|
||
|
|
||
| @NotBlank(message = "Название категории не может быть пустым") | ||
| @Size(min = 1, max = 50, message = "Название категории должно содержать от {min} до {max} символов") | ||
| String name | ||
| ) { | ||
| } | ||
This file contains hidden or 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
16 changes: 16 additions & 0 deletions
16
main-service/src/main/java/ru/practicum/category/mapper/CategoryMapper.java
This file contains hidden or 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,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); | ||
| } |
22 changes: 22 additions & 0 deletions
22
main-service/src/main/java/ru/practicum/category/model/Category.java
This file contains hidden or 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.category.model; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.AccessLevel; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| @Entity | ||
|
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; | ||
| } | ||
4 changes: 4 additions & 0 deletions
4
main-service/src/main/java/ru/practicum/category/repository/CategoryRepository.java
This file contains hidden or 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,4 @@ | ||
| package ru.practicum.category.repository; | ||
|
|
||
| public class CategoryRepository { | ||
|
Naz1anmak marked this conversation as resolved.
|
||
| } | ||
4 changes: 4 additions & 0 deletions
4
main-service/src/main/java/ru/practicum/category/service/CategoryService.java
This file contains hidden or 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,4 @@ | ||
| package ru.practicum.category.service; | ||
|
|
||
| public interface CategoryService { | ||
| } |
4 changes: 4 additions & 0 deletions
4
main-service/src/main/java/ru/practicum/category/service/CategoryServiceImpl.java
This file contains hidden or 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,4 @@ | ||
| package ru.practicum.category.service; | ||
|
|
||
| public class CategoryServiceImpl implements CategoryService { | ||
| } |
4 changes: 4 additions & 0 deletions
4
...service/src/main/java/ru/practicum/compilation/controller/AdminCompilationController.java
This file contains hidden or 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,4 @@ | ||
| package ru.practicum.compilation.controller; | ||
|
|
||
| public class AdminCompilationController { | ||
| } |
4 changes: 4 additions & 0 deletions
4
...ervice/src/main/java/ru/practicum/compilation/controller/PublicCompilationController.java
This file contains hidden or 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,4 @@ | ||
| package ru.practicum.compilation.controller; | ||
|
|
||
| public class PublicCompilationController { | ||
| } |
This file contains hidden or 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 hidden or 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
4 changes: 4 additions & 0 deletions
4
main-service/src/main/java/ru/practicum/compilation/mapper/CompilationMapper.java
This file contains hidden or 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,4 @@ | ||
| package ru.practicum.compilation.mapper; | ||
|
|
||
| public class CompilationMapper { | ||
| } |
36 changes: 36 additions & 0 deletions
36
main-service/src/main/java/ru/practicum/compilation/model/Compilation.java
This file contains hidden or 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,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; | ||
|
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; | ||
| } | ||
7 changes: 7 additions & 0 deletions
7
main-service/src/main/java/ru/practicum/compilation/repository/CompilationRepository.java
This file contains hidden or 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,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> { | ||
| } |
4 changes: 4 additions & 0 deletions
4
main-service/src/main/java/ru/practicum/compilation/service/CompilationService.java
This file contains hidden or 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,4 @@ | ||
| package ru.practicum.compilation.service; | ||
|
|
||
| public interface CompilationService { | ||
| } |
4 changes: 4 additions & 0 deletions
4
main-service/src/main/java/ru/practicum/compilation/service/CompilationServiceImpl.java
This file contains hidden or 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,4 @@ | ||
| package ru.practicum.compilation.service; | ||
|
|
||
| public class CompilationServiceImpl implements CompilationService { | ||
| } |
39 changes: 39 additions & 0 deletions
39
main-service/src/main/java/ru/practicum/event/controller/AdminEventController.java
This file contains hidden or 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,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); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.