diff --git a/src/db.rs b/src/db.rs index f720416..71137f0 100644 --- a/src/db.rs +++ b/src/db.rs @@ -3,6 +3,8 @@ use serde::Serialize; use std::{fs, path::Path}; use welds::{connections::sqlite::SqliteClient, prelude::*}; +use crate::InsertArgs; + #[derive(WeldsModel, Clone, Serialize)] #[welds(table = "authorize")] pub struct Authorize { @@ -16,15 +18,6 @@ pub struct Authorize { pub insert_time: String, } -pub struct InsertArgs { - pub project: String, - pub token: String, - pub device_id: String, - pub disable: i8, - pub expire: String, - pub insert_time: String, -} - /// 包装类,内部持有 SQLite 连接 pub struct Db { client: SqliteClient, diff --git a/src/main.rs b/src/main.rs index 0ef72fa..dd8b0b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,7 +72,7 @@ async fn create_token( let token: String = state.generator.generate(16); let _token_id = state .db - .insert_authorize(db::InsertArgs { + .insert_authorize(InsertArgs { project: args.project.clone(), token: token.clone(), device_id: args.device_id.clone(), @@ -224,6 +224,15 @@ fn add_day(t: &str, days: i64) -> Result { Ok(new_time.format("%Y-%m-%d %H:%M:%S").to_string()) } +pub struct InsertArgs { + pub project: String, + pub token: String, + pub device_id: String, + pub disable: i8, + pub expire: String, + pub insert_time: String, +} + #[derive(Clone)] struct AppState { db: Arc,