11package com .back .web7_9_codecrete_be .global .initData ;
22
3+ import java .time .LocalDate ;
4+ import java .time .LocalDateTime ;
5+
6+ import org .springframework .context .annotation .Profile ;
7+ import org .springframework .security .crypto .password .PasswordEncoder ;
8+ import org .springframework .stereotype .Component ;
9+
10+ import com .back .web7_9_codecrete_be .domain .concerts .entity .Concert ;
11+ import com .back .web7_9_codecrete_be .domain .concerts .entity .ConcertPlace ;
12+ import com .back .web7_9_codecrete_be .domain .concerts .repository .ConcertPlaceRepository ;
13+ import com .back .web7_9_codecrete_be .domain .concerts .repository .ConcertRepository ;
314import com .back .web7_9_codecrete_be .domain .users .entity .SocialType ;
415import com .back .web7_9_codecrete_be .domain .users .entity .User ;
516import com .back .web7_9_codecrete_be .domain .users .repository .UserRepository ;
17+
618import jakarta .annotation .PostConstruct ;
719import lombok .RequiredArgsConstructor ;
8- import org .springframework .context .annotation .Profile ;
9- import org .springframework .security .crypto .password .PasswordEncoder ;
10- import org .springframework .stereotype .Component ;
11-
12- import java .time .LocalDate ;
1320
1421@ Profile ("dev" )
1522@ Component
@@ -19,10 +26,14 @@ public class BaseInitData {
1926 private final UserRepository userRepository ;
2027 private final PasswordEncoder passwordEncoder ;
2128
29+ private final ConcertRepository concertRepository ;
30+ private final ConcertPlaceRepository concertPlaceRepository ;
31+
2232 @ PostConstruct
2333 public void init () {
2434 createTestUser ();
2535 createAdminUser ();
36+ createConcertsForChatTest ();
2637 }
2738
2839 private void createTestUser () {
@@ -63,4 +74,79 @@ private void createAdminUser() {
6374
6475 userRepository .save (adminUser );
6576 }
77+
78+
79+ /* =========================
80+ * Concert / ConcertPlace Init (Chat Test)
81+ * ========================= */
82+ private void createConcertsForChatTest () {
83+ if (concertRepository .count () > 0 ) {
84+ return ;
85+ }
86+
87+ ConcertPlace place = concertPlaceRepository .findAll ().stream ()
88+ .findFirst ()
89+ .orElseGet (() ->
90+ concertPlaceRepository .save (
91+ new ConcertPlace (
92+ "테스트 공연장" ,
93+ "서울특별시 중구 테스트로 123" ,
94+ 37.5665 ,
95+ 126.9780 ,
96+ 5000 ,
97+ "API-CONCERT-PLACE-1"
98+ )
99+ )
100+ );
101+
102+ LocalDateTime now = LocalDateTime .now ();
103+
104+ // 채팅 가능 (정책 기간 중)
105+ concertRepository .save (
106+ new Concert (
107+ place ,
108+ "채팅 가능 공연" ,
109+ "채팅 테스트용 공연 (정책 기간 중)" ,
110+ LocalDate .now (),
111+ LocalDate .now ().plusDays (2 ),
112+ LocalDateTime .of (2025 , 12 , 19 , 0 , 0 ),
113+ 150000 ,
114+ 50000 ,
115+ "https://example.com/poster1.jpg" ,
116+ "API-CONCERT-CHAT-1"
117+ )
118+ );
119+
120+ // 채팅 불가 (정책 시작 전)
121+ concertRepository .save (
122+ new Concert (
123+ place ,
124+ "채팅 불가 공연 - 시작 전" ,
125+ "아직 채팅이 오픈되지 않은 공연" ,
126+ LocalDate .now ().plusDays (5 ),
127+ LocalDate .now ().plusDays (7 ),
128+ LocalDateTime .of (2025 , 12 , 25 , 0 , 0 ),
129+ 120000 ,
130+ 40000 ,
131+ "https://example.com/poster2.jpg" ,
132+ "API-CONCERT-CHAT-2"
133+ )
134+ );
135+
136+ // 채팅 불가 (정책 종료 후)
137+ concertRepository .save (
138+ new Concert (
139+ place ,
140+ "채팅 종료된 공연" ,
141+ "채팅 가능 기간이 지난 공연" ,
142+ LocalDate .now ().minusDays (10 ),
143+ LocalDate .now ().minusDays (7 ),
144+ LocalDateTime .of (2025 , 11 , 1 , 0 , 0 ),
145+ 100000 ,
146+ 30000 ,
147+ "https://example.com/poster3.jpg" ,
148+ "API-CONCERT-CHAT-3"
149+ )
150+ );
151+ }
66152}
0 commit comments