site is changed

This commit is contained in:
병준 박 2022-08-10 01:59:01 +00:00
parent 93332c1628
commit c894033251
10 changed files with 94 additions and 28 deletions

View File

@ -30,7 +30,7 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
tokio-cron-scheduler = { version = "0" } tokio-cron-scheduler = { version = "0" }
uuid = { version = "0", features = ["serde", "v4", "v5"] } uuid = { version = "0", features = ["serde", "v4", "v5"] }
beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.27-snapshot" } beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.28-snapshot" }
beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.10-snapshot" } beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.11-snapshot" }
[build-dependencies] [build-dependencies]

View File

@ -1,11 +1,13 @@
CREATE TABLE IF NOT EXISTS sites ( CREATE TABLE IF NOT EXISTS sites (
id UUID DEFAULT uuid_generate_v4(), id UUID DEFAULT uuid_generate_v4(),
url TEXT NOT NULL, url TEXT NOT NULL,
name TEXT NOT NULL,
path TEXT,
show BOOLEAN NOT NULL DEFAULT TRUE, show BOOLEAN NOT NULL DEFAULT TRUE,
can_use BOOLEAN NOT NULL DEFAULT TRUE, can_use BOOLEAN NOT NULL DEFAULT TRUE,
expires_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000), created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
updated_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000), updated_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000),
deleted_at BIGINT,
PRIMARY KEY (id), PRIMARY KEY (id),
UNIQUE (url) UNIQUE (url)
); );

View File

