Added a bunch of things
This commit is contained in:
1 parent
c365289914
commit
ce92916942
15 files changed
+131
-55
No files matched your search
@@ -1,6 +1,26 @@
|
||||
use crate::db::external_id::SecurityId;
|
||||
use crate::db::securities::{list_securities, Security};
|
||||
use rusqlite::Connection;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub struct SecurityDTO {}
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct SecurityDTO {
|
||||
id: SecurityId,
|
||||
symbol: String,
|
||||
name: String,
|
||||
security_type: String,
|
||||
}
|
||||
|
||||
impl SecurityDTO {
|
||||
fn from_entity(sec: &Security) -> SecurityDTO {
|
||||
SecurityDTO {
|
||||
id: sec.id(),
|
||||
symbol: sec.symbol(),
|
||||
name: sec.name().to_string(),
|
||||
security_type: sec.security_type().to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SecurityService<'a> {
|
||||
conn: &'a Connection,
|
||||
@@ -12,6 +32,10 @@ impl SecurityService<'_> {
|
||||
}
|
||||
|
||||
pub fn list_securities(self) -> Vec<SecurityDTO> {
|
||||
vec![]
|
||||
list_securities(self.conn)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(SecurityDTO::from_entity)
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user