Skip to content

Commit

Permalink
refactor : code convention
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Diger committed Feb 11, 2024
1 parent 7728096 commit 401739e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import usw.suwiki.domain.apilogger.ApiLogger;
Expand All @@ -24,6 +25,7 @@ public class ApiLoggerService {
private final String userOption = "user";
private final String noticeOption = "notice";

@Async
@Transactional
public void logApi(LocalDate today, Long currentProcessTime, String option) {
Optional<ApiLogger> apiLogger = apiLoggerRepository.findByCallDate(today);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public List<EvaluatePostResponseByUserIdxDto> readEvaluatePostsByUserId(
}

public boolean verifyIsUserCanWriteEvaluatePost(Long userIdx, Long lectureId) {
Lecture lecture = lectureService.findLectureById(lectureId);;
Lecture lecture = lectureService.findLectureById(lectureId);
User user = userCRUDService.loadUserFromUserIdx(userIdx);
return evaluatePostCRUDService.isAlreadyWritten(user, lecture);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/usw/suwiki/domain/lecture/domain/Lecture.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public class Lecture extends BaseTimeEntity {
private int postsCount = 0;

@OneToMany(mappedBy = "lecture", cascade = CascadeType.ALL, orphanRemoval = true)
private List<LectureSchedule> scheduleList = new ArrayList<>();
private final List<LectureSchedule> scheduleList = new ArrayList<>();

@OneToMany(mappedBy = "lecture", cascade = CascadeType.ALL, orphanRemoval = true)
private List<EvaluatePost> evaluatePostList = new ArrayList<>();
private final List<EvaluatePost> evaluatePostList = new ArrayList<>();

@Builder
public Lecture(
Expand Down Expand Up @@ -159,4 +159,4 @@ private static String buildAddedSemester(String originalSemesters, String semest
return originalSemesters + ", " + semester;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class Timetable extends BaseTimeEntity {
private Semester semester;

@OneToMany(mappedBy = "timetable", cascade = CascadeType.ALL, orphanRemoval = true)
private List<TimetableCell> cellList = new ArrayList<>();
private final List<TimetableCell> cellList = new ArrayList<>();

@Builder
public Timetable(String name, Integer year, Semester semester) {
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/usw/suwiki/global/config/AsyncConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package usw.suwiki.global.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

@Configuration
@EnableAsync
public class AsyncConfig implements AsyncConfigurer {

@Override
public Executor getAsyncExecutor() {
final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(3);
executor.setMaxPoolSize(30);
executor.setQueueCapacity(90);
executor.setThreadNamePrefix("ASYNC-");
executor.initialize();

return executor;
}
}

0 comments on commit 401739e

Please sign in to comment.