Skip to content

Commit 67d26ae

Browse files
committed
snapshot
1 parent a17110c commit 67d26ae

6 files changed

Lines changed: 88 additions & 42 deletions

File tree

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[workspace]
22
resolver = "2"
33
members = ["file_classification_*"]
4-
default-members = ["file_classification_cli"]
54

65
[profile.release]
76
codegen-units = 1

file_classification_webapi/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ diesel = { version = "2.2.12", features = ["r2d2"] }
1313
serde_json = "1.0.142"
1414
once_cell = "1.21.3"
1515
env_logger = "0.11.8"
16+
17+
[[bin]]
18+
name = "file_classification_webapi"
19+
doc = false
Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
use actix_web::{web, App, HttpServer, middleware::Logger};
2-
use file_classification_core::utils::database::establish_connection;
3-
mod handlers;
4-
mod utils;
5-
#[actix_web::main]
6-
async fn main() -> std::io::Result<()> {
7-
env_logger::init();
8-
9-
println!("正在启动文件分类 Web API...");
10-
11-
HttpServer::new(|| {
12-
App::new()
13-
.app_data(web::Data::new(establish_connection()))
14-
.wrap(Logger::default())
15-
.service(handlers::files::api_list_files)
16-
.service(handlers::files::api_list_files_by_conditions)
17-
// .service(handlers::files::api_create_file)
18-
.service(handlers::files::api_update_files_by_conditions)
19-
.service(handlers::files::api_delete_file)
20-
.service(handlers::groups::api_list_groups)
21-
.service(handlers::groups::api_list_groups_by_conditions)
22-
.service(handlers::groups::api_create_group)
23-
.service(handlers::groups::api_update_groups_by_conditions)
24-
.service(handlers::groups::api_delete_group)
25-
.service(handlers::tags::api_list_tags)
26-
.service(handlers::tags::api_list_tags_by_conditions)
27-
.service(handlers::tags::api_create_tag)
28-
.service(handlers::tags::api_update_tags_by_conditions)
29-
.service(handlers::tags::api_delete_tag)
30-
.service(handlers::file_groups::api_list_file_groups_by_conditions)
31-
.service(handlers::file_groups::api_create_file_group)
32-
.service(handlers::file_groups::api_delete_file_group)
33-
.service(handlers::group_tags::api_list_group_tags_by_conditions)
34-
.service(handlers::group_tags::api_create_group_tag)
35-
.service(handlers::group_tags::api_delete_group_tag)
36-
})
37-
.bind("127.0.0.1:8080")?
38-
.run()
39-
.await
40-
}
1+
use actix_web::{web, App, HttpServer, middleware::Logger};
2+
use file_classification_core::utils::database::establish_connection;
3+
mod handlers;
4+
mod utils;
5+
#[actix_web::main]
6+
async fn main() -> std::io::Result<()> {
7+
env_logger::init();
8+
9+
println!("正在启动文件分类 Web API...");
10+
11+
HttpServer::new(|| {
12+
App::new()
13+
.app_data(web::Data::new(establish_connection()))
14+
.wrap(Logger::default())
15+
.service(handlers::files::api_list_files)
16+
.service(handlers::files::api_list_files_by_conditions)
17+
// .service(handlers::files::api_create_file)
18+
.service(handlers::files::api_update_files_by_conditions)
19+
.service(handlers::files::api_delete_file)
20+
.service(handlers::groups::api_list_groups)
21+
.service(handlers::groups::api_list_groups_by_conditions)
22+
.service(handlers::groups::api_create_group)
23+
.service(handlers::groups::api_update_groups_by_conditions)
24+
.service(handlers::groups::api_delete_group)
25+
.service(handlers::tags::api_list_tags)
26+
.service(handlers::tags::api_list_tags_by_conditions)
27+
.service(handlers::tags::api_create_tag)
28+
.service(handlers::tags::api_update_tags_by_conditions)
29+
.service(handlers::tags::api_delete_tag)
30+
.service(handlers::file_groups::api_list_file_groups_by_conditions)
31+
.service(handlers::file_groups::api_create_file_group)
32+
.service(handlers::file_groups::api_delete_file_group)
33+
.service(handlers::group_tags::api_list_group_tags_by_conditions)
34+
.service(handlers::group_tags::api_create_group_tag)
35+
.service(handlers::group_tags::api_delete_group_tag)
36+
})
37+
.bind("127.0.0.1:8080")?
38+
.run()
39+
.await
40+
}

flake.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
rustPlatform
4747
;
4848
};
49+
file_classification_webapi = pkgs.callPackage ./nix/file_classification_webapi.nix {
50+
inherit
51+
version
52+
rev
53+
date
54+
rustPlatform
55+
;
56+
};
4957
default = self.packages.${system}.file_classification_cli;
5058
};
5159

nix/file_classification_cli.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
fileset = lib.fileset.unions [
1717
../Cargo.toml
1818
../Cargo.lock
19-
(lib.fileset.fromSource (lib.sources.sourceByRegex ../. ["^file_classification_.*"]))
19+
# (lib.fileset.fromSource (lib.sources.sourceByRegex ../. ["^file_classification_.*"]))
20+
../file_classification_core
21+
../file_classification_cli
2022
];
2123
};
2224
in

nix/file_classification_webapi.nix

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
rustPlatform,
3+
version ? "git",
4+
rev ? "unknown",
5+
date ? "19700101",
6+
sqlite,
7+
mysql80,
8+
postgresql,
9+
pkg-config,
10+
lib,
11+
...
12+
}: let
13+
manifest = (lib.importTOML ../file_classification_webapi/Cargo.toml).package;
14+
src = lib.fileset.toSource {
15+
root = ../.;
16+
fileset = lib.fileset.unions [
17+
../Cargo.toml
18+
../Cargo.lock
19+
../file_classification_core
20+
../file_classification_webapi
21+
];
22+
};
23+
in
24+
rustPlatform.buildRustPackage rec {
25+
inherit src;
26+
nativeBuildInputs = [sqlite];
27+
buildInputs = [sqlite];
28+
# nativeBuildInputs = [pkg-config sqlite mysql80 postgresql];
29+
# buildInputs = [pkg-config sqlite mysql80 postgresql];
30+
pname = manifest.name;
31+
version = manifest.version;
32+
cargoLock.lockFile = ../Cargo.lock;
33+
}

0 commit comments

Comments
 (0)