File tree Expand file tree Collapse file tree 3 files changed +66
-3
lines changed
src/main/java/com/somemore/volunteer/repository Expand file tree Collapse file tree 3 files changed +66
-3
lines changed Original file line number Diff line number Diff line change 1+ package com .somemore .volunteer .repository ;
2+
3+ import com .somemore .volunteer .domain .Volunteer ;
4+ import org .springframework .data .jpa .repository .JpaRepository ;
5+
6+ import java .util .Optional ;
7+ import java .util .UUID ;
8+
9+ public interface VolunteerJpaRepository extends JpaRepository <Volunteer , Long > {
10+ Volunteer findById (UUID id );
11+ Optional <Volunteer > findByOauthId (String oauthId );
12+ }
Original file line number Diff line number Diff line change 11package com .somemore .volunteer .repository ;
22
33import com .somemore .volunteer .domain .Volunteer ;
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 VolunteerRepository extends JpaRepository <Volunteer , UUID > {
12-
10+ public interface VolunteerRepository {
11+ Volunteer save (Volunteer volunteer );
12+ Volunteer findById (UUID id );
13+ String findNicknameById (UUID id );
1314 Optional <Volunteer > findByOauthId (String oauthId );
15+ void deleteAllInBatch ();
1416}
Original file line number Diff line number Diff line change 1+ package com .somemore .volunteer .repository ;
2+
3+ import com .querydsl .jpa .impl .JPAQueryFactory ;
4+ import com .somemore .volunteer .domain .QVolunteer ;
5+ import com .somemore .volunteer .domain .Volunteer ;
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 VolunteerRepositoryImpl implements VolunteerRepository {
15+
16+ private final VolunteerJpaRepository volunteerJpaRepository ;
17+ private final JPAQueryFactory queryFactory ;
18+
19+ @ Override
20+ public Volunteer save (Volunteer volunteer ) {
21+ return volunteerJpaRepository .save (volunteer );
22+ }
23+
24+ @ Override
25+ public Volunteer findById (UUID id ) {
26+ return volunteerJpaRepository .findById (id );
27+ }
28+
29+ @ Override
30+ public String findNicknameById (UUID id ) {
31+ QVolunteer volunteer = QVolunteer .volunteer ;
32+
33+ return queryFactory
34+ .select (volunteer .nickname )
35+ .from (volunteer )
36+ .where (volunteer .id .eq (id ))
37+ .fetchOne ();
38+ }
39+
40+ @ Override
41+ public Optional <Volunteer > findByOauthId (String oauthId ) {
42+ return volunteerJpaRepository .findByOauthId (oauthId );
43+ }
44+
45+ @ Override
46+ public void deleteAllInBatch () {
47+ volunteerJpaRepository .deleteAllInBatch ();
48+ }
49+ }
You can’t perform that action at this time.
0 commit comments