@ -70,8 +70,8 @@ INSERT INTO role_resource_actions (role_id, resource_action_id) VALUES ('b6a2b66
-- identity.signout -- identity.signout
INSERT INTO role_resource_actions (role_id, resource_action_id) VALUES ('b6a2b662-e21e-44e7-a96c-dacd86f9d6b8', '37b99823-188b-4b30-afb7-815a7e79662b'); INSERT INTO role_resource_actions (role_id, resource_action_id) VALUES ('b6a2b662-e21e-44e7-a96c-dacd86f9d6b8', '37b99823-188b-4b30-afb7-815a7e79662b');
INSERT INTO sites (id, url, show) VALUES ('d7cbae26-53b6-4cb1-85a4-66b956cbe1d4', '*', false); INSERT INTO sites (id, url, name, path, show, expires_at) VALUES ('d7cbae26-53b6-4cb1-85a4-66b956cbe1d4', '*', '전체', '/', false, (extract(epoch from now() + INTERVAL '10 year') * 1000));
INSERT INTO sites (id, url, show) VALUES ('8429a7ab-b9de-400b-a209-28ff46e22bec', '127.0.0.1', true); INSERT INTO sites (id, url, name, path, show, expires_at) VALUES ('8429a7ab-b9de-400b-a209-28ff46e22bec', '127.0.0.1', '개발용', '/', true, (extract(epoch from now() + INTERVAL '3 month') * 1000));
INSERT INTO member_levels (id, name, sort_order, show) VALUES ('c238463f-949d-49eb-92ab-dca7a09371db', 'LEVEL0', 0, false); INSERT INTO member_levels (id, name, sort_order, show) VALUES ('c238463f-949d-49eb-92ab-dca7a09371db', 'LEVEL0', 0, false);

View File

@ -54,11 +54,13 @@ impl Composition {
s.id as s_id, s.id as s_id,
s.url as s_url, s.url as s_url,
s.name as s_name,
s.path as s_path,
s.show as s_show, s.show as s_show,
s.can_use as s_can_use, s.can_use as s_can_use,
s.expires_at as s_expires_at,
s.created_at as s_created_at, s.created_at as s_created_at,
s.updated_at as s_updated_at, s.updated_at as s_updated_at,
s.deleted_at as s_deleted_at,
mc.id as mc_id, mc.id as mc_id,
mc.parent_id as mc_parent_id, mc.parent_id as mc_parent_id,

View File

@ -73,11 +73,13 @@ impl QueryableByName<diesel::pg::Pg> for Member {
site: _Site { site: _Site {
id: row.get("s_id")?, id: row.get("s_id")?,
url: row.get("s_url")?, url: row.get("s_url")?,
name: row.get("s_name")?,
path: row.get("s_path")?,
show: row.get("s_show")?, show: row.get("s_show")?,
can_use: row.get("s_can_use")?, can_use: row.get("s_can_use")?,
expires_at: row.get("s_expires_at")?,
created_at: row.get("s_created_at")?, created_at: row.get("s_created_at")?,
updated_at: row.get("s_updated_at")?, updated_at: row.get("s_updated_at")?,
deleted_at: row.get("s_deleted_at")?,
}, },
member_class: _MemberClass { member_class: _MemberClass {
id: row.get("mc_id")?, id: row.get("mc_id")?,

View File

@ -10,15 +10,19 @@ pub struct Site {
/// ///
pub url: String, pub url: String,
/// ///
pub name: String,
///
pub path: String,
///
pub show: bool, pub show: bool,
/// ///
pub can_use: bool, pub can_use: bool,
/// ///
pub expires_at: i64,
///
pub created_at: i64, pub created_at: i64,
/// ///
pub updated_at: i64, pub updated_at: i64,
///
pub deleted_at: Option<i64>,
} }
/// ///
@ -28,9 +32,15 @@ pub struct NewSite {
/// ///
pub url: String, pub url: String,
/// ///
pub name: String,
///
pub path: String,
///
pub show: bool, pub show: bool,
/// ///
pub can_use: bool, pub can_use: bool,
///
pub expires_at: i64,
} }
/// ///
@ -40,21 +50,31 @@ pub struct ModifySite {
/// ///
pub url: String, pub url: String,
/// ///
pub name: String,
///
pub path: String,
///
pub show: bool, pub show: bool,
/// ///
pub can_use: bool, pub can_use: bool,
///
pub expires_at: i64,
} }
/// ///
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct FindAll { pub struct FindAll {
///
pub url_like: Option<String>,
///
pub name_like: Option<String>,
///
pub path_like: Option<String>,
/// ///
pub show: Option<bool>, pub show: Option<bool>,
/// ///
pub can_use: Option<bool>, pub can_use: Option<bool>,
/// ///
pub url_like: Option<String>,
///
pub pagination: Option<bcr::models::pagination::Pagination>, pub pagination: Option<bcr::models::pagination::Pagination>,
/// ///
pub sorts: Option<Vec<bcr::models::pagination::Sort>>, pub sorts: Option<Vec<bcr::models::pagination::Sort>>,

View File

@ -82,15 +82,21 @@ impl Repository {
) -> Result<i64, Error> { ) -> Result<i64, Error> {
let mut q = sites::table.into_boxed(); let mut q = sites::table.into_boxed();
if let Some(sp) = find_all.url_like {
q = q.filter(sites::dsl::url.like(sp));
}
if let Some(sp) = find_all.name_like {
q = q.filter(sites::dsl::url.like(sp));
}
if let Some(sp) = find_all.path_like {
q = q.filter(sites::dsl::path.like(sp));
}
if let Some(sp) = find_all.show { if let Some(sp) = find_all.show {
q = q.filter(sites::dsl::show.eq(sp)); q = q.filter(sites::dsl::show.eq(sp));
} }
if let Some(sp) = find_all.can_use { if let Some(sp) = find_all.can_use {
q = q.filter(sites::dsl::can_use.eq(sp)); 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));
}
q.count().get_result(conn) q.count().get_result(conn)
} }
@ -103,15 +109,21 @@ impl Repository {
) -> Result<Vec<models::Site>, Error> { ) -> Result<Vec<models::Site>, Error> {
let mut q = sites::table.into_boxed(); let mut q = sites::table.into_boxed();
if let Some(sp) = find_all.url_like {
q = q.filter(sites::dsl::url.like(sp));
}
if let Some(sp) = find_all.name_like {
q = q.filter(sites::dsl::url.like(sp));
}
if let Some(sp) = find_all.path_like {
q = q.filter(sites::dsl::path.like(sp));
}
if let Some(sp) = find_all.show { if let Some(sp) = find_all.show {
q = q.filter(sites::dsl::show.eq(sp)); q = q.filter(sites::dsl::show.eq(sp));
} }
if let Some(sp) = find_all.can_use { if let Some(sp) = find_all.can_use {
q = q.filter(sites::dsl::can_use.eq(sp)); 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));
}
if let Some(p) = find_all.pagination { if let Some(p) = find_all.pagination {
let page = p.page.unwrap_or(1); let page = p.page.unwrap_or(1);
@ -128,30 +140,42 @@ impl Repository {
"url" => { "url" => {
q = q.order_by(sites::url.asc()); q = q.order_by(sites::url.asc());
} }
"name" => {
q = q.order_by(sites::url.asc());
}
"path" => {
q = q.order_by(sites::url.asc());
}
"expires_at" => {
q = q.order_by(sites::expires_at.asc());
}
"created_at" => { "created_at" => {
q = q.order_by(sites::created_at.asc()); q = q.order_by(sites::created_at.asc());
} }
"updated_at" => { "updated_at" => {
q = q.order_by(sites::updated_at.asc()); q = q.order_by(sites::updated_at.asc());
} }
"deleted_at" => {
q = q.order_by(sites::deleted_at.asc());
}
_ => {} _ => {}
}, },
bcr::models::pagination::Sort::DESC(property) => match property.as_str() { bcr::models::pagination::Sort::DESC(property) => match property.as_str() {
"url" => { "url" => {
q = q.order_by(sites::url.desc()); q = q.order_by(sites::url.desc());
} }
"name" => {
q = q.order_by(sites::url.desc());
}
"path" => {
q = q.order_by(sites::url.desc());
}
"expires_at" => {
q = q.order_by(sites::expires_at.desc());
}
"created_at" => { "created_at" => {
q = q.order_by(sites::created_at.desc()); q = q.order_by(sites::created_at.desc());
} }
"updated_at" => { "updated_at" => {
q = q.order_by(sites::updated_at.desc()); q = q.order_by(sites::updated_at.desc());
} }
"deleted_at" => {
q = q.order_by(sites::deleted_at.desc());
}
_ => {} _ => {}
}, },
}; };

View File

@ -9,14 +9,18 @@ table! {
/// ///
url -> Text, url -> Text,
/// ///
name -> Text,
///
path -> Text,
///
show -> Bool, show -> Bool,
/// ///
can_use -> Bool, can_use -> Bool,
/// ///
expires_at -> BigInt,
///
created_at -> BigInt, created_at -> BigInt,
/// ///
updated_at -> BigInt, updated_at -> BigInt,
///
deleted_at -> Nullable<BigInt>,
} }
} }

