Skip to content

Commit

Permalink
Merge pull request #171 from WE-ARE-RACCOONS/develop
Browse files Browse the repository at this point in the history
RAC-322 deploy : 운영 반영
  • Loading branch information
ywj9811 authored Mar 12, 2024
2 parents 7bb3cb6 + 2408b87 commit 1123150
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.postgraduate.domain.salary.util.SalaryUtil;
import com.postgraduate.domain.senior.domain.entity.Senior;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
Expand All @@ -17,13 +18,15 @@

@Service
@RequiredArgsConstructor
@Slf4j
public class SalaryGetService {
private static final int ADMIN_PAGE_SIZE = 15;

private final SalaryRepository salaryRepository;

public Salary bySenior(Senior senior) {
LocalDate salaryDate = SalaryUtil.getSalaryDate();
log.info("salaryDate : {}", salaryDate);
return salaryRepository.findBySeniorAndSalaryDate(senior, salaryDate).orElseThrow(SalaryNotFoundException::new);
}

Expand All @@ -37,6 +40,7 @@ public List<Salary> findAllLast() {
LocalDate salaryDate =
SalaryUtil.getSalaryDate()
.minusDays(7);
log.info("salaryDate : {}", salaryDate);
return salaryRepository.findAllLastSalary(salaryDate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

import com.postgraduate.domain.admin.presentation.constant.SalaryStatus;
import com.postgraduate.domain.salary.domain.entity.Salary;
import lombok.extern.slf4j.Slf4j;

import java.time.DayOfWeek;
import java.time.LocalDate;

import static com.postgraduate.domain.admin.presentation.constant.SalaryStatus.*;

@Slf4j
public class SalaryUtil {
private static final int SALARY_DATE = 4; // λͺ©μš”일
private static final int SALARY_END_DATE = 7; // μΌμš”μΌ
private static final int ONE_WEEK = 7;
private static final int ZERO = 0;

private SalaryUtil() {
throw new IllegalArgumentException();
Expand All @@ -20,12 +24,12 @@ public static LocalDate getSalaryDate() {
LocalDate now = LocalDate.now();
DayOfWeek dayOfWeek = now.getDayOfWeek();
return dayOfWeek.getValue() == SALARY_END_DATE
? now.plusDays(7 + (SALARY_DATE - dayOfWeek.getValue()))
: now.plusDays(7 + SALARY_DATE);
? now.plusDays(ONE_WEEK + SALARY_DATE)
: now.plusDays(ONE_WEEK + (SALARY_DATE - dayOfWeek.getValue()));
}

public static SalaryStatus getStatus(Salary salary) {
if (salary.getTotalAmount() == 0) {
if (salary.getTotalAmount() == ZERO) {
return NONE;
}
if (salary.status())
Expand Down

0 comments on commit 1123150

Please sign in to comment.