From d0dda6d23cd277f8d2998d6950eeebcd71644dbf Mon Sep 17 00:00:00 2001 From: huangzhe <3451701311@qq.com> Date: Thu, 18 Sep 2025 14:35:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=BA=9B=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/dataSources.xml | 2 +- .idea/serv.iml | 1 + Cargo.toml | 3 +- packages/model/lib/id_card/mod.rs | 3 +- packages/serv/Cargo.toml | 4 ++- .../serv/http/frps/dashboard/dashboard.http | 7 +++++ .../http/frps/dashboard/http-client.env.json | 7 +++++ packages/serv/src/test/id_card.rs | 31 ++++++++++++++++--- 8 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 packages/serv/http/frps/dashboard/dashboard.http create mode 100644 packages/serv/http/frps/dashboard/http-client.env.json diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index 8d9310c..8ac7241 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -5,7 +5,7 @@ postgresql true org.postgresql.Driver - jdbc:postgresql://home.hzer.xyz:5432/postgres + jdbc:postgresql://home.hzer.xyz:65500/postgres $ProjectFileDir$ diff --git a/.idea/serv.iml b/.idea/serv.iml index ac57fb6..f444bbc 100644 --- a/.idea/serv.iml +++ b/.idea/serv.iml @@ -10,6 +10,7 @@ + diff --git a/Cargo.toml b/Cargo.toml index ee7465e..de9c0a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,4 +20,5 @@ env_logger = "0.11.8" futures = "0.3.31" log = "0.4.27" actix-web = "4.11.0" -hutils = { path = "./packages/hutils"} \ No newline at end of file +hutils = { path = "./packages/hutils"} +model = { path = "./packages/model"} diff --git a/packages/model/lib/id_card/mod.rs b/packages/model/lib/id_card/mod.rs index c81e906..bc7bcbe 100644 --- a/packages/model/lib/id_card/mod.rs +++ b/packages/model/lib/id_card/mod.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; #[derive(DeriveEntityModel, Clone, Debug, PartialEq, Serialize, Deserialize)] #[sea_orm(table_name = "id_card")] pub struct Model { - #[sea_orm(primary_key)] + #[sea_orm(primary_key, unique)] pub id: String, pub name: String, pub gender: Gender, @@ -13,6 +13,7 @@ pub struct Model { pub address: Option, pub nation: String, pub create_at: DateTime, + pub update_at: DateTime, } pub type IDCardModel = Model; diff --git a/packages/serv/Cargo.toml b/packages/serv/Cargo.toml index 06f4618..a58b060 100644 --- a/packages/serv/Cargo.toml +++ b/packages/serv/Cargo.toml @@ -9,4 +9,6 @@ gotify-ws.workspace = true log.workspace = true sea-orm.workspace = true regex.workspace = true -actix-web.workspace = true \ No newline at end of file +actix-web.workspace = true +model.workspace = true +hutils.workspace = true \ No newline at end of file diff --git a/packages/serv/http/frps/dashboard/dashboard.http b/packages/serv/http/frps/dashboard/dashboard.http new file mode 100644 index 0000000..92c4ad7 --- /dev/null +++ b/packages/serv/http/frps/dashboard/dashboard.http @@ -0,0 +1,7 @@ +### TCP代理请求 +GET http://home.hzer.xyz:7500/api/proxy/tcp +Authorization: Basic {{token}} + +### UDP代理请求 +GET http://home.hzer.xyz:7500/api/proxy/udp +Authorization: Basic {{token}} \ No newline at end of file diff --git a/packages/serv/http/frps/dashboard/http-client.env.json b/packages/serv/http/frps/dashboard/http-client.env.json new file mode 100644 index 0000000..5ce1d22 --- /dev/null +++ b/packages/serv/http/frps/dashboard/http-client.env.json @@ -0,0 +1,7 @@ +{ + "dev": { + "user": "hz", + "password": "hzer0428", + "token": "aHo6aHplcjA0Mjg=" + } +} \ No newline at end of file diff --git a/packages/serv/src/test/id_card.rs b/packages/serv/src/test/id_card.rs index 65f785f..d0ae651 100644 --- a/packages/serv/src/test/id_card.rs +++ b/packages/serv/src/test/id_card.rs @@ -1,7 +1,11 @@ +use actix_web::rt::Runtime; +use log::info; use regex::Regex; +use sea_orm::{ActiveModelTrait, Database, DatabaseConnection, Set}; use std::env; use std::fs::File; use std::io::{BufRead, BufReader}; +use std::iter::once; use std::path::Path; use std::sync::OnceLock; @@ -11,7 +15,7 @@ fn test_split() { let str = "朱春艳----320681197904304224"; if let Some((name, id)) = split_str(str) { println!("name: {}, id: {}", name, id); - get_id_info(id) + get_id_info(id, name) } } @@ -26,7 +30,7 @@ fn split_str(str: &str) -> Option<(&str, &str)> { value } -fn get_id_info(id: &str) { +fn get_id_info(id: &str, name: &str) { let location = &id[0..6]; println!("location: {}", location); let born = &id[6..14]; @@ -49,18 +53,37 @@ fn test_get_file() { } fn get_id_file() { + use hutils; + use model::id_card; + hutils::logger::init_logger(); + let db: OnceLock = OnceLock::new(); + + let rt = Runtime::new().expect("创建 Runtime 失败"); + + db.get_or_init(|| rt.block_on(async { Database::connect("sqlite://id-card.sqlite?mode=rwc").await.unwrap() })); let _ = env::current_dir().unwrap(); println!("当前的路径 {:#?}", env::current_dir().unwrap()); let path = Path::new("resources/ID/id.txt"); - // let path = Path::new("resources/id.txt"); + // let path = Path::new("resources/id.txt");x` let file = File::open(path).expect("打开文件失败"); let buffer = BufReader::new(file); for line in buffer.lines() { // println!("line {}", line.unwrap()); - if let Some((_, id)) = split_str(line.unwrap().as_str()) { + if let Some((name, id)) = split_str(line.unwrap().as_str()) { // println!("name: {}, id: {}", name, id); + let person = id_card::ActiveModel { + id: Set(id.to_string()), + name: Set(name.to_string()), + gender: Default::default(), + birth: Default::default(), + address: Default::default(), + nation: Default::default(), + create_at: Default::default(), + update_at: Default::default(), + }; + info!("{:#?}", person); if id.len() != 18 { // println!("name: {}, id: {}", name, id); continue;