mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
feat(mandate_kv): add kv support for mandate (#4275)
Co-authored-by: Akshay S <akshay.s@Akshay-Subramanian-D66TQ6D97K.local> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -12,6 +12,7 @@ pub mod customers;
|
||||
pub mod database;
|
||||
pub mod errors;
|
||||
mod lookup;
|
||||
pub mod mandate;
|
||||
pub mod metrics;
|
||||
pub mod mock_db;
|
||||
pub mod payment_method;
|
||||
@ -372,6 +373,15 @@ impl UniqueConstraints for diesel_models::PaymentMethod {
|
||||
}
|
||||
}
|
||||
|
||||
impl UniqueConstraints for diesel_models::Mandate {
|
||||
fn unique_constraints(&self) -> Vec<String> {
|
||||
vec![format!("mand_{}_{}", self.merchant_id, self.mandate_id)]
|
||||
}
|
||||
fn table_name(&self) -> &str {
|
||||
"Mandate"
|
||||
}
|
||||
}
|
||||
|
||||
impl UniqueConstraints for diesel_models::Customer {
|
||||
fn unique_constraints(&self) -> Vec<String> {
|
||||
vec![format!(
|
||||
|
||||
5
crates/storage_impl/src/mandate.rs
Normal file
5
crates/storage_impl/src/mandate.rs
Normal file
@ -0,0 +1,5 @@
|
||||
use diesel_models::Mandate;
|
||||
|
||||
use crate::redis::kv_store::KvStorePartition;
|
||||
|
||||
impl KvStorePartition for Mandate {}
|
||||
@ -40,6 +40,10 @@ pub enum PartitionKey<'a> {
|
||||
merchant_id: &'a str,
|
||||
payout_attempt_id: &'a str,
|
||||
},
|
||||
MerchantIdMandateId {
|
||||
merchant_id: &'a str,
|
||||
mandate_id: &'a str,
|
||||
},
|
||||
}
|
||||
// PartitionKey::MerchantIdPaymentId {merchant_id, payment_id}
|
||||
impl<'a> std::fmt::Display for PartitionKey<'a> {
|
||||
@ -62,6 +66,10 @@ impl<'a> std::fmt::Display for PartitionKey<'a> {
|
||||
merchant_id,
|
||||
payout_attempt_id,
|
||||
} => f.write_str(&format!("mid_{merchant_id}_poa_{payout_attempt_id}")),
|
||||
PartitionKey::MerchantIdMandateId {
|
||||
merchant_id,
|
||||
mandate_id,
|
||||
} => f.write_str(&format!("mid_{merchant_id}_mandate_{mandate_id}")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user