본문 바로가기
반응형

전체 글149

Error: resolved [org.springframework.web.httpmediatypenotsupportedexception: content type '' not supported, Error: response status is 415 이전 글에서의 에러 상황 https://brightgarden02.com/entry/REST-API-%EB%B0%B1%EC%97%94%EB%93%9C%EC%97%90%EC%84%9C-%ED%94%84%EB%A1%A0%ED%8A%B8%EB%A1%9C-%EB%8D%B0%EC%9D%B4%ED%84%B0-%EC%A0%84%EC%86%A1 Spring REST API 백엔드에서 프론트로 데이터 전송 백엔드와 프론트는 HTTP 통신을 통해 데이터를 주고 받으므로 백엔드 컨트롤러에서 ResponseEntity를 통해 감싸서 데이터를 전송한다 @RestController @RequiredArgsConstructor @RequestMapping(value = "/usr/mypage", consu brightGarden0.. 2022. 12. 1.
Spring REST API 백엔드에서 프론트로 데이터 전송 MenteeMyPageController에서 데이터 전송(백엔드 -> 프론트)을 하려고 한다 @RestController @RequiredArgsConstructor @RequestMapping(value = "/usr/mypage", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @Tag(name = "MenteeMyPageController", description = "개인정보조회, 개인정보수정, 수강중인 클래스 정보 제공 기능을 담당") public class MenteeMyPageController { private final MenteeMyPageService menteeMyPageService; @Operation.. 2022. 12. 1.
Why & How to use Builder Pattern, good things Why use Builder Pattern : Making constructor is cumbersome. When collaborating with other developers, multiple constructors can lead to confusion about which constructor to use. Even if made constructor, some values could be null. It is cumbersome to put null. Builder Pattern's Good things: It is easy to make constructor. You don't have to think what values' order, neither what values to put Bui.. 2022. 11. 27.
빌더 패턴(Builder Pattern) 쓰는 이유, 장점, 단점, 사용법 빌더 패턴을 쓰는 이유: 생성자를 여러개 만들기 번거러움, 다른 개발자와 협력할 때 생성자가 여러개면 어떤 생성자를 써야할지 헷깔릴 수 있음, 생성자를 만들어도 null 값을 일일이 넣어야할 경우가 있을 수 있는데 번거러움 빌더 패턴 장점: 생성자 만들기 편함 생성자 만들때 어떤 값을 넣을지 순서는 어떻게 할지 고려하지 않아도 됨 빌더 패턴 단점: 없는듯 빌더패턴 사용법(스프링): 1. 롬복(lombok) 설정 2. @SuperBuilder 어노테이션 사용 @Builder가 아닌 @SuperBuilder를 쓰는 이유 -> 부모인 BaseEntity를 상속받는 자식 객체인 Chef를 만들기 위함 -> 부모객체의 값도 입력하게 하기 위함 @Entity @Getter @AllArgsConstructor @No.. 2022. 11. 27.
Spring Security 로그인 문제 @Getter public class MemberContext extends User { private final Long id; private final LocalDateTime createDate; private final LocalDateTime modifyDate; private final String name; MemberContext에서 User를 상속받아 구현했다. 그런데 로그인이 안되는 에러가 생겼다. 디비에 저장이 안된건가 확인해봤다. 디비에는 잘 저장되어있다. 이유는 간단했다. MemberContext 클래스가 User를 상속받는데 User에 있는 username을 사용하기 때문이다. name이 아닌 username으로 사용해야했다. import org.springframework.se.. 2022. 11. 20.
AppointmentCommandService Class - Test Code I wrote test code per one class. I chose AppointmentCommandService to write test code. Before wrtting test code, I put data in database. I classified into 3 categories in one method. "given, when, then" given: something is given. when: something is done. then: verification @Test void appointmentStatusTest() throws Exception { //given Appointment appointment1 = appointmentRepository.findById(1L)... 2022. 11. 11.
AppointmenCommandService 클래스 - 테스트 코드 단일 클래스에 대해 짰으며 AppointmenCommandService 클래스에 대해 테스트 코드를 짜보았다. 데이터를 디비에 이미 넣어둔 상태로 테스트 코드를 작성을 진행하였다. 테스트코드는 given, when, then으로 나누어 작성하였다. given: 00이 주어짐 when: 00한 경우 then: 검증 @Test void appointmentStatusTest() throws Exception { //given Appointment appointment1 = appointmentRepository.findById(1L).get(); //when appointmentCommandService.updateAppointmentStatus(appointment1.getId(), AppointmentS.. 2022. 11. 11.
AppointmentQueryService Class - Test Code I wrote test code per one class. I chose AppointmentQueryService to write test code. Before wrtting test code, I put data in database. I classified into 3 categories in one method. "given, when, then" given: something is given. when: something is done. then: verification @Test void findAllAppointmentEntityListTest() throws Exception { //given Doctor doctor = doctorRepository.findById(5L).get(); .. 2022. 11. 10.

반응형
반응형