40 lines
1.6 KiB
Java
40 lines
1.6 KiB
Java
package ru.gorodar.mapper;
|
|
|
|
import org.mapstruct.Mapper;
|
|
import org.mapstruct.Mapping;
|
|
import org.mapstruct.ReportingPolicy;
|
|
import ru.gorodar.api.dto.PhotoDtos.PhotoResponse;
|
|
import ru.gorodar.api.dto.PhotoDtos.PhotoVerifyResponse;
|
|
import ru.gorodar.api.dto.PhotoDtos.ReferenceMatchResult;
|
|
import ru.gorodar.dao.entity.AttractionPhoto;
|
|
import ru.gorodar.dao.entity.VerifyVerdict;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.util.List;
|
|
|
|
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.ERROR)
|
|
public interface PhotoMapper {
|
|
|
|
@Mapping(target = "photoUrl", source = "photoUrl")
|
|
PhotoResponse toResponse(AttractionPhoto photo, String photoUrl);
|
|
|
|
@Mapping(target = "photoId", source = "photo.id")
|
|
@Mapping(target = "sortOrder", source = "photo.sortOrder")
|
|
@Mapping(target = "confidence", source = "confidence")
|
|
@Mapping(target = "match", source = "match")
|
|
ReferenceMatchResult toReferenceMatchResult(AttractionPhoto photo, float confidence, boolean match);
|
|
|
|
@Mapping(target = "verdict", source = "verdict")
|
|
@Mapping(target = "confidence", source = "confidence")
|
|
@Mapping(target = "matchThreshold", source = "matchThreshold")
|
|
@Mapping(target = "noMatchThreshold", source = "noMatchThreshold")
|
|
@Mapping(target = "references", source = "references")
|
|
PhotoVerifyResponse toVerifyResponse(VerifyVerdict verdict, float confidence,
|
|
BigDecimal matchThreshold, BigDecimal noMatchThreshold,
|
|
List<ReferenceMatchResult> references);
|
|
|
|
default String map(VerifyVerdict verdict) {
|
|
return verdict.name().toLowerCase();
|
|
}
|
|
}
|