View File

@ -6,11 +6,13 @@ impl From<&repositories::site::models::Site> for bpr::models::domain::Site {
bpr::models::domain::Site { bpr::models::domain::Site {
id: d.id.to_string(), id: d.id.to_string(),
url: d.url.clone(), url: d.url.clone(),
name: d.name.clone(),
path: d.path.clone(),
show: d.show, show: d.show,
can_use: d.can_use, can_use: d.can_use,
expires_at: d.expires_at as u64,
created_at: d.created_at as u64, created_at: d.created_at as u64,
updated_at: d.updated_at as u64, updated_at: d.updated_at as u64,
deleted_at: d.deleted_at.map(|d| d as u64),
} }
} }
} }

View File

@ -137,9 +137,11 @@ impl Service {
.select_all_count( .select_all_count(
&conn, &conn,
repositories::site::models::FindAll { repositories::site::models::FindAll {
url_like: None,
name_like: None,
path_like: None,
show: None, show: None,
can_use: None, can_use: None,
url_like: None,
pagination: req pagination: req
.pagination .pagination
.as_ref() .as_ref()
@ -166,9 +168,11 @@ impl Service {
.select_all( .select_all(
&conn, &conn,
repositories::site::models::FindAll { repositories::site::models::FindAll {
url_like: None,
name_like: None,
path_like: None,
show: None, show: None,
can_use: None, can_use: None,
url_like: None,
pagination: req pagination: req
.pagination .pagination
.as_ref() .as_ref()
@ -281,8 +285,11 @@ impl Service {
&conn, &conn,
&repositories::site::models::NewSite { &repositories::site::models::NewSite {
url: req.url, url: req.url,
name: req.name,
path: req.path,
show: req.show, show: req.show,
can_use: req.can_use, can_use: req.can_use,
expires_at: req.expires_at as i64,
}, },
) )
.map_err(|e| { .map_err(|e| {
@ -395,8 +402,11 @@ impl Service {
id, id,
&repositories::site::models::ModifySite { &repositories::site::models::ModifySite {
url: req.url, url: req.url,
name: req.name,
path: req.path,
show: req.show, show: req.show,
can_use: req.can_use, can_use: req.can_use,
expires_at: req.expires_at as i64,
}, },
) )
.map_err(|e| { .map_err(|e| {