ResOk增加none和some函数
This commit is contained in:
parent
7c571063a5
commit
789c801fa3
@ -11,7 +11,7 @@ pub async fn authenticate_google(
|
|||||||
|
|
||||||
service::account::authenticate_google(req).await?;
|
service::account::authenticate_google(req).await?;
|
||||||
|
|
||||||
Ok(ResOK(None))
|
Ok(ResOK::none())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn authenticate_with_password(
|
pub async fn authenticate_with_password(
|
||||||
|
@ -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)]
|
#[derive(Debug)]
|
||||||
pub enum ResErr {
|
pub enum ResErr {
|
||||||
Error(i32, String),
|
Error(i32, String),
|
||||||
|
@ -58,5 +58,5 @@ pub async fn authenticate_google(
|
|||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
return Ok(ResOK(Some((token, refresh_token))));
|
return Ok(ResOK::some((token, refresh_token)));
|
||||||
}
|
}
|
||||||
|
@ -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();
|
let feedback_list = Feedback::search_feedback(page, page_size, db!()).await.ok();
|
||||||
if feedback_list.is_none() {
|
if feedback_list.is_none() {
|
||||||
tracing::error!("反馈信息为空");
|
tracing::error!("反馈信息为空");
|
||||||
return Ok(ResOK(Some(Pageable::<Feedback>::empty())));
|
return Ok(ResOK::some(Pageable::<Feedback>::empty()));
|
||||||
}
|
}
|
||||||
let total = get_feedback_count().await;
|
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())
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user