package cz.muni.fi.pa165.soccermanager.mapper;

import cz.muni.fi.pa165.soccermanager.dto.TeamDto;
import cz.muni.fi.pa165.soccermanager.dto.request.UpdateTeamDto;
import cz.muni.fi.pa165.soccermanager.dto.request.CreateTeamRequest;
import cz.muni.fi.pa165.soccermanager.factory.TeamFactory;
import cz.muni.fi.pa165.soccermanager.entity.Team;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

import java.util.List;

/**
 * @author Petr Balazy (uco: 527362)
 */
@Mapper(uses = TeamFactory.class)
public interface TeamMapper {

    @Mapping(target = "user.name", source = "user.nickName")
    TeamDto map(Team source);

    @Mapping(target = "championship", ignore = true)
    @Mapping(target = "id", ignore = true)
    Team map(UpdateTeamDto source);

    @Mapping(target = "user.name", source = "user.nickName")
    List<TeamDto> map(List<Team> source);

    @Mapping(target = "id", ignore = true)
    void mapOnUpdate(@MappingTarget Team target, UpdateTeamDto source);

    @Mapping(target = "id", ignore = true)
    Team map(CreateTeamRequest request);

}
