Skip to content
Snippets Groups Projects
Commit 343351e7 authored by 황 재인's avatar 황 재인
Browse files

final

parent 1676d1f1
Branches
No related tags found
No related merge requests found
Pipeline #11571 failed
FROM openjdk:17-jdk # 1단계: 빌드용 이미지
FROM maven:3.9.6-eclipse-temurin-17 AS builder
WORKDIR /app WORKDIR /app
COPY target/*.jar app.jar
# pom.xml과 소스 복사
COPY pom.xml .
COPY src ./src
# 의존성 캐시를 위한 별도 단계
RUN mvn dependency:go-offline
# 애플리케이션 빌드
RUN mvn clean package -DskipTests
# 2단계: 실행용 이미지
FROM eclipse-temurin:17-jdk
WORKDIR /app
# 빌드된 JAR 복사
COPY --from=builder /app/target/myweb-0.0.1-SNAPSHOT.jar app.jar
# 8080 포트 열기
EXPOSE 8080 EXPOSE 8080
# Spring Boot 앱 실행
ENTRYPOINT ["java", "-jar", "app.jar"] ENTRYPOINT ["java", "-jar", "app.jar"]
version: "3.3" version: '3.8'
services: services:
myweb: myweb:
build: . image: myweb
build:
context: .
dockerfile: Dockerfile
ports: ports:
- "8080:8080" - "8080:8080"
...@@ -23,8 +23,6 @@ public class MusicService { ...@@ -23,8 +23,6 @@ public class MusicService {
private final FavoriteRepository albumsRepo; private final FavoriteRepository albumsRepo;
private final RestTemplate restTemplate = new RestTemplate(); private final RestTemplate restTemplate = new RestTemplate();
//iTunes API를 호출해 앨범 검색 결과(MusicList) 반환
public MusicList searchMusic(String name) { public MusicList searchMusic(String name) {
try { try {
String url = String.format("https://itunes.apple.com/search?term=%s&entity=album", name); String url = String.format("https://itunes.apple.com/search?term=%s&entity=album", name);
...@@ -39,21 +37,15 @@ public class MusicService { ...@@ -39,21 +37,15 @@ public class MusicService {
} }
} }
//DB에서 FavoriteMusic 목록을 조회
public List<FavoriteMusic> getLikes() { public List<FavoriteMusic> getLikes() {
return albumsRepo.findAll(); return albumsRepo.findAll();
} }
//즐겨찾기 등록
//DTO -> 엔티티 변환 후 DB에 저장, 성공 시 1, 실패 시 0 반환
public int saveFavorite(FavoriteMusicRequestDto favorite) { public int saveFavorite(FavoriteMusicRequestDto favorite) {
FavoriteMusic music = albumsRepo.save(favorite.toEntity()); FavoriteMusic music = albumsRepo.save(favorite.toEntity());
return (music != null) ? 1 : 0; return (music != null) ? 1 : 0;
} }
// 존재하는지 확인 (없으면 예외 혹은 0 return 등)
public int deleteFavorite(String id) { public int deleteFavorite(String id) {
try { try {
if (albumsRepo.existsById(id)) { if (albumsRepo.existsById(id)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment