package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

/**
 * Mapper for the entity TBActivity and its DTO TBActivityDTO.
 */
@Mapper(componentModel = "spring", uses = {TBDetailUserMapper.class, TBActivityTypeMapper.class, TBCropMapper.class})
public interface TBActivityMapper extends EntityMapper<TBActivityDTO, TBActivity> {

    @Mapping(source = "deletedBy.id", target = "deletedById")
    @Mapping(source = "createdBy.fullName", target = "createdByName")
    @Mapping(source = "createdBy.id", target = "createdById")
    @Mapping(source = "modifiedBy.id", target = "modifiedById")
    @Mapping(source = "modifiedBy.fullName", target = "modifiedByName")
    @Mapping(source = "activityType.id", target = "activityTypeId")
    @Mapping(source = "activityType.name", target = "activityTypeName")
    @Mapping(source = "activityType.description", target = "activityTypeDescription")
    @Mapping(source = "crop.id", target = "cropId")
    TBActivityDTO toDto(TBActivity tBActivity);

    @Mapping(source = "deletedById", target = "deletedBy")
    @Mapping(source = "createdById", target = "createdBy")
    @Mapping(source = "modifiedById", target = "modifiedBy")
    @Mapping(source = "activityTypeId", target = "activityType")
    @Mapping(source = "cropId", target = "crop")
    TBActivity toEntity(TBActivityDTO tBActivityDTO);

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