Skip to content

Commit

Permalink
Merge pull request #277 from WE-ARE-RACCOONS/RAC-386
Browse files Browse the repository at this point in the history
RAC-386 feat : ๋ฐฐ์น˜ ์ฒ˜๋ฆฌ ๊ด€๋ จ ๋กœ๊ทธ ์ถ”๊ฐ€
  • Loading branch information
ywj9811 authored May 25, 2024
2 parents db20042 + 80d4e6d commit ec82b0e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ public class DoneMentoringSkipListener implements SkipListener<DoneMentoring, Do

@Override
public void onSkipInRead(Throwable t) {
log.info("๋ฉ˜ํ† ๋ง ์ž๋™ ์™„๋ฃŒ ItemReader Skip message : {}", t.getMessage());
log.error("๋ฉ˜ํ† ๋ง ์ž๋™ ์™„๋ฃŒ ItemReader Skip message : {}", t.getMessage());
}

@Override
public void onSkipInProcess(DoneMentoring doneMentoring, Throwable t) {
log.info("mentoringId : {} ์ž๋™ ์™„๋ฃŒ ์‹คํŒจ, message : {}", doneMentoring.mentoringId(), t.getMessage());
log.error("mentoringId : {} ์ž๋™ ์™„๋ฃŒ ์‹คํŒจ, message : {}", doneMentoring.mentoringId(), t.getMessage());
slackErrorMessage.sendSlackMentoringError(doneMentoring.mentoringId(), t);
}

@Override
public void onSkipInWrite(DoneMentoring doneMentoring, Throwable t) {
log.info("mentoringId : {} ์ž๋™ ์™„๋ฃŒ ์‹คํŒจ, message : {}", doneMentoring.mentoringId(), t.getMessage());
log.error("mentoringId : {} ์ž๋™ ์™„๋ฃŒ ์‹คํŒจ, message : {}", doneMentoring.mentoringId(), t.getMessage());
slackErrorMessage.sendSlackMentoringError(doneMentoring.mentoringId(), t);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CreateSalaryItemWriter implements ItemWriter<CreateSalary> {
private final CreateSalaryRepository createSalaryRepository;

@Override
public void write(Chunk<? extends CreateSalary> chunk) throws Exception {
public void write(Chunk<? extends CreateSalary> chunk) {
List<CreateSalary> createSalaries = new ArrayList<>();
chunk.forEach(createSalaries::add);
createSalaryRepository.insertAllSalary(createSalaries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.postgraduate.domain.salary.domain.service.SalaryGetService;
import com.postgraduate.global.slack.SlackSalaryMessage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.job.builder.JobBuilder;
Expand All @@ -19,13 +20,15 @@
import org.springframework.transaction.PlatformTransactionManager;

import javax.sql.DataSource;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.postgraduate.domain.salary.util.SalaryUtil.getSalaryDate;

@Configuration
@Slf4j
@RequiredArgsConstructor
public class CreateSalaryJobConfig {
private final JobRepository jobRepository;
Expand Down Expand Up @@ -73,7 +76,9 @@ public Step createSalaryStep() throws Exception {
@Bean(name = "salaryReader")
public JdbcPagingItemReader<CreateSalary> salaryReader() throws Exception {
Map<String, Object> parameters = new HashMap<>();
parameters.put("salaryDate", getSalaryDate().plusDays(7));
LocalDate salaryDate = getSalaryDate().plusDays(7);
parameters.put("salaryDate", salaryDate);
log.info("salaryReader salaryDate : {}", salaryDate);
return new JdbcPagingItemReaderBuilder<CreateSalary>()
.pageSize(CHUNK_SIZE)
.fetchSize(CHUNK_SIZE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.postgraduate.batch.salary;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
Expand All @@ -14,6 +15,7 @@

@Component
@RequiredArgsConstructor
@Slf4j
public class CreateSalaryRepository {
private final NamedParameterJdbcTemplate jdbcTemplate;
private static final String INSERT_SALARY = "insert into salary " +
Expand All @@ -32,6 +34,7 @@ private SqlParameterSource[] generateParameterSource(List<CreateSalary> createSa
}

private Map<String, Object> generateEntityParams(CreateSalary createSalary) {
log.info("create salary for seniorId : {}", createSalary.seniorId());
HashMap<String, Object> parameter = new HashMap<>();
parameter.put("salaryDate", getSalaryDate().plusDays(7));
parameter.put("seniorId", createSalary.seniorId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ public class CreateSalarySkipListener implements SkipListener<CreateSalary, Crea

@Override
public void onSkipInRead(Throwable t) {
log.info("์ •์‚ฐ ์ž๋™ ์ƒ์„ฑ ItemReader Skip message : {}", t.getMessage());
log.error("์ •์‚ฐ ์ž๋™ ์ƒ์„ฑ ItemReader Skip message : {}", t.getMessage());
}

@Override
public void onSkipInProcess(CreateSalary createSalary, Throwable t) {
log.info("seniorId : {} ์ •์‚ฐ ์ž๋™ ์ƒ์„ฑ, message : {}", createSalary.seniorId(), t.getMessage());
log.error("seniorId : {} ์ •์‚ฐ ์ž๋™ ์ƒ์„ฑ, message : {}", createSalary.seniorId(), t.getMessage());
slackErrorMessage.sendSlackSalaryError(createSalary.seniorId(), t);
}

@Override
public void onSkipInWrite(CreateSalary createSalary, Throwable t) {
log.info("seniorId : {} ์ •์‚ฐ ์ž๋™ ์ƒ์„ฑ, message : {}", createSalary.seniorId(), t.getMessage());
log.error("seniorId : {} ์ •์‚ฐ ์ž๋™ ์ƒ์„ฑ, message : {}", createSalary.seniorId(), t.getMessage());
slackErrorMessage.sendSlackSalaryError(createSalary.seniorId(), t);
}
}

0 comments on commit ec82b0e

Please sign in to comment.