Skip to content

Commit

Permalink
#45 - feat: 상품 시작날짜, 만기 날짜 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
chaeyeon-yang authored Jul 3, 2024
2 parents f9637ef + 0bc4609 commit d07caab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/com/hana/api/group/entity/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ public class Group extends BaseEntity {
private String wakeupTime;

@Column
@Setter
private LocalDateTime startedAt;

@Column
private LocalDateTime endeddAt;
@Setter
private LocalDateTime endedAt;

@Column(nullable = false)
@ColumnDefault("0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ public void scheduleStatusUpdate(long groupId) {
.withMinute(0)
.withSecond(0);

// 차주 월요일로부터 3개월 후의 날짜 계산
LocalDateTime threeMonthsLater = nextMonday.plusMonths(3);

// 스케줄링할 작업 정의
Runnable task = () -> {
Group group = groupRepository.findById(groupId).orElseThrow(() -> new BaseException(BaseResponseStatus.GROUPS_EMPTY_GROUP_ID));
group.setStatus(2);
group.setStartedAt(nextMonday);
group.setEndedAt(threeMonthsLater);
groupRepository.save(group);
};

Expand Down

0 comments on commit d07caab

Please sign in to comment.