Skip to content

Commit

Permalink
Merge branch 'develop' into luchobackend
Browse files Browse the repository at this point in the history
  • Loading branch information
Luciano-A1 committed Dec 2, 2024
2 parents fbafe1b + 633cb8f commit bbbb3ba
Show file tree
Hide file tree
Showing 21 changed files with 262 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.web.app.controllers;

import com.web.app.dto.ExtendedBaseResponse;
import com.web.app.dto.album.AlbumRequest;
import com.web.app.dto.album.AlbumResponse;
import com.web.app.service.AlbumService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand All @@ -25,25 +25,39 @@ public class AlbumController {

private final AlbumService service;

@Operation(summary = "Crea un album con la Api Deezer.",
description = "Crea un album de la Api Deezer y todas las canciones del album.")
@Operation(summary = "Crea un album con su artista y sus pistas con la Api Deezer.",
description = "Crea un album con su artista y sus pistas con la Api Deezer.")
@ApiResponses(value = {
@ApiResponse(
responseCode = "201",
description = "Album creado exitosamente.",
content = {
@Content(mediaType = "application/json",
schema = @Schema(implementation = ExtendedBaseResponse.class))
}),

content = @Content(
examples = @ExampleObject(
value = "{\n" +
" \"isError\": false,\n" +
" \"code\": 201,\n" +
" \"status\": \"Created\",\n" +
" \"message\": \"Album creado.\",\n" +
" \"data\": \"http://localhost:8080/albums/15103893\"\n" +
"}" )
)
),
@ApiResponse(
responseCode = "404",
description = "Album no encontrado.",
content = @Content
),
@ApiResponse(
responseCode = "500",
description = "Error interno del servidor.",
content = @Content
)
})
@PostMapping("/import/{id}")
public ResponseEntity<ExtendedBaseResponse<URI>> createDeezerAlbum (@PathVariable long id) {
public ResponseEntity<ExtendedBaseResponse<URI>> createDeezerAlbum (
@Parameter(name = "id", example = "15103893", required = true)
@PathVariable long id
) {
ExtendedBaseResponse<URI> albumResponse = service.createDeezerAlbum(id);
return ResponseEntity.status(201).body(albumResponse);
}
Expand All @@ -53,20 +67,19 @@ public ResponseEntity<ExtendedBaseResponse<URI>> createDeezerAlbum (@PathVariabl
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
description = "Album encontrado.",
content = {
@Content(mediaType = "application/json",
schema = @Schema(implementation = ExtendedBaseResponse.class))
}),

description = "Album encontrado."
),
@ApiResponse(
responseCode = "404",
description = "Album no encontrado.",
content = @Content
)
})
@GetMapping("/{id}")
public ResponseEntity<ExtendedBaseResponse<AlbumResponse>> findAlbum (@PathVariable long id) {
public ResponseEntity<ExtendedBaseResponse<AlbumResponse>> findAlbum (
@Parameter(name = "id", example = "15103893", required = true)
@PathVariable long id
) {
ExtendedBaseResponse<AlbumResponse> albumResponse = service.findAlbum(id);
return ResponseEntity.ok(albumResponse);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.web.app.dto.ExtendedBaseResponse;
import com.web.app.dto.search.SearchDeezerResponse;
import com.web.app.dto.search.db.SearchDBResponseProjection;
import com.web.app.service.impl.SearchServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
Expand All @@ -12,15 +13,17 @@
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "Buscador", description = "Buscar canciones, album, artist tanto desde la API de Deezar como la nuestra")
@RestController
@RequestMapping("/search")
@RequiredArgsConstructor
public class SearchController {
public final SearchServiceImpl searchService;
// Implementación de los métodos para buscar canciones, albums y artistas
@Operation(summary = "Buscador",
description = "Al Buscar canciones, album, artist, hacerlo entre comillas"
@Operation(summary = "Buscador API Deezer",
description ="Al Buscar canciones, album, artist, hacerlo entre comillas"
)
@ApiResponses( value = {
@ApiResponse(
Expand All @@ -32,10 +35,28 @@ public class SearchController {
})
})
@GetMapping
public ExtendedBaseResponse<SearchDeezerResponse> findTracksByAlbumId(
public ExtendedBaseResponse<SearchDeezerResponse> findBySearchDeezer(
@RequestParam(required = false) String artist,
@Schema(example="'nueva era'")
@RequestParam(required = false) String track,
@RequestParam(required = false) String album) {
return searchService.searchDeezaer(artist,track,album);
}

@Operation(summary = "Buscador DB http://localhost:8080/search/{busqueda}",
description ="Al Buscar canciones, album, artist, puede buscar por " +
"palabras parciles ej: nuev o nueva y te un album, cancion o artista " +
"que coincidan en la DB"
)
@ApiResponses( value = {
@ApiResponse(
responseCode = "200",
description = "Busqueda por DB.")
})
@GetMapping("/{search}")
public ExtendedBaseResponse<List<SearchDBResponseProjection>> findBySearchDB(
@Schema(example = "nuev")
@PathVariable() String search) {
return searchService.searchDB(search);
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package com.web.app.controllers;

import com.web.app.dto.ExtendedBaseResponse;
import com.web.app.dto.track.TrackRequest;
import com.web.app.dto.track.TrackResponse;
import com.web.app.service.TrackService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.net.URI;
import java.util.List;

@Tag(name = "Pistas", description = "Gestionar todos los End-Points de pistas.")
@RestController
Expand All @@ -27,24 +26,40 @@ public class TrackController {

private final TrackService service;

@Operation(summary = "Crea una pista con la api Deezer.", description = "Crea una pista con la api Deezer.")
@Operation(summary = "Crea una pista con su album y su artist con la Api Deezer.",
description = "Crea una pista con su album y su artist con la Api Deezer.")
@ApiResponses(value = {
@ApiResponse(
responseCode = "201",
description = "Pista creada.",
content = {
@Content(mediaType = "application/json",
schema = @Schema(implementation = ExtendedBaseResponse.class))
}
content = @Content(
examples = @ExampleObject(
value = "{\n" +
" \"isError\": false,\n" +
" \"code\": 201,\n" +
" \"status\": \"Created\",\n" +
" \"message\": \"Pista creada.\",\n" +
" \"data\": \"http://localhost:8080/tracks/15103893\"\n" +
"}"
)
)
),
@ApiResponse(
responseCode = "404",
description = "Pista no encontrada.",
content = @Content
),
@ApiResponse(
responseCode = "500",
description = "Error interno del servidor.",
content = @Content
)
})
@PostMapping("/import/{id}")
public ResponseEntity<ExtendedBaseResponse<URI>> createDeezerTrack(@PathVariable long id) throws IOException {
public ResponseEntity<ExtendedBaseResponse<URI>> createDeezerTrack(
@Parameter(name = "id", example = "140295501", required = true)
@PathVariable long id
) throws IOException {
ExtendedBaseResponse<URI> trackResponse = service.createDeezerTrack(id);
return ResponseEntity.status(201).body(trackResponse);
}
Expand All @@ -53,11 +68,7 @@ public ResponseEntity<ExtendedBaseResponse<URI>> createDeezerTrack(@PathVariable
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
description = "Pista creada.",
content = {
@Content(mediaType = "application/json",
schema = @Schema(implementation = ExtendedBaseResponse.class))
}
description = "Pista creada."
),
@ApiResponse(
responseCode = "404",
Expand All @@ -66,7 +77,10 @@ public ResponseEntity<ExtendedBaseResponse<URI>> createDeezerTrack(@PathVariable
)
})
@GetMapping("/{id}")
public ResponseEntity<ExtendedBaseResponse<TrackResponse>> findTrack(@PathVariable long id) throws IOException {
public ResponseEntity<ExtendedBaseResponse<TrackResponse>> findTrack(
@Parameter(name = "id", example = "140295501", required = true)
@PathVariable long id
) throws IOException {
ExtendedBaseResponse<TrackResponse> trackResponse = service.findTrack(id);
return ResponseEntity.ok(trackResponse);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@

import com.web.app.dto.artist.ShortArtistResponse;
import com.web.app.dto.track.ShortTrackResponse;
import com.web.app.dto.track.TrackResponse;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;

import java.time.LocalDate;
import java.util.List;


public record AlbumResponse (
@Schema(example = "15103893")
Long id,

@Schema(example = "Faded")
String name,

@Schema(example = "2015-12-04")
String releaseDate,

@Schema(example = "https://api.deezer.com/album/15103893/image")
String pictureUrl,

@ArraySchema(schema = @Schema(examples = {"Electro", "Techno/House", "Dance"}))
List<String> genres,

ShortArtistResponse artist,

List<ShortTrackResponse> tracks
) {
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
package com.web.app.dto.album;

import com.web.app.dto.artist.ShortArtistResponse;
import com.web.app.dto.track.ShortTrackResponse;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;

import java.time.LocalDate;
import java.util.List;

public record ShortAlbumResponse(
@Schema(example = "15103893")
Long id,

@Schema(example = "Faded")
String name,

@Schema(example = "2015-12-04")
String releaseDate,

@Schema(example = "https://api.deezer.com/album/15103893/image")
String pictureUrl,

@ArraySchema(schema = @Schema(examples = {"Electro", "Techno/House", "Dance"}))
List<String> genres,

ShortArtistResponse artist
) {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package com.web.app.dto.artist;

import io.swagger.v3.oas.annotations.media.Schema;

public record ShortArtistResponse(
@Schema(example = "4999707")
Long id,

@Schema(example = "Alan Walker")
String name,

@Schema(example = "https://api.deezer.com/artist/4999707/image")
String pictureUrl,

@Schema(example = "3914389")
Long fanNum
) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.web.app.dto.search.db;

public record SearchDBResponse(
String track,
String album,
String picture_url,
String type,
Long id
) {
// public SearchDBResponse(String track, String album, String pictureUrl, String type, Long id) {
// this.track = track;
// this.album = album;
// this.pictureUrl = pictureUrl;
// this.type = type;
// this.id = id;
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.web.app.dto.search.db;

import io.swagger.v3.oas.annotations.media.Schema;

public interface SearchDBResponseProjection {
@Schema(example = "Nueva Era")
String getTrack();
@Schema(example = "AMERI")
String getAlbum();
@Schema(example = "DUKI")
String getArtist();
@Schema(example = "https://api.deezer.com/album/664113131/image")
String getPicture_url();
@Schema(example = "track")
String getType();
@Schema(example = "3069012151")
Long getId();
}
Loading

0 comments on commit bbbb3ba

Please sign in to comment.