This commit is contained in:
2026-07-27 10:38:22 +02:00
parent 7b33b76b3d
commit ed4cb2a39c
11 changed files with 316 additions and 179 deletions
+3 -5
View File
@@ -1,4 +1,5 @@
use crate::models::{channel, channel_role_permission, channel_user_permission};
use crate::repositories::types::ChannelFilter;
use crate::repositories::{AnyResult, RepositoryContext};
use sea_orm::sea_query::OnConflict;
use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set};
@@ -21,14 +22,11 @@ impl ChannelRepository {
Ok(channel::Entity::find().all(&self.context.db).await?)
}
pub async fn filter(&self, server_id: Option<Uuid>, category_id: Option<Uuid>) -> AnyResult<Vec<channel::Model>> {
pub async fn filter(&self, filter: ChannelFilter) -> AnyResult<Vec<channel::Model>> {
let mut query = channel::Entity::find();
if let Some(s_id) = server_id {
if let Some(s_id) = filter.server_id {
query = query.filter(channel::Column::ServerId.eq(s_id));
}
if let Some(c_id) = category_id {
query = query.filter(channel::Column::CategoryId.eq(c_id));
}
Ok(query.all(&self.context.db).await?)
}