File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use rust_db_manager_core::commons::configuration::configuration::Configuration;
44
55use 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
99pub 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 > {
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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;
You can’t perform that action at this time.
0 commit comments