22
33import java .io .File ;
44import 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 ;
105import java .time .LocalDate ;
116import 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}
0 commit comments