bug fixed

This commit is contained in:
병준 박 2022-08-08 01:51:31 +00:00
parent 6fe18fc3db
commit 700b65ba2d
4 changed files with 25 additions and 1 deletions

View File

@ -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,

View File

@ -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<bool>,
///
pub can_use: Option<bool>,
///
pub url_like: Option<String>,
///

View File

@ -61,6 +61,12 @@ impl Repository {
) -> Result<i64, 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));
}
@ -76,6 +82,12 @@ impl Repository {
) -> Result<Vec<models::Site>, 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));
}

View File

@ -9,6 +9,10 @@ table! {
///
url -> Text,
///
show -> Bool,
///
can_use -> Bool,
///
created_at -> BigInt,
///
updated_at -> BigInt,