package com.bio.bio_backend.domain.admin.common_code.mapper;

import com.bio.bio_backend.domain.admin.common_code.dto.CommonGroupCodeDto;
import com.bio.bio_backend.domain.admin.common_code.dto.CreateCommonGroupCodeRequestDto;
import com.bio.bio_backend.domain.admin.common_code.dto.CreateCommonGroupCodeResponseDto;
import com.bio.bio_backend.domain.admin.common_code.dto.UpdateCommonGroupCodeRequestDto;
import com.bio.bio_backend.domain.admin.common_code.entity.CommonGroupCode;
import com.bio.bio_backend.global.annotation.IgnoreBaseEntityMapping;
import com.bio.bio_backend.global.config.GlobalMapperConfig;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

@Mapper(config = GlobalMapperConfig.class)
public interface CommonGroupCodeMapper {
    
    /**
     * CommonGroupCode 엔티티를 CommonGroupCodeDto로 변환
     */
    CommonGroupCodeDto toCommonGroupCodeDto(CommonGroupCode commonGroupCode);

    /**
     * CommonGroupCodeDto를 CommonGroupCode 엔티티로 변환
     */
    CommonGroupCode toCommonGroupCode(CommonGroupCodeDto commonGroupCodeDto);
    
    /**
     * CommonGroupCode 엔티티 리스트를 CommonGroupCodeDto 리스트로 변환
     */
    List<CommonGroupCodeDto> toCommonGroupCodeDtoList(List<CommonGroupCode> commonGroupCodes);
    
    /**
     * CommonGroupCodeDto를 CreateCommonGroupCodeResponseDto로 변환
     */
    CreateCommonGroupCodeResponseDto toCreateCommonGroupCodeResponseDto(CommonGroupCodeDto commonGroupCodeDto);
    
    /**
     * CreateCommonGroupCodeRequestDto를 CommonGroupCodeDto로 변환
     */
    @Mapping(target = "oid", ignore = true)
    CommonGroupCodeDto toCommonGroupCodeDto(CreateCommonGroupCodeRequestDto createRequestDto);
    
    /**
     * UpdateCommonGroupCodeRequestDto를 CommonGroupCodeDto로 변환
     */
    @Mapping(target = "oid", ignore = true)
    @Mapping(target = "code", ignore = true)
    CommonGroupCodeDto toCommonGroupCodeDto(UpdateCommonGroupCodeRequestDto updateRequestDto);
    
    /**
     * CommonGroupCodeDto의 값으로 CommonGroupCode 엔티티를 업데이트
     */
    @IgnoreBaseEntityMapping
    void updateCommonGroupCodeFromDto(CommonGroupCodeDto commonGroupCodeDto, @org.mapstruct.MappingTarget CommonGroupCode commonGroupCode);
}
