File tree Expand file tree Collapse file tree 3 files changed +65
-5
lines changed
src/main/java/com/somemore/center/repository Expand file tree Collapse file tree 3 files changed +65
-5
lines changed Original file line number Diff line number Diff line change 1+ package com .somemore .center .repository ;
2+
3+ import com .somemore .center .domain .Center ;
4+ import org .springframework .data .jpa .repository .JpaRepository ;
5+
6+ import java .util .Optional ;
7+ import java .util .UUID ;
8+
9+ public interface CenterJpaRepository extends JpaRepository <Center , Long > {
10+ boolean existsById (UUID id );
11+ Optional <Center > findCenterById (UUID id );
12+ }
Original file line number Diff line number Diff line change 11package com .somemore .center .repository ;
22
33import com .somemore .center .domain .Center ;
4- import org .springframework .data .jpa .repository .JpaRepository ;
54import org .springframework .stereotype .Repository ;
65
76import java .util .Optional ;
87import java .util .UUID ;
98
109@ Repository
11- public interface CenterRepository extends JpaRepository < Center , UUID > {
12-
10+ public interface CenterRepository {
11+ Center save ( Center center );
1312 boolean existsById (UUID id );
14-
1513 default boolean doesNotExistById (UUID id ) {
1614 return !existsById (id );
1715 }
18-
1916 Optional <Center > findCenterById (UUID id );
17+ String findNameById (UUID id );
18+ void deleteAllInBatch ();
2019}
Original file line number Diff line number Diff line change 1+ package com .somemore .center .repository ;
2+
3+ import com .querydsl .jpa .impl .JPAQueryFactory ;
4+ import com .somemore .center .domain .Center ;
5+ import com .somemore .center .domain .QCenter ;
6+ import lombok .RequiredArgsConstructor ;
7+ import org .springframework .stereotype .Repository ;
8+
9+ import java .util .Optional ;
10+ import java .util .UUID ;
11+
12+ @ RequiredArgsConstructor
13+ @ Repository
14+ public class CenterRepositoryImpl implements CenterRepository {
15+
16+ private final CenterJpaRepository centerJpaRepository ;
17+ private final JPAQueryFactory queryFactory ;
18+
19+ @ Override
20+ public Center save (Center center ) {
21+ return centerJpaRepository .save (center );
22+ }
23+
24+ @ Override
25+ public boolean existsById (UUID id ) {
26+ return centerJpaRepository .existsById (id );
27+ }
28+
29+ @ Override
30+ public Optional <Center > findCenterById (UUID id ) {
31+ return centerJpaRepository .findCenterById (id );
32+ }
33+
34+ @ Override
35+ public String findNameById (UUID id ) {
36+ QCenter center = QCenter .center ;
37+
38+ return queryFactory
39+ .select (center .name )
40+ .from (center )
41+ .where (center .id .eq (id ))
42+ .fetchOne ();
43+ }
44+
45+ @ Override
46+ public void deleteAllInBatch () {
47+ centerJpaRepository .deleteAllInBatch ();
48+ }
49+ }
You can’t perform that action at this time.
0 commit comments