Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hubobe 14 be 날씨 정보 크롤링 #9

Merged
merged 31 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
665ac99
refactor: 패키지 구조 변경
haroya01 Jun 24, 2024
8609777
feat: WeatherEndpointConfig key 설정 추가
haroya01 Jun 25, 2024
445116b
feat: weather 관련 enum 파일 추가
haroya01 Jun 25, 2024
ec85964
chore: 안 쓰는 파일 제거
haroya01 Jun 25, 2024
62309e0
feat: ApiResponse dto 추가
haroya01 Jun 26, 2024
caf4a87
feat: City Entity 에 날씨 코드 추가
haroya01 Jun 26, 2024
e520e07
refactor: CityCrawl 를 CityCrawlName 으로 이름 변경
haroya01 Jun 26, 2024
3e7b259
refactor: dto 클래스들 이름 변경
haroya01 Jun 26, 2024
92ae153
feat: redis 의존성 추가
haroya01 Jun 26, 2024
4066fcb
refactor: dto 메서드 이름이 변경됨에 따라 수정
haroya01 Jun 26, 2024
a0db5ff
feat: current 날씨 API URI 생성 추가
haroya01 Jun 26, 2024
12b4139
feat: CrawlExceptionCode 에러 추가
haroya01 Jun 26, 2024
c5a6882
feat: weather currentCrawl 추가
haroya01 Jun 26, 2024
4f35dc3
refactor: 변경된 CityCrawlName에 맞게 수정
haroya01 Jun 26, 2024
234f1bd
refactor: handler domain 으로 이동
haroya01 Jun 26, 2024
3f40e25
feat: 날씨 관련 api에 대응하도록 수정
haroya01 Jun 27, 2024
b224149
feat: redis 쿼리도 로깅 하도록 추가
haroya01 Jun 27, 2024
1de803d
feat: RedisConfig 추가
haroya01 Jun 27, 2024
d40ed9e
feat: MediumTermSkyCondition 추가
haroya01 Jun 27, 2024
18e2095
refactor: roadCrawl 관련 리펙토링
haroya01 Jun 27, 2024
f8b7260
feat: 날씨 관련 dto 작성
haroya01 Jun 27, 2024
06f07e4
feat: MediumTermSkyCondition 추가
haroya01 Jun 27, 2024
e59f4bc
refactor: 달라진 DTO 이름에 따른 변경
haroya01 Jun 27, 2024
3fa327e
refactor: api를 처리하는 로직과 api호출,저장하는 로직 분리
haroya01 Jun 27, 2024
4120adb
refactor: 누락된 코드 추가
haroya01 Jun 27, 2024
f8e6081
chore: 주석으로 설명 추가
haroya01 Jun 27, 2024
a80e8ab
feat: 일기 예보 3~7일 관련 ResponseDTO 작성
haroya01 Jun 27, 2024
8ec3353
feat: 날씨 크롤링 관련 기능 추가
haroya01 Jun 27, 2024
d2b2374
refactor: RoadDuruAbstractCrawlDuruService로 이름 변경 및 public 접근 제어자 제거
haroya01 Jun 27, 2024
8764525
refactor: 패키지 경로 변경에 따른 수정
haroya01 Jun 27, 2024
2891448
test: 테스트 코드 추가 및 주석처리
haroya01 Jun 29, 2024
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
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
Loading