-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[BE/feat] Docker Volume과 log 파일 연동
- Loading branch information
Showing
15 changed files
with
921 additions
and
799 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
Large diffs are not rendered by default.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
BE/exceed/src/main/java/com/gaebaljip/exceed/common/data/MariaDBAutoComplete.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,60 @@ | ||
package com.gaebaljip.exceed.common.data; | ||
|
||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import org.springframework.boot.ApplicationArguments; | ||
import org.springframework.boot.ApplicationRunner; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.gaebaljip.exceed.food.adapter.out.FoodEntity; | ||
import com.gaebaljip.exceed.food.application.port.out.FoodPort; | ||
import com.opencsv.CSVReader; | ||
import com.opencsv.CSVReaderBuilder; | ||
import com.opencsv.exceptions.CsvException; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Component | ||
@Log4j2 | ||
@RequiredArgsConstructor | ||
@ConditionalOnExpression("${ableAutoComplete:true}") | ||
public class MariaDBAutoComplete implements ApplicationRunner { | ||
|
||
private final FoodPort foodPort; | ||
|
||
@Override | ||
public void run(ApplicationArguments args) throws Exception { | ||
|
||
// CSV 파일에서 식품명 열 데이터 로드 | ||
String csvPath = args.getSourceArgs()[0]; | ||
try (CSVReader reader = | ||
new CSVReaderBuilder(new FileReader(csvPath)) | ||
.withSkipLines(1) // 첫 번째 행(헤더) 건너뛰기 | ||
.build()) { | ||
List<String[]> allRows = reader.readAll(); | ||
List<FoodEntity> foodEntities = | ||
allRows.stream() | ||
.map( | ||
row -> | ||
FoodEntity.builder() | ||
.calorie(Double.valueOf(row[1])) | ||
.carbohydrate(Double.valueOf(row[2])) | ||
.fat(Double.valueOf(row[3])) | ||
.name(row[4]) | ||
.protein(Double.valueOf(row[5])) | ||
.servingSize(Double.valueOf(row[6])) | ||
.sugars(Double.valueOf(row[7])) | ||
.dietaryFiber(Double.valueOf(row[8])) | ||
.sodium(Double.valueOf(row[9])) | ||
.build()) | ||
.toList(); | ||
foodPort.saveAll(foodEntities); | ||
} catch (IOException | CsvException e) { | ||
log.error("Failed to read CSV file: {}", e.getMessage()); | ||
} | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...ceed/infrastructure/redis/RedisUtils.java → ...aljip/exceed/common/redis/RedisUtils.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
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
18 changes: 18 additions & 0 deletions
18
BE/exceed/src/main/java/com/gaebaljip/exceed/health/HealthController.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,18 @@ | ||
package com.gaebaljip.exceed.health; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.gaebaljip.exceed.common.ApiResponse; | ||
import com.gaebaljip.exceed.common.ApiResponseGenerator; | ||
|
||
@RestController | ||
@RequestMapping("/api") | ||
public class HealthController { | ||
@GetMapping("/health") | ||
public ApiResponse<ApiResponse.CustomBody<Void>> health() { | ||
return ApiResponseGenerator.success(HttpStatus.OK); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -70,3 +70,10 @@ management: | |
include: "*" | ||
exclude: "env, beans" | ||
|
||
logging: | ||
level: | ||
org: | ||
hibernate: | ||
type: | ||
descriptor: | ||
sql: trace |
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 |
---|---|---|
|
@@ -75,3 +75,10 @@ management: | |
include: "*" | ||
exclude: "env, beans" | ||
|
||
logging: | ||
level: | ||
org: | ||
hibernate: | ||
type: | ||
descriptor: | ||
sql: trace |
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