Move dpts-core to dpts and split crates
This commit is contained in:
parent
25e80f74a8
commit
e91fd0f2bf
29 changed files with 97 additions and 141 deletions
40
Cargo.lock
generated
40
Cargo.lock
generated
|
@ -770,34 +770,60 @@ version = "0.15.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dpts"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"dpts-csv",
|
||||||
|
"dpts-entity",
|
||||||
|
"dpts-error",
|
||||||
|
"dpts-migration",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dpts-cli"
|
name = "dpts-cli"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"dpts-core",
|
"dpts",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dpts-core"
|
name = "dpts-csv"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"csv",
|
||||||
|
"dpts-entity",
|
||||||
|
"dpts-error",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dpts-entity"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
|
||||||
"async-graphql",
|
"async-graphql",
|
||||||
"axum",
|
"axum",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
|
||||||
"csv",
|
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"dpts-migration",
|
"dpts-migration",
|
||||||
"log",
|
"log",
|
||||||
"sea-orm",
|
"sea-orm",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 2.0.12",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dpts-error"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"clap",
|
||||||
|
"thiserror 2.0.12",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dpts-migration"
|
name = "dpts-migration"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -812,7 +838,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"dpts-core",
|
"dpts",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
21
Cargo.toml
21
Cargo.toml
|
@ -1,12 +1,29 @@
|
||||||
|
[package]
|
||||||
|
name = "dpts"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
dpts-csv = { workspace = true }
|
||||||
|
dpts-entity = { workspace = true }
|
||||||
|
dpts-error = { workspace = true }
|
||||||
|
dpts-migration = { workspace = true }
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["dpts-*"]
|
members = [".", "dpts-*"]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
dpts-core = {path = "dpts-core"}
|
dpts = { path = "." }
|
||||||
|
dpts-csv = { path = "dpts-csv" }
|
||||||
|
dpts-entity = { path = "dpts-entity" }
|
||||||
|
dpts-error = { path = "dpts-error" }
|
||||||
dpts-migration = {path = "dpts-migration"}
|
dpts-migration = {path = "dpts-migration"}
|
||||||
chrono = {version = "0.4", features = ["serde"]}
|
chrono = {version = "0.4", features = ["serde"]}
|
||||||
clap = "4.5"
|
clap = "4.5"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
|
serde = "1.0.219"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
@ -6,6 +6,6 @@ edition.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dpts-core = {workspace = true}
|
dpts = {workspace = true}
|
||||||
chrono = {workspace = true}
|
chrono = {workspace = true}
|
||||||
clap = {workspace = true, features = ["derive"]}
|
clap = {workspace = true, features = ["derive"]}
|
||||||
|
|
|
@ -4,7 +4,7 @@ mod record;
|
||||||
//use label::LabelArgs;
|
//use label::LabelArgs;
|
||||||
use record::{RecordArgs,RecordAddArgs};
|
use record::{RecordArgs,RecordAddArgs};
|
||||||
|
|
||||||
use dpts_core::error::Error;
|
use dpts::error::Error;
|
||||||
|
|
||||||
use clap::{Args, CommandFactory, Parser, Subcommand};
|
use clap::{Args, CommandFactory, Parser, Subcommand};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use clap::{Args, Subcommand};
|
use clap::{Args, Subcommand};
|
||||||
use dpts_core::error::Error;
|
use dpts::error::Error;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[derive(Args, Clone, Debug)]
|
#[derive(Args, Clone, Debug)]
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
use super::id::*;
|
|
||||||
|
|
||||||
pub struct Achievement<T, U>
|
|
||||||
where T: MayId,
|
|
||||||
U: MayId,
|
|
||||||
{
|
|
||||||
id: T,
|
|
||||||
lavel: U,
|
|
||||||
count: i8,
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct IdNumber(usize);
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct IdString(String);
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct NoId();
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
|
||||||
pub enum IdValue {
|
|
||||||
Number(usize),
|
|
||||||
String(String)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait MayId {
|
|
||||||
fn is_id() -> bool;
|
|
||||||
fn get_value(&self) -> Option<IdValue>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MayId for IdNumber {
|
|
||||||
fn is_id() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
fn get_value(&self) -> Option<IdValue> {
|
|
||||||
Some(IdValue::Number(self.0))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl MayId for IdString {
|
|
||||||
fn is_id() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
fn get_value(&self) -> Option<IdValue> {
|
|
||||||
Some(IdValue::String(self.0.clone()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl MayId for NoId {
|
|
||||||
fn is_id() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
fn get_value(&self) -> Option<IdValue> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
#[test]
|
|
||||||
fn parse_values() {
|
|
||||||
assert_eq!(Some(IdValue::Number(1)), IdNumber(1).get_value());
|
|
||||||
assert_eq!(Some(IdValue::String("Test".to_string())), IdString("Test".to_string()).get_value());
|
|
||||||
assert_eq!(None, NoId().get_value());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Label {
|
|
||||||
pub name: String,
|
|
||||||
pub description: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
mod id;
|
|
||||||
mod label;
|
|
||||||
mod record;
|
|
||||||
mod achievement;
|
|
||||||
|
|
||||||
pub use id::*;
|
|
||||||
pub use label::*;
|
|
||||||
pub use record::*;
|
|
||||||
pub use achievement::*;
|
|
|
@ -1,9 +0,0 @@
|
||||||
use chrono::prelude::*;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct Record {
|
|
||||||
pub comment: String,
|
|
||||||
pub date: DateTime<Utc>,
|
|
||||||
pub achievements: HashMap<String, i8>,
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
pub mod csv;
|
|
||||||
pub mod data;
|
|
||||||
pub mod entity;
|
|
||||||
pub mod error;
|
|
||||||
pub use self::data::Label;
|
|
||||||
pub use self::data::Record;
|
|
||||||
|
|
||||||
pub fn add(left: u64, right: u64) -> u64 {
|
|
||||||
left + right
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn it_works() {
|
|
||||||
let result = add(2, 2);
|
|
||||||
assert_eq!(result, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
13
dpts-csv/Cargo.toml
Normal file
13
dpts-csv/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[package]
|
||||||
|
name = "dpts-csv"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
dpts-entity = { workspace = true }
|
||||||
|
dpts-error = { workspace = true }
|
||||||
|
chrono = { workspace = true }
|
||||||
|
serde = { workspace = true }
|
||||||
|
csv = "1.3.1"
|
|
@ -8,7 +8,7 @@ pub use record::CsvRecord;
|
||||||
pub use table::CsvTable;
|
pub use table::CsvTable;
|
||||||
pub use writer::CsvWriter;
|
pub use writer::CsvWriter;
|
||||||
|
|
||||||
use crate::error::Error;
|
use dpts_error::Error;
|
||||||
|
|
||||||
use chrono::{DateTime, NaiveDateTime};
|
use chrono::{DateTime, NaiveDateTime};
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|
@ -1,7 +1,7 @@
|
||||||
use chrono::{DateTime, NaiveDateTime};
|
use chrono::{DateTime, NaiveDateTime};
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
use dpts_entity::RecordDetailModel;
|
||||||
|
use dpts_error::Error;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||||
pub struct CsvRecord{
|
pub struct CsvRecord{
|
||||||
|
@ -11,9 +11,9 @@ pub struct CsvRecord{
|
||||||
pub count: i32,
|
pub count: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<crate::entity::RecordDetailModel> for CsvRecord{
|
impl TryFrom<RecordDetailModel> for CsvRecord{
|
||||||
type Error = crate::error::Error;
|
type Error = Error;
|
||||||
fn try_from(model: crate::entity::RecordDetailModel) -> Result<Self, Self::Error> {
|
fn try_from(model: RecordDetailModel) -> Result<Self, Self::Error> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::error::Error;
|
use dpts_error::Error;
|
||||||
use super::CsvRecord;
|
use super::CsvRecord;
|
||||||
pub struct CsvTable{
|
pub struct CsvTable{
|
||||||
inner: Vec<CsvRecord>
|
inner: Vec<CsvRecord>
|
|
@ -1,23 +1,19 @@
|
||||||
[package]
|
[package]
|
||||||
name = "dpts-core"
|
name = "dpts-entity"
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
license.workspace = true
|
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dpts-migration = { workspace = true }
|
dpts-migration = { workspace = true }
|
||||||
anyhow = "1.0"
|
|
||||||
async-graphql = {version = "7.0", features = ["chrono"]}
|
async-graphql = {version = "7.0", features = ["chrono"]}
|
||||||
axum = "0.8"
|
axum = "0.8"
|
||||||
chrono = {workspace = true}
|
chrono = {workspace = true}
|
||||||
clap = {workspace = true}
|
|
||||||
dotenv = {workspace = true}
|
dotenv = {workspace = true}
|
||||||
log = "0.4.27"
|
log = "0.4.27"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
thiserror = "2.0"
|
|
||||||
tokio = "1.44.2"
|
tokio = "1.44.2"
|
||||||
csv = "1.3.1"
|
|
||||||
|
|
||||||
[dependencies.sea-orm]
|
[dependencies.sea-orm]
|
||||||
version = "1.1"
|
version = "1.1"
|
|
@ -2,7 +2,7 @@ use std::time::Duration;
|
||||||
use chrono::{offset, FixedOffset, Local, TimeZone};
|
use chrono::{offset, FixedOffset, Local, TimeZone};
|
||||||
use sea_orm::{entity::*, query::*, ConnectOptions, Database};
|
use sea_orm::{entity::*, query::*, ConnectOptions, Database};
|
||||||
use dpts_migration::{Migrator, MigratorTrait};
|
use dpts_migration::{Migrator, MigratorTrait};
|
||||||
use dpts_core::entity::*;
|
use dpts_entity::*;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn main() {
|
async fn main() {
|
11
dpts-error/Cargo.toml
Normal file
11
dpts-error/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "dpts-error"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0.98"
|
||||||
|
thiserror = "2.0.12"
|
||||||
|
clap = { workspace = true }
|
3
dpts-error/src/main.rs
Normal file
3
dpts-error/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
|
@ -6,6 +6,6 @@ edition.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dpts-core = {workspace = true}
|
dpts = {workspace = true}
|
||||||
chrono = {workspace = true}
|
chrono = {workspace = true}
|
||||||
clap = {workspace = true, features = ["derive"]}
|
clap = {workspace = true, features = ["derive"]}
|
||||||
|
|
4
src/lib.rs
Normal file
4
src/lib.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
pub use dpts_csv as csv;
|
||||||
|
pub use dpts_entity as entity;
|
||||||
|
pub use dpts_error as error;
|
||||||
|
pub use dpts_migration as migration;
|
Loading…
Add table
Reference in a new issue