Skip to content

Commit b88355f

Browse files
committed
feat(center): center Repository 구조 변경 및 조회 기능 추가
1 parent de43f60 commit b88355f

File tree

3 files changed

+65
-5
lines changed

3 files changed

+65
-5
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
package com.somemore.center.repository;
22

33
import com.somemore.center.domain.Center;
4-
import org.springframework.data.jpa.repository.JpaRepository;
54
import org.springframework.stereotype.Repository;
65

76
import java.util.Optional;
87
import 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
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
}

0 commit comments

Comments
 (0)