Skip to content

Commit 4df9057

Browse files
committed
feat: add update for file group tag
1 parent e398dba commit 4df9057

12 files changed

Lines changed: 1667 additions & 6 deletions

file_classification_cli/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ doc = false
2323
name = "delete_file"
2424
doc = false
2525

26+
[[bin]]
27+
name = "update_files_by_conditions"
28+
doc = false
29+
2630
[[bin]]
2731
name = "list_groups"
2832
doc = false
@@ -39,6 +43,10 @@ doc = false
3943
name = "delete_group"
4044
doc = false
4145

46+
[[bin]]
47+
name = "update_groups_by_conditions"
48+
doc = false
49+
4250
[[bin]]
4351
name = "list_tags"
4452
doc = false
@@ -55,6 +63,10 @@ doc = false
5563
name = "delete_tag"
5664
doc = false
5765

66+
[[bin]]
67+
name = "update_tags_by_conditions"
68+
doc = false
69+
5870
[[bin]]
5971
name = "list_group_tags_by_conditions"
6072
doc = false

file_classification_webapi/Cargo.toml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
[package]
2-
name = "file_classification_webapi"
2+
name = "file_classification_cli"
33
version = "0.2.0"
44
edition = "2024"
55

66
[dependencies]
77
file_classification_core = { path = "../file_classification_core" }
8+
chrono = { workspace = true }
89

910
[[bin]]
1011
name = "list_files"
1112
doc = false
1213

14+
[[bin]]
15+
name = "list_files_by_conditions"
16+
doc = false
17+
1318
[[bin]]
1419
name = "create_file"
1520
doc = false
@@ -18,10 +23,18 @@ doc = false
1823
name = "delete_file"
1924
doc = false
2025

26+
[[bin]]
27+
name = "update_files_by_conditions"
28+
doc = false
29+
2130
[[bin]]
2231
name = "list_groups"
2332
doc = false
2433

34+
[[bin]]
35+
name = "list_groups_by_conditions"
36+
doc = false
37+
2538
[[bin]]
2639
name = "create_group"
2740
doc = false
@@ -30,10 +43,18 @@ doc = false
3043
name = "delete_group"
3144
doc = false
3245

46+
[[bin]]
47+
name = "update_groups_by_conditions"
48+
doc = false
49+
3350
[[bin]]
3451
name = "list_tags"
3552
doc = false
3653

54+
[[bin]]
55+
name = "list_tags_by_conditions"
56+
doc = false
57+
3758
[[bin]]
3859
name = "create_tag"
3960
doc = false
@@ -42,11 +63,30 @@ doc = false
4263
name = "delete_tag"
4364
doc = false
4465

66+
[[bin]]
67+
name = "update_tags_by_conditions"
68+
doc = false
69+
70+
[[bin]]
71+
name = "list_group_tags_by_conditions"
72+
doc = false
73+
4574
[[bin]]
4675
name = "create_group_tag"
4776
doc = false
4877

78+
[[bin]]
79+
name = "delete_group_tag"
80+
doc = false
81+
82+
[[bin]]
83+
name = "list_file_groups_by_conditions"
84+
doc = false
85+
4986
[[bin]]
5087
name = "create_file_group"
5188
doc = false
5289

