2222import devkor .com .teamcback .domain .user .entity .User ;
2323import devkor .com .teamcback .domain .user .repository .UserRepository ;
2424import devkor .com .teamcback .global .exception .exception .GlobalException ;
25+ import devkor .com .teamcback .global .response .CursorPageRes ;
2526import lombok .RequiredArgsConstructor ;
2627import lombok .extern .slf4j .Slf4j ;
2728import org .springframework .data .domain .PageRequest ;
@@ -64,23 +65,27 @@ public class SearchService {
6465 static final int BASE_SCORE_OUTDOOR_TAG_DEFAULT = 750 ;
6566
6667 // 건물 상세 모달 아이콘으로 표시할 편의시설 종류
67- private final List <PlaceType > iconTypes = Arrays .asList (PlaceType .VENDING_MACHINE , PlaceType .PRINTER , PlaceType .LOUNGE ,
68+ private static final List <PlaceType > iconTypes = Arrays .asList (PlaceType .VENDING_MACHINE , PlaceType .PRINTER , PlaceType .LOUNGE ,
6869 PlaceType .READING_ROOM , PlaceType .STUDY_ROOM , PlaceType .CAFE , PlaceType .CONVENIENCE_STORE , PlaceType .CAFETERIA ,
6970 PlaceType .SLEEPING_ROOM , PlaceType .SHOWER_ROOM , PlaceType .BANK , PlaceType .GYM );
7071
7172 // 통합 검색 결과에 표시하지 않을 편의시설 종류
7273 //TODO: 자전거보관소, 벤치 디자인 요청 후 List에서 제거
73- private final List <String > excludedTypes = Arrays .asList (PlaceType .CLASSROOM .getName (), PlaceType .TOILET .getName (),
74+ private static final List <String > excludedTypes = Arrays .asList (PlaceType .CLASSROOM .getName (), PlaceType .TOILET .getName (),
7475 PlaceType .MEN_TOILET .getName (), PlaceType .WOMEN_TOILET .getName (), PlaceType .MEN_HANDICAPPED_TOILET .getName (),
7576 PlaceType .WOMEN_HANDICAPPED_TOILET .getName (), PlaceType .LOCKER .getName (), PlaceType .TRASH_CAN .getName (),
7677 PlaceType .BICYCLE_RACK .getName (), PlaceType .BENCH .getName ());
7778
7879 // 통합 검색 결과에서 "건물명 + 기본편의시설명"의 형태로 제공되어야 하는 편의시설 종류
79- private final List <PlaceType > outerTagTypes = Arrays .asList (PlaceType .CAFE , PlaceType .CAFETERIA , PlaceType .CONVENIENCE_STORE ,
80+ private static final List <PlaceType > outerTagTypes = Arrays .asList (PlaceType .CAFE , PlaceType .CAFETERIA , PlaceType .CONVENIENCE_STORE ,
8081 PlaceType .READING_ROOM , PlaceType .STUDY_ROOM , PlaceType .BOOK_RETURN_MACHINE , PlaceType .LOUNGE , PlaceType .WATER_PURIFIER ,
8182 PlaceType .VENDING_MACHINE , PlaceType .PRINTER , PlaceType .TUMBLER_WASHER , PlaceType .ONESTOP_AUTO_MACHINE , PlaceType .BANK ,
8283 PlaceType .SMOKING_BOOTH , PlaceType .SHOWER_ROOM , PlaceType .GYM , PlaceType .SLEEPING_ROOM , PlaceType .HEALTH_OFFICE , PlaceType .DISABLED_PARKING );
8384
85+ // 건물 상세 조회 : 대표 편의시설 종류
86+ private static final List <PlaceType > mainFacilityTypes = Arrays .asList (PlaceType .LOUNGE , PlaceType .CAFE , PlaceType .CONVENIENCE_STORE , PlaceType .CAFETERIA ,
87+ PlaceType .READING_ROOM , PlaceType .STUDY_ROOM , PlaceType .GYM , PlaceType .SLEEPING_ROOM , PlaceType .SHOWER_ROOM );
88+
8489 /**
8590 * 통합 검색
8691 */
@@ -264,10 +269,8 @@ public SearchMaskIndexByPlaceRes searchMaskIndexByPlace(Long placeId) {
264269 public SearchBuildingDetailRes searchBuildingDetail (Long userId , Long buildingId ) {
265270 Building building = findBuilding (buildingId );
266271
267- //(임의) 가져올 대표 시설 정보 List (라운지, 카페, 편의점, 식당, 헬스장, 열람실, 스터디룸, 수면실, 샤워실)
268- //자세한 회의 후 List 수정하기
269- List <PlaceType > types = Arrays .asList (PlaceType .LOUNGE , PlaceType .CAFE , PlaceType .CONVENIENCE_STORE , PlaceType .CAFETERIA , PlaceType .READING_ROOM , PlaceType .STUDY_ROOM , PlaceType .GYM , PlaceType .SLEEPING_ROOM , PlaceType .SHOWER_ROOM );
270- List <Place > mainFacilities = getFacilitiesByBuildingAndTypes (building , types );
272+ // TODO: 배포 버전 수정 후 편의시설 조회 제거
273+ List <Place > mainFacilities = getFacilitiesByBuildingAndTypes (building , mainFacilityTypes );
271274 List <SearchMainFacilityRes > res = new ArrayList <>();
272275
273276 for (Place place : mainFacilities ) {
@@ -292,10 +295,22 @@ public SearchBuildingDetailRes searchBuildingDetail(Long userId, Long buildingId
292295 bookmarked = true ;
293296 }
294297 }
298+ return new SearchBuildingDetailRes (res , containPlaceTypes , building , bookmarked );
299+ }
300+
301+ @ Transactional (readOnly = true )
302+ public CursorPageRes <SearchMainFacilityRes > searchBuildingMainFacilityList (Long buildingId , Long lastPlaceId , int size ) {
303+ Place lastPlace = (lastPlaceId == null ) ? null : findPlace (lastPlaceId );
295304
296- // TODO: 커뮤니티 구상 완료되면 커뮤니티 정보 넣기
305+ List <SearchMainFacilityRes > mainFacilities = placeRepository .getFacilitiesByBuildingAndTypesWithPage (buildingId , mainFacilityTypes , lastPlace , size + 1 )
306+ .stream ().map (SearchMainFacilityRes ::new ).collect (Collectors .toList ());
297307
298- return new SearchBuildingDetailRes (res , containPlaceTypes , building , bookmarked );
308+ boolean hasNext = mainFacilities .size () > size ;
309+ if (hasNext ) mainFacilities .remove (size );
310+
311+ Long lastCursorId = mainFacilities .isEmpty () ? null : mainFacilities .get (mainFacilities .size () - 1 ).getPlaceId ();
312+
313+ return new CursorPageRes <>(mainFacilities , hasNext , lastCursorId );
299314 }
300315
301316 /**
0 commit comments