Spring29 일정 관리 프로그램 프로젝트 트러블슈팅 (Ambiguous handler methods 이슈 등) 결과물 : https://github.com/wjdals0508/ScheduleProject GitHub - wjdals0508/ScheduleProjectContribute to wjdals0508/ScheduleProject development by creating an account on GitHub.github.com JpaAuditing 이슈@Getter@MappedSuperclass@EntityListeners(AuditingEntityListener.class)public class BaseEntity { // Jpa Auditing @CreatedDate @Column(updatable = false) @Temporal(TemporalType.TIMESTAMP) .. 2026. 6. 26. CRUD 구현 9 - 간단한 페이지네이션(Pagination) 구현 페이지네이션(Pagination)이란?대용량 데이터를 여러 화면으로 나누어 표시하고 탐색하는 기법 프로젝트 구현JpaRepository에서 제공하는 페이지네이션을 사용함참고 : https://jundyu.tistory.com/19 [Spring Data] JPA를 활용해 pagination 구현하기들어가며웹 애플리케이션에서 무한 스크롤이나 페이징을 통해 데이터를 나눠 불러오는 방식은 서버 성능과 사용자 경험을 모두 고려한 방식입니다. 한 번에 모든 데이터를 불러오면 페이지 로jundyu.tistory.com import 추가모든 service에 추가 :import org.springframework.data.domain.Page;import org.springframework.data.domain.Pa.. 2026. 5. 18. CRUD 구현 8 - Postman을 이용한 테스트 프로젝트 빌드, 실행 후 아래와 같이 테스트 1. 상품 생성method : POSTurl : http://localhost:8080/productsbody : { "name": "맥북 미니", "price": 1300000, "stock": 5} resopnse : 응답에 새로 생성된 id 데이터가 들어있는 것을 확인DB : DB table에 상품이 추가된 것을 확인 (1행, 2행 데이터는 이미 있던 데이터) 2. 특정 상품 조회method : GETurl : http://localhost:8080/products/1 resopnse : id = 1 인 데이터 조회 확인 3. 모든 상품 조회method : GETurl : http://localhost:8080/products resopnse :.. 2026. 5. 15. CRUD 구현 7 - Controller 구현 Controller란? “클라이언트의 HTTP 요청을 받아 처리하는 계층” Controller의 역할요청 검증인증예외 처리 요청 유효성 검사응답 프로젝트 구현@RestController@RequiredArgsConstructor@RequestMapping("/products")public class ProductController { private final ProductService productService; @PostMapping public ProductResponse create(@RequestBody ProductRequest request) { return productService.create(request); } @GetMapping("/{id}").. 2026. 5. 15. CRUD 구현 6 - Service 구현 Service란? “비즈니스 로직을 담당하는 계층” 비즈니스 로직이란?업무 규칙! "재고가 부족하면 주문 불가"는 DB 규칙이 아니라 비즈니스 규칙이다. Service의 역할비즈니스 로직 처리트랜잭션 관리여러 Repository에 접근중복되는 비즈니스 로직 정리하여 재사용 프로젝트 구현@Service@RequiredArgsConstructor@Transactional(readOnly = true)public class OrderService { private final OrderRepository orderRepository; private final ProductRepository productRepository; @Transactional public OrderResponse.. 2026. 5. 15. CRUD 구현 5 - DTO (Data Transfer Object) 구현 DTO란? “계층 간 데이터를 안전하고 명확하게 전달하기 위한 객체” DTO와 Entity의 차이Entity DB 테이블과 직접 연결된 원본 데이터DTO사용자에게 보여주길 원하는 데이터 (* 필요한 데이터만 전달) Entity를 직접 사용하면 안되는 이유Entity는 DB 구조이다. 이를 그대로 사용자에게 전송할 경우, 보안 문제 발생 가능! (DB 구조(Entity) ≠ API 응답 구조)Entity 변경시, API 응답이 변경되어 프론트엔드 에러 발생 가능! DTO 장점API 안정성 (DTO 외 코드가 변경되어도 API 형식 유지 가능)보안 (민감 정보 숨김)필요한 데이터 전달 (응답 크기 감소)유지보수 편리무한 참조 방지 (JPA 연관관계 문제 해결) 프로젝트 구현public record Order.. 2026. 5. 15. 이전 1 2 3 4 5 다음