90+
[[bin]]
91+
name = "delete_file_group"
92+
doc = false
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use file_classification_core::service::file_group::delete_file_group;
2+
use file_classification_core::utils::database::establish_connection;
3+
use std::io::{stdin, stdout, Write};
4+
5+
fn main() {
6+
let connection = &mut establish_connection();
7+
8+
let mut file_id_input = String::new();
9+
let mut group_id_input = String::new();
10+
11+
print!("Please input File ID: ");
12+
stdout().flush().unwrap();
13+
stdin().read_line(&mut file_id_input).unwrap();
14+
let file_id: i32 = file_id_input.trim().parse().expect("Invalid File ID");
15+
16+
print!("Please input Group ID: ");
17+
stdout().flush().unwrap();
18+
stdin().read_line(&mut group_id_input).unwrap();
19+
let group_id: i32 = group_id_input.trim().parse().expect("Invalid Group ID");
20+
21+
let result = delete_file_group(connection, file_id, group_id);
22+
match result {
23+
Ok(deleted_file_group_num) => {
24+
if deleted_file_group_num == 0 {
25+
println!("No FileGroup deleted!");
26+
} else { println!("FileGroup deleted successfully!({:?} line changed)", deleted_file_group_num) }
27+
}
28+
Err(e) => eprintln!("Error deleting FileGroup: {}", e),
29+
}
30+
}
31+
32+
#[allow(dead_code)]
33+
#[cfg(not(windows))]
34+
const EOF: &str = "CTRL+D";
35+
36+
#[allow(dead_code)]
37+
#[cfg(windows)]
38+
const EOF: &str = "CTRL+Z";
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use file_classification_core::service::group_tag::delete_group_tag;
2+
use file_classification_core::utils::database::establish_connection;
3+
use std::io::{stdin, stdout, Write};
4+
5+
fn main() {
6+
let connection = &mut establish_connection();
7+
8+
let mut group_id_input = String::new();
9+
let mut tag_id_input = String::new();
10+
11+
print!("Please input Group ID: ");
12+
stdout().flush().unwrap();
13+
stdin().read_line(&mut group_id_input).unwrap();
14+
let group_id: i32 = group_id_input.trim().parse().expect("Invalid Group ID");
15+
16+
print!("Please input Tag ID: ");
17+
stdout().flush().unwrap();
18+
stdin().read_line(&mut tag_id_input).unwrap();
19+
let tag_id: i32 = tag_id_input.trim().parse().expect("Invalid Tag ID");
20+
21+
let result = delete_group_tag(connection, group_id, tag_id);
22+
match result {
23+
Ok(deleted_group_tag_num) => {
24+
if deleted_group_tag_num == 0 {
25+
println!("No GroupTag deleted!");
26+
} else {
27+
println!("GroupTag deleted successfully!({:?} line changed)", deleted_group_tag_num)
28+
}
29+
}
30+
Err(e) => eprintln!("Error deleting GroupTag: {}", e),
31+
}
32+
}
33+
34+
#[allow(dead_code)]
35+
#[cfg(not(windows))]
36+
const EOF: &str = "CTRL+D";
37+
38+
#[allow(dead_code)]
39+
#[cfg(windows)]
40+
const EOF: &str = "CTRL+Z";

file_classification_webapi/src/bin/list_file_groups_by_conditions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use file_classification_core::model::models::FileGroupCondition;
2+
use file_classification_core::service::file_group::select_file_groups_by_conditions;
23
use file_classification_core::utils::database::establish_connection;
34
use std::io::{self, Write};
4-
use file_classification_core::service::file_group::select_file_groups_by_conditions;
55

66
fn main() {
77
let connection = &mut establish_connection();

file_classification_webapi/src/bin/list_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use file_classification_core::model::models::FileFilter;
12
use file_classification_core::service::files::select_files;
23
use file_classification_core::utils::database::establish_connection;
3-
use file_classification_core::model::models::FileFilter;
44
// 引入select_files和SearchFile
55

66
fn main() {

file_classification_webapi/src/bin/list_group_tags_by_conditions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use file_classification_core::model::models::GroupTagCondition;
2+
use file_classification_core::service::group_tag::select_group_tags_by_conditions;
23
use file_classification_core::utils::database::establish_connection;
34
use std::io::{self, Write};
4-
use file_classification_core::service::group_tag::select_group_tags_by_conditions;
55

66
fn main() {
77
let connection = &mut establish_connection();

file_classification_webapi/src/bin/list_groups.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use file_classification_core::model::models::GroupFilter;
12
use file_classification_core::service::groups::select_groups;
23
use file_classification_core::utils::database::establish_connection;
3-
use file_classification_core::model::models::GroupFilter;
44
// 引入select_groups和SearchGroup
55

66
fn main() {

file_classification_webapi/src/bin/list_tags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use file_classification_core::model::models::TagFilter;
12
use file_classification_core::service::tags::select_tags;
23
use file_classification_core::utils::database::establish_connection;
3-
use file_classification_core::model::models::TagFilter;
44
// 引入select_tags和SearchTag
55

66
fn main() {

0 commit comments

Comments
 (0)