use bios_sdk_invoke::clients::SimpleInvokeClient; use tardis::basic::dto::TardisContext; use tardis::tokio; use tardis::web::context_extractor::TardisContextExtractor; use tardis::web::poem_openapi::param::{Path, Query}; use tardis::web::poem_openapi; use tardis::web::web_resp::{TardisApiResult, TardisPage, TardisResp}; #[derive(Clone, Default)] /// 用户触达消息-公共控制台 pub struct Api; pub struct Client {} impl SimpleInvokeClient for Client { const DOMAIN_CODE: &'static str = "test"; fn get_ctx(&self) -> &'_ TardisContext { unimplemented!() } fn get_base_url(&self) -> &str { unimplemented!() } fn get_funs(&self) -> &tardis::TardisFunsInst { todo!() } } #[simple_invoke_client_macro::simple_invoke_client(Client)] #[poem_openapi::OpenApi(prefix_path = "/ct/msg")] impl Api { /// 获取所有用户触达消息数据分页 #[oai(method = "get", path = "/page")] pub async fn get_page( &self, page_number: Query>, page_size: Query>, TardisContextExtractor(ctx): TardisContextExtractor, ) -> TardisApiResult> { TardisResp::ok(TardisPage { page_number: 1, page_size: 10, total_size: 1, records: vec!["hello".to_string()], }) } /// 获取所有用户触达消息数据分页 #[oai(method = "get", path = "/page/:page_number/size/:page_size")] pub async fn get_page_path(&self, page_number: Path, page_size: Path, TardisContextExtractor(ctx): TardisContextExtractor) -> TardisApiResult> { TardisResp::ok(TardisPage { page_number: 1, page_size: 10, total_size: 1, records: vec!["hello".to_string()], }) } } #[tokio::test] async fn test_client_macro() { let client = Client {}; let resp = client.get_page(None, None).await; let resp = client.get_page_path(1, 2).await; }