use std::collections::HashMap;
use crate::domain::models::Chat;
use async_trait::async_trait;
use modkit_db::secure::DBRunner;
use modkit_odata::{ODataQuery, Page};
use modkit_security::AccessScope;
use uuid::Uuid;
use crate::domain::error::DomainError;
#[async_trait]
pub trait ChatRepository: Send + Sync {
async fn get<C: DBRunner>(
&self,
conn: &C,
scope: &AccessScope,
id: Uuid,
) -> Result<Option<Chat>, DomainError>;
async fn list_page<C: DBRunner>(
&self,
conn: &C,
scope: &AccessScope,
query: &ODataQuery,
) -> Result<Page<Chat>, DomainError>;
async fn create<C: DBRunner>(
&self,
conn: &C,
scope: &AccessScope,
chat: Chat,
) -> Result<Chat, DomainError>;
async fn update<C: DBRunner>(
&self,
conn: &C,
scope: &AccessScope,
chat: Chat,
) -> Result<Chat, DomainError>;
async fn soft_delete<C: DBRunner>(
&self,
conn: &C,
scope: &AccessScope,
id: Uuid,
) -> Result<bool, DomainError>;
async fn get_for_update<C: DBRunner>(
&self,
conn: &C,
scope: &AccessScope,
id: Uuid,
) -> Result<Option<Chat>, DomainError>;
async fn count_messages<C: DBRunner>(
&self,
conn: &C,
scope: &AccessScope,
chat_id: Uuid,
) -> Result<i64, DomainError>;
async fn count_messages_batch<C: DBRunner>(
&self,
conn: &C,
scope: &AccessScope,
chat_ids: &[Uuid],
) -> Result<HashMap<Uuid, i64>, DomainError>;
async fn is_deleted_system<C: DBRunner>(
&self,
conn: &C,
chat_id: Uuid,
) -> Result<bool, DomainError>;
}