Merge dpts-csv and dpts-entity into dpts-core
This commit is contained in:
parent
1fb1e853f5
commit
e294adcacd
25 changed files with 145 additions and 94 deletions
109
Cargo.lock
generated
109
Cargo.lock
generated
|
@ -113,6 +113,18 @@ dependencies = [
|
|||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "argon2"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"blake2",
|
||||
"cpufeatures",
|
||||
"password-hash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ascii_utils"
|
||||
version = "0.9.3"
|
||||
|
@ -463,6 +475,15 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "blake2"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe"
|
||||
dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
|
@ -817,8 +838,8 @@ dependencies = [
|
|||
"chrono",
|
||||
"chrono-tz",
|
||||
"clap",
|
||||
"csv",
|
||||
"dotenv",
|
||||
"dpts-entity",
|
||||
"dpts-migration",
|
||||
"iana-time-zone",
|
||||
"log",
|
||||
|
@ -829,32 +850,6 @@ dependencies = [
|
|||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dpts-csv"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"csv",
|
||||
"dpts-entity",
|
||||
"serde",
|
||||
"thiserror 2.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dpts-entity"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-graphql",
|
||||
"axum",
|
||||
"chrono",
|
||||
"dotenv",
|
||||
"dpts-migration",
|
||||
"log",
|
||||
"sea-orm",
|
||||
"serde",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dpts-migration"
|
||||
version = "0.1.0"
|
||||
|
@ -867,10 +862,12 @@ dependencies = [
|
|||
name = "dpts-server"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"argon2",
|
||||
"axum",
|
||||
"chrono",
|
||||
"clap",
|
||||
"dpts-core",
|
||||
"rand 0.9.1",
|
||||
"serde",
|
||||
"thiserror 2.0.12",
|
||||
"tokio",
|
||||
|
@ -1745,7 +1742,7 @@ dependencies = [
|
|||
"num-integer",
|
||||
"num-iter",
|
||||
"num-traits",
|
||||
"rand",
|
||||
"rand 0.8.5",
|
||||
"smallvec",
|
||||
"zeroize",
|
||||
]
|
||||
|
@ -1910,6 +1907,17 @@ dependencies = [
|
|||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "password-hash"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"rand_core 0.6.4",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pem-rfc7468"
|
||||
version = "0.7.0"
|
||||
|
@ -1996,7 +2004,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
|
||||
dependencies = [
|
||||
"phf_shared",
|
||||
"rand",
|
||||
"rand 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2157,8 +2165,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97"
|
||||
dependencies = [
|
||||
"rand_chacha 0.9.0",
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2168,7 +2186,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2180,6 +2208,15 @@ dependencies = [
|
|||
"getrandom 0.2.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||
dependencies = [
|
||||
"getrandom 0.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.11"
|
||||
|
@ -2260,7 +2297,7 @@ dependencies = [
|
|||
"num-traits",
|
||||
"pkcs1",
|
||||
"pkcs8",
|
||||
"rand_core",
|
||||
"rand_core 0.6.4",
|
||||
"signature",
|
||||
"spki",
|
||||
"subtle",
|
||||
|
@ -2630,7 +2667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"rand_core",
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2806,7 +2843,7 @@ dependencies = [
|
|||
"memchr",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"rand",
|
||||
"rand 0.8.5",
|
||||
"rsa",
|
||||
"serde",
|
||||
"sha1",
|
||||
|
@ -2845,7 +2882,7 @@ dependencies = [
|
|||
"md-5",
|
||||
"memchr",
|
||||
"once_cell",
|
||||
"rand",
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
members = ["dpts-*"]
|
||||
|
||||
[workspace.dependencies]
|
||||
async-graphql = { version = "7.0", features = ["chrono"] }
|
||||
dpts-cli.path = "dpts-cli"
|
||||
dpts-client.path = "dpts-client"
|
||||
dpts-core = { path = "dpts-core" }
|
||||
dpts-csv = { path = "dpts-csv" }
|
||||
dpts-entity = { path = "dpts-entity" }
|
||||
dpts-migration = {path = "dpts-migration"}
|
||||
dpts-server.path = "dpts-server"
|
||||
dpts-server = { path = "dpts-server" }
|
||||
chrono = {version = "0.4", features = ["serde"]}
|
||||
chrono-tz = {version = "0.10.3", features = ["serde"]}
|
||||
clap = {version = "4.5", features = ["derive"]}
|
||||
|
|
|
@ -10,13 +10,13 @@ default = ["clap",]
|
|||
clap = ["dep:clap"]
|
||||
|
||||
[dependencies]
|
||||
async-graphql = { version = "7.0", features = ["chrono"] }
|
||||
async-graphql.workspace = true
|
||||
axum = "0.8"
|
||||
chrono = {workspace = true}
|
||||
chrono-tz.workspace = true
|
||||
clap = { workspace = true, optional = true }
|
||||
csv = "1.3.1"
|
||||
dotenv = {workspace = true}
|
||||
dpts-entity = { workspace = true }
|
||||
dpts-migration = { workspace = true }
|
||||
iana-time-zone = "0.1.63"
|
||||
log = "0.4.27"
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use chrono::{DateTime, NaiveDateTime};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use dpts_entity::RecordDetailModel;
|
||||
use crate::error::Error;
|
||||
use crate::{
|
||||
entity::RecordDetailModel,
|
||||
error::Error,
|
||||
};
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
pub struct CsvRecord{
|
|
@ -72,7 +72,7 @@ mod tests {
|
|||
use chrono::{offset, FixedOffset, Local, TimeZone};
|
||||
use sea_orm::{entity::*, query::*, ConnectOptions, Database};
|
||||
use dpts_migration::{Migrator, MigratorTrait};
|
||||
use dpts_entity::*;
|
||||
use crate::entity::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn check_database_connection() {
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use async_graphql::*;
|
||||
use chrono::{DateTime, FixedOffset,};
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize, SimpleObject)]
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "user")]
|
||||
#[graphql(concrete(name = "User", params()))]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
#[serde(skip_deserializing)]
|
||||
|
@ -17,6 +15,22 @@ pub struct Model {
|
|||
pub updated_at: DateTimeWithTimeZone,
|
||||
}
|
||||
|
||||
#[async_graphql::Object]
|
||||
impl Model {
|
||||
pub async fn id(&self) -> i32 {
|
||||
self.id
|
||||
}
|
||||
pub async fn login_name(&self) -> String {
|
||||
self.login_name.clone()
|
||||
}
|
||||
pub async fn created_at(&self) -> DateTimeWithTimeZone {
|
||||
self.created_at.clone()
|
||||
}
|
||||
pub async fn updated_at(&self) -> DateTimeWithTimeZone {
|
||||
self.updated_at.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, DeriveRelation, EnumIter)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::record_header::Entity")]
|
|
@ -1,6 +1,6 @@
|
|||
mod mutation;
|
||||
mod query;
|
||||
|
||||
mod response;
|
||||
|
||||
//pub use query::GraphqlQuery;
|
||||
//pub use response::GraphqlResponse;
|
||||
mod record_detail;
|
||||
mod record_header;
|
||||
mod record_tag;
|
||||
mod user;
|
|
@ -0,0 +1,10 @@
|
|||
use async_graphql::*;
|
||||
use super::user::UserObject;
|
||||
struct Query;
|
||||
|
||||
#[Object]
|
||||
impl Query {
|
||||
async fn user(&self, username: String) -> Result<Option<UserObject>> {
|
||||
todo!()
|
||||
}
|
||||
}
|
0
dpts-core/src/graphql/record_detail.rs
Normal file
0
dpts-core/src/graphql/record_detail.rs
Normal file
0
dpts-core/src/graphql/record_header.rs
Normal file
0
dpts-core/src/graphql/record_header.rs
Normal file
0
dpts-core/src/graphql/record_tag.rs
Normal file
0
dpts-core/src/graphql/record_tag.rs
Normal file
27
dpts-core/src/graphql/user.rs
Normal file
27
dpts-core/src/graphql/user.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
use async_graphql::*;
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
|
||||
|
||||
pub struct UserObject {
|
||||
pub id: i32,
|
||||
pub login_name: Option<String>,
|
||||
pub created_at: Option<DateTime<FixedOffset>>,
|
||||
pub updated_at: Option<DateTime<FixedOffset>>,
|
||||
}
|
||||
|
||||
#[Object]
|
||||
impl UserObject {
|
||||
async fn id(&self) -> i32 {
|
||||
todo!()
|
||||
}
|
||||
async fn login_name(&self) -> Option<String> {
|
||||
todo!()
|
||||
}
|
||||
async fn created_at(&self) -> Option<DateTime<FixedOffset>> {
|
||||
todo!()
|
||||
}
|
||||
async fn updated_at(&self) -> Option<DateTime<FixedOffset>> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
pub mod config;
|
||||
mod database_connection;
|
||||
pub mod csv;
|
||||
pub mod database_connection;
|
||||
pub mod entity;
|
||||
pub mod error;
|
||||
mod graphql;
|
||||
pub mod graphql;
|
||||
|
||||
pub use database_connection::*;
|
||||
pub use error::Error;
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
[package]
|
||||
name = "dpts-csv"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[dependencies]
|
||||
dpts-entity = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
csv = "1.3.1"
|
||||
thiserror.workspace = true
|
|
@ -1,27 +0,0 @@
|
|||
[package]
|
||||
name = "dpts-entity"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[dependencies]
|
||||
dpts-migration = { workspace = true }
|
||||
async-graphql = {version = "7.0", features = ["chrono"]}
|
||||
axum = "0.8"
|
||||
chrono = {workspace = true}
|
||||
dotenv = {workspace = true}
|
||||
log = "0.4.27"
|
||||
serde = { workspace = true }
|
||||
tokio = "1.44.2"
|
||||
|
||||
[dependencies.sea-orm]
|
||||
version = "1.1"
|
||||
features = [
|
||||
"macros",
|
||||
"debug-print",
|
||||
"runtime-tokio-native-tls",
|
||||
"sqlx-sqlite",
|
||||
"with-chrono",
|
||||
]
|
||||
default-features = false
|
Loading…
Add table
Reference in a new issue