generated from yandex-praktikum/java-explore-with-me
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Реализовывал фичу Комментарии #5
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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,2 +1,4 @@ | ||
# java-explore-with-me | ||
Template repository for ExploreWithMe project. | ||
|
||
https://github.com/aigunov/java-explore-with-me/pull/5 |
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,4 +1,4 @@ | ||
FROM amazoncorretto:21 | ||
FROM openjdk:21 | ||
COPY target/*.jar app.jar | ||
ENTRYPOINT ["java","-jar","/app.jar"] | ||
EXPOSE 8080 |
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
38 changes: 38 additions & 0 deletions
38
...ce/src/main/java/ru/practicum/mainservice/controller/adminapi/AdminCommentController.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,38 @@ | ||
package ru.practicum.mainservice.controller.adminapi; | ||
|
||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.PositiveOrZero; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
import ru.practicum.mainservice.data.dto.comment.CommentDto; | ||
import ru.practicum.mainservice.data.dto.comment.CommentStatusUpdateRequest; | ||
import ru.practicum.mainservice.data.dto.comment.CommentStatusUpdateResult; | ||
import ru.practicum.mainservice.service.interfaces.CommentService; | ||
|
||
@RestController | ||
@RequestMapping("/admin/comments") | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
@Validated | ||
public class AdminCommentController { | ||
private final CommentService commentService; | ||
|
||
@GetMapping("/{commentId}") | ||
public CommentDto getCommentById(@PositiveOrZero @PathVariable Long commentId) { | ||
CommentDto commentById = commentService.findCommentById(commentId); | ||
log.info("GET /admin/comments/{commentId} commentId = {} result = {}", commentById, commentById); | ||
return commentById; | ||
} | ||
|
||
@PatchMapping("/event/{eventId}") | ||
@ResponseStatus(HttpStatus.CREATED) | ||
public CommentStatusUpdateResult decisionComments(@PositiveOrZero @PathVariable Long eventId, | ||
@Valid @RequestBody CommentStatusUpdateRequest commentStatusUpdateRequest) { | ||
CommentStatusUpdateResult decision = commentService.decisionComments(eventId, commentStatusUpdateRequest); | ||
log.info("PATCH /admin/comments/event/{eventId}eventId = {} patchedComment = {}", eventId, decision); | ||
return decision; | ||
} | ||
} |
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
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
64 changes: 64 additions & 0 deletions
64
...c/main/java/ru/practicum/mainservice/controller/privateapi/PrivateCommentsController.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,64 @@ | ||
package ru.practicum.mainservice.controller.privateapi; | ||
|
||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.PositiveOrZero; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
import ru.practicum.mainservice.data.dto.comment.CommentDto; | ||
import ru.practicum.mainservice.service.interfaces.CommentService; | ||
|
||
import java.util.List; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/users/{userId}/event/{eventId}/comments") | ||
@RequiredArgsConstructor | ||
public class PrivateCommentsController { | ||
private final CommentService commentService; | ||
|
||
@PostMapping | ||
@ResponseStatus(HttpStatus.CREATED) | ||
public CommentDto createComment(@PositiveOrZero @PathVariable Long userId, | ||
@PositiveOrZero @PathVariable Long eventId, | ||
@Valid @RequestBody CommentDto comment) { | ||
CommentDto createdComment = commentService.createComment(userId, eventId, comment); | ||
log.info("POST /users/{userId}/event/{eventId}/comments userId = {} eventId = {} createdComment = {}", userId, | ||
eventId, createdComment); | ||
return createdComment; | ||
} | ||
|
||
@DeleteMapping("/{commentId}") | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
public void deleteComment(@PositiveOrZero @PathVariable Long userId, | ||
@PositiveOrZero @PathVariable Long eventId, | ||
@PositiveOrZero @PathVariable Long commentId) { | ||
log.info("DELETE /users/{userId}/event/{eventId}/comments/{commentId} userId = {}," + | ||
" eventId = {}, commentId = {}", userId, eventId, commentId); | ||
commentService.deleteComment(userId, eventId, commentId); | ||
} | ||
|
||
@GetMapping | ||
public List<CommentDto> getCommentsByEventId(@PositiveOrZero @PathVariable Long userId, | ||
@PositiveOrZero @PathVariable Long eventId, | ||
@PositiveOrZero @RequestParam(defaultValue = "0") Integer from, | ||
@PositiveOrZero @RequestParam(defaultValue = "0") Integer size) { | ||
List<CommentDto> commentsByEventId = commentService.getCommentsByEventId(userId, eventId, PageRequest.of(from / size, size)); | ||
log.info("GET /users/{userId}/event/{eventId}/comments userId = {} eventId = {} result = {}", userId, | ||
eventId, commentsByEventId); | ||
return commentsByEventId; | ||
} | ||
|
||
@GetMapping("/{commentId}") | ||
public CommentDto findComment(@PositiveOrZero @PathVariable Long userId, | ||
@PositiveOrZero @PathVariable Long eventId, | ||
@PositiveOrZero @PathVariable Long commentId) { | ||
log.info("GET /users/{userId}/event/{eventId}/comments/{commentId}" + | ||
" userId = {} eventId = {} commentId = {}", userId, eventId, commentId); | ||
CommentDto commentByIdAndEventId = commentService.getCommentByIdAndEventId(userId, eventId, commentId); | ||
log.info("Найденный комментарий {}", commentByIdAndEventId); | ||
return commentByIdAndEventId; | ||
} | ||
} |
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
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
26 changes: 26 additions & 0 deletions
26
main-service/src/main/java/ru/practicum/mainservice/data/dto/comment/CommentDto.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,26 @@ | ||
package ru.practicum.mainservice.data.dto.comment; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.*; | ||
import ru.practicum.mainservice.data.model.enums.CommentStatus; | ||
import ru.practicum.statsdto.dto.UserDto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Setter | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder(toBuilder = true) | ||
public class CommentDto { | ||
private Long id; | ||
private Long eventId; | ||
private String comment; | ||
private UserDto user; | ||
@NotBlank | ||
private String description; | ||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
private LocalDateTime publishedOn; | ||
private CommentStatus status; | ||
} |
26 changes: 26 additions & 0 deletions
26
...e/src/main/java/ru/practicum/mainservice/data/dto/comment/CommentStatusUpdateRequest.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,26 @@ | ||
package ru.practicum.mainservice.data.dto.comment; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import jakarta.validation.constraints.NotEmpty; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.Set; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class CommentStatusUpdateRequest { | ||
@NotEmpty | ||
private Set<Long> ids; | ||
@NotNull | ||
private Status status; | ||
|
||
public enum Status { | ||
APPROVE, | ||
REJECT | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ce/src/main/java/ru/practicum/mainservice/data/dto/comment/CommentStatusUpdateResult.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,12 @@ | ||
package ru.practicum.mainservice.data.dto.comment; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Builder(toBuilder = true) | ||
public class CommentStatusUpdateResult { | ||
private List<CommentDto> resolvedComments; | ||
} |
3 changes: 2 additions & 1 deletion
3
.../mainservice/data/dto/CompilationDto.java → .../data/dto/compilation/CompilationDto.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
2 changes: 1 addition & 1 deletion
2
...inservice/data/dto/NewCompilationDto.java → ...ta/dto/compilation/NewCompilationDto.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
2 changes: 1 addition & 1 deletion
2
...ce/data/dto/UpdateCompilationRequest.java → ...compilation/UpdateCompilationRequest.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
2 changes: 1 addition & 1 deletion
2
...nservice/data/dto/EventRequestStatus.java → ...ce/data/dto/event/EventRequestStatus.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
2 changes: 1 addition & 1 deletion
2
.../dto/EventRequestStatusUpdateRequest.java → ...vent/EventRequestStatusUpdateRequest.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
3 changes: 2 additions & 1 deletion
3
...a/dto/EventRequestStatusUpdateResult.java → ...event/EventRequestStatusUpdateResult.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
4 changes: 2 additions & 2 deletions
4
...ainservice/data/dto/EventResponseDto.java → ...vice/data/dto/event/EventResponseDto.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
5 changes: 3 additions & 2 deletions
5
...m/mainservice/data/dto/EventShortDto.java → ...service/data/dto/event/EventShortDto.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
2 changes: 1 addition & 1 deletion
2
...cum/mainservice/data/dto/LocationDto.java → ...inservice/data/dto/event/LocationDto.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
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
2 changes: 1 addition & 1 deletion
2
...cum/mainservice/data/dto/UpdateEvent.java → ...inservice/data/dto/event/UpdateEvent.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
2 changes: 1 addition & 1 deletion
2
...ice/data/dto/UpdateEventAdminRequest.java → ...ta/dto/event/UpdateEventAdminRequest.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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нет нет логирвования водящего запроса. Ведь сначала нужно понять что он пришел
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо большое
наконец-то проект закрыт и с курсом закончено
как же хочу применить свои навыки
спасибо