Skip to content

Commit 5dfaf65

Browse files
committed
[FEATURE] find_services end-point updated.
1 parent 4bcc88f commit 5dfaf65

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/infrastructure/controller.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rust_db_manager_core::commons::configuration::configuration::Configuration;
44

55
use crate::{commons::exception::api_exception::ApiException, domain::builder_db_service::BuilderDBService};
66

7-
use super::dto::db_service::dto_db_service::DTODBService;
7+
use super::dto::db_service::{dto_db_service::DTODBService, dto_db_service_lite::DTODBServiceLite};
88

99
pub struct Controller{
1010
}
@@ -18,9 +18,10 @@ impl Controller {
1818
.route("/:service/status", get(Controller::status))
1919
}
2020

21-
async fn services() -> (StatusCode, Json<Vec<String>>) {
21+
async fn services() -> (StatusCode, Json<Vec<DTODBServiceLite>>) {
2222
let services = Configuration::find_services();
23-
(StatusCode::ACCEPTED, Json(services))
23+
let dto = DTODBServiceLite::from_vec(services);
24+
(StatusCode::ACCEPTED, Json(dto))
2425
}
2526

2627
async fn insert_service(Json(dto): Json<DTODBService>) -> Result<(StatusCode, String), impl IntoResponse> {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use rust_db_manager_core::infrastructure::db_service_lite::DBServiceLite;
2+
use serde::{Deserialize, Serialize};
3+
4+
#[derive(Clone, Serialize, Deserialize)]
5+
pub struct DTODBServiceLite {
6+
pub name: String,
7+
pub category: String
8+
}
9+
10+
impl DTODBServiceLite {
11+
12+
pub fn from_vec(collection: Vec<DBServiceLite>) -> Vec<DTODBServiceLite> {
13+
collection.iter().map(|s| DTODBServiceLite{name: s.name(), category: s.category().to_string()}).collect()
14+
}
15+
16+
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod infrastructure {
1212
pub mod db_service {
1313
pub mod dto_db_connection_data;
1414
pub mod dto_db_service;
15+
pub mod dto_db_service_lite;
1516
}
1617
}
1718
pub mod controller;

0 commit comments

Comments
 (0)