Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/prod-cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Java CI with Gradle

on:
push:
branches: [ "develop" ]
branches: [ "develop" , "test" ]

permissions:
contents: read
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.plotting.server.user.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.grammars.hql.HqlParser;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -24,7 +23,6 @@
import java.time.LocalDateTime;
import java.util.List;

import static com.plotting.server.plogging.domain.QPlogging.plogging;
import static com.plotting.server.plogging.exception.errorcode.PloggingErrorCode.PLOGGING_NOT_FOUND;
import static com.plotting.server.plogging.util.PloggingConstants.*;

Expand All @@ -42,12 +40,15 @@ public class PloggingService {
private final PloggingStarRepository ploggingStarRepository;

//플로깅 검색-> 상단 제일 첫번째 1개만 검색
public PloggingGetStarResponse getPloggingWithTitle(String title) {
public PloggingGetStarResponse getPloggingWithTitle(Long userId, String title) {
User user = userService.getUser(userId);

return ploggingRepository.findByTitleContaining(title)
.stream()
.map(plogging -> {
Boolean isStar = ploggingStarRepository.existsByUserIdAndPloggingId(plogging.getUser().getId(), plogging.getId());
Boolean isStar = ploggingStarRepository.existsByUserIdAndPloggingId(user.getId(), plogging.getId());
Long currentPeople = ploggingUserRepository.countActivePloggingUsersByPloggingId(plogging.getId());

return PloggingGetStarResponse.of(plogging, currentPeople ,isStar);
})
.findFirst() // 첫 번째 항목을 선택
Expand All @@ -56,10 +57,11 @@ public PloggingGetStarResponse getPloggingWithTitle(String title) {

//플로깅 홈
public HomeResponse getHome(Long userId) {
PloggingGetStarListResponse plogging = getPloggingStar();
PlowerListResponse plowerStar = getPlowerStar();
User user = userService.getUser(userId);

PloggingGetStarListResponse plogging = getPloggingStar(user);
PlowerListResponse plowerStar = getPlowerStar();

return HomeResponse.of(plogging, plowerStar, user);
}

Expand All @@ -73,11 +75,12 @@ private PlowerListResponse getPlowerStar() {
}

// 플로깅 즐겨찾기
private PloggingGetStarListResponse getPloggingStar() {
private PloggingGetStarListResponse getPloggingStar(User user) {
List<PloggingGetStarResponse> ploggingList = ploggingRepository.findTop3Ploggings().stream()
.map(plogging -> {
Boolean isStar = ploggingStarRepository.existsByUserIdAndPloggingId(plogging.getUser().getId(), plogging.getId());
Boolean isStar = ploggingStarRepository.existsByUserIdAndPloggingId(user.getId(), plogging.getId());
Long currentPeople = ploggingUserRepository.countActivePloggingUsersByPloggingId(plogging.getId());

return PloggingGetStarResponse.of(plogging, currentPeople, isStar);
})
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ public class PloggingController {
@Operation(summary = "플로깅 검색", description = "플로깅 검색 화면입니다.")
@GetMapping("/{title}")
public ResponseEntity<ResponseTemplate<?>> getPloggingWithTitle(
@PathVariable String title) {
@AuthenticationPrincipal JwtUserDetails jwtUserDetails,
@PathVariable String title
) {

PloggingGetStarResponse response = ploggingService.getPloggingWithTitle(title);
PloggingGetStarResponse response = ploggingService.getPloggingWithTitle(jwtUserDetails.userId(), title);

return ResponseEntity
.status(HttpStatus.OK)
Expand Down
Loading