본문 바로가기

스프링과 JPA 기반 웹 어플리케이션 개발85

73. 스터디 개설 알림 스터디를 만들때가 아니라 공개할 때 알림 알림 받을 사람: 스터디 주제와 지역에 매칭이 되는 Account 알림 제목: 스터디 이름 알림 메시지: 스터디 짧은 소개 QueryDSL설정 http://www.querydsl.com/ 타입 세이프하게 JPA 쿼리를 작성할 수 있다. QueryDSL 설치 com.querydsl querydsl-jpa com.mysema.maven apt-maven-plugin 1.1.3 process target/generated-sources/java com.querydsl.apt.jpa.JPAAnnotationProcessor com.querydsl querydsl-apt ${querydsl.version} 이후에 반드시 메이븐 컴파일 빌드 (mvc compile)를 해야 .. 2020. 5. 11.
72. 알림 처리 설계 ApplicationEventPublisher와 스프링 @Async 기능을 사용해서 비동기 이벤트 기반으로 알림 처리. 주요 로직 응답 시간에 영향을 주지 않기. 코드를 최대한 주요 로직에 집중하고 알림 처리 로직은 분리. 스프링 이벤트 프로그래밍 모델 ApplicationEventPublisher.publishEvent(Event) // 이벤트 발생 @EventListener // 이벤트 처리 public void handlerEvent(Event event) 스프링 @Async 기능 설정 @Configuration @EnableAsync public class AsyncConfig implements AsyncConfigurer { // Executor 설정 } ThreadPoolTaskExecuto.. 2020. 5. 11.
71. 알림 도메인 Notification에서 Account로 ManyToOne 단방향 관계 Notification 제목 링크 짧은 메시지 확인 여부 누구에게 (Account) 언제 알림 타입(새 스터디, 참여중인 스터디, 모임 참가 신청 결과) 알림 기능을 담당 할 Notification 엔티티 생성 package me.weekbelt.studyolle.modules.notification; @Getter @Setter @EqualsAndHashCode(of = "id") @Entity public class Notification { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String title; private St.. 2020. 5. 10.
70. 테스트 클래스 정리 ObjectMother를 적용하자 https://martinfowler.com/bliki/ObjectMother.html 테스트에 필요한 데이터를 만드는데 도움을 주는 유틸리티 AccountFactory와 StudyFactoryt를 만들고 테스트 픽처 메소드 옮기기 상속 보다는 위임을 커스텀 애노테이션으로 테스트 애노테이션 묶음 만들기 @Retention(RetentionPilicy.RUNTIME) @Target(ElementType.TYPE) @Transactional @SpringBootTest @AutoConfigureMockMvc public @interface MockMvcTest { } Account 생성을 도와주는 AccountFactory 클래스 생성 package me.weekbelt.s.. 2020. 5. 6.