본문 바로가기

Java Spring Boot

@Mapper란 ? 그리고 사용 이유?

 

@Mapper(componentModel = "spring")
public interface ChurchMapper {

  List<ChurchResDto.getChurch> getChurchList(List<ChurchEntity> churchList);
  
  !! 사용 이유: Entity랑 DTO간 데이터 전환, 필요한 데이터만 보내기에 효율성과 보안성 높일 수 있음.

// 3. DTO 매핑
return this.churchMapper.getBodyListByChurchId(bodyList);

!! (componentModel = "spring")는 MapStruct에서 코드를 생성하는 방식을 지정하는 옵션 중 하나입니다.
    여기서 "spring"은 Spring 프레임워크와의 통합을 위한 옵션입니다.