Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ dependencies {

// XML 파싱
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")

// Spotify
implementation("se.michaelthelin.spotify:spotify-web-api-java:8.4.1")
}

tasks.withType<Test> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
package com.back.web7_9_codecrete_be.domain.artists.controller;

import com.back.web7_9_codecrete_be.domain.artists.service.ArtistsService;
import com.back.web7_9_codecrete_be.domain.artists.service.ArtistService;
import com.back.web7_9_codecrete_be.domain.artists.service.ArtistEnrichService;
import com.back.web7_9_codecrete_be.global.rsData.RsData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/artists")
@RequiredArgsConstructor
@Tag(name = "Artists", description = "공연에 대한 정보를 제공하는 API 입니다.")
public class ArtistsController {
private final ArtistsService artistsService;
private final ArtistService artistService;
private final ArtistEnrichService enrichService;

@Operation(summary = "아티스트 저장", description = "임의의 가수 300명(or 팀)을 DB에 저장합니다.")
@GetMapping("/saved")
public RsData<Integer> saveArtist() {
int saved = artistService.setArtist();
return RsData.success("아티스트 저장에 성공하였습니다.", saved);
}

@Operation(summary = "아티스트 정보 보완", description = "아티스트 한국어 이름, 그룹 여부, 소속 그룹 정보 보완")
@PostMapping("/enrich")
public RsData<Integer> enrich(
@RequestParam(required = false, defaultValue = "100") int limit
) {
int updated = enrichService.enrichArtist(limit);
return RsData.success("enrich 성공", updated);
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.back.web7_9_codecrete_be.domain.artists.dto.request;

import com.back.web7_9_codecrete_be.domain.artists.entity.Genre;


public record CreateRequest(
String artistName,
String artistGroup,
String artistType,
Genre genre
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.back.web7_9_codecrete_be.domain.artists.dto.request;

import com.back.web7_9_codecrete_be.domain.artists.entity.Genre;


public record UpdateRequest(
String artistName,
String artistGroup,
String artistType,
Genre genre
) {
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,54 @@
package com.back.web7_9_codecrete_be.domain.artists.entity;

import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;


@Entity
@Getter
@Table(name = "arist")
@Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "artist")
public class Artist {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "artist_id")
private long id;

@Column(name = "artist_name", nullable = false, length = 30)
@Column(name = "artist_name", nullable = false)
private String artistName;

@Column(name = "artist_group", length = 30)
@Column(name = "artist_group")
private String artistGroup;

@Column(name = "artist_type", nullable = false, length = 20)
@Column(name = "artist_type")
private String artistType;

@ManyToOne(fetch = FetchType.LAZY)
private Genre genre;

@Column(name = "spotify_artist_id", unique = true)
private String spotifyArtistId;

@Column(name = "name_ko", length = 200)
private String nameKo;

public Artist(String spotifyArtistId, String artistName, String artistGroup, String artistType, Genre genre) {
this.spotifyArtistId = spotifyArtistId;
this.artistName = artistName;
this.artistGroup = artistGroup; // 옵션 B: seed에서는 null
this.artistType = artistType; // 옵션 B: seed에서는 "SINGER"
this.genre = genre;
}

public void updateProfile(String nameKo, String artistGroup, String artistType) {
this.nameKo = nameKo;
this.artistGroup = artistGroup; // nullable
this.artistType = artistType; // "SOLO" / "GROUP"
}


}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.back.web7_9_codecrete_be.domain.artists.entity;

import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "genre")
public class Genre {
@Id
Expand All @@ -19,4 +22,10 @@ public class Genre {

@Column(name = "genre_memo")
private String genreMemo;

public Genre(String genreName, String genreGroup, String genreMemo) {
this.genreName = genreName;
this.genreGroup = genreGroup;
this.genreMemo = genreMemo;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package com.back.web7_9_codecrete_be.domain.artists.repository;

import com.back.web7_9_codecrete_be.domain.artists.entity.Artist;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ArtistRepository extends JpaRepository<Artist, Long> {
boolean existsBySpotifyArtistId(String spotifyArtistId);

@Query("SELECT a FROM Artist a WHERE a.nameKo IS NULL ORDER BY a.id ASC")
List<Artist> findByNameKoIsNullOrderByIdAsc(Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface GenreRepository extends JpaRepository<Genre, Long> {
Optional<Genre> findByGenreName(String genreName);
}
Loading