Added nice security page.
This commit is contained in:
1 parent
18e7b0df1c
commit
509794f02d
12 files changed
+103
-25
No files matched your search
@@ -1,7 +1,9 @@
|
||||
use crate::db::external_id::SecurityId;
|
||||
use crate::db::securities::{list_securities, Security};
|
||||
use crate::db::securities::{Security};
|
||||
use rusqlite::Connection;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::db::{accounts, securities};
|
||||
use crate::util::CustomResult;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SecurityDTO {
|
||||
@@ -31,11 +33,20 @@ impl SecurityService<'_> {
|
||||
SecurityService { conn }
|
||||
}
|
||||
|
||||
pub fn list_securities(self) -> Vec<SecurityDTO> {
|
||||
list_securities(self.conn)
|
||||
pub fn list_securities(&self) -> Vec<SecurityDTO> {
|
||||
securities::list_securities(self.conn)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(SecurityDTO::from_entity)
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn get_security_by_id(&self, sec_id: &SecurityId) -> CustomResult<Option<SecurityDTO>> {
|
||||
let ret = securities::get_security_by_id(self.conn, sec_id)?;
|
||||
Ok(ret.map(|sec|SecurityDTO::from_entity(&sec)))
|
||||
}
|
||||
|
||||
pub fn get_security_market_cap(&self, sec_id: &SecurityId)-> CustomResult<i64> {
|
||||
accounts::get_security_market_cap(self.conn, sec_id)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user