13
13
import org .springframework .stereotype .Service ;
14
14
import org .springframework .transaction .annotation .Transactional ;
15
15
16
+ import com .sponus .coredomain .domain .bookmark .repository .BookmarkRepository ;
16
17
import com .sponus .coredomain .domain .organization .Organization ;
17
18
import com .sponus .coredomain .domain .organization .enums .OrganizationType ;
18
19
import com .sponus .coredomain .domain .organization .enums .ProfileStatus ;
@@ -36,6 +37,7 @@ public class OrganizationQueryService {
36
37
37
38
private final OrganizationRepository organizationRepository ;
38
39
private final SearchHistoryRepository searchHistoryRepository ;
40
+ private final BookmarkRepository bookmarkRepository ;
39
41
40
42
public Boolean verifyName (String name ) {
41
43
return organizationRepository .existsByName (name );
@@ -46,10 +48,10 @@ public PageResponse<OrganizationGetResponse> getOrganizations(
46
48
PageCondition pageCondition ,
47
49
OrganizationType organizationType ) {
48
50
// TODO: FETCH JOIN으로 변경
49
- Set <Long > bookmarkedOrganizationIds = authOrganization .getBookmarks ()
50
- .stream ()
51
- .map (bookmark -> bookmark .getTarget ().getId ())
51
+ Set <Long > bookmarkedOrganizationIds = bookmarkRepository .findByOrganization (authOrganization ).stream ()
52
+ .map ((bookmark ) -> bookmark .getTarget ().getId ())
52
53
.collect (Collectors .toSet ());
54
+
53
55
Pageable pageable = PageRequest .of (pageCondition .getPage () - 1 , pageCondition .getSize ());
54
56
List <OrganizationGetResponse > organizations = organizationRepository .findOrganizations (
55
57
organizationType , pageable , authOrganization .getId ())
@@ -66,10 +68,10 @@ public PageResponse<OrganizationGetResponse> getOrganizations(
66
68
public PageResponse <OrganizationSearchResponse > searchOrganizations (PageCondition pageCondition , String keyword ,
67
69
Organization authOrganization ) {
68
70
69
- Set <Long > bookmarkedOrganizationIds = authOrganization .getBookmarks ()
70
- .stream ()
71
- .map (bookmark -> bookmark .getTarget ().getId ())
71
+ Set <Long > bookmarkedOrganizationIds = bookmarkRepository .findByOrganization (authOrganization ).stream ()
72
+ .map ((bookmark ) -> bookmark .getTarget ().getId ())
72
73
.collect (Collectors .toSet ());
74
+
73
75
Pageable pageable = PageRequest .of (pageCondition .getPage () - 1 , pageCondition .getSize ());
74
76
75
77
List <OrganizationSearchResponse > organizations = organizationRepository .findByNameContains (
@@ -95,9 +97,8 @@ public PageResponse<OrganizationSearchResponse> searchOrganizationsV2(
95
97
96
98
Page <Organization > organizations = organizationRepository .searchOrganizationV2 (condition , pageable );
97
99
98
- Set <Long > bookmarkedOrganizationIds = authOrganization .getBookmarks ()
99
- .stream ()
100
- .map (bookmark -> bookmark .getTarget ().getId ())
100
+ Set <Long > bookmarkedOrganizationIds = bookmarkRepository .findByOrganization (authOrganization ).stream ()
101
+ .map ((bookmark ) -> bookmark .getTarget ().getId ())
101
102
.collect (Collectors .toSet ());
102
103
103
104
return PageResponse .of (organizations .map (organization ->
0 commit comments