试图理解.png
This commit is contained in:
parent
40752741c1
commit
0eaaa544e9
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -442,8 +442,10 @@ checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
|
||||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"wasm-bindgen",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
@ -2595,6 +2597,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
"blake3",
|
||||
"chrono",
|
||||
"colored",
|
||||
"futures",
|
||||
"migration",
|
||||
|
@ -36,3 +36,4 @@ serde = { version = "1.0", features = ["serde_derive"] }
|
||||
toml = "0.8"
|
||||
blake3 = "1.5.4"
|
||||
quick-xml = { version = "0.36.1", features = ["async-tokio"] }
|
||||
chrono = "0.4.38"
|
||||
|
@ -1,8 +1,8 @@
|
||||
use blake3::Hasher;
|
||||
use sea_orm::{
|
||||
ActiveModelTrait, ColumnTrait, ConnectionTrait, DatabaseConnection, EntityTrait,
|
||||
IntoActiveModel, ModelTrait, QueryFilter, QuerySelect, Statement, TransactionTrait,
|
||||
ActiveEnum, ActiveModelTrait, ColumnTrait, ConnectionTrait, DatabaseConnection, EntityTrait, IntoActiveModel, ModelTrait, QueryFilter, QuerySelect, Statement, TransactionTrait
|
||||
};
|
||||
use tracing::{event, Level};
|
||||
// use tracing::{event, Level};
|
||||
|
||||
use crate::model;
|
||||
@ -85,7 +85,7 @@ impl DbData {
|
||||
/// 直接从 full_data 里选即可
|
||||
pub async fn from_db(save_id: SaveId, db: &DatabaseConnection) -> Option<Self> {
|
||||
let sql = format!(
|
||||
"SELECT * FROM {} WHERE save_id = {}",
|
||||
"SELECT save_type::\"varchar\",* FROM {} WHERE save_id = {}",
|
||||
FULL_DATA_VIEW, save_id
|
||||
);
|
||||
let datas = db
|
||||
@ -96,14 +96,14 @@ impl DbData {
|
||||
.await
|
||||
.ok()??;
|
||||
let text = datas.try_get("", "data").ok()?;
|
||||
let save_id: SaveId = datas.try_get("", "save_id").ok()?;
|
||||
let save_type: SaveType = datas.try_get("", "save_type").ok()?;
|
||||
let save_id: i32 = datas.try_get("", "save_id").ok()?;
|
||||
let save_type: String = datas.try_get("", "save_type").ok()?;
|
||||
let len: i64 = datas.try_get("", "len").ok()?;
|
||||
let blake_hash: String = datas.try_get("", "blake_hash").ok()?;
|
||||
Some(Self {
|
||||
text,
|
||||
save_id,
|
||||
save_type,
|
||||
save_id: save_id as SaveId,
|
||||
save_type: SaveType::try_from_value(&save_type).unwrap(),
|
||||
len,
|
||||
blake_hash,
|
||||
})
|
||||
@ -156,6 +156,7 @@ where
|
||||
// 干活之前, 先检查一下数据是否已经存在
|
||||
// 如果已经存在, 那就根据策略来处理
|
||||
let cover_strategy = cover_strategy.unwrap_or_default();
|
||||
let time = chrono::Utc::now();
|
||||
let save_type: SaveType = save_type.into();
|
||||
let exitst_data: Option<model::main_data::Model> = {
|
||||
model::main_data::Entity::find()
|
||||
@ -227,6 +228,7 @@ where
|
||||
len: data_len as i64,
|
||||
short_data: None,
|
||||
xml_tested,
|
||||
time: time.into(),
|
||||
};
|
||||
let long_data = model::long_data::Model {
|
||||
save_id: save_id as i32,
|
||||
@ -246,6 +248,7 @@ where
|
||||
len: data_len as i64,
|
||||
short_data: Some(data),
|
||||
xml_tested,
|
||||
time: time.into(),
|
||||
};
|
||||
new_data.into_active_model().insert(db).await?;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ pub struct Model {
|
||||
pub len: i64,
|
||||
pub short_data: Option<String>,
|
||||
pub xml_tested: Option<bool>,
|
||||
pub time: DateTimeWithTimeZone,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
Loading…
Reference in New Issue
Block a user