From 700b65ba2db84dd7b6834b5f4cfea5e483c07093 Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Mon, 8 Aug 2022 01:51:31 +0000 Subject: [PATCH] bug fixed --- migrations/202206181000_site/up.sql | 2 +- src/repositories/site/models.rs | 8 ++++++++ src/repositories/site/repository.rs | 12 ++++++++++++ src/repositories/site/schema.rs | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/migrations/202206181000_site/up.sql b/migrations/202206181000_site/up.sql index 9b2e64b..4ca6ba1 100644 --- a/migrations/202206181000_site/up.sql +++ b/migrations/202206181000_site/up.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS sites ( id UUID DEFAULT uuid_generate_v4(), url TEXT NOT NULL, show BOOLEAN NOT NULL DEFAULT TRUE, - use BOOLEAN NOT NULL DEFAULT TRUE, + can_use BOOLEAN NOT NULL DEFAULT TRUE, created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000), updated_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000), deleted_at BIGINT, diff --git a/src/repositories/site/models.rs b/src/repositories/site/models.rs index d5061df..7603b5a 100644 --- a/src/repositories/site/models.rs +++ b/src/repositories/site/models.rs @@ -10,6 +10,10 @@ pub struct Site { /// pub url: String, /// + pub show: bool, + /// + pub can_use: bool, + /// pub created_at: i64, /// pub updated_at: i64, @@ -20,6 +24,10 @@ pub struct Site { /// #[derive(Debug, Clone)] pub struct FindAll { + /// + pub show: Option, + /// + pub can_use: Option, /// pub url_like: Option, /// diff --git a/src/repositories/site/repository.rs b/src/repositories/site/repository.rs index 7d4c966..ba25644 100644 --- a/src/repositories/site/repository.rs +++ b/src/repositories/site/repository.rs @@ -61,6 +61,12 @@ impl Repository { ) -> Result { let mut q = sites::table.into_boxed(); + if let Some(sp) = find_all.show { + q = q.filter(sites::dsl::show.eq(sp)); + } + if let Some(sp) = find_all.can_use { + q = q.filter(sites::dsl::can_use.eq(sp)); + } if let Some(sp) = find_all.url_like { q = q.filter(sites::dsl::url.like(sp)); } @@ -76,6 +82,12 @@ impl Repository { ) -> Result, Error> { let mut q = sites::table.into_boxed(); + if let Some(sp) = find_all.show { + q = q.filter(sites::dsl::show.eq(sp)); + } + if let Some(sp) = find_all.can_use { + q = q.filter(sites::dsl::can_use.eq(sp)); + } if let Some(sp) = find_all.url_like { q = q.filter(sites::dsl::url.like(sp)); } diff --git a/src/repositories/site/schema.rs b/src/repositories/site/schema.rs index fc9835f..30d44bc 100644 --- a/src/repositories/site/schema.rs +++ b/src/repositories/site/schema.rs @@ -9,6 +9,10 @@ table! { /// url -> Text, /// + show -> Bool, + /// + can_use -> Bool, + /// created_at -> BigInt, /// updated_at -> BigInt,