This commit is contained in:
2026-07-27 09:15:28 +02:00
parent d0e4bdd90e
commit 70c0b649e6
6 changed files with 62 additions and 7 deletions
+13
View File
@@ -3,6 +3,19 @@ use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
use uuid::Uuid;
#[derive(Debug, Serialize, Deserialize, ToSchema, utoipa::IntoParams)]
pub struct CategoryQueryParams {
pub server_id: Option<Uuid>,
}
impl Default for CategoryQueryParams {
fn default() -> Self {
Self {
server_id: None,
}
}
}
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct CreateCategoryRequest {
pub server_id: Uuid,
+7 -3
View File
@@ -2,11 +2,11 @@ use crate::core::state::AppState;
use crate::http::context::Superuser;
use crate::http::error::HTTPError;
use crate::routes::category::dto::{
CategoryResponse, CreateCategoryRequest, UpdateCategoryRequest,
CategoryQueryParams, CategoryResponse, CreateCategoryRequest, UpdateCategoryRequest,
};
use crate::routes::category::mapper;
use axum::{
extract::{Path, State},
extract::{Path, Query, State},
http::StatusCode,
Json,
};
@@ -20,12 +20,16 @@ use uuid::Uuid;
(status = 200, description = "Liste des catégories récupérée avec succès", body = [CategoryResponse]),
(status = 500, description = "Erreur interne du serveur")
),
params(
CategoryQueryParams
),
tag = "Categories"
)]
pub async fn get_all(
State(state): State<AppState>,
Query(filters): Query<CategoryQueryParams>,
) -> Result<Json<Vec<CategoryResponse>>, HTTPError> {
let categories = state.repositories.category.get_all().await?;
let categories = state.repositories.category.filter(filters.server_id).await?;
Ok(Json(
categories
.into_iter()
+15
View File
@@ -4,6 +4,21 @@ use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
use uuid::Uuid;
#[derive(Debug, Serialize, Deserialize, ToSchema, utoipa::IntoParams)]
pub struct ChannelQueryParams {
pub server_id: Option<Uuid>,
pub category_id: Option<Uuid>,
}
impl Default for ChannelQueryParams {
fn default() -> Self {
Self {
server_id: None,
category_id: None,
}
}
}
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct CreateChannelRequest {
pub server_id: Option<Uuid>,
+7 -3
View File
@@ -2,12 +2,12 @@ use crate::core::state::AppState;
use crate::http::context::Superuser;
use crate::http::error::HTTPError;
use crate::routes::channel::dto::{
ChannelResponse, ChannelRolePermissionResponse, ChannelUserPermissionResponse,
ChannelQueryParams, ChannelResponse, ChannelRolePermissionResponse, ChannelUserPermissionResponse,
CreateChannelRequest, SetChannelPermissionRequest, UpdateChannelRequest,
};
use crate::routes::channel::mapper;
use axum::{
extract::{Path, State},
extract::{Path, Query, State},
http::StatusCode,
Json,
};
@@ -21,12 +21,16 @@ use uuid::Uuid;
(status = 200, description = "Liste des channels récupérée avec succès", body = [ChannelResponse]),
(status = 500, description = "Erreur interne du serveur")
),
params(
ChannelQueryParams
),
tag = "Channels"
)]
pub async fn get_all(
State(state): State<AppState>,
Query(filters): Query<ChannelQueryParams>,
) -> Result<Json<Vec<ChannelResponse>>, HTTPError> {
let channels = state.repositories.channel.get_all().await?;
let channels = state.repositories.channel.filter(filters.server_id, filters.category_id).await?;
Ok(Json(
channels
.into_iter()