package vn.azteam.tpf.service.mapper;

import vn.azteam.tpf.domain.*;
import vn.azteam.tpf.service.dto.TBRoleDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity TBRole and its DTO TBRoleDTO.
 */
@Mapper(componentModel = "spring", uses = {TBDetailUserMapper.class, TBCustomerMapper.class})
public interface TBRoleMapper extends EntityMapper<TBRoleDTO, TBRole> {

    @Mapping(source = "createdBy.id", target = "createdById")
    @Mapping(source = "tbCustomer.id", target = "tbCustomerId")
    @Mapping(source = "modifiedBy.id", target = "modifiedById")
    @Mapping(source = "deletedBy.id", target = "deletedById")
    TBRoleDTO toDto(TBRole tBRole);

    @Mapping(source = "tbCustomerId", target = "tbCustomer")
    @Mapping(source = "createdById", target = "createdBy")
    @Mapping(source = "modifiedById", target = "modifiedBy")
    @Mapping(source = "deletedById", target = "deletedBy")
    TBRole toEntity(TBRoleDTO tBRoleDTO);

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