-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
104 additions
and
84 deletions.
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
42 changes: 39 additions & 3 deletions
42
src/main/java/ru/nsu/fit/directors/establishmentservice/mapper/TagConverter.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 |
---|---|---|
@@ -1,28 +1,64 @@ | ||
package ru.nsu.fit.directors.establishmentservice.mapper; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import ru.nsu.fit.directors.establishmentservice.dto.request.RequestTagDto; | ||
import ru.nsu.fit.directors.establishmentservice.dto.response.ResponseTagDto; | ||
import ru.nsu.fit.directors.establishmentservice.enums.Tag; | ||
import ru.nsu.fit.directors.establishmentservice.service.ImageWorker; | ||
import ru.nsu.fit.directors.establishmentservice.service.AmazonImageServiceImpl; | ||
import ru.nsu.fit.directors.establishmentservice.utils.EnumUtils; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@ParametersAreNonnullByDefault | ||
public class TagConverter { | ||
private final ImageWorker imageWorker; | ||
private final AmazonImageServiceImpl imageService; | ||
|
||
@Nonnull | ||
public List<ResponseTagDto> toResponse(Collection<Tag> tags) { | ||
return tags.stream() | ||
.map(x -> new ResponseTagDto(x.getTranslate(), imageWorker.getImageFromResource(x.getAssets()))) | ||
.map(this::toResponse) | ||
.toList(); | ||
|
||
} | ||
|
||
@Nonnull | ||
public List<ResponseTagDto> toResponse(Tag[] tags) { | ||
return Arrays.stream(tags) | ||
.map(this::toResponse) | ||
.toList(); | ||
} | ||
|
||
@Nonnull | ||
public ResponseTagDto toResponse(Tag tag) { | ||
return new ResponseTagDto(tag.getTranslate(), imageService.getByKey(tag.getAssets())); | ||
} | ||
|
||
@Nonnull | ||
public ResponseTagDto toSpotResponse(Tag tag) { | ||
return new ResponseTagDto(tag.getTranslateForSpot(), imageService.getByKey(tag.getAssets())); | ||
} | ||
|
||
@Nonnull | ||
public List<ResponseTagDto> toSpotResponse(Collection<Tag> tags) { | ||
return tags.stream() | ||
.map(this::toSpotResponse) | ||
.toList(); | ||
} | ||
|
||
@Nonnull | ||
public Set<Tag> toModel(Set<RequestTagDto> tagDtoSet) { | ||
return tagDtoSet.stream() | ||
.map(x -> EnumUtils.parseEnum(x.getName(), Tag.class)) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |
57 changes: 0 additions & 57 deletions
57
src/main/java/ru/nsu/fit/directors/establishmentservice/mapper/TagMapper.java
This file was deleted.
Oops, something went wrong.
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
35 changes: 35 additions & 0 deletions
35
src/test/resources/http/response/establishment/valid_time_internal.json
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,35 @@ | ||
{ | ||
"result": [ | ||
{ | ||
"hour": "12", | ||
"minute": "30", | ||
"seconds": "00" | ||
}, | ||
{ | ||
"hour": "12", | ||
"minute": "30", | ||
"seconds": "00" | ||
}, | ||
{ | ||
"hour": "12", | ||
"minute": "30", | ||
"seconds": "00" | ||
}, | ||
{ | ||
"hour": "12", | ||
"minute": "30", | ||
"seconds": "00" | ||
}, | ||
{ | ||
"hour": "12", | ||
"minute": "30", | ||
"seconds": "00" | ||
}, | ||
{ | ||
"hour": "12", | ||
"minute": "30", | ||
"seconds": "00" | ||
} | ||
], | ||
"exception": null | ||
} |
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