package vn.azteam.tpf.service.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import vn.azteam.tpf.domain.TBCodeDetails;
import vn.azteam.tpf.service.dto.TBCodeDetailsDTO;

@Mapper(componentModel = "spring", uses = {TBDetailUserMapper.class})
public interface TBCodeDetailsMapper extends EntityMapper<TBCodeDetailsDTO, TBCodeDetails> {
    @Mapping(source = "createdBy.id", target = "createdById")
    @Mapping(source = "modifiedBy.id", target = "modifiedById")
    @Mapping(source = "deletedBy.id", target = "deletedById")
    TBCodeDetailsDTO toDto(TBCodeDetails tBCodeDetails);

    @Mapping(source = "tbCode", target = "tbCode")
    @Mapping(source = "createdById", target = "createdBy")
    @Mapping(source = "modifiedById", target = "modifiedBy")
    @Mapping(source = "deletedById", target = "deletedBy")
    TBCodeDetails toEntity(TBCodeDetailsDTO tBCodeDetailsDTO);

    default TBCodeDetails fromId(Long id) {
        if (id == null) {
            return null;
        }
        TBCodeDetails tBCodeDetails = new TBCodeDetails();
        tBCodeDetails.setId(id);
        return tBCodeDetails;
    }
}
