Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main배포 v0.2.7 #148

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ResponseEntity<PageResponseDto<List<AcceptedClimbingGymSimpleResponse>>>
@GetMapping("/{gymId}")
public ResponseEntity<ClimbingGymDetailResponse> getClimbingGymInfo(
@PathVariable Long gymId, @CurrentUser User user) {
return ResponseEntity.ok(climbingGymService.getClimbingGymInfo(gymId));
return ResponseEntity.ok(climbingGymService.getClimbingGymInfo(gymId, user));
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.climeet.climeet_backend.domain.climbinggym;

import io.lettuce.core.dynamic.annotation.Param;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
Expand All @@ -14,5 +17,6 @@ public interface ClimbingGymRepository extends JpaRepository<ClimbingGym, Long>

Page<ClimbingGym> findByNameContaining(String gymName, Pageable pageable);

Page<ClimbingGym> findByNameContainingAndManagerIsNotNull(String gymName, Pageable pageable);
@Query("SELECT cg FROM ClimbingGym cg LEFT JOIN Manager m on cg.id = m.climbingGym.id WHERE cg.name LIKE %:name% AND m.id IS NOT NULL")
Page<ClimbingGym> findByNameContainingAndManagerIsNotNull(@Param("name") String name, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public PageResponseDto<List<AcceptedClimbingGymSimpleResponse>> searchAcceptedCl

}

public ClimbingGymDetailResponse getClimbingGymInfo(Long gymId) {
public ClimbingGymDetailResponse getClimbingGymInfo(Long gymId, User user) {
ClimbingGym climbingGym = climbingGymRepository.findById(gymId)
.orElseThrow(() -> new GeneralException(ErrorStatus._EMPTY_CLIMBING_GYM));

Expand All @@ -119,8 +119,11 @@ public ClimbingGymDetailResponse getClimbingGymInfo(Long gymId) {
ClimbingGymBackgroundImage backgroundImage = climbingGymBackgroundImageRepository.findByClimbingGym(
climbingGym)
.orElseThrow(() -> new GeneralException(ErrorStatus._EMPTY_BACKGROUND_IMAGE));

return ClimbingGymDetailResponse.toDTO(climbingGym, manager, backgroundImage.getImgUrl());
Boolean status = false;
if(followRelationshipRepository.findByFollowerIdAndFollowingId(user.getId(),climbingGym.getManager().getId()).isPresent()){
status = true;
}
return ClimbingGymDetailResponse.toDTO(climbingGym, manager, backgroundImage.getImgUrl(),status);
}

public ClimbingGymTabInfoResponse getClimbingGymTabInfo(Long gymId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ public static class ClimbingGymDetailResponse {
private Long followingCount;
private float averageRating;
private int reviewCount;
private Boolean isFollower;

public static ClimbingGymDetailResponse toDTO(ClimbingGym climbingGym, Manager manager,
String gymBackGroundImageUrl) {
String gymBackGroundImageUrl, Boolean isFollower) {
return ClimbingGymDetailResponse.builder()
.gymId(climbingGym.getId())
.gymProfileImageUrl(climbingGym.getProfileImageUrl())
Expand All @@ -88,6 +89,7 @@ public static ClimbingGymDetailResponse toDTO(ClimbingGym climbingGym, Manager m
.followingCount(manager.getFollowingCount())
.averageRating(climbingGym.getAverageRating())
.reviewCount(climbingGym.getReviewCount())
.isFollower(isFollower)
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,13 @@ public ResponseEntity<List<VisitedClimbingGym>> getVisitedGymList(
@RequestParam int month) {
return ResponseEntity.ok(climbingRecordService.getVisitedGymList(userId, year, month));
}

@Operation(summary = "나의 운동한 암장 리스트 조회")
@GetMapping("/users/months/list")
public ResponseEntity<List<VisitedClimbingGym>> getVisitedGymList(
@CurrentUser User user,
@RequestParam int year,
@RequestParam int month) {
return ResponseEntity.ok(climbingRecordService.getVisitedGymList(user.getId(), year, month));
}
}
Loading