Skip to content

Commit 6cd360a

Browse files
committed
Исправлена ошибка с маппингом комментариев
1 parent c489529 commit 6cd360a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/ru/skypro/homework/mapper/CommentMapper.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import ru.skypro.homework.entity.Image;
1111
import ru.skypro.homework.entity.User;
1212

13+
import java.util.Objects;
14+
1315
@Mapper(componentModel = "spring", injectionStrategy = InjectionStrategy.CONSTRUCTOR)
1416
public interface CommentMapper {
1517

@@ -27,9 +29,10 @@ default CommentDto toDto(Comment comment) {
2729

2830
CommentDto commentDto = new CommentDto();
2931
commentDto.setPk(comment.getCommentId());
30-
commentDto.setCreatedAt(comment.getCreatedAt());
3132
commentDto.setText(comment.getText());
3233

34+
commentDto.setCreatedAt(Objects.requireNonNullElse(comment.getCreatedAt(), 0L));
35+
3336
User author = comment.getAuthor();
3437
if (author != null) {
3538

0 commit comments

Comments
 (0)