diff --git a/libs/client-api/src/http_template.rs b/libs/client-api/src/http_template.rs index f9eb8229..05ae6b5e 100644 --- a/libs/client-api/src/http_template.rs +++ b/libs/client-api/src/http_template.rs @@ -18,7 +18,7 @@ fn category_resources_url(base_url: &str) -> String { format!("{}/category", template_api_prefix(base_url)) } -fn category_resource_url(base_url: &str, category_id: &Uuid) -> String { +fn category_resource_url(base_url: &str, category_id: Uuid) -> String { format!("{}/{}", category_resources_url(base_url), category_id) } @@ -26,7 +26,7 @@ fn template_creator_resources_url(base_url: &str) -> String { format!("{}/creator", template_api_prefix(base_url)) } -fn template_creator_resource_url(base_url: &str, creator_id: &Uuid) -> String { +fn template_creator_resource_url(base_url: &str, creator_id: Uuid) -> String { format!( "{}/{}", template_creator_resources_url(base_url), @@ -86,7 +86,7 @@ impl Client { pub async fn get_template_category( &self, - category_id: &Uuid, + category_id: Uuid, ) -> Result { let url = category_resource_url(&self.base_url, category_id); let resp = self @@ -99,7 +99,7 @@ impl Client { .into_data() } - pub async fn delete_template_category(&self, category_id: &Uuid) -> Result<(), AppResponseError> { + pub async fn delete_template_category(&self, category_id: Uuid) -> Result<(), AppResponseError> { let url = category_resource_url(&self.base_url, category_id); let resp = self .http_client_with_auth(Method::DELETE, &url) @@ -112,7 +112,7 @@ impl Client { #[allow(clippy::too_many_arguments)] pub async fn update_template_category( &self, - category_id: &Uuid, + category_id: Uuid, name: &str, icon: &str, bg_color: &str, @@ -183,7 +183,7 @@ impl Client { pub async fn get_template_creator( &self, - creator_id: &Uuid, + creator_id: Uuid, ) -> Result { let url = template_creator_resource_url(&self.base_url, creator_id); let resp = self @@ -196,7 +196,7 @@ impl Client { .into_data() } - pub async fn delete_template_creator(&self, creator_id: &Uuid) -> Result<(), AppResponseError> { + pub async fn delete_template_creator(&self, creator_id: Uuid) -> Result<(), AppResponseError> { let url = template_creator_resource_url(&self.base_url, creator_id); let resp = self .http_client_with_auth(Method::DELETE, &url) @@ -208,7 +208,7 @@ impl Client { pub async fn update_template_creator( &self, - creator_id: &Uuid, + creator_id: Uuid, name: &str, avatar_url: &str, account_links: Vec, diff --git a/libs/database/src/template.rs b/libs/database/src/template.rs index 23f8a2a9..58762875 100644 --- a/libs/database/src/template.rs +++ b/libs/database/src/template.rs @@ -46,7 +46,7 @@ pub async fn insert_new_template_category<'a, E: Executor<'a, Database = Postgre #[allow(clippy::too_many_arguments)] pub async fn update_template_category_by_id<'a, E: Executor<'a, Database = Postgres>>( executor: E, - id: &Uuid, + id: Uuid, name: &str, description: &str, icon: &str, @@ -129,7 +129,7 @@ pub async fn select_template_categories<'a, E: Executor<'a, Database = Postgres> pub async fn select_template_category_by_id<'a, E: Executor<'a, Database = Postgres>>( executor: E, - category_id: &Uuid, + category_id: Uuid, ) -> Result { let category = sqlx::query_as!( TemplateCategory, @@ -154,7 +154,7 @@ pub async fn select_template_category_by_id<'a, E: Executor<'a, Database = Postg pub async fn delete_template_category_by_id<'a, E: Executor<'a, Database = Postgres>>( executor: E, - category_id: &Uuid, + category_id: Uuid, ) -> Result<(), AppError> { let rows_affected = sqlx::query!( r#" @@ -228,7 +228,7 @@ pub async fn insert_template_creator<'a, E: Executor<'a, Database = Postgres>>( pub async fn update_template_creator_by_id<'a, E: Executor<'a, Database = Postgres>>( executor: E, - creator_id: &Uuid, + creator_id: Uuid, name: &str, avatar_url: &str, account_links: &[AccountLink], @@ -282,7 +282,7 @@ pub async fn update_template_creator_by_id<'a, E: Executor<'a, Database = Postgr pub async fn delete_template_creator_account_links<'a, E: Executor<'a, Database = Postgres>>( executor: E, - creator_id: &Uuid, + creator_id: Uuid, ) -> Result<(), AppError> { sqlx::query!( r#" @@ -324,7 +324,7 @@ pub async fn select_template_creators_by_name<'a, E: Executor<'a, Database = Pos pub async fn select_template_creator_by_id<'a, E: Executor<'a, Database = Postgres>>( executor: E, - creator_id: &Uuid, + creator_id: Uuid, ) -> Result { let creator_row = sqlx::query_as!( AFTemplateCreatorRow, @@ -350,7 +350,7 @@ pub async fn select_template_creator_by_id<'a, E: Executor<'a, Database = Postgr pub async fn delete_template_creator_by_id<'a, E: Executor<'a, Database = Postgres>>( executor: E, - creator_id: &Uuid, + creator_id: Uuid, ) -> Result<(), AppError> { let rows_affected = sqlx::query!( r#" diff --git a/src/api/template.rs b/src/api/template.rs index ac056587..11071cf8 100644 --- a/src/api/template.rs +++ b/src/api/template.rs @@ -85,7 +85,7 @@ async fn update_template_category_handler( let category_id = category_id.into_inner(); let updated_template_category = update_template_category( &state.pg_pool, - &category_id, + category_id, &data.name, &data.description, &data.icon, @@ -102,7 +102,7 @@ async fn get_template_category_handler( state: Data, ) -> Result> { let category_id = category_id.into_inner(); - let category = get_template_category(&state.pg_pool, &category_id).await?; + let category = get_template_category(&state.pg_pool, category_id).await?; Ok(Json(AppResponse::Ok().with_data(category))) } @@ -111,7 +111,7 @@ async fn delete_template_category_handler( state: Data, ) -> Result> { let category_id = category_id.into_inner(); - delete_template_category(&state.pg_pool, &category_id).await?; + delete_template_category(&state.pg_pool, category_id).await?; Ok(Json(AppResponse::Ok())) } @@ -147,7 +147,7 @@ async fn update_template_creator_handler( let creator_id = creator_id.into_inner(); let updated_creator = update_template_creator( &state.pg_pool, - &creator_id, + creator_id, &data.name, &data.avatar_url, &data.account_links, @@ -161,7 +161,7 @@ async fn get_template_creator_handler( state: Data, ) -> Result> { let creator_id = creator_id.into_inner(); - let template_creator = get_template_creator(&state.pg_pool, &creator_id).await?; + let template_creator = get_template_creator(&state.pg_pool, creator_id).await?; Ok(Json(AppResponse::Ok().with_data(template_creator))) } @@ -170,6 +170,6 @@ async fn delete_template_creator_handler( state: Data, ) -> Result> { let creator_id = creator_id.into_inner(); - delete_template_creator(&state.pg_pool, &creator_id).await?; + delete_template_creator(&state.pg_pool, creator_id).await?; Ok(Json(AppResponse::Ok())) } diff --git a/src/biz/template/ops.rs b/src/biz/template/ops.rs index 4cca154a..a47d065d 100644 --- a/src/biz/template/ops.rs +++ b/src/biz/template/ops.rs @@ -37,7 +37,7 @@ pub async fn create_new_template_category( #[allow(clippy::too_many_arguments)] pub async fn update_template_category( pg_pool: &PgPool, - category_id: &Uuid, + category_id: Uuid, name: &str, description: &str, icon: &str, @@ -70,7 +70,7 @@ pub async fn get_template_categories( pub async fn get_template_category( pg_pool: &PgPool, - category_id: &Uuid, + category_id: Uuid, ) -> Result { let category = select_template_category_by_id(pg_pool, category_id).await?; Ok(category) @@ -78,7 +78,7 @@ pub async fn get_template_category( pub async fn delete_template_category( pg_pool: &PgPool, - category_id: &Uuid, + category_id: Uuid, ) -> Result<(), AppResponseError> { delete_template_category_by_id(pg_pool, category_id).await?; Ok(()) @@ -97,7 +97,7 @@ pub async fn create_new_template_creator( pub async fn update_template_creator( pg_pool: &PgPool, - creator_id: &Uuid, + creator_id: Uuid, name: &str, avatar_url: &str, account_links: &[AccountLink], @@ -128,7 +128,7 @@ pub async fn get_template_creators( pub async fn get_template_creator( pg_pool: &PgPool, - creator_id: &Uuid, + creator_id: Uuid, ) -> Result { let creator = select_template_creator_by_id(pg_pool, creator_id).await?; Ok(creator) @@ -136,7 +136,7 @@ pub async fn get_template_creator( pub async fn delete_template_creator( pg_pool: &PgPool, - creator_id: &Uuid, + creator_id: Uuid, ) -> Result<(), AppResponseError> { delete_template_creator_by_id(pg_pool, creator_id).await?; Ok(()) diff --git a/tests/workspace/template.rs b/tests/workspace/template.rs index cb423b46..455dfc85 100644 --- a/tests/workspace/template.rs +++ b/tests/workspace/template.rs @@ -78,7 +78,7 @@ async fn test_template_category_crud() { let updated_category_name = Uuid::new_v4().to_string(); let updated_template_category = authorized_client .update_template_category( - &new_template_category.id, + new_template_category.id, updated_category_name.as_str(), "new_icon", "new_bg_color", @@ -100,7 +100,7 @@ async fn test_template_category_crud() { let guest_client = localhost_client(); let template_category = guest_client - .get_template_category(&new_template_category.id) + .get_template_category(new_template_category.id) .await .unwrap(); assert_eq!(template_category.name, updated_category_name); @@ -154,16 +154,16 @@ async fn test_template_category_crud() { .iter() .any(|r| r.name == second_category_name)); let result = guest_client - .delete_template_category(&new_template_category.id) + .delete_template_category(new_template_category.id) .await; assert!(result.is_err()); assert_eq!(result.unwrap_err().code, ErrorCode::NotLoggedIn); authorized_client - .delete_template_category(&new_template_category.id) + .delete_template_category(new_template_category.id) .await .unwrap(); let result = guest_client - .get_template_category(&new_template_category.id) + .get_template_category(new_template_category.id) .await; assert!(result.is_err()); assert_eq!(result.unwrap_err().code, ErrorCode::RecordNotFound); @@ -197,7 +197,7 @@ async fn test_template_creator_crud() { }]; let updated_creator = authorized_client .update_template_creator( - &new_creator.id, + new_creator.id, "new_name", "new_avatar_url", updated_account_links, @@ -211,7 +211,7 @@ async fn test_template_creator_crud() { assert_eq!(updated_creator.account_links[0].url, "twitter_url"); let creator = guest_client - .get_template_creator(&new_creator.id) + .get_template_creator(new_creator.id) .await .unwrap(); assert_eq!(creator.name, "new_name"); @@ -220,14 +220,14 @@ async fn test_template_creator_crud() { assert_eq!(creator.account_links[0].link_type, "twitter"); assert_eq!(creator.account_links[0].url, "twitter_url"); - let result = guest_client.delete_template_creator(&new_creator.id).await; + let result = guest_client.delete_template_creator(new_creator.id).await; assert!(result.is_err()); assert_eq!(result.unwrap_err().code, ErrorCode::NotLoggedIn); authorized_client - .delete_template_creator(&new_creator.id) + .delete_template_creator(new_creator.id) .await .unwrap(); - let result = guest_client.get_template_creator(&new_creator.id).await; + let result = guest_client.get_template_creator(new_creator.id).await; assert!(result.is_err()); assert_eq!(result.unwrap_err().code, ErrorCode::RecordNotFound); }