ResOk增加none和some函数

This commit is contained in:
李运家 2024-06-03 10:46:29 +08:00
parent 7c571063a5
commit 789c801fa3
4 changed files with 14 additions and 5 deletions

View File

@ -11,7 +11,7 @@ pub async fn authenticate_google(
service::account::authenticate_google(req).await?;
Ok(ResOK(None))
Ok(ResOK::none())
}
pub async fn authenticate_with_password(

View File

@ -24,6 +24,15 @@ where
}
}
impl <T: Serialize> ResOK<T> {
pub fn none() -> Self {
ResOK(None)
}
pub fn some(data: T) -> Self {
ResOK(Some(data))
}
}
#[derive(Debug)]
pub enum ResErr {
Error(i32, String),

View File

@ -58,5 +58,5 @@ pub async fn authenticate_google(
)
.await;
return Ok(ResOK(Some((token, refresh_token))));
return Ok(ResOK::some((token, refresh_token)));
}

View File

@ -9,10 +9,10 @@ pub async fn get_feedback_list_by_page(page: i64, page_size: i64) -> ResResult<R
let feedback_list = Feedback::search_feedback(page, page_size, db!()).await.ok();
if feedback_list.is_none() {
tracing::error!("反馈信息为空");
return Ok(ResOK(Some(Pageable::<Feedback>::empty())));
return Ok(ResOK::some(Pageable::<Feedback>::empty()));
}
let total = get_feedback_count().await;
Ok(ResOK(Some(Pageable::new(feedback_list.unwrap(), total))))
Ok(ResOK::some(Pageable::new(feedback_list.unwrap(), total)))
}
/// 获取反馈信息总数
@ -41,5 +41,5 @@ pub async fn add_feedback(req: FeedbackAdd) -> ResResult<ResOK<()>> {
}
}
Ok(ResOK(None))
Ok(ResOK::none())
}