Skip to content

Commit

Permalink
Merge pull request #9 from hubo-gillajabi/HUBOBE-14-be-날씨-정보-크롤링
Browse files Browse the repository at this point in the history
Hubobe 14 be 날씨 정보 크롤링
  • Loading branch information
haroya01 authored Jun 29, 2024
2 parents 3ae62ac + 2891448 commit b6dfbc6
Show file tree
Hide file tree
Showing 97 changed files with 2,366 additions and 961 deletions.
2 changes: 1 addition & 1 deletion BE-hubo-gillajabi-resources
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis:3.2.5'


// https://mvnrepository.com/artifact/junit/junit
testImplementation 'junit:junit:4.13.1'

Expand Down

This file was deleted.

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.response.RoadCrawlResponse;
import com.hubo.gillajabi.crawl.application.service.RoadCrawlFacadeService;
import com.hubo.gillajabi.crawl.domain.constant.CityCrawlName;
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/road/crawl")
@RequiredArgsConstructor
@Tag(name = "Road crawl 컨트롤러", description = "관리자 공공데이터 포털 호출 api(길 관련)")
public class RoadCrawlController {

private final RoadCrawlFacadeService roadCrawlFacadeService;

@Operation(summary = "전국 길 크롤링 ", description = "만약 해당 정보가 존재한다면 생략합니다.")
@PostMapping("/courses")
public ResponseEntity<RoadCrawlResponse.CourseResult> startCrawlingCurse(@Valid @RequestParam CityCrawlName cityCrawlName) {

RoadCrawlResponse.CourseResult response = roadCrawlFacadeService.getCourse(cityCrawlName);

return ResponseEntity.ok().body(response);
}

@Operation(summary = "전국 길 테마 크롤링", description = "전국 길 테마 크롤링 (ex: 남파랑길)")
@PostMapping("/themes")
public ResponseEntity<RoadCrawlResponse.ThemeResult> startCrawlingTheme(@Valid @RequestParam CityCrawlName cityCrawlName) {

RoadCrawlResponse.ThemeResult response = roadCrawlFacadeService.getTheme(cityCrawlName);

return ResponseEntity.ok().body(response);
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.hubo.gillajabi.crawl.application.presenation;

import com.hubo.gillajabi.crawl.domain.service.WeatherCrawlService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/weather/crawl")
@RequiredArgsConstructor
@Tag(name = "Weather crawl 컨트롤러 ", description = "관리자 공공 데이터 포털 호출 api(날씨 관련)")
public class WeatherCrawlController {

private final WeatherCrawlService weatherCrawlService;

@Operation(summary = "전국 날씨 크롤링 (당일) ", description = "전국 날씨를 3일치를 들고 옵니다.")
@PostMapping("/current")
public ResponseEntity<?> startWeatherCurrentCrawl() {

weatherCrawlService.currentCrawl();

return ResponseEntity.ok().build();
}

@Operation(summary = "전국 날씨 크롤링 (일주일) ", description = "3일 이후 부터 ~7일까지의 날씨 정보를 크롤링합니다.")
@PostMapping("/medium-term")
public ResponseEntity<?> startWeatherMediumTermCrawl() {

weatherCrawlService.weatherMediumTermCrawl();

return ResponseEntity.ok().build();
}

@Operation(summary = "전국 기상 특보 크롤링 (지금 현재) ", description = "미구현")
@PostMapping("/weather_alert")
public ResponseEntity<?> startWeatherAlertCrawl() {

weatherCrawlService.alertCrawl();

return ResponseEntity.status(500).body("미구현");
}

}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hubo.gillajabi.crawl.application.dto.response;
package com.hubo.gillajabi.crawl.application.response;

import com.hubo.gillajabi.crawl.domain.entity.*;
import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -11,7 +11,7 @@

@Getter
@Setter
public class CrawlResponse {
public class RoadCrawlResponse {

@Getter
@Setter
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.hubo.gillajabi.crawl.application.service;


import com.hubo.gillajabi.crawl.application.response.RoadCrawlResponse;
import com.hubo.gillajabi.crawl.domain.constant.CityCrawlName;
import com.hubo.gillajabi.crawl.domain.service.busan.RoadBusanThemeHandler;
import com.hubo.gillajabi.crawl.domain.service.busan.RoadCrawlBusanCourseHandler;
import com.hubo.gillajabi.crawl.domain.service.duru.RoadCourseDuruHandler;
import com.hubo.gillajabi.crawl.domain.service.duru.RoadThemeDuruHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;


@Service
@RequiredArgsConstructor
public class RoadCrawlFacadeService {

private final RoadCourseDuruHandler roadCourseDuruHandler;
private final RoadCrawlBusanCourseHandler roadCrawlBusanCourseHandler;
private final RoadThemeDuruHandler roadThemeDuruHandler;
private final RoadBusanThemeHandler roadBusanThemeHandler;

public RoadCrawlResponse.CourseResult getCourse(final CityCrawlName cityCrawlName) {
return switch (cityCrawlName) {
case DURU -> roadCourseDuruHandler.handle();
case BUSAN -> roadCrawlBusanCourseHandler.handle();
};
}

public RoadCrawlResponse.ThemeResult getTheme(final CityCrawlName cityCrawlName) {
return switch (cityCrawlName) {
case DURU -> roadThemeDuruHandler.handle();
case BUSAN -> roadBusanThemeHandler.handle();
};
}
}




Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.hubo.gillajabi.crawl.domain.constant;

public enum CityName {
public enum CityCrawlName {
DURU("두루누비"),
BUSAN("부산");

private final String name;

CityName(String name) {
CityCrawlName(String name) {
this.name = name;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.hubo.gillajabi.crawl.domain.constant;

import com.hubo.gillajabi.crawl.infrastructure.dto.response.DuruCourseResponse;
import com.hubo.gillajabi.crawl.infrastructure.dto.response.ApiCourseResponse;

public enum CycleType {
CYCLE, SINGLE;

public static CycleType fromValue(DuruCourseResponse.Course course) {
public static CycleType fromValue(ApiCourseResponse.Course course) {
return switch (course.getCrsCycle()) {
case "순환형" -> CYCLE;
case "비순환형" -> SINGLE;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.hubo.gillajabi.crawl.domain.constant;

public enum ForecastType {
CURRENT, // 당일 예보
MEDIUM_TERM, // 중기 예보
WEATHER_ALERT // 기상 특보
}
Loading

0 comments on commit b6dfbc6

Please sign in to comment.