fix: share query param struct for api client and server
This commit is contained in:
parent
62f32e8757
commit
ea8ca36b5b
|
|
@ -1,7 +1,7 @@
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use client_api_entity::{
|
use client_api_entity::{
|
||||||
CreateGlobalCommentParams, CreateReactionParams, DeleteGlobalCommentParams, DeleteReactionParams,
|
CreateGlobalCommentParams, CreateReactionParams, DeleteGlobalCommentParams, DeleteReactionParams,
|
||||||
GlobalComments, PublishInfo, Reactions, UpdatePublishNamespace,
|
GetReactionQueryParams, GlobalComments, PublishInfo, Reactions, UpdatePublishNamespace,
|
||||||
};
|
};
|
||||||
use reqwest::Method;
|
use reqwest::Method;
|
||||||
use shared_entity::response::{AppResponse, AppResponseError};
|
use shared_entity::response::{AppResponse, AppResponseError};
|
||||||
|
|
@ -259,12 +259,14 @@ impl Client {
|
||||||
"{}/api/workspace/published-info/{}/reaction",
|
"{}/api/workspace/published-info/{}/reaction",
|
||||||
self.base_url, view_id
|
self.base_url, view_id
|
||||||
);
|
);
|
||||||
let url = if let Some(comment_id) = comment_id {
|
let resp = self
|
||||||
format!("{}?comment_id={}", url, comment_id)
|
.cloud_client
|
||||||
} else {
|
.get(url)
|
||||||
url
|
.query(&GetReactionQueryParams {
|
||||||
};
|
comment_id: *comment_id,
|
||||||
let resp = self.cloud_client.get(&url).send().await?;
|
})
|
||||||
|
.send()
|
||||||
|
.await?;
|
||||||
AppResponse::<Reactions>::from_response(resp)
|
AppResponse::<Reactions>::from_response(resp)
|
||||||
.await?
|
.await?
|
||||||
.into_data()
|
.into_data()
|
||||||
|
|
|
||||||
|
|
@ -890,6 +890,11 @@ pub struct Reaction {
|
||||||
pub comment_id: Uuid,
|
pub comment_id: Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct GetReactionQueryParams {
|
||||||
|
pub comment_id: Option<Uuid>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct CreateReactionParams {
|
pub struct CreateReactionParams {
|
||||||
pub reaction_type: String,
|
pub reaction_type: String,
|
||||||
|
|
|
||||||
|
|
@ -1263,7 +1263,7 @@ pub async fn select_reactions_for_published_view<'a, E: Executor<'a, Database =
|
||||||
})
|
})
|
||||||
.or_default();
|
.or_default();
|
||||||
users.push(AFWebUser {
|
users.push(AFWebUser {
|
||||||
uid: row.user_uuid.clone(),
|
uid: row.user_uuid,
|
||||||
name: row.user_name.clone(),
|
name: row.user_name.clone(),
|
||||||
avatar_url: None,
|
avatar_url: None,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ use collab::entity::EncodedCollab;
|
||||||
use collab_entity::CollabType;
|
use collab_entity::CollabType;
|
||||||
use futures_util::future::try_join_all;
|
use futures_util::future::try_join_all;
|
||||||
use prost::Message as ProstMessage;
|
use prost::Message as ProstMessage;
|
||||||
use serde::Deserialize;
|
|
||||||
use sqlx::types::uuid;
|
use sqlx::types::uuid;
|
||||||
use tokio::time::Instant;
|
use tokio::time::Instant;
|
||||||
use tokio_stream::StreamExt;
|
use tokio_stream::StreamExt;
|
||||||
|
|
@ -1135,14 +1134,9 @@ async fn delete_published_collab_comment_handler(
|
||||||
Ok(Json(AppResponse::Ok()))
|
Ok(Json(AppResponse::Ok()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
struct GetReactionQuery {
|
|
||||||
comment_id: Option<Uuid>,
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_published_collab_reaction_handler(
|
async fn get_published_collab_reaction_handler(
|
||||||
view_id: web::Path<Uuid>,
|
view_id: web::Path<Uuid>,
|
||||||
query: web::Query<GetReactionQuery>,
|
query: web::Query<GetReactionQueryParams>,
|
||||||
state: Data<AppState>,
|
state: Data<AppState>,
|
||||||
) -> Result<JsonAppResponse<Reactions>> {
|
) -> Result<JsonAppResponse<Reactions>> {
|
||||||
let view_id = view_id.into_inner();
|
let view_id = view_id.into_inner();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue