티스토리 뷰
본 포스팅은 백기선님의 스프링과 JPA 기반 웹 애플리케이션 개발 강의를 참고하여 작성하였습니다.
소스 코드는 여기 있습니다. (commit hash: 804ac38)> git clone https://github.com/lcalmsky/spring-boot-app.git > git checkout 804ac38ℹ️ squash merge를 사용해 기존 branch를 삭제하기로 하여 앞으로는 commit hash로 포스팅 시점의 소스 코드를 공유할 예정입니다.
Overview
알림 도메인을 설계합니다.
Design
Entity간의 관계를 살펴보면 아래와 같습니다.
Notification은 Account와 단방향 ManyToOne 관계를 가집니다.
알림(Notification)이 가지는 속성은 다음과 같습니다.
- 제목
- 링크
- 짧은 메시지
- 확인 여부
- 사용자
- 시간
- 알림 타입
- 새 스터디
- 참여중인 스터디
- 모임 참가 신청 결과
Entity 작성
notification 패키지를 생성하고 하위에 Notification 클래스를 생성합니다.
/src/main/java/io/lcalmsky/app/modules/notification/domain/entity/Notification.java
package io.lcalmsky.app.modules.notification.domain.entity;
import io.lcalmsky.app.modules.account.domain.entity.Account;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.time.LocalDateTime;
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Notification {
@Id @GeneratedValue
private Long id;
private String title;
private String link;
private String message;
private boolean checked;
@ManyToOne
private Account account;
private LocalDateTime created;
@Enumerated(EnumType.STRING)
private NotificationType notificationType;
}
Account와 @ManyToOne 관계를 지정하였고, 알림 유형은 enum 타입으로 지정하였습니다.
같은 패키지 안에 NotificationType 클래스를 생성합니다.
/src/main/java/io/lcalmsky/app/modules/notification/domain/entity/NotificationType.java
package io.lcalmsky.app.modules.notification.domain.entity;
public enum NotificationType {
STUDY_CREATED,
STUDY_UPDATED,
EVENT_ENROLLMENT,
}'SpringBoot > Web Application 만들기' 카테고리의 다른 글
| 스프링 부트 웹 애플리케이션 제작(61): Querydsl 설정 (0) | 2022.06.07 |
|---|---|
| 스프링 부트 웹 애플리케이션 제작(60): 알림 인프라 구축 (0) | 2022.06.06 |
| 스프링 부트 웹 애플리케이션 제작(58): 테스트 리팩터링 (0) | 2022.06.02 |
| 스프링 부트 웹 애플리케이션 제작(57): 패키지 구조 리팩터링 (0) | 2022.06.01 |
| 스프링 부트 웹 애플리케이션 제작(56): 모임 신청 수락/거절, 출석 체크/취소 기능 구현 (0) | 2022.05.31 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- spring boot app
- r
- spring boot jwt
- 알고리즘
- Java
- 헥사고날 아키텍처
- 클린 아키텍처
- proto3
- gRPC
- @ManyToOne
- 스프링 부트 회원 가입
- 스프링 부트
- Spring Data JPA
- Spring Boot
- leetcode
- QueryDSL
- spring boot application
- JSON
- intellij
- 스프링 부트 애플리케이션
- 스프링 부트 튜토리얼
- 스프링부트
- Linux
- JPA
- 스프링 데이터 jpa
- Spring Boot Tutorial
- Spring Boot JPA
- 함께 자라기 후기
- 함께 자라기
- Jackson
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
글 보관함
