added image for post

This commit is contained in:
SlimusMinus
2026-06-01 01:57:16 +03:00
parent d4cb1ec2e3
commit 723e92baf1
9 changed files with 152 additions and 40 deletions

View File

@@ -5,6 +5,9 @@ import com.krylov.refound.dto.PostResponse;
import com.krylov.refound.entity.Post;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import com.krylov.refound.entity.Image;
import org.mapstruct.Named;
import java.util.List;
@Mapper(componentModel = "spring")
public interface PostMapper {
@@ -12,5 +15,14 @@ public interface PostMapper {
Post toEntity(PostRequest request);
@Mapping(source = "user.login", target = "userEmail")
@Mapping(source = "images", target = "images", qualifiedByName = "imagesToUrls")
PostResponse toResponse(Post post);
@Named("imagesToUrls")
default List<String> imagesToUrls(List<Image> images) {
if (images == null) return List.of();
return images.stream()
.map(Image::getUrl)
.toList();
}
}