增加一些字段

This commit is contained in:
2025-09-18 14:35:31 +08:00
parent 3f538cdc0b
commit d0dda6d23c
8 changed files with 50 additions and 8 deletions

View File

@@ -9,4 +9,6 @@ gotify-ws.workspace = true
log.workspace = true
sea-orm.workspace = true
regex.workspace = true
actix-web.workspace = true
actix-web.workspace = true
model.workspace = true
hutils.workspace = true

View File

@@ -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}}

View File

@@ -0,0 +1,7 @@
{
"dev": {
"user": "hz",
"password": "hzer0428",
"token": "aHo6aHplcjA0Mjg="
}
}

View File

@@ -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<DatabaseConnection> = 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;