[매퍼 설정 개선] CommonCodeMapper, CommonGroupCodeMapper, MemberMapper에서 componentModel 설정을 GlobalMapperConfig로 변경하여 매퍼 설정을 통일하고, GlobalMapperConfig 클래스를 새로 추가하여 매핑 전략을 정의.
This commit is contained in:
		@@ -6,12 +6,13 @@ import com.bio.bio_backend.domain.admin.common_code.dto.CreateCommonCodeResponse
 | 
			
		||||
import com.bio.bio_backend.domain.admin.common_code.dto.UpdateCommonCodeRequestDto;
 | 
			
		||||
import com.bio.bio_backend.domain.admin.common_code.entity.CommonCode;
 | 
			
		||||
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(componentModel = "spring")
 | 
			
		||||
@Mapper(config = GlobalMapperConfig.class)
 | 
			
		||||
public interface CommonCodeMapper {
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -6,12 +6,13 @@ import com.bio.bio_backend.domain.admin.common_code.dto.CreateCommonGroupCodeRes
 | 
			
		||||
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(componentModel = "spring")
 | 
			
		||||
@Mapper(config = GlobalMapperConfig.class)
 | 
			
		||||
public interface CommonGroupCodeMapper {
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -5,16 +5,15 @@ import com.bio.bio_backend.domain.base.member.dto.CreateMemberResponseDto;
 | 
			
		||||
import com.bio.bio_backend.domain.base.member.dto.MemberDto;
 | 
			
		||||
import com.bio.bio_backend.domain.base.member.entity.Member;
 | 
			
		||||
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 org.mapstruct.factory.Mappers;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Mapper(componentModel = "spring")
 | 
			
		||||
@Mapper(config = GlobalMapperConfig.class)
 | 
			
		||||
public interface MemberMapper {
 | 
			
		||||
    
 | 
			
		||||
    MemberMapper INSTANCE = Mappers.getMapper(MemberMapper.class);
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * CreateMemberRequestDto를 MemberDto로 변환
 | 
			
		||||
     * 기본값 설정: role = MemberRole.MEMBER, useFlag = true
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
package com.bio.bio_backend.global.config;
 | 
			
		||||
 | 
			
		||||
import org.mapstruct.*;
 | 
			
		||||
 | 
			
		||||
@MapperConfig(
 | 
			
		||||
    componentModel = "spring",
 | 
			
		||||
    
 | 
			
		||||
    // null 값은 매핑하지 않음 (부분 업데이트)
 | 
			
		||||
    nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
 | 
			
		||||
    
 | 
			
		||||
    // NPE 방지용 null 체크
 | 
			
		||||
    nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
 | 
			
		||||
    
 | 
			
		||||
    // 매핑 누락 시 컴파일 오류
 | 
			
		||||
    unmappedTargetPolicy = ReportingPolicy.ERROR,
 | 
			
		||||
    
 | 
			
		||||
    // 컬렉션 매핑 전략
 | 
			
		||||
    collectionMappingStrategy = CollectionMappingStrategy.ACCESSOR_ONLY
 | 
			
		||||
)
 | 
			
		||||
public interface GlobalMapperConfig {
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user