Skip to content

Commit

Permalink
improve mappers target ignores were added
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisKalyakin committed Nov 15, 2023
1 parent 70c23ef commit a5639d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/mate/academy/mapstruct/mapper/GroupMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import mate.academy.mapstruct.exception.EntityNotFoundException;
import mate.academy.mapstruct.model.Group;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;

@Mapper(config = MapperConfig.class)
public interface GroupMapper {
GroupDto toDto(Group group);

@Mapping(target = "id", ignore = true)
Group toModel(CreateGroupRequestDto requestDto);

@Named("groupById")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@Mapper(config = MapperConfig.class, uses = GroupMapper.class)
public interface StudentMapper {
@Mapping(source = "group.id", target = "groupId")
@Mapping(target = "subjectIds", ignore = true)
StudentDto toDto(Student student);

@AfterMapping
Expand All @@ -30,6 +31,9 @@ default void setSubjectsIds(
StudentWithoutSubjectsDto toEmployeeWithoutSubjectsDto(Student student);

@Mapping(target = "group", source = "groupId", qualifiedByName = "groupById")
@Mapping(target = "socialSecurityNumber", ignore = true)
@Mapping(target = "subjects", ignore = true)
@Mapping(target = "id", ignore = true)
Student toModel(CreateStudentRequestDto requestDto);

@AfterMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import mate.academy.mapstruct.dto.subject.SubjectDto;
import mate.academy.mapstruct.model.Subject;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(config = MapperConfig.class)
public interface SubjectMapper {
SubjectDto toDto(Subject subject);

@Mapping(target = "id", ignore = true)
Subject toModel(CreateSubjectRequestDto requestDto);
}

0 comments on commit a5639d7

Please sign in to comment.