Skip to content

Commit ad018cf

Browse files
authored
hotfix/data.sql deprecate-HwuanPage (#79)
* hotfix/data.sql deprecate-HwuanPage * portnum fix
1 parent a7c6ab8 commit ad018cf

File tree

3 files changed

+6
-84
lines changed

3 files changed

+6
-84
lines changed

src/main/java/sevenstar/marineleisure/alert/controller/AlertController.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public ResponseEntity<BaseResponse<JellyfishResponseDto>> getJellyfishList() {
3535
// 명시적으로 크롤링작업을 호출하기 위함입니다. 프론트에서 사용하지는 않습니다.
3636
// 동작 테스트 완료했습니다.
3737
// OpenAi Token발생하므로 꼭 필요할때만 사용해주세요.
38-
// @GetMapping("/jellyfish/crawl")
39-
// public ResponseEntity<String> triggerCrawl() {
40-
// jellyfishService.updateLatestReport();
41-
// return ResponseEntity.ok("해파리 리포트 크롤링 완료");
42-
// }
38+
@GetMapping("/jellyfish/crawl")
39+
public ResponseEntity<String> triggerCrawl() {
40+
jellyfishService.updateLatestReport();
41+
return ResponseEntity.ok("해파리 리포트 크롤링 완료");
42+
}
4343
}

src/main/java/sevenstar/marineleisure/alert/service/JellyfishService.java

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
import java.io.File;
44
import java.io.IOException;
5-
import java.nio.charset.StandardCharsets;
6-
import java.nio.file.Files;
7-
import java.nio.file.Path;
8-
import java.nio.file.Paths;
9-
import java.nio.file.StandardOpenOption;
105
import java.time.LocalDate;
116
import java.util.List;
127

@@ -89,7 +84,7 @@ public void updateLatestReport() {
8984
speciesRepository.save(species);
9085
log.info("신종 해파리등록 : {}", dto.species());
9186

92-
appendToDataSql(dto.species(), ToxicityLevel.NONE);
87+
// appendToDataSql(dto.species(), ToxicityLevel.NONE);
9388
}
9489

9590
DensityLevel densityLevel = dto.densityType().equals("HIGH") ? DensityLevel.HIGH : DensityLevel.LOW;
@@ -109,35 +104,4 @@ public void updateLatestReport() {
109104
}
110105
}
111106

112-
/**
113-
* DB적재중 신종해파리 등록시 자동으로 data.sql에 INSERT문을 추가하는 메서드입니다.
114-
* @param speciesName 신종 해파리 등록
115-
* @param toxicity 무독성 고정
116-
*/
117-
private void appendToDataSql(String speciesName, ToxicityLevel toxicity) {
118-
try {
119-
120-
String resourcePath = "src/main/resources/data.sql";
121-
Path dataFilePath = Paths.get(resourcePath);
122-
123-
if (!Files.exists(dataFilePath)) {
124-
Files.createFile(dataFilePath);
125-
log.info("data.sql 파일 생성");
126-
}
127-
128-
String insertStatement = String.format(
129-
"INSERT INTO jellyfish_species (name, toxicity, created_at, updated_at)\n" +
130-
"VALUES ('%s', '%s', NOW(), NOW());\n",
131-
speciesName, toxicity.name()
132-
);
133-
134-
Files.write(dataFilePath, insertStatement.getBytes(StandardCharsets.UTF_8),
135-
StandardOpenOption.APPEND);
136-
137-
log.info("새로운 종 인서트문 생성: {}", speciesName);
138-
139-
} catch (IOException e) {
140-
log.error("쓰기 실패", e);
141-
}
142-
}
143107
}

src/main/resources/data.sql

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)