|
1 | 1 | use file_classification_core::establish_connection; |
2 | | -use file_classification_core::{select_files, models::SearchFile}; // 引入select_files和SearchFile |
| 2 | +use file_classification_core::{models::SearchFile, select_files}; // 引入select_files和SearchFile |
3 | 3 |
|
4 | 4 | fn main() { |
5 | | - let connection = &mut establish_connection(); |
6 | | - |
7 | | - // 定义一个空的 SearchFile 来进行无条件查询 |
8 | | - let search_input = SearchFile { |
9 | | - id: None, |
10 | | - type_: None, |
11 | | - path: None, |
12 | | - reference_count: None, |
13 | | - group_id: None, |
14 | | - }; |
15 | | - |
16 | | - // 使用 select_files 函数进行查询 |
17 | | - let results = select_files(connection, search_input, 5) |
18 | | - .expect("Error loading files"); |
19 | | - |
20 | | - println!("Displaying {} files", results.len()); |
21 | | - for file in results { |
22 | | - let mut output = format!("ID: {}", file.id); |
23 | | - |
24 | | - output.push_str(&format!(", Type: '{}'", file.type_)); |
25 | | - |
26 | | - output.push_str(&format!(", Path: '{}'", file.path)); |
27 | | - |
28 | | - output.push_str(&format!(", ReferenceCount: {}", file.reference_count)); |
29 | | - |
30 | | - output.push_str(&format!(", GroupID: {}", file.group_id)); |
31 | | - |
32 | | - println!("{}", output); |
33 | | - } |
| 5 | + let connection = &mut establish_connection(); |
| 6 | + |
| 7 | + // 定义一个空的 SearchFile 来进行无条件查询 |
| 8 | + let search_input = |
| 9 | + SearchFile { id: None, type_: None, path: None, reference_count: None, group_id: None }; |
| 10 | + |
| 11 | + // 使用 select_files 函数进行查询 |
| 12 | + let results = select_files(connection, search_input, 5).expect("Error loading files"); |
| 13 | + |
| 14 | + println!("Displaying {} files", results.len()); |
| 15 | + for file in results { |
| 16 | + let mut output = format!("ID: {}", file.id); |
| 17 | + |
| 18 | + output.push_str(&format!(", Type: '{}'", file.type_)); |
| 19 | + |
| 20 | + output.push_str(&format!(", Path: '{}'", file.path)); |
| 21 | + |
| 22 | + output.push_str(&format!(", ReferenceCount: {}", file.reference_count)); |
| 23 | + |
| 24 | + output.push_str(&format!(", GroupID: {}", file.group_id)); |
| 25 | + |
| 26 | + println!("{}", output); |
| 27 | + } |
34 | 28 | } |
0 commit comments