1
1
package ru .practicum .ewm .entities ;
2
2
3
+ import jakarta .validation .constraints .*;
3
4
import lombok .*;
4
5
5
6
import jakarta .persistence .*;
@@ -18,60 +19,61 @@ public class EventEntity {
18
19
@ Column (name = "event_id" , nullable = false )
19
20
private Long id ;
20
21
22
+ @ NotBlank
23
+ @ Size (min = 3 , max = 120 )
21
24
@ Column (nullable = false )
22
25
private String title ;
23
26
27
+ @ NotBlank
28
+ @ Size (min = 20 , max = 2000 )
24
29
private String annotation ;
25
30
31
+ @ NotBlank
32
+ @ Size (min = 20 , max = 7000 )
26
33
@ Column (nullable = false )
27
34
private String description ;
28
35
29
36
@ ManyToOne (fetch = FetchType .LAZY , optional = false )
30
37
@ JoinColumn (name = "cat_id" , nullable = false )
31
38
private CategoryEntity categoryEntity ;
32
39
40
+ @ PositiveOrZero
41
+ @ NotNull
33
42
private int participantLimit ;
34
43
35
- @ Builder .Default
36
44
@ Enumerated (EnumType .STRING )
37
45
@ Column (nullable = false )
38
- private EventState state = EventState . PENDING ;
46
+ private EventState state ;
39
47
40
- private boolean paid ;
48
+ @ NotNull
49
+ private Boolean paid ;
41
50
42
- @ Column (nullable = false )
51
+ @ NotNull
52
+ @ Future
53
+ @ Column (name = "event_date" , nullable = false )
43
54
private LocalDateTime eventDate ;
44
55
45
56
private float latitude ;
46
57
47
58
private float longitude ;
48
59
49
- @ Builder .Default
50
- @ Column (nullable = false )
51
- private LocalDateTime createdOn = LocalDateTime .now ();
60
+ @ Column (name = "created_on" , nullable = false )
61
+ private LocalDateTime createdOn ;
52
62
63
+ @ Column (name = "published_on" )
53
64
private LocalDateTime publishedOn ;
54
65
66
+ @ Column (name = "confirmed_requests" )
67
+ private long confirmedRequests ;
68
+
55
69
@ ManyToOne (fetch = FetchType .LAZY , optional = false )
56
70
@ JoinColumn (name = "initiator_id" , nullable = false )
57
71
private UserEntity initiator ;
58
72
59
- @ Builder .Default
60
- @ Column (name = "req_moderation" )
61
- private boolean requestModeration = true ;
62
-
63
- @ Transient
64
- public boolean isPublished () {
65
- return state .equals (EventState .PUBLISHED );
66
- }
67
-
68
- @ Transient
69
- public boolean isCanceled () {
70
- return state .equals (EventState .CANCELED );
71
- }
73
+ @ NotNull
74
+ @ Column (name = "request_moderation" )
75
+ private Boolean requestModeration ;
72
76
73
77
@ Transient
74
- public boolean isPending () {
75
- return state .equals (EventState .PENDING );
76
- }
78
+ private long views ;
77
79
}
0 commit comments