Skip to content

Commit

Permalink
refactor: timeGenrator를 사용하여 시간을 얻도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hong-sile committed Apr 7, 2024
1 parent 76efeec commit da0ac08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import unithon.uniletter.member.Member;
import unithon.uniletter.message.dto.MessageResponse;
import unithon.uniletter.message.repository.MessageRepository;
import unithon.uniletter.time.service.TimeGenerator;

import java.time.LocalDate;
import java.util.Arrays;
Expand All @@ -22,6 +23,7 @@ public class EventService {

private final EventRepository eventRepository;
private final MessageRepository messageRepository;
private final TimeGenerator timeGenerator;

@Transactional
public String addEvent(final Member member, final LocalDate plannedAt, final String content, final EventType type) {
Expand All @@ -37,7 +39,7 @@ public String addEvent(final Member member, final LocalDate plannedAt, final Str

@Transactional(readOnly = true)
public List<Event> findMemberEventAfterToday(final String nickName) {
return eventRepository.findEventsAfterToday(nickName, LocalDate.now());
return eventRepository.findEventsAfterToday(nickName, timeGenerator.generate());
}

public List<EventType> findEventTypeAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import unithon.uniletter.message.dto.MessageRequest;
import unithon.uniletter.message.dto.MessageResponse;
import unithon.uniletter.message.repository.MessageRepository;
import unithon.uniletter.time.service.TimeGenerator;

import java.util.List;
import java.util.UUID;
Expand All @@ -23,6 +24,7 @@
@Transactional
public class MessageService {

private final TimeGenerator timeGenerator;
private final MessageRepository messageRepository;
private final MemberRepository memberRepository;
private final EventRepository eventRepository;
Expand All @@ -44,7 +46,7 @@ public void sendMessage(final MessageRequest request, final Member loginMember)

@Transactional
public List<MessageResponse> getUnreadMessages(final Member member) {
final List<Message> messages = messageRepository.findByReceiverIdAndIsReadOrderBySendPlannedAtAsc(member.getId(), false);
final List<Message> messages = messageRepository.readArriveMessage(member.getId(), false, timeGenerator.generate());
messages.forEach(Message::read);
return getMessageWithEvent(messages);
}
Expand Down

0 comments on commit da0ac08

Please sign in to comment.