Skip to content

Commit

Permalink
Fix : validation 추가, modifiedDate 어노테이션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Astin01 committed Oct 23, 2024
1 parent 94defe5 commit ae222cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ public ResponseEntity<InformationCommentResponse> createInformationComment(@Auth
BindingResult bindingResult) {
Utils.validationRequest(bindingResult);

InformationCommentResponse informationCommentResponse = informationCommentService.createInformationComment(userId, informationId, informationCommentRequest);
InformationCommentResponse informationCommentResponse = informationCommentService.createInformationComment(
userId, informationId, informationCommentRequest);

return ResponseEntity
.status(HttpStatus.CREATED)
.body(informationCommentResponse);
}

@GetMapping("/{informationId}")
public ResponseEntity<Page<InformationCommentListResponse>> getPageInformationComment(@RequestParam(defaultValue = "0") int page,
@PathVariable Long informationId) {
public ResponseEntity<Page<InformationCommentListResponse>> getPageInformationComment(
@RequestParam(defaultValue = "0") int page,
@PathVariable Long informationId) {

final int PAGE_SIZE = 5;
Pageable pageable = PageRequest.of(page, PAGE_SIZE);
Page<InformationCommentListResponse> pageInformation = informationCommentService.getPageInformationComment(pageable, informationId);
Page<InformationCommentListResponse> pageInformation = informationCommentService.getPageInformationComment(
pageable, informationId);

return ResponseEntity
.status(HttpStatus.OK)
Expand All @@ -58,7 +61,9 @@ public ResponseEntity<Page<InformationCommentListResponse>> getPageInformationCo
@PutMapping("/{informationCommentId}")
public ResponseEntity<Void> modifyInformationComment(@AuthenticationPrincipal Long userId,
@PathVariable Long informationCommentId,
@Valid @RequestBody InformationCommentRequest informationCommentRequest) {
@Valid @RequestBody InformationCommentRequest informationCommentRequest,
BindingResult bindingResult) {
Utils.validationRequest(bindingResult);

informationCommentService.modifyInformationComment(userId, informationCommentId, informationCommentRequest);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import solitour_backend.solitour.information.entity.Information;
import solitour_backend.solitour.information_comment.dto.request.InformationCommentRequest;
Expand Down Expand Up @@ -43,11 +44,11 @@ public class InformationComment {
@Column(name = "information_comment_created_date")
private LocalDateTime createdDate;

@LastModifiedDate
@Column(name = "information_comment_updated_date")
private LocalDateTime updatedDate;

public void updateComment(@Valid InformationCommentRequest informationCommentRequest) {
this.content = informationCommentRequest.getComment();
this.updatedDate = LocalDateTime.now();
}
}

0 comments on commit ae222cc

Please sign in to comment.