refactor(customer): refactor customer db with storage utils and move trait to domain_models and impl to storage_model (#7538)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Jagan
2025-04-15 12:53:33 +05:30
committed by GitHub
parent 92f6821316
commit e8e0b5df0e
8 changed files with 1114 additions and 1580 deletions

View File

@ -179,6 +179,37 @@ impl<T: DatabaseStore> RouterStore<T> {
.change_context(StorageError::DecryptionError)
}
pub async fn find_optional_resource<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
execute_query_fut: R,
) -> error_stack::Result<Option<D>, StorageError>
where
D: Debug + Sync + Conversion,
R: futures::Future<
Output = error_stack::Result<Option<M>, diesel_models::errors::DatabaseError>,
> + Send,
M: ReverseConversion<D>,
{
match execute_query_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})? {
Some(resource) => Ok(Some(
resource
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)?,
)),
None => Ok(None),
}
}
pub async fn find_resources<D, R, M>(
&self,
state: &KeyManagerState,