Merge pull request 'j3/fix/refactor/routes' (#179) from j3/fix/refactor/routes into dev
Reviewed-on: https://10.4.0.131/gitea/DI1-P4-E1/Webzine/pulls/179 Reviewed-by: j.vetu <josephine.vetu@diiage.org>
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
{
|
{
|
||||||
<tr class="align-middle">
|
<tr class="align-middle">
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="Details" asp-controller="Titre" asp-route-id="@commentaire.Titre.IdTitre">
|
<a asp-controller="Titre" asp-action="Index" asp-route-id="@commentaire.Titre.IdTitre">
|
||||||
@commentaire.Titre.Libelle
|
@commentaire.Titre.Libelle
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -95,7 +95,7 @@
|
|||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<a asp-area=""
|
<a asp-area=""
|
||||||
asp-controller="Titre"
|
asp-controller="Titre"
|
||||||
asp-action="Details"
|
asp-action="Index"
|
||||||
asp-route-id="@Model.IdMusiqueLaPlusJouee">
|
asp-route-id="@Model.IdMusiqueLaPlusJouee">
|
||||||
<div class="ratio ratio-4x3">
|
<div class="ratio ratio-4x3">
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="nom">Le nom de l'artiste à rechercher, formaté en kebab-case (ex: "fatal-bazooka").</param>
|
/// <param name="nom">Le nom de l'artiste à rechercher, formaté en kebab-case (ex: "fatal-bazooka").</param>
|
||||||
/// <returns>La vue de l'artiste avec son ViewModel, ou une redirection vers l'accueil si le nom est vide, ou une erreur 404 si l'artiste n'est pas trouvé.</returns>
|
/// <returns>La vue de l'artiste avec son ViewModel, ou une redirection vers l'accueil si le nom est vide, ou une erreur 404 si l'artiste n'est pas trouvé.</returns>
|
||||||
[HttpGet("/artiste/{nom}")]
|
|
||||||
public IActionResult Index(string nom)
|
public IActionResult Index(string nom)
|
||||||
{
|
{
|
||||||
this.logger.LogInformation("Tentative d'accès à l'artiste avec le nom : {NomArtiste}", nom);
|
this.logger.LogInformation("Tentative d'accès à l'artiste avec le nom : {NomArtiste}", nom);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// Affichage de la page Recherche depuis le header de l'app.
|
/// Affichage de la page Recherche depuis le header de l'app.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mot">Nom d'artiste ou de titre.</param>
|
/// <param name="mot">Nom d'artiste ou de titre.</param>
|
||||||
/// <returns>Page de recherche avec les résultats.</returns>
|
/// <returns>Page de recherche avec les r<EFBFBD>sultats.</returns>
|
||||||
public IActionResult Index(string mot)
|
public IActionResult Index(string mot)
|
||||||
{
|
{
|
||||||
// Logger la recherche.
|
// Logger la recherche.
|
||||||
@@ -41,7 +41,7 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
// Recherche des artistes.
|
// Recherche des artistes.
|
||||||
var artistes = this.artisteRepository.Search(mot);
|
var artistes = this.artisteRepository.Search(mot);
|
||||||
|
|
||||||
// Paramètres a retourner à la vue.
|
// Param<EFBFBD>tres a retourner <EFBFBD> la vue.
|
||||||
var vm = new RechercheIndexViewModel
|
var vm = new RechercheIndexViewModel
|
||||||
{
|
{
|
||||||
Mot = mot,
|
Mot = mot,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// affichage des details, filtrage par style,
|
/// affichage des details, filtrage par style,
|
||||||
/// ajout de likes, commentaires et recherche.
|
/// ajout de likes, commentaires et recherche.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("titre")]
|
|
||||||
public class TitreController : Controller
|
public class TitreController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger<TitreController> logger;
|
private readonly ILogger<TitreController> logger;
|
||||||
@@ -40,8 +39,8 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Identifiant du titre.</param>
|
/// <param name="id">Identifiant du titre.</param>
|
||||||
/// <returns>Vue des details ou 404 si introuvable.</returns>
|
/// <returns>Vue des details ou 404 si introuvable.</returns>
|
||||||
[HttpGet("{id}")]
|
|
||||||
public IActionResult Details(int id)
|
public IActionResult Index(int id)
|
||||||
{
|
{
|
||||||
this.logger.LogInformation("Demande d'affichage du detail pour le titre ID {Id}.", id);
|
this.logger.LogInformation("Demande d'affichage du detail pour le titre ID {Id}.", id);
|
||||||
|
|
||||||
@@ -82,7 +81,6 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="style">Nom du style musical.</param>
|
/// <param name="style">Nom du style musical.</param>
|
||||||
/// <returns>Vue contenant la liste filtree.</returns>
|
/// <returns>Vue contenant la liste filtree.</returns>
|
||||||
[HttpGet("style/{style}")]
|
|
||||||
public IActionResult Style(string style)
|
public IActionResult Style(string style)
|
||||||
{
|
{
|
||||||
this.logger.LogInformation("Recherche des titres pour le style : {Style}.", style);
|
this.logger.LogInformation("Recherche des titres pour le style : {Style}.", style);
|
||||||
@@ -103,7 +101,7 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model">Modele contenant l'identifiant du titre.</param>
|
/// <param name="model">Modele contenant l'identifiant du titre.</param>
|
||||||
/// <returns>Redirection vers la page detail.</returns>
|
/// <returns>Redirection vers la page detail.</returns>
|
||||||
[HttpPost("like")]
|
[HttpPost]
|
||||||
public IActionResult Like(TitreLike model)
|
public IActionResult Like(TitreLike model)
|
||||||
{
|
{
|
||||||
this.logger.LogInformation("Ajout d'un like pour le titre ID {Id}.", model.IdTitre);
|
this.logger.LogInformation("Ajout d'un like pour le titre ID {Id}.", model.IdTitre);
|
||||||
@@ -126,7 +124,7 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model">Donnees du commentaire.</param>
|
/// <param name="model">Donnees du commentaire.</param>
|
||||||
/// <returns>Redirection vers la page detail.</returns>
|
/// <returns>Redirection vers la page detail.</returns>
|
||||||
[HttpPost("comment")]
|
[HttpPost]
|
||||||
public IActionResult Comment(TitreComment model)
|
public IActionResult Comment(TitreComment model)
|
||||||
{
|
{
|
||||||
if (!this.ModelState.IsValid)
|
if (!this.ModelState.IsValid)
|
||||||
|
|||||||
@@ -7,6 +7,41 @@ public static class RouteConfiguration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void MapCustomRoutes(this IEndpointRouteBuilder endpoints)
|
public static void MapCustomRoutes(this IEndpointRouteBuilder endpoints)
|
||||||
{
|
{
|
||||||
|
// ----------- TITRE -----------
|
||||||
|
endpoints.MapControllerRoute(
|
||||||
|
name: "TitreStyle",
|
||||||
|
pattern: "titres/style/{style}",
|
||||||
|
defaults: new { controller = "Titre", action = "Style" });
|
||||||
|
|
||||||
|
endpoints.MapControllerRoute(
|
||||||
|
name: "TitreIndex",
|
||||||
|
pattern: "titre/{id}",
|
||||||
|
defaults: new { controller = "Titre", action = "Index" });
|
||||||
|
|
||||||
|
endpoints.MapControllerRoute(
|
||||||
|
name: "ArtisteIndex",
|
||||||
|
pattern: "artiste/{nom}",
|
||||||
|
defaults: new { controller = "Artiste", action = "Index" });
|
||||||
|
|
||||||
|
|
||||||
|
// ----------- ADMIN -----------
|
||||||
|
|
||||||
|
var adminRoutes = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "artistes", "Artiste" }, { "commentaires", "Commentaire" }, { "styles", "Style" }, { "titres", "Titre" },
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var route in adminRoutes)
|
||||||
|
{
|
||||||
|
endpoints.MapControllerRoute(
|
||||||
|
name: $"Admin{route.Value}Index",
|
||||||
|
pattern: $"administration/{route.Key}",
|
||||||
|
defaults: new { area = "Administration", controller = route.Value, action = "Index" });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// --- AUTRE PROUTES ---
|
||||||
|
|
||||||
endpoints.MapControllerRoute(
|
endpoints.MapControllerRoute(
|
||||||
name: "areas",
|
name: "areas",
|
||||||
pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
|
pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
@titre.Artiste.Nom
|
@titre.Artiste.Nom
|
||||||
</a>
|
</a>
|
||||||
-
|
-
|
||||||
<a asp-action="Details"
|
<a asp-action="Index"
|
||||||
asp-controller="Titre"
|
asp-controller="Titre"
|
||||||
asp-route-id="@titre.IdTitre">
|
asp-route-id="@titre.IdTitre">
|
||||||
@titre.Libelle
|
@titre.Libelle
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
<!-- Footer -->
|
<!-- Footer -->
|
||||||
<div class="d-flex flex-wrap align-items-center gap-3">
|
<div class="d-flex flex-wrap align-items-center gap-3">
|
||||||
<a asp-action="Details"
|
<a asp-action="Index"
|
||||||
asp-controller="Titre"
|
asp-controller="Titre"
|
||||||
asp-route-id="@titre.IdTitre"
|
asp-route-id="@titre.IdTitre"
|
||||||
class="btn btn-primary btn-sm">
|
class="btn btn-primary btn-sm">
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
<img class="card-img-top" src="@titre.UrlJaquette" alt="@titre.Album" loading="lazy" />
|
<img class="card-img-top" src="@titre.UrlJaquette" alt="@titre.Album" loading="lazy" />
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<a asp-controller="Titre" asp-action="Details" asp-route-id="@titre.IdTitre" class="card-link">
|
<a asp-controller="Titre" asp-action="Index" asp-route-id="@titre.IdTitre" class="card-link">
|
||||||
@titre.Libelle
|
@titre.Libelle
|
||||||
</a>
|
</a>
|
||||||
<br />
|
<br />
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ else
|
|||||||
<td class="text-secondary font-monospace">@dureeFormatee</td>
|
<td class="text-secondary font-monospace">@dureeFormatee</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-controller="Titre"
|
<a asp-controller="Titre"
|
||||||
asp-action="Details"
|
asp-action="Index"
|
||||||
asp-route-id="@titre.IdTitre"
|
asp-route-id="@titre.IdTitre"
|
||||||
class="text-primary">
|
class="text-primary">
|
||||||
@titre.Libelle
|
@titre.Libelle
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
@if (!Model.Artistes.Any())
|
@if (!Model.Artistes.Any())
|
||||||
{
|
{
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
<p>Aucun artiste n'a été trouvé.</p>
|
<p>Aucun artiste n'a été trouvé.</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
@if (!Model.Titres.Any())
|
@if (!Model.Titres.Any())
|
||||||
{
|
{
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
<p>Aucun titre n'a été trouvé.</p>
|
<p>Aucun titre n'a été trouvé.</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
{
|
{
|
||||||
<div class="d-flex align-items-start my-3">
|
<div class="d-flex align-items-start my-3">
|
||||||
<a asp-controller="Titre"
|
<a asp-controller="Titre"
|
||||||
asp-action="Details"
|
asp-action="Index"
|
||||||
asp-route-id="@titre.IdTitre"
|
asp-route-id="@titre.IdTitre"
|
||||||
class="me-3 text-black">
|
class="me-3 text-black">
|
||||||
<img src="@titre.UrlJaquette" alt="@titre.Libelle" width="70" height="70" class="object-fit-cover" loading="lazy" />
|
<img src="@titre.UrlJaquette" alt="@titre.Libelle" width="70" height="70" class="object-fit-cover" loading="lazy" />
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
</a>
|
</a>
|
||||||
-
|
-
|
||||||
<a asp-controller="Titre"
|
<a asp-controller="Titre"
|
||||||
asp-action="Details"
|
asp-action="Index"
|
||||||
asp-route-id="@titre.IdTitre">
|
asp-route-id="@titre.IdTitre">
|
||||||
@titre.Libelle
|
@titre.Libelle
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ info "── Titre – Par style ───────────────
|
|||||||
STYLES=("Rock" "Pop" "Rap" "Jazz" "Metal" "Electronic" "Hip-Hop" "Soul" "Funk")
|
STYLES=("Rock" "Pop" "Rap" "Jazz" "Metal" "Electronic" "Hip-Hop" "Soul" "Funk")
|
||||||
for STYLE in "${STYLES[@]}"; do
|
for STYLE in "${STYLES[@]}"; do
|
||||||
ENCODE=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$STYLE'))" 2>/dev/null || echo "$STYLE")
|
ENCODE=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$STYLE'))" 2>/dev/null || echo "$STYLE")
|
||||||
verifier_endpoint GET "$BASE_URL/titre/style/$ENCODE" "GET /titre/style/$STYLE"
|
verifier_endpoint GET "$BASE_URL/titres/style/$ENCODE" "GET /titres/style/$STYLE"
|
||||||
done
|
done
|
||||||
|
|
||||||
log ""
|
log ""
|
||||||
@@ -160,26 +160,26 @@ verifier_endpoint GET "$BASE_URL/Administration/Dashboard" "GET /A
|
|||||||
|
|
||||||
log ""
|
log ""
|
||||||
info "── Administration – Artiste ──────────────────────────────"
|
info "── Administration – Artiste ──────────────────────────────"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste" "GET /Administration/Artiste (liste)"
|
verifier_endpoint GET "$BASE_URL/Administration/Artistes" "GET /Administration/Artistes (liste)"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Create" "GET /Administration/Artiste/Create"
|
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Create" "GET /Administration/Artiste/Create"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Edit/1" "GET /Administration/Artiste/Edit/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Edit/1" "GET /Administration/Artiste/Edit/1"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Delete/1" "GET /Administration/Artiste/Delete/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Delete/1" "GET /Administration/Artiste/Delete/1"
|
||||||
|
|
||||||
log ""
|
log ""
|
||||||
info "── Administration – Commentaire ──────────────────────────"
|
info "── Administration – Commentaire ──────────────────────────"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Commentaire" "GET /Administration/Commentaire (liste)"
|
verifier_endpoint GET "$BASE_URL/Administration/Commentaires" "GET /Administration/Commentaires (liste)"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Commentaire/Delete/1" "GET /Administration/Commentaire/Delete/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Commentaire/Delete/1" "GET /Administration/Commentaire/Delete/1"
|
||||||
|
|
||||||
log ""
|
log ""
|
||||||
info "── Administration – Style ────────────────────────────────"
|
info "── Administration – Style ────────────────────────────────"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Style" "GET /Administration/Style (liste)"
|
verifier_endpoint GET "$BASE_URL/Administration/Styles" "GET /Administration/Styles (liste)"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Style/Create" "GET /Administration/Style/Create"
|
verifier_endpoint GET "$BASE_URL/Administration/Style/Create" "GET /Administration/Style/Create"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Style/Edit/1" "GET /Administration/Style/Edit/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Style/Edit/1" "GET /Administration/Style/Edit/1"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Style/Delete/1" "GET /Administration/Style/Delete/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Style/Delete/1" "GET /Administration/Style/Delete/1"
|
||||||
|
|
||||||
log ""
|
log ""
|
||||||
info "── Administration – Titre ────────────────────────────────"
|
info "── Administration – Titre ────────────────────────────────"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Titre" "GET /Administration/Titre (liste)"
|
verifier_endpoint GET "$BASE_URL/Administration/Titres" "GET /Administration/Titres (liste)"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Titre/Create" "GET /Administration/Titre/Create"
|
verifier_endpoint GET "$BASE_URL/Administration/Titre/Create" "GET /Administration/Titre/Create"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Titre/Edit/1" "GET /Administration/Titre/Edit/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Titre/Edit/1" "GET /Administration/Titre/Edit/1"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Titre/Delete/1" "GET /Administration/Titre/Delete/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Titre/Delete/1" "GET /Administration/Titre/Delete/1"
|
||||||
|
|||||||
Reference in New Issue
Block a user