Skip to content

Commit

Permalink
refactor: move datamap api to archguard
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Aug 14, 2023
1 parent 2b9a613 commit 966a7a4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 38 deletions.
3 changes: 1 addition & 2 deletions counit-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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())
Expand Down
9 changes: 9 additions & 0 deletions counit-server/src/model/archguard_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
sqls: Vec<String>,
}
13 changes: 12 additions & 1 deletion counit-server/src/server/archguard_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)]
Expand All @@ -25,6 +26,16 @@ pub struct ArchGuardParams {
repo_id: String,
}

pub async fn save_datamap(
Extension(app): Extension<Application>,

Check warning on line 30 in counit-server/src/server/archguard_api.rs

View workflow job for this annotation

GitHub Actions / Rust project

unused variable: `app`
Path(systemId): Path<u32>,
Query(params): Query<ArchGuardParams>,

Check warning on line 32 in counit-server/src/server/archguard_api.rs

View workflow job for this annotation

GitHub Actions / Rust project

unused variable: `params`
Json(payload): Json<Vec<CodeDatabaseRelation>>,

Check warning on line 33 in counit-server/src/server/archguard_api.rs

View workflow job for this annotation

GitHub Actions / Rust project

unused variable: `payload`
) -> (StatusCode, Json<()>) {
println!("systemId: {:?}", systemId);

(StatusCode::CREATED, Json(()))
}

pub async fn save_class_items(
Extension(app): Extension<Application>,

Check warning on line 41 in counit-server/src/server/archguard_api.rs

View workflow job for this annotation

GitHub Actions / Rust project

unused variable: `app`
Expand Down
34 changes: 0 additions & 34 deletions counit-server/src/server/datamap_api.rs

This file was deleted.

1 change: 0 additions & 1 deletion counit-server/src/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod embedding_api;
pub mod translate_api;
pub mod datamap_api;
pub mod archguard_api;

0 comments on commit 966a7a4

Please sign in to comment.