728x90
반응형

DTO 3

[Connect PLC to Server] Postman으로 MultipartFile, RequestBody 요청 테스트

모듈을 통해 이미지 파일과 API에 필요한 데이터를 받아서 로직 처리를 하는 API를 제작하고 있었습니다. 아직 이미지파일과 데이터를 받는 작업은 완료되지 않아서 포스트맨 프로그램을 통해 테스트 해보려고 했습니다. 그런데 MultipartFile과 RequestBody를 한번에 요청할 수 없었습니다. @RequestPart Cpmtemt-type이 'multipart/form-data'와 관련된 경우 사용합니다. 즉, @RequestBody가 필요하지만 Binary Stream이 포함되는 MultipartFile과 같은 경우에 사용할 수 있습니다. MultipartFile도 사용가능하고 RequestBody에 포함되는 부분도 content-type을 명시하고 사용할 수 있기 때문에 @RequestPart..

[Management] Spring Data JPA : nativeQuery의 결과를 DTO에 직접 매핑

Error No converter found capable of converting from type [org.springframework.data.jpa.repository.query 1. 문제 인식 원자재 아이템 항목의 전체 재고를 한번에 조회하기 위한 쿼리를 만들었습니다. Spring Data Jpa 를 사용하기 때문에 @Query를 이용해서 작성했습니다. @Query(value = "SELECT item.name AS itemName, SUM(material.count) AS sumCount, MAX(material.created_date) AS recentCreatedDate " + "FROM material JOIN item ON item.id = material.item WHERE mater..

Project/Management 2022.11.11

[Management] QueryDSL : QueryReuslt Dto로 반환 & Join Error & Alias orderBy 참조 방법

오늘은 QueryDSL 사용 시 Q객체를 사용하지 않고, 결과값을 사용하지 않고 DTO를 이용해서 반환하는 방법을 정리해보겠습니다. 1. DTO를 이용해서 반환하는 경우 sum()이나 count() 같은 메서드 사용하는 경우 join을 이용해 다른 엔티티 정보를 반환하는 경우 2. DTO를 반환하는 방법 queryFactory.select( Projections.bean ( Entity.class, QEntity.entity.properties ... ) ) Setter를 이용한 바인딩으로 잘 사용하지는 않는 방법입니다. queryFactory.select( Projections.constructor( Entity.class, QEntity.entity.properties ... ) ) 생성자를 이용한 ..

Project/Management 2022.11.09
728x90
반응형