Skip to content

Commit

Permalink
Merge branch 'spring-petclinic:master' into problem-detail-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
joaobertholino authored Nov 23, 2024
2 parents 55b6870 + b4c7dd5 commit 697b9a8
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.springframework.samples.petclinic.mapper;

import org.mapstruct.Mapper;
import org.springframework.samples.petclinic.rest.dto.OwnerDto;
import org.mapstruct.Mapping;
import org.springframework.samples.petclinic.model.Owner;
import org.springframework.samples.petclinic.rest.dto.OwnerDto;
import org.springframework.samples.petclinic.rest.dto.OwnerFieldsDto;

import java.util.Collection;
Expand All @@ -18,6 +19,8 @@ public interface OwnerMapper {

Owner toOwner(OwnerDto ownerDto);

@Mapping(target = "id", ignore = true)
@Mapping(target = "pets", ignore = true)
Owner toOwner(OwnerFieldsDto ownerDto);

List<OwnerDto> toOwnerDtoCollection(Collection<Owner> ownerCollection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.samples.petclinic.model.Pet;
import org.springframework.samples.petclinic.model.PetType;
import org.springframework.samples.petclinic.rest.dto.PetDto;
import org.springframework.samples.petclinic.rest.dto.PetFieldsDto;
import org.springframework.samples.petclinic.rest.dto.PetTypeDto;
import org.springframework.samples.petclinic.model.Pet;
import org.springframework.samples.petclinic.model.PetType;

import java.util.Collection;

/**
* Map Pet & PetDto using mapstruct
*/
@Mapper
@Mapper(uses = VisitMapper.class)
public interface PetMapper {

@Mapping(source = "owner.id", target = "ownerId")
Expand All @@ -26,6 +26,9 @@ public interface PetMapper {
@Mapping(source = "ownerId", target = "owner.id")
Pet toPet(PetDto petDto);

@Mapping(target = "id", ignore = true)
@Mapping(target = "owner", ignore = true)
@Mapping(target = "visits", ignore = true)
Pet toPet(PetFieldsDto petFieldsDto);

PetTypeDto toPetTypeDto(PetType petType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.springframework.samples.petclinic.mapper;

import org.mapstruct.Mapper;
import org.springframework.samples.petclinic.rest.dto.PetTypeDto;
import org.mapstruct.Mapping;
import org.springframework.samples.petclinic.model.PetType;
import org.springframework.samples.petclinic.rest.dto.PetTypeDto;
import org.springframework.samples.petclinic.rest.dto.PetTypeFieldsDto;

import java.util.Collection;
Expand All @@ -16,6 +17,7 @@ public interface PetTypeMapper {

PetType toPetType(PetTypeDto petTypeDto);

@Mapping(target = "id", ignore = true)
PetType toPetType(PetTypeFieldsDto petTypeFieldsDto);

PetTypeDto toPetTypeDto(PetType petType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.springframework.samples.petclinic.mapper;

import org.mapstruct.Mapper;
import org.springframework.samples.petclinic.rest.dto.RoleDto;
import org.springframework.samples.petclinic.rest.dto.UserDto;
import org.mapstruct.Mapping;
import org.springframework.samples.petclinic.model.Role;
import org.springframework.samples.petclinic.model.User;
import org.springframework.samples.petclinic.rest.dto.RoleDto;
import org.springframework.samples.petclinic.rest.dto.UserDto;

import java.util.Collection;

Expand All @@ -13,6 +14,9 @@
*/
@Mapper
public interface UserMapper {

@Mapping(target = "id", ignore = true)
@Mapping(target = "user", ignore = true)
Role toRole(RoleDto roleDto);

RoleDto toRoleDto(Role role);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.springframework.samples.petclinic.mapper;

import org.mapstruct.Mapper;
import org.springframework.samples.petclinic.rest.dto.VetDto;
import org.mapstruct.Mapping;
import org.springframework.samples.petclinic.model.Vet;
import org.springframework.samples.petclinic.rest.dto.VetDto;
import org.springframework.samples.petclinic.rest.dto.VetFieldsDto;

import java.util.Collection;
Expand All @@ -14,6 +15,7 @@
public interface VetMapper {
Vet toVet(VetDto vetDto);

@Mapping(target = "id", ignore = true)
Vet toVet(VetFieldsDto vetFieldsDto);

VetDto toVetDto(Vet vet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.samples.petclinic.rest.dto.VisitDto;
import org.springframework.samples.petclinic.model.Visit;
import org.springframework.samples.petclinic.rest.dto.VisitDto;
import org.springframework.samples.petclinic.rest.dto.VisitFieldsDto;

import java.util.Collection;
Expand All @@ -16,6 +16,8 @@ public interface VisitMapper {
@Mapping(source = "petId", target = "pet.id")
Visit toVisit(VisitDto visitDto);

@Mapping(target = "id", ignore = true)
@Mapping(target = "pet", ignore = true)
Visit toVisit(VisitFieldsDto visitFieldsDto);

@Mapping(source = "pet.id", target = "petId")
Expand Down

0 comments on commit 697b9a8

Please sign in to comment.