From 0143d4d51c50cf22fef8ba19319b70151c2aa16f Mon Sep 17 00:00:00 2001 From: Javier Parada Date: Sun, 15 Dec 2024 10:53:42 +0100 Subject: [PATCH] add find one breach query --- .../application/find_one/find_breach_query.rs | 32 +++++++++++++++++++ .../src/breaches/application/find_one/mod.rs | 1 + 2 files changed, 33 insertions(+) create mode 100644 libs/cti/src/breaches/application/find_one/find_breach_query.rs diff --git a/libs/cti/src/breaches/application/find_one/find_breach_query.rs b/libs/cti/src/breaches/application/find_one/find_breach_query.rs new file mode 100644 index 0000000..0e412f0 --- /dev/null +++ b/libs/cti/src/breaches/application/find_one/find_breach_query.rs @@ -0,0 +1,32 @@ +use std::any::Any; + +use cqrs::domain::query::Query; + +pub struct FindBreachQuery { + pub cve_id: Option, + pub vendor: Option, + pub product: Option, + pub version: Option, +} + +impl FindBreachQuery { + pub const QUERY_TYPE: &'static str = "FindBreachQuery"; + + pub fn new(cve_id: Option, vendor: Option, product: Option, version: Option) -> FindBreachQuery { + FindBreachQuery { cve_id, vendor, product, version } + } + + pub fn new_boxed(cve_id: Option, vendor: Option, product: Option, version: Option) -> Box { + Box::new(FindBreachQuery::new(cve_id, vendor, product, version)) + } +} + +impl Query for FindBreachQuery { + fn get_type(&self) -> String { + FindBreachQuery::QUERY_TYPE.to_string() + } + + fn as_any(&self) -> &dyn Any { + self + } +} diff --git a/libs/cti/src/breaches/application/find_one/mod.rs b/libs/cti/src/breaches/application/find_one/mod.rs index e69de29..4c889b5 100644 --- a/libs/cti/src/breaches/application/find_one/mod.rs +++ b/libs/cti/src/breaches/application/find_one/mod.rs @@ -0,0 +1 @@ +pub mod find_breach_query; \ No newline at end of file