-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathClubJpaEntity.java
More file actions
56 lines (46 loc) · 1.42 KB
/
ClubJpaEntity.java
File metadata and controls
56 lines (46 loc) · 1.42 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package kgu.developers.domain.club.infrastructure;
import jakarta.persistence.*;
import kgu.developers.common.domain.BaseTimeEntity;
import kgu.developers.domain.club.domain.Club;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import static jakarta.persistence.GenerationType.IDENTITY;
import static lombok.AccessLevel.PROTECTED;
@Entity
@Table(name = "\"club\"")
@Builder
@Getter
@AllArgsConstructor
@NoArgsConstructor(access = PROTECTED)
public class ClubJpaEntity extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = IDENTITY)
private Long id;
@Column(nullable = false, unique = true, length = 16)
private String name;
@Column(nullable = false, length = 100)
private String description;
@Column(length = 50)
private String site;
private Long fileId;
public Club toDomain() {
return Club.builder()
.id(id)
.name(name)
.description(description)
.site(site)
.fileId(fileId)
.build();
}
public static ClubJpaEntity fromDomain(Club club) {
return ClubJpaEntity.builder()
.id(club.getId())
.name(club.getName())
.description(club.getDescription())
.site(club.getSite())
.fileId(club.getFileId())
.build();
}
}