tsk-245: Modify result when getting songs but no songs are present
This commit is contained in:
@@ -251,10 +251,15 @@ pub mod endpoint {
|
|||||||
|
|
||||||
match repo::song::get_all_songs(&pool).await {
|
match repo::song::get_all_songs(&pool).await {
|
||||||
Ok(songs) => {
|
Ok(songs) => {
|
||||||
|
if songs.is_empty() {
|
||||||
|
response.message = String::from("No songs available");
|
||||||
|
(axum::http::StatusCode::NO_CONTENT, axum::Json(response))
|
||||||
|
} else {
|
||||||
response.message = String::from(super::super::response::SUCCESSFUL);
|
response.message = String::from(super::super::response::SUCCESSFUL);
|
||||||
response.data = songs;
|
response.data = songs;
|
||||||
(axum::http::StatusCode::OK, axum::Json(response))
|
(axum::http::StatusCode::OK, axum::Json(response))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
response.message = err.to_string();
|
response.message = err.to_string();
|
||||||
(axum::http::StatusCode::NOT_FOUND, axum::Json(response))
|
(axum::http::StatusCode::NOT_FOUND, axum::Json(response))
|
||||||
|
|||||||
Reference in New Issue
Block a user