Add basic employee hour balance report
This commit is contained in:
parent
0eb885216a
commit
d4adcb182f
31 changed files with 2155 additions and 5 deletions
34
rest/src/working_hours.rs
Normal file
34
rest/src/working_hours.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
use axum::{
|
||||
body::Body, extract::State, response::Response, routing::post, Extension, Json, Router,
|
||||
};
|
||||
use rest_types::WorkingHoursTO;
|
||||
|
||||
use service::working_hours::WorkingHoursService;
|
||||
|
||||
use crate::{error_handler, Context, RestStateDef};
|
||||
|
||||
pub fn generate_route<RestState: RestStateDef>() -> Router<RestState> {
|
||||
Router::new().route("/", post(create_working_hours::<RestState>))
|
||||
}
|
||||
|
||||
pub async fn create_working_hours<RestState: RestStateDef>(
|
||||
rest_state: State<RestState>,
|
||||
Extension(context): Extension<Context>,
|
||||
Json(working_hours): Json<WorkingHoursTO>,
|
||||
) -> Response {
|
||||
error_handler(
|
||||
(async {
|
||||
let working_hours = WorkingHoursTO::from(
|
||||
&rest_state
|
||||
.working_hours_service()
|
||||
.create(&(&working_hours).into(), context.into())
|
||||
.await?,
|
||||
);
|
||||
Ok(Response::builder()
|
||||
.status(200)
|
||||
.body(Body::new(serde_json::to_string(&working_hours).unwrap()))
|
||||
.unwrap())
|
||||
})
|
||||
.await,
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue