Skip to content

Commit

Permalink
Merge pull request #79 from code-review-platform-flow/hotfix/mailbox
Browse files Browse the repository at this point in the history
feat: mailbox 수정
  • Loading branch information
abwarten authored Dec 17, 2024
2 parents 3366fc3 + 14b7cfd commit f74c7fa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ public interface CoffeeChatsRepository extends JpaRepository<CoffeeChatsEntity,
@Query("SELECT c FROM CoffeeChatsEntity c WHERE c.initiatorUser.userId = :initiatorUserId")
List<CoffeeChatsEntity> findAllCoffeeChatsByInitiatorUserIdWithPageable(@Param("initiatorUserId") Long initiatorUserId, Pageable pageable);

@Query("SELECT c FROM CoffeeChatsEntity c WHERE c.recipientUser.userId = :recipientUserId")
List<CoffeeChatsEntity> findAllCoffeeChatsByRecipientUserIdWithPageable(@Param("recipientUserId") Long recipientUserId, Pageable pageable);

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.springframework.stereotype.Service;

import com.flow.main.dto.controller.coffeeChats.request.CoffeeChatsGetAllRequestDto;
import com.flow.main.dto.controller.coffeeChats.response.CoffeeChatsGetAllResponseDto;
import com.flow.main.dto.jpa.coffeeChats.CoffeeChatsDto;
import com.flow.main.dto.jpa.users.UsersDto;
Expand All @@ -23,8 +24,18 @@ public class CoffeeChatsGetAllService {

public CoffeeChatsGetAllResponseDto getAllWithPageable(String email, Pageable pageable) {
UsersDto usersDto = usersService.findByEmail(email);
List<CoffeeChatsDto> coffeeChatsDtoList = coffeeChatsService.getAllByInitiatorUserIdWithPageable(usersDto.getUserId(), pageable);
return CoffeeChatsGetAllResponseDto.builder().coffeeChat(coffeeChatsDtoList).pageable(pageable).build();
List<CoffeeChatsDto> coffeeChatsDtoListInitiator = coffeeChatsService.getAllByInitiatorUserIdWithPageable(usersDto.getUserId(), pageable);
List<CoffeeChatsDto> coffeeChatsDtoListRecipient = coffeeChatsService.getAllByRecipientUserIdWithPageable(usersDto.getUserId(), pageable);

List<CoffeeChatsDto> combinedList = Stream.concat(
coffeeChatsDtoListInitiator.stream(),
coffeeChatsDtoListRecipient.stream()
).collect(Collectors.toList());

return CoffeeChatsGetAllResponseDto.builder()
.coffeeChat(combinedList)
.pageable(pageable)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public List<CoffeeChatsDto> getAllByInitiatorUserIdWithPageable(Long initiatorUs
return coffeeChatsMapper.toListDto(coffeeChatsRepository.findAllCoffeeChatsByInitiatorUserIdWithPageable(initiatorUserId, pageable));
}

@Transactional(readOnly = true)
public List<CoffeeChatsDto> getAllByRecipientUserIdWithPageable(Long recipientUserId, Pageable pageable) {
return coffeeChatsMapper.toListDto(coffeeChatsRepository.findAllCoffeeChatsByRecipientUserIdWithPageable(recipientUserId, pageable));
}

@Transactional
public CoffeeChatsDto save(CoffeeChatsDto coffeeChatsDto) {
CoffeeChatsEntity coffeeChatsEntity = coffeeChatsMapper.toEntity(coffeeChatsDto);
Expand Down

0 comments on commit f74c7fa

Please sign in to comment.