-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from hubo-gillajabi/HUBOBE-3-be-두루누비-정보-서비스-가져오기
Hubo be 3 두루누비 정보 서비스 가져오기
- Loading branch information
Showing
86 changed files
with
3,371 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule BE-hubo-gillajabi-resources
updated
from cfee0d to f5e47b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.anyConstructor.addConstructorProperties=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/com/hubo/gillajabi/crawl/application/dto/response/CrawlResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.hubo.gillajabi.crawl.application.dto.response; | ||
|
||
import com.hubo.gillajabi.crawl.domain.entity.*; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Setter | ||
public class CrawlResponse { | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Schema(name = "CrawlResponse.Course", description = "코스 크롤링 갯수 DTO") | ||
public static class CourseResult { | ||
private Integer cityCount; | ||
private Integer courseCount; | ||
private Integer courseDetailCount; | ||
private Integer gpxInfoCount; | ||
|
||
public static CourseResult of(final List<City> cities, final List<Course> courses, | ||
final List<CourseDetail> courseDetails, final List<GpxInfo> gpxInfos) { | ||
CourseResult courseResult = new CourseResult(); | ||
courseResult.setCityCount(cities.size()); | ||
courseResult.setCourseCount(courses.size()); | ||
courseResult.setCourseDetailCount(courseDetails.size()); | ||
courseResult.setGpxInfoCount(gpxInfos.size()); | ||
return courseResult; | ||
} | ||
} | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Schema(name = "CrawlResponse.Theme", description = "코스 테마 갯수 DTO") | ||
public static class ThemeResult{ | ||
private Integer themeCount; | ||
|
||
public static ThemeResult from(final List<CourseTheme> themes) { | ||
ThemeResult theme = new ThemeResult(); | ||
theme.setThemeCount(themes.size()); | ||
return theme; | ||
} | ||
} | ||
|
||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/hubo/gillajabi/crawl/application/presenation/CrawlController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.hubo.gillajabi.crawl.application.presenation; | ||
|
||
|
||
import com.hubo.gillajabi.crawl.application.dto.response.CrawlResponse; | ||
import com.hubo.gillajabi.crawl.application.service.CrawlFacadeService; | ||
import com.hubo.gillajabi.crawl.domain.constant.CityName; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/api/crawl") | ||
@RequiredArgsConstructor | ||
@Tag(name = "crawl 컨트롤러", description = "관리자 공공데이터 포털 호출 api") | ||
public class CrawlController { | ||
|
||
private final CrawlFacadeService crawlFacadeService; | ||
|
||
@Operation(summary = "전국 길 크롤링 ", description = "만약 해당 정보가 존재한다면 생략합니다.") | ||
@GetMapping("/courses") | ||
public ResponseEntity<CrawlResponse.CourseResult> startCrawlingCurse(@Valid @RequestParam CityName cityName) { | ||
|
||
CrawlResponse.CourseResult response = crawlFacadeService.getCourse(cityName); | ||
|
||
return ResponseEntity.ok().body(response); | ||
} | ||
|
||
@Operation(summary = "전국 길 테마 크롤링", description = "전국 길 테마 크롤링 (ex: 남파랑길)") | ||
@GetMapping("/themes") | ||
public ResponseEntity<CrawlResponse.ThemeResult> startCrawlingTheme(@Valid @RequestParam CityName cityName) { | ||
|
||
CrawlResponse.ThemeResult response = crawlFacadeService.getTheme(cityName); | ||
|
||
return ResponseEntity.ok().body(response); | ||
} | ||
} | ||
|
||
|
12 changes: 12 additions & 0 deletions
12
src/main/java/com/hubo/gillajabi/crawl/application/service/BusanCourseHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.hubo.gillajabi.crawl.application.service; | ||
|
||
import com.hubo.gillajabi.crawl.application.dto.response.CrawlResponse; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class BusanCourseHandler { | ||
|
||
public CrawlResponse.CourseResult handle() { | ||
return null; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/hubo/gillajabi/crawl/application/service/BusanThemeHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.hubo.gillajabi.crawl.application.service; | ||
|
||
import com.hubo.gillajabi.crawl.application.dto.response.CrawlResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class BusanThemeHandler { | ||
|
||
public CrawlResponse.ThemeResult handle() { | ||
return null; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/hubo/gillajabi/crawl/application/service/CrawlFacadeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.hubo.gillajabi.crawl.application.service; | ||
|
||
|
||
import com.hubo.gillajabi.crawl.application.dto.response.CrawlResponse; | ||
import com.hubo.gillajabi.crawl.domain.constant.CityName; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CrawlFacadeService { | ||
|
||
private final DuruCourseHandler duruCourseHandler; | ||
private final BusanCourseHandler busanCourseHandler; | ||
private final DuruThemeHandler duruThemeHandler; | ||
private final BusanThemeHandler busanThemeHandler; | ||
|
||
public CrawlResponse.CourseResult getCourse(final CityName cityName) { | ||
return switch (cityName) { | ||
case DURU -> duruCourseHandler.handle(); | ||
case BUSAN -> busanCourseHandler.handle(); | ||
}; | ||
} | ||
|
||
public CrawlResponse.ThemeResult getTheme(final CityName cityName) { | ||
return switch (cityName) { | ||
case DURU -> duruThemeHandler.handle(); | ||
case BUSAN -> busanThemeHandler.handle(); | ||
}; | ||
} | ||
} | ||
|
||
|
||
|
||
|
35 changes: 35 additions & 0 deletions
35
src/main/java/com/hubo/gillajabi/crawl/application/service/DuruCourseHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.hubo.gillajabi.crawl.application.service; | ||
|
||
import com.hubo.gillajabi.crawl.application.dto.response.CrawlResponse; | ||
import com.hubo.gillajabi.crawl.domain.entity.City; | ||
import com.hubo.gillajabi.crawl.domain.entity.Course; | ||
import com.hubo.gillajabi.crawl.domain.entity.CourseDetail; | ||
import com.hubo.gillajabi.crawl.domain.entity.GpxInfo; | ||
import com.hubo.gillajabi.crawl.domain.service.duru.*; | ||
import com.hubo.gillajabi.crawl.infrastructure.dto.response.DuruCourseResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class DuruCourseHandler { | ||
|
||
private final CrawlDuruServiceImpl duruCrawlService; | ||
private final CityDuruService cityService; | ||
private final CourseDuruService courseDuruService; | ||
private final CourseDetailDuruService courseDetailDuruService; | ||
private final GpxInfoDuruService gpxInfoDuruService; | ||
|
||
public CrawlResponse.CourseResult handle() { | ||
List<DuruCourseResponse.Course> rawCourses = duruCrawlService.crawlCourse(); | ||
List<City> cities = cityService.saveCity(rawCourses); | ||
List<Course> courses = courseDuruService.saveDuruCourse(rawCourses, cities); | ||
List<CourseDetail> courseDetails = courseDetailDuruService.saveDuruCourseDetail(rawCourses, courses); | ||
List<GpxInfo> gpxInfos = gpxInfoDuruService.saveGpxInfo(courseDetails); | ||
|
||
return CrawlResponse.CourseResult.of(cities, courses, courseDetails, gpxInfos); | ||
|
||
} | ||
} |
Oops, something went wrong.