Skip to content

Commit

Permalink
Merge branch 'feature/attend-forlate' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeongh00 committed Jan 25, 2024
2 parents c8a86cd + 5870dbe commit e44b80f
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
@RequiredArgsConstructor
public class AttendSaveService {
Expand All @@ -28,7 +30,23 @@ public Attend saveAttend(Long curriculumId, Long memberId) {

Member member = memberQueryService.findMemberById(memberId);
Curriculum curriculum = curriculumQueryService.findCurriculumById(curriculumId);
final Attend attend = Attend.builder().curriculum(curriculum).member(member).status(AttendStatus.출석).build();

LocalDateTime currentTime = LocalDateTime.now();
final Attend attend;

if (currentTime.isAfter(curriculum.getStartTime())) {
attend = Attend.builder()
.curriculum(curriculum)
.member(member)
.status(AttendStatus.지각)
.build();
} else {
attend = Attend.builder()
.curriculum(curriculum)
.member(member)
.status(AttendStatus.출석)
.build();
}

return attendRepository.save(attend);
}
Expand Down

0 comments on commit e44b80f

Please sign in to comment.