renamed
This commit is contained in:
parent
f2d52a39f5
commit
6fe18fc3db
4
migrations/202206181000_site/down.sql
Normal file
4
migrations/202206181000_site/down.sql
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
DROP UNIQUE INDEX uidx_sites_url;
|
||||||
|
DROP TRIGGER tg_sites_updated_at;
|
||||||
|
DROP TABLE sites;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
CREATE TABLE IF NOT EXISTS member_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,
|
||||||
show BOOLEAN NOT NULL DEFAULT TRUE,
|
show BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
@ -10,11 +10,11 @@ CREATE TABLE IF NOT EXISTS member_sites (
|
||||||
UNIQUE (url)
|
UNIQUE (url)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE UNIQUE INDEX uidx_member_sites_url ON member_sites (url);
|
CREATE UNIQUE INDEX uidx_sites_url ON sites (url);
|
||||||
|
|
||||||
-- trigger (updated_at)
|
-- trigger (updated_at)
|
||||||
CREATE TRIGGER tg_member_sites_updated_at
|
CREATE TRIGGER tg_sites_updated_at
|
||||||
BEFORE UPDATE
|
BEFORE UPDATE
|
||||||
ON member_sites
|
ON sites
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
EXECUTE PROCEDURE update_updated_at_column();
|
EXECUTE PROCEDURE update_updated_at_column();
|
|
@ -1,4 +0,0 @@
|
||||||
DROP UNIQUE INDEX uidx_member_sites_url;
|
|
||||||
DROP TRIGGER tg_member_sites_updated_at;
|
|
||||||
DROP TABLE member_sites;
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ CREATE TYPE member_state AS ENUM ('normal', 'pending', 'withdrawal', 'dormancy',
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS members (
|
CREATE TABLE IF NOT EXISTS members (
|
||||||
id UUID DEFAULT uuid_generate_v4(),
|
id UUID DEFAULT uuid_generate_v4(),
|
||||||
member_site_id UUID NOT NULL,
|
site_id UUID NOT NULL,
|
||||||
member_class_id UUID NOT NULL,
|
member_class_id UUID NOT NULL,
|
||||||
member_level_id UUID NOT NULL,
|
member_level_id UUID NOT NULL,
|
||||||
username TEXT NOT NULL,
|
username TEXT NOT NULL,
|
||||||
|
@ -21,9 +21,9 @@ CREATE TABLE IF NOT EXISTS members (
|
||||||
deleted_at BIGINT,
|
deleted_at BIGINT,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
UNIQUE (username),
|
UNIQUE (username),
|
||||||
CONSTRAINT fk_members_member_site_id
|
CONSTRAINT fk_members_site_id
|
||||||
FOREIGN KEY(member_site_id)
|
FOREIGN KEY(site_id)
|
||||||
REFERENCES member_sites(id),
|
REFERENCES sites(id),
|
||||||
CONSTRAINT fk_members_member_class_id
|
CONSTRAINT fk_members_member_class_id
|
||||||
FOREIGN KEY(member_class_id)
|
FOREIGN KEY(member_class_id)
|
||||||
REFERENCES member_classes(id),
|
REFERENCES member_classes(id),
|
||||||
|
|
|
@ -70,9 +70,9 @@ 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, show) VALUES ('8429a7ab-b9de-400b-a209-28ff46e22bec', '127.0.0.1', true);
|
||||||
|
|
||||||
INSERT INTO member_sites (id, url, show) VALUES ('d7cbae26-53b6-4cb1-85a4-66b956cbe1d4', '*', false);
|
|
||||||
INSERT INTO member_sites (id, url, show) VALUES ('8429a7ab-b9de-400b-a209-28ff46e22bec', '127.0.0.1', true);
|
|
||||||
|
|
||||||
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);
|
||||||
INSERT INTO member_levels (id, name, sort_order, show) VALUES ('c56231ac-2120-4a81-a30a-5d41fafb6c57', 'LEVEL1', 1, true);
|
INSERT INTO member_levels (id, name, sort_order, show) VALUES ('c56231ac-2120-4a81-a30a-5d41fafb6c57', 'LEVEL1', 1, true);
|
||||||
|
@ -92,7 +92,7 @@ INSERT INTO member_classes (id, name, parent_id, show) VALUES ('4598f07a-86d1-42
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -104,7 +104,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -116,7 +116,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -128,7 +128,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -140,7 +140,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -152,7 +152,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -164,7 +164,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -176,7 +176,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -188,7 +188,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -205,7 +205,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -217,7 +217,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -229,7 +229,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -241,7 +241,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -257,7 +257,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -269,7 +269,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -281,7 +281,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -293,7 +293,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -310,7 +310,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -322,7 +322,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -334,7 +334,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -346,7 +346,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -363,7 +363,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -375,7 +375,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -387,7 +387,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
@ -399,7 +399,7 @@ INSERT INTO members(
|
||||||
|
|
||||||
INSERT INTO members(
|
INSERT INTO members(
|
||||||
id,
|
id,
|
||||||
member_site_id, member_class_id, member_level_id,
|
site_id, member_class_id, member_level_id,
|
||||||
username, password, nickname, mobile_phone_number,
|
username, password, nickname, mobile_phone_number,
|
||||||
state
|
state
|
||||||
) VALUES (
|
) VALUES (
|
||||||
|
|
|
@ -8,7 +8,7 @@ pub struct Member {
|
||||||
///
|
///
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
///
|
///
|
||||||
pub member_site_id: uuid::Uuid,
|
pub site_id: uuid::Uuid,
|
||||||
///
|
///
|
||||||
pub member_class_id: uuid::Uuid,
|
pub member_class_id: uuid::Uuid,
|
||||||
///
|
///
|
||||||
|
@ -46,7 +46,7 @@ pub struct Member {
|
||||||
#[table_name = "members"]
|
#[table_name = "members"]
|
||||||
pub struct NewMember {
|
pub struct NewMember {
|
||||||
///
|
///
|
||||||
pub member_site_id: uuid::Uuid,
|
pub site_id: uuid::Uuid,
|
||||||
///
|
///
|
||||||
pub member_class_id: uuid::Uuid,
|
pub member_class_id: uuid::Uuid,
|
||||||
///
|
///
|
||||||
|
@ -68,7 +68,7 @@ pub struct NewMember {
|
||||||
#[table_name = "members"]
|
#[table_name = "members"]
|
||||||
pub struct ModifyMember {
|
pub struct ModifyMember {
|
||||||
///
|
///
|
||||||
pub member_site_id: Option<uuid::Uuid>,
|
pub site_id: Option<uuid::Uuid>,
|
||||||
///
|
///
|
||||||
pub member_level_id: Option<uuid::Uuid>,
|
pub member_level_id: Option<uuid::Uuid>,
|
||||||
///
|
///
|
||||||
|
@ -99,7 +99,7 @@ pub struct ModifyMember4DeletedAt {
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FindAll {
|
pub struct FindAll {
|
||||||
///
|
///
|
||||||
pub member_site_id: Option<uuid::Uuid>,
|
pub site_id: Option<uuid::Uuid>,
|
||||||
///
|
///
|
||||||
pub member_class_id: Option<uuid::Uuid>,
|
pub member_class_id: Option<uuid::Uuid>,
|
||||||
///
|
///
|
||||||
|
|
|
@ -105,8 +105,8 @@ impl Repository {
|
||||||
|
|
||||||
let mut q = members::table.into_boxed();
|
let mut q = members::table.into_boxed();
|
||||||
|
|
||||||
if let Some(sp) = find_all.member_site_id {
|
if let Some(sp) = find_all.site_id {
|
||||||
q = q.filter(dsl::member_site_id.eq(sp));
|
q = q.filter(dsl::site_id.eq(sp));
|
||||||
}
|
}
|
||||||
if let Some(sp) = find_all.member_class_id {
|
if let Some(sp) = find_all.member_class_id {
|
||||||
q = q.filter(dsl::member_class_id.eq(sp));
|
q = q.filter(dsl::member_class_id.eq(sp));
|
||||||
|
@ -148,8 +148,8 @@ impl Repository {
|
||||||
|
|
||||||
let mut q = members::table.into_boxed();
|
let mut q = members::table.into_boxed();
|
||||||
|
|
||||||
if let Some(sp) = find_all.member_site_id {
|
if let Some(sp) = find_all.site_id {
|
||||||
q = q.filter(dsl::member_site_id.eq(sp));
|
q = q.filter(dsl::site_id.eq(sp));
|
||||||
}
|
}
|
||||||
if let Some(sp) = find_all.member_class_id {
|
if let Some(sp) = find_all.member_class_id {
|
||||||
q = q.filter(dsl::member_class_id.eq(sp));
|
q = q.filter(dsl::member_class_id.eq(sp));
|
||||||
|
|
|
@ -21,7 +21,7 @@ table! {
|
||||||
///
|
///
|
||||||
id -> Uuid,
|
id -> Uuid,
|
||||||
///
|
///
|
||||||
member_site_id -> Uuid,
|
site_id -> Uuid,
|
||||||
///
|
///
|
||||||
member_class_id -> Uuid,
|
member_class_id -> Uuid,
|
||||||
///
|
///
|
||||||
|
|
|
@ -4,8 +4,8 @@ pub mod member_level;
|
||||||
pub mod member_permission;
|
pub mod member_permission;
|
||||||
pub mod member_role;
|
pub mod member_role;
|
||||||
pub mod member_session;
|
pub mod member_session;
|
||||||
pub mod member_site;
|
|
||||||
pub mod resource;
|
pub mod resource;
|
||||||
pub mod resource_action;
|
pub mod resource_action;
|
||||||
pub mod role;
|
pub mod role;
|
||||||
pub mod role_resource_action;
|
pub mod role_resource_action;
|
||||||
|
pub mod site;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use super::schema::member_sites;
|
use super::schema::sites;
|
||||||
use beteran_common_rust as bcr;
|
use beteran_common_rust as bcr;
|
||||||
|
|
||||||
///
|
///
|
||||||
#[derive(Eq, Hash, Identifiable, Queryable, PartialEq, Debug, Clone)]
|
#[derive(Eq, Hash, Identifiable, Queryable, PartialEq, Debug, Clone)]
|
||||||
#[table_name = "member_sites"]
|
#[table_name = "sites"]
|
||||||
pub struct MemberSite {
|
pub struct Site {
|
||||||
///
|
///
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
///
|
///
|
|
@ -1,6 +1,6 @@
|
||||||
//!
|
//!
|
||||||
//!
|
//!
|
||||||
use super::{models, schema::member_sites};
|
use super::{models, schema::sites};
|
||||||
use beteran_common_rust as bcr;
|
use beteran_common_rust as bcr;
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
use diesel::result::Error;
|
use diesel::result::Error;
|
||||||
|
@ -10,7 +10,7 @@ pub struct Repository {}
|
||||||
|
|
||||||
impl std::fmt::Debug for Repository {
|
impl std::fmt::Debug for Repository {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
f.debug_struct("Repository of member_sites").finish()
|
f.debug_struct("Repository of sites").finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,14 +27,10 @@ impl Repository {
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
pub fn select(
|
pub fn select(&self, conn: &diesel::PgConnection, id: uuid::Uuid) -> Result<models::Site, Error> {
|
||||||
&self,
|
sites::table
|
||||||
conn: &diesel::PgConnection,
|
|
||||||
id: uuid::Uuid,
|
|
||||||
) -> Result<models::MemberSite, Error> {
|
|
||||||
member_sites::table
|
|
||||||
.find(id as uuid::Uuid)
|
.find(id as uuid::Uuid)
|
||||||
.first::<models::MemberSite>(conn)
|
.first::<models::Site>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -42,12 +38,12 @@ impl Repository {
|
||||||
&self,
|
&self,
|
||||||
conn: &diesel::PgConnection,
|
conn: &diesel::PgConnection,
|
||||||
url: &str,
|
url: &str,
|
||||||
) -> Result<Option<models::MemberSite>, Error> {
|
) -> Result<Option<models::Site>, Error> {
|
||||||
use member_sites::dsl;
|
use sites::dsl;
|
||||||
|
|
||||||
match member_sites::table
|
match sites::table
|
||||||
.filter(dsl::url.eq(url))
|
.filter(dsl::url.eq(url))
|
||||||
.first::<models::MemberSite>(conn)
|
.first::<models::Site>(conn)
|
||||||
{
|
{
|
||||||
Ok(m) => Ok(Some(m)),
|
Ok(m) => Ok(Some(m)),
|
||||||
Err(e) => match e {
|
Err(e) => match e {
|
||||||
|
@ -63,10 +59,10 @@ impl Repository {
|
||||||
conn: &diesel::PgConnection,
|
conn: &diesel::PgConnection,
|
||||||
find_all: models::FindAll,
|
find_all: models::FindAll,
|
||||||
) -> Result<i64, Error> {
|
) -> Result<i64, Error> {
|
||||||
let mut q = member_sites::table.into_boxed();
|
let mut q = sites::table.into_boxed();
|
||||||
|
|
||||||
if let Some(sp) = find_all.url_like {
|
if let Some(sp) = find_all.url_like {
|
||||||
q = q.filter(member_sites::dsl::url.like(sp));
|
q = q.filter(sites::dsl::url.like(sp));
|
||||||
}
|
}
|
||||||
|
|
||||||
q.count().get_result(conn)
|
q.count().get_result(conn)
|
||||||
|
@ -77,11 +73,11 @@ impl Repository {
|
||||||
&self,
|
&self,
|
||||||
conn: &diesel::PgConnection,
|
conn: &diesel::PgConnection,
|
||||||
find_all: models::FindAll,
|
find_all: models::FindAll,
|
||||||
) -> Result<Vec<models::MemberSite>, Error> {
|
) -> Result<Vec<models::Site>, Error> {
|
||||||
let mut q = member_sites::table.into_boxed();
|
let mut q = sites::table.into_boxed();
|
||||||
|
|
||||||
if let Some(sp) = find_all.url_like {
|
if let Some(sp) = find_all.url_like {
|
||||||
q = q.filter(member_sites::dsl::url.like(sp));
|
q = q.filter(sites::dsl::url.like(sp));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(p) = find_all.pagination {
|
if let Some(p) = find_all.pagination {
|
||||||
|
@ -97,31 +93,31 @@ impl Repository {
|
||||||
match s {
|
match s {
|
||||||
bcr::models::pagination::Sort::ASC(property) => match property.as_str() {
|
bcr::models::pagination::Sort::ASC(property) => match property.as_str() {
|
||||||
"url" => {
|
"url" => {
|
||||||
q = q.order_by(member_sites::url.asc());
|
q = q.order_by(sites::url.asc());
|
||||||
}
|
}
|
||||||
"created_at" => {
|
"created_at" => {
|
||||||
q = q.order_by(member_sites::created_at.asc());
|
q = q.order_by(sites::created_at.asc());
|
||||||
}
|
}
|
||||||
"updated_at" => {
|
"updated_at" => {
|
||||||
q = q.order_by(member_sites::updated_at.asc());
|
q = q.order_by(sites::updated_at.asc());
|
||||||
}
|
}
|
||||||
"deleted_at" => {
|
"deleted_at" => {
|
||||||
q = q.order_by(member_sites::deleted_at.asc());
|
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(member_sites::url.desc());
|
q = q.order_by(sites::url.desc());
|
||||||
}
|
}
|
||||||
"created_at" => {
|
"created_at" => {
|
||||||
q = q.order_by(member_sites::created_at.desc());
|
q = q.order_by(sites::created_at.desc());
|
||||||
}
|
}
|
||||||
"updated_at" => {
|
"updated_at" => {
|
||||||
q = q.order_by(member_sites::updated_at.desc());
|
q = q.order_by(sites::updated_at.desc());
|
||||||
}
|
}
|
||||||
"deleted_at" => {
|
"deleted_at" => {
|
||||||
q = q.order_by(member_sites::deleted_at.desc());
|
q = q.order_by(sites::deleted_at.desc());
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
@ -129,6 +125,6 @@ impl Repository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
q.load::<models::MemberSite>(conn)
|
q.load::<models::Site>(conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
///
|
///
|
||||||
member_sites(id) {
|
sites(id) {
|
||||||
///
|
///
|
||||||
id -> Uuid,
|
id -> Uuid,
|
||||||
///
|
///
|
|
@ -16,7 +16,7 @@ pub struct Service<'a> {
|
||||||
queue_broker: String,
|
queue_broker: String,
|
||||||
pool: Pool<ConnectionManager<PgConnection>>,
|
pool: Pool<ConnectionManager<PgConnection>>,
|
||||||
member_repository: repositories::member::repository::Repository,
|
member_repository: repositories::member::repository::Repository,
|
||||||
member_site_repository: repositories::member_site::repository::Repository,
|
member_site_repository: repositories::site::repository::Repository,
|
||||||
member_session_repository: repositories::member_session::repository::Repository,
|
member_session_repository: repositories::member_session::repository::Repository,
|
||||||
argon2_config: argon2::Config<'a>,
|
argon2_config: argon2::Config<'a>,
|
||||||
captcha_salt: String,
|
captcha_salt: String,
|
||||||
|
@ -44,7 +44,7 @@ impl Service<'_> {
|
||||||
queue_broker,
|
queue_broker,
|
||||||
pool,
|
pool,
|
||||||
member_repository: repositories::member::repository::Repository::new(),
|
member_repository: repositories::member::repository::Repository::new(),
|
||||||
member_site_repository: repositories::member_site::repository::Repository::new(),
|
member_site_repository: repositories::site::repository::Repository::new(),
|
||||||
member_session_repository: repositories::member_session::repository::Repository::new(),
|
member_session_repository: repositories::member_session::repository::Repository::new(),
|
||||||
argon2_config: argon2::Config::default(),
|
argon2_config: argon2::Config::default(),
|
||||||
captcha_salt,
|
captcha_salt,
|
||||||
|
@ -544,7 +544,7 @@ impl Service<'_> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if m.member_site_id != ms.id {
|
if m.site_id != ms.id {
|
||||||
return Err(bcr::error::rpc::Error::InvalidParams(
|
return Err(bcr::error::rpc::Error::InvalidParams(
|
||||||
bcr::error::rpc::InvalidParams {
|
bcr::error::rpc::InvalidParams {
|
||||||
message: "invalid site_url".to_string(),
|
message: "invalid site_url".to_string(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user