diff --git a/Cargo.toml b/Cargo.toml index 76bafdb..05157bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] } tokio-cron-scheduler = { version = "0" } uuid = { version = "0", features = ["serde", "v4", "v5"] } -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.11-snapshot" } +beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.29-snapshot" } +beteran-common-rust = { git = "https://gitlab.loafle.net/bet/beteran-common-rust.git", tag = "v0.1.12-snapshot" } [build-dependencies] diff --git a/migrations/202206181000_site/up.sql b/migrations/202206181000_site/up.sql index c3b4d75..79c9a62 100644 --- a/migrations/202206181000_site/up.sql +++ b/migrations/202206181000_site/up.sql @@ -1,11 +1,12 @@ CREATE TABLE IF NOT EXISTS sites ( id UUID DEFAULT uuid_generate_v4(), url TEXT NOT NULL, - name TEXT NOT NULL, + name TEXT, path TEXT, show BOOLEAN NOT NULL DEFAULT TRUE, can_use BOOLEAN NOT NULL DEFAULT TRUE, - expires_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000), + memo TEXT, + expires_at BIGINT, created_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000), updated_at BIGINT NOT NULL DEFAULT (extract(epoch from now()) * 1000), PRIMARY KEY (id), diff --git a/migrations/202208011200_initial_data/up.sql b/migrations/202208011200_initial_data/up.sql index dc7ebb2..4c88cd7 100644 --- a/migrations/202208011200_initial_data/up.sql +++ b/migrations/202208011200_initial_data/up.sql @@ -70,8 +70,8 @@ INSERT INTO role_resource_actions (role_id, resource_action_id) VALUES ('b6a2b66 -- 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 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, 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 sites (id, url, name, path, show) VALUES ('d7cbae26-53b6-4cb1-85a4-66b956cbe1d4', '*', '전체', '/', false); +INSERT INTO sites (id, url, name, path, show) VALUES ('8429a7ab-b9de-400b-a209-28ff46e22bec', '127.0.0.1', '개발용', '/', false); INSERT INTO member_levels (id, name, sort_order, show) VALUES ('c238463f-949d-49eb-92ab-dca7a09371db', 'LEVEL0', 0, false); diff --git a/src/compositions/member/composition.rs b/src/compositions/member/composition.rs index 34c41d5..2f40182 100644 --- a/src/compositions/member/composition.rs +++ b/src/compositions/member/composition.rs @@ -58,6 +58,7 @@ impl Composition { s.path as s_path, s.show as s_show, s.can_use as s_can_use, + s.memo as s_memo, s.expires_at as s_expires_at, s.created_at as s_created_at, s.updated_at as s_updated_at, diff --git a/src/compositions/member/models.rs b/src/compositions/member/models.rs index 5a6429b..c67598a 100644 --- a/src/compositions/member/models.rs +++ b/src/compositions/member/models.rs @@ -77,6 +77,7 @@ impl QueryableByName for Member { path: row.get("s_path")?, show: row.get("s_show")?, can_use: row.get("s_can_use")?, + memo: row.get("s_memo")?, expires_at: row.get("s_expires_at")?, created_at: row.get("s_created_at")?, updated_at: row.get("s_updated_at")?, diff --git a/src/repositories/site/models.rs b/src/repositories/site/models.rs index 81ac6c5..b62c3a6 100644 --- a/src/repositories/site/models.rs +++ b/src/repositories/site/models.rs @@ -10,15 +10,17 @@ pub struct Site { /// pub url: String, /// - pub name: String, + pub name: Option, /// - pub path: String, + pub path: Option, /// pub show: bool, /// pub can_use: bool, /// - pub expires_at: i64, + pub memo: Option, + /// + pub expires_at: Option, /// pub created_at: i64, /// @@ -32,15 +34,17 @@ pub struct NewSite { /// pub url: String, /// - pub name: String, + pub name: Option, /// - pub path: String, + pub path: Option, /// pub show: bool, /// pub can_use: bool, /// - pub expires_at: i64, + pub memo: Option, + /// + pub expires_at: Option, } /// @@ -50,15 +54,17 @@ pub struct ModifySite { /// pub url: String, /// - pub name: String, + pub name: Option, /// - pub path: String, + pub path: Option, /// pub show: bool, /// pub can_use: bool, /// - pub expires_at: i64, + pub memo: Option, + /// + pub expires_at: Option, } /// @@ -75,6 +81,8 @@ pub struct FindAll { /// pub can_use: Option, /// + pub memo_like: Option, + /// pub pagination: Option, /// pub sorts: Option>, diff --git a/src/repositories/site/repository.rs b/src/repositories/site/repository.rs index d15ecdf..b5b34df 100644 --- a/src/repositories/site/repository.rs +++ b/src/repositories/site/repository.rs @@ -97,6 +97,9 @@ impl Repository { if let Some(sp) = find_all.can_use { q = q.filter(sites::dsl::can_use.eq(sp)); } + if let Some(sp) = find_all.memo_like { + q = q.filter(sites::dsl::memo.like(sp)); + } q.count().get_result(conn) } @@ -124,6 +127,9 @@ impl Repository { if let Some(sp) = find_all.can_use { q = q.filter(sites::dsl::can_use.eq(sp)); } + if let Some(sp) = find_all.memo_like { + q = q.filter(sites::dsl::memo.like(sp)); + } if let Some(p) = find_all.pagination { let page = p.page.unwrap_or(1); diff --git a/src/repositories/site/schema.rs b/src/repositories/site/schema.rs index 4cb5cd6..63dd69e 100644 --- a/src/repositories/site/schema.rs +++ b/src/repositories/site/schema.rs @@ -9,15 +9,17 @@ table! { /// url -> Text, /// - name -> Text, + name -> Nullable, /// - path -> Text, + path -> Nullable, /// show -> Bool, /// can_use -> Bool, /// - expires_at -> BigInt, + memo -> Nullable, + /// + expires_at -> Nullable, /// created_at -> BigInt, /// diff --git a/src/services/site/models.rs b/src/services/site/models.rs index 594eaa2..b875dec 100644 --- a/src/services/site/models.rs +++ b/src/services/site/models.rs @@ -10,7 +10,8 @@ impl From<&repositories::site::models::Site> for bpr::models::domain::Site { path: d.path.clone(), show: d.show, can_use: d.can_use, - expires_at: d.expires_at as u64, + memo: d.memo.clone(), + expires_at: d.expires_at.map(|d| d as u64), created_at: d.created_at as u64, updated_at: d.updated_at as u64, } diff --git a/src/services/site/service.rs b/src/services/site/service.rs index a72a2f9..87bef94 100644 --- a/src/services/site/service.rs +++ b/src/services/site/service.rs @@ -140,6 +140,7 @@ impl Service { url_like: None, name_like: None, path_like: None, + memo_like: None, show: None, can_use: None, pagination: req @@ -171,6 +172,7 @@ impl Service { url_like: None, name_like: None, path_like: None, + memo_like: None, show: None, can_use: None, pagination: req @@ -289,7 +291,8 @@ impl Service { path: req.path, show: req.show, can_use: req.can_use, - expires_at: req.expires_at as i64, + memo: req.memo, + expires_at: req.expires_at.map(|d| d as i64), }, ) .map_err(|e| { @@ -406,7 +409,8 @@ impl Service { path: req.path, show: req.show, can_use: req.can_use, - expires_at: req.expires_at as i64, + memo: req.memo, + expires_at: req.expires_at.map(|d| d as i64), }, ) .map_err(|e| {