From 966a7a4c983b68708776c03a40f31eea717ed40d Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Mon, 14 Aug 2023 09:36:22 +0800 Subject: [PATCH] refactor: move datamap api to archguard --- counit-server/src/main.rs | 3 +- counit-server/src/model/archguard_model.rs | 9 ++++++ counit-server/src/server/archguard_api.rs | 13 ++++++++- counit-server/src/server/datamap_api.rs | 34 ---------------------- counit-server/src/server/mod.rs | 1 - 5 files changed, 22 insertions(+), 38 deletions(-) delete mode 100644 counit-server/src/server/datamap_api.rs diff --git a/counit-server/src/main.rs b/counit-server/src/main.rs index bfd71a3..7598a7c 100644 --- a/counit-server/src/main.rs +++ b/counit-server/src/main.rs @@ -7,7 +7,7 @@ use tracing::info; use crate::application::Application; use crate::configuration::Configuration; -use crate::server::{archguard_api, datamap_api, embedding_api, translate_api}; +use crate::server::{archguard_api, embedding_api, translate_api}; pub mod server; pub mod model; @@ -28,7 +28,6 @@ async fn main() -> anyhow::Result<()> { .with_state(app.clone()) .route("/", get(root)) .route("/embedding/rest_api", post(embedding_api::rest_api_embedding)) - .route("/embedding/datamap", post(datamap_api::datamap_embedding)) // knowledge init .nest("/translate/domain_language", translate_api::router()) diff --git a/counit-server/src/model/archguard_model.rs b/counit-server/src/model/archguard_model.rs index 89ecffb..4cd6f3c 100644 --- a/counit-server/src/model/archguard_model.rs +++ b/counit-server/src/model/archguard_model.rs @@ -44,3 +44,12 @@ pub struct ContainerDemand { #[serde(default)] pub(crate) call_data: String, } + +#[derive(Serialize, Deserialize)] +pub struct CodeDatabaseRelation { + package_name: String, + class_name: String, + function_name: String, + tables: Vec, + sqls: Vec, +} \ No newline at end of file diff --git a/counit-server/src/server/archguard_api.rs b/counit-server/src/server/archguard_api.rs index a4d5612..5326150 100644 --- a/counit-server/src/server/archguard_api.rs +++ b/counit-server/src/server/archguard_api.rs @@ -5,7 +5,7 @@ use serde::Deserialize; use tokio::runtime::Handle; use crate::application::Application; -use crate::model::CodeDataStruct; +use crate::model::{CodeDatabaseRelation, CodeDataStruct}; use crate::model::ContainerService; pub fn router() -> Router { @@ -14,6 +14,7 @@ pub fn router() -> Router { Router::new() .route("/:systemId/reporting/class-items", post(save_class_items)) .route("/:systemId/reporting/container-services", post(save_container)) + .route("/:systemId/reporting/datamap-relations", post(save_datamap)) } #[derive(Deserialize, Debug)] @@ -25,6 +26,16 @@ pub struct ArchGuardParams { repo_id: String, } +pub async fn save_datamap( + Extension(app): Extension, + Path(systemId): Path, + Query(params): Query, + Json(payload): Json>, +) -> (StatusCode, Json<()>) { + println!("systemId: {:?}", systemId); + + (StatusCode::CREATED, Json(())) +} pub async fn save_class_items( Extension(app): Extension, diff --git a/counit-server/src/server/datamap_api.rs b/counit-server/src/server/datamap_api.rs deleted file mode 100644 index 97ee27f..0000000 --- a/counit-server/src/server/datamap_api.rs +++ /dev/null @@ -1,34 +0,0 @@ -use axum::http::StatusCode; -use axum::Json; -use serde::{Deserialize, Serialize}; - -pub async fn datamap_embedding( - Json(payload): Json, -) -> (StatusCode, Json) { - let api: DatamapEmbedding = DatamapEmbedding { - id: 1 - }; - - (StatusCode::CREATED, Json(api)) -} - -#[derive(Deserialize)] -pub struct DatamapRequest { - system_id: String, - repo_name: String, - repo_url: String, -} - -#[derive(Serialize)] -pub struct DatamapEmbedding { - id: u64, -} - -#[derive(Serialize)] -pub struct CodeDatabaseRelation { - package_name: String, - class_name: String, - function_name: String, - tables: Vec, - sqls: Vec, -} \ No newline at end of file diff --git a/counit-server/src/server/mod.rs b/counit-server/src/server/mod.rs index 67d17f9..71e0aa3 100644 --- a/counit-server/src/server/mod.rs +++ b/counit-server/src/server/mod.rs @@ -1,5 +1,4 @@ pub mod embedding_api; pub mod translate_api; -pub mod datamap_api; pub mod archguard_api;