Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,28 +206,4 @@ public ResponseEntity<ResponseDto.Success> createTestAccount(@Valid @RequestBody
.build()
);
}

/* 강의 시간 및 장소 정보 동기화 컨트톨러 */
@PostMapping("/api/admin/course-time-location-synchronization")
@Operation(summary = "강의 시간 및 장소 정보 동기화")
@Parameters(value = {
@Parameter(in = ParameterIn.HEADER, name = "Authorization", description = "Bearer {access token}"),
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200"),
})
public ResponseEntity<ResponseDto.Success> checkTimeLocationSynchronization(@Valid @RequestBody CrawlingDto.Synchronization dto)
{
adminService.checkTimeLocationSynchronization(dto);

return ResponseEntity.status(HttpStatus.OK)
.body(
ResponseDto.Success.builder()
.message("강의 시간 및 장소 동기화를 성공적으로 수행하였습니다.")
.data(null)
.version(versionProvider.getVersion())
.build()
);
}

}
29 changes: 0 additions & 29 deletions src/main/java/com/example/Devkor_project/service/AdminService.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,33 +403,4 @@ public void createTestAccount(ProfileDto.CreateTestAccount dto)
// 해당 엔티티를 데이터베이스에 저장
profileRepository.save(profile);
}

/* 강의 시간 및 장소 동기화 서비스 */
@Transactional
public void checkTimeLocationSynchronization(CrawlingDto.Synchronization dto)
{
// 현재 데이터베이스에 존재하는 해당 연도와 학기의 모든 강의 정보
List<Course> allCourseInDatabase = courseRepository.findCourseByYearAndSemester(dto.getYear(), dto.getSemester());

for(Course course:allCourseInDatabase)
{
// 해당 강의의 time_location 정보를 CourseDto.TimeLocation 리스트로 변환
List<CourseDto.TimeLocation> timeLocations = parseTimeLocation(course.getTime_location());

// TimeLocation 엔티티 추가
if (timeLocations != null && !timeLocations.isEmpty()) {
for (CourseDto.TimeLocation timeLocationDto : timeLocations) {
TimeLocation timeLocation = TimeLocation.builder()
.course_id(course)
.day(timeLocationDto.getDay())
.startPeriod(timeLocationDto.getStartPeriod())
.endPeriod(timeLocationDto.getEndPeriod())
.location(timeLocationDto.getLocation())
.build();

timeLocationRepository.save(timeLocation);
}
}
}
}
}
Loading