-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add files via upload
- Loading branch information
Showing
93 changed files
with
3,535 additions
and
4,698 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"liveServer.settings.port": 5503 | ||
"liveServer.settings.port": 5501 | ||
} |
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
33 changes: 33 additions & 0 deletions
33
Astro/src/main/java/com/example/Astro/Controller/PlaylistController.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,33 @@ | ||
package com.example.Astro.Controller; | ||
|
||
import com.example.Astro.Model.Playlist; | ||
import com.example.Astro.Service.PlaylistService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/playlists") | ||
public class PlaylistController { | ||
private final PlaylistService playlistService; | ||
|
||
public PlaylistController(PlaylistService playlistService) { | ||
this.playlistService = playlistService; | ||
} | ||
|
||
@GetMapping("/user/{userId}") | ||
public ResponseEntity<List<Playlist>> getPlaylistsByUser(@PathVariable Long userId) { | ||
return ResponseEntity.ok(playlistService.getPlaylistsByUser(userId)); | ||
} | ||
|
||
@PostMapping | ||
public ResponseEntity<Playlist> createPlaylist(@RequestBody Playlist playlist) { | ||
return ResponseEntity.ok(playlistService.createPlaylist(playlist)); | ||
} | ||
|
||
@PutMapping("/{id}") | ||
public ResponseEntity<Playlist> updatePlaylist(@PathVariable Long id, @RequestBody Playlist updatedPlaylist) { | ||
return ResponseEntity.ok(playlistService.updatePlaylist(id, updatedPlaylist)); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
Astro/src/main/java/com/example/Astro/Controller/ThemeController.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,47 @@ | ||
package com.example.Astro.Controller; | ||
|
||
import com.example.Astro.Model.User; | ||
import com.example.Astro.Repository.UserRepository; | ||
import com.example.Astro.service.UserService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.Map; | ||
|
||
@RestController | ||
@RequestMapping("/api") | ||
public class ThemeController { | ||
|
||
@Autowired | ||
private UserService userService; // Serviço para gerenciar usuários | ||
@Autowired | ||
private UserRepository repository; | ||
|
||
@PostMapping("/save-theme") | ||
public ResponseEntity<String> saveTheme(@RequestBody Map<String, String> request, @RequestHeader("Authorization") String token) { | ||
String theme = request.get("theme"); | ||
|
||
if (theme == null || theme.isEmpty()) { | ||
return ResponseEntity.badRequest().body("Tema não fornecido."); | ||
} | ||
|
||
// Remove o prefixo "Bearer " do token | ||
token = token.replace("Bearer ", ""); | ||
System.out.println("token: \n" +token); | ||
|
||
// Busca o usuário pelo token | ||
User user = userService.getUserByToken(token); | ||
if (user == null) { | ||
System.out.println("\nUsuário não encontrado\n"); | ||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Usuário não autenticado."); | ||
} | ||
|
||
// Atualiza o tema no banco de dados | ||
user.setTheme(theme); // Supondo que você tenha um campo `theme` na entidade `User` | ||
repository.save(user); // Salva o usuário atualizado no banco de dados | ||
|
||
return ResponseEntity.ok("Tema salvo com sucesso!"); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.example.Astro.Model; | ||
|
||
import jakarta.persistence.*; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Entity | ||
@Table(name ="playlists") | ||
public class Playlist { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "idPlaylists") | ||
private long idPlaylists; | ||
|
||
@Column(name = "Name") | ||
private String name; | ||
|
||
@Column(name = "Update_At") | ||
private LocalDate updateAt; | ||
|
||
@Column(name = "Public") | ||
private Boolean publicPlay; | ||
|
||
@Column(name = "id_User_Details") | ||
private Long idUserDetails; | ||
|
||
public void setIdPlaylists(long idPlaylists) { | ||
this.idPlaylists = idPlaylists; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public void setUpdateAt(LocalDate updateAt) { | ||
this.updateAt = updateAt; | ||
} | ||
|
||
public void setPublicPlay(Boolean publicPlay) { | ||
this.publicPlay = publicPlay; | ||
} | ||
|
||
public void setIdUserDetails(Long idUserDetails) { | ||
this.idUserDetails = idUserDetails; | ||
} | ||
|
||
public LocalDate getUpdateAt() { | ||
return updateAt; | ||
} | ||
|
||
public Boolean getPublicPlay() { | ||
return publicPlay; | ||
} | ||
|
||
public Long getIdUserDetails() { | ||
return idUserDetails; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public long getIdPlaylists() { | ||
return idPlaylists; | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
Astro/src/main/java/com/example/Astro/Repository/PlaylistRepository.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,12 @@ | ||
package com.example.Astro.Repository; | ||
|
||
import com.example.Astro.Model.Playlist; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface PlaylistRepository extends JpaRepository<Playlist, Long> { | ||
List<Playlist> findByIdUserDetails(Long userId); // Para buscar playlists de um usuário específico | ||
} |
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
Oops, something went wrong.