Skip to content

Instantly share code, notes, and snippets.

@srdelarosa
Created March 19, 2021 01:30
Show Gist options
  • Save srdelarosa/f66f6869358b9c6327df434ba0439f7c to your computer and use it in GitHub Desktop.
Save srdelarosa/f66f6869358b9c6327df434ba0439f7c to your computer and use it in GitHub Desktop.
package com.newhorizons.takeitnow.products.application.mainmodule.mapper;
import com.newhorizons.takeitnow.products.application.mainmodule.dto.ProductDto;
import com.newhorizons.takeitnow.products.domain.entity.Product;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import java.util.List;
@Mapper(componentModel = "spring")
public interface IProductMapper {
@Mappings({
@Mapping(source = "id", target = "productId"),
@Mapping(source = "description", target = "description"),
@Mapping(source = "price", target = "price")
})
ProductDto toProductDto(Product product);
List<ProductDto> toProductsDto(List<Product> products);
@InheritInverseConfiguration
@Mappings({
@Mapping(target = "createAt", ignore = true)
})
Product toProduct(ProductDto productDto);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment