Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ideal-world/bios
Browse files Browse the repository at this point in the history
  • Loading branch information
ljl committed Apr 9, 2024
2 parents 27253c3 + 7109713 commit 4b1bee9
Show file tree
Hide file tree
Showing 33 changed files with 83 additions and 82 deletions.
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ members = [
"frontend/sdks/*",
"frontend/clients/*",
]

resolver = "2"
[workspace.package]
version = "0.1.0"
authors = [
Expand Down Expand Up @@ -61,9 +61,9 @@ run_script = { version = "0.10" }
testcontainers-modules = { version = "0.3", features = ["redis"] }
strum = { version = "0.26", features = ["derive"] }
# tardis
# tardis = { version = "0.1.0-rc.10" }
tardis = { version = "0.1.0-rc.11" }
# tardis = { path = "../tardis/tardis" }
tardis = { git = "https://github.com/ideal-world/tardis.git", rev = "191f3ec" }
# tardis = { git = "https://github.com/ideal-world/tardis.git", rev = "191f3ec" }
#spacegate

# spacegate-kernel = { git = "https://github.com/ideal-world/spacegate.git", rev = "f37a81a", features = [
Expand All @@ -81,7 +81,6 @@ spacegate-shell = { git = "https://github.com/ideal-world/spacegate.git", branch
"cache",
"k8s",
"ext-redis",
"ext-axum",
] }

spacegate-plugin = { git = "https://github.com/ideal-world/spacegate.git", branch = "master" }
2 changes: 1 addition & 1 deletion backend/middlewares/event/src/event_initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async fn init_log_ws_client() -> TardisWSClient {
let conf = funs.conf::<EventConfig>();
let mut event_conf = conf.log_event.clone();
if event_conf.avatars.is_empty() {
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, tardis::pkg!()))
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, env!("CARGO_PKG_NAME")))
}
let default_avatar = event_conf.avatars[0].clone();
set_default_log_avatar(default_avatar);
Expand Down
2 changes: 1 addition & 1 deletion backend/middlewares/flow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async-trait.workspace = true
async-recursion.workspace = true
lazy_static.workspace = true
itertools.workspace = true
tardis = { workspace = true, features = ["reldb-postgres", "web-client", "build-info"] }
tardis = { workspace = true, features = ["reldb-postgres", "web-client"] }
bios-basic = { path = "../../basic", features = ["default"] }
bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = ["default"] }
[dev-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion backend/middlewares/flow/src/api/ci/flow_ci_model_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ use bios_basic::helper::bios_ctx_helper::unsafe_fill_ctx;
use bios_basic::rbum::dto::rbum_filer_dto::RbumBasicFilterReq;
use bios_basic::rbum::serv::rbum_item_serv::RbumItemCrudOperation;
use tardis::web::context_extractor::TardisContextExtractor;
use tardis::web::poem::web::{Json, Query};
use tardis::web::poem::Request;
use tardis::web::poem_openapi;
use tardis::web::poem_openapi::param::Query;
use tardis::web::poem_openapi::payload::Json;
use tardis::web::web_resp::{TardisApiResult, TardisResp};

use crate::dto::flow_model_dto::{FlowModelAddCustomModelReq, FlowModelAddCustomModelResp, FlowModelAggResp, FlowModelFilterReq, FlowModelFindRelStateResp};
Expand Down
3 changes: 2 additions & 1 deletion backend/middlewares/flow/src/api/ci/flow_ci_state_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use bios_basic::rbum::helper::rbum_scope_helper;
use bios_basic::rbum::rbum_enumeration::RbumScopeLevelKind;
use bios_basic::rbum::serv::rbum_item_serv::RbumItemCrudOperation;
use tardis::web::context_extractor::TardisContextExtractor;
use tardis::web::poem::web::{Json, Query};
use tardis::web::poem::Request;
use tardis::web::poem_openapi;
use tardis::web::poem_openapi::param::Query;
use tardis::web::poem_openapi::payload::Json;
use tardis::web::web_resp::{TardisApiResult, TardisPage, TardisResp};

use crate::dto::flow_state_dto::{FlowStateCountGroupByStateReq, FlowStateCountGroupByStateResp, FlowStateFilterReq, FlowStateKind, FlowStateSummaryResp, FlowSysStateKind};
Expand Down
2 changes: 1 addition & 1 deletion backend/middlewares/flow/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub async fn start_flow_event_service(config: &EventTopicConfig) -> TardisResult
let client = event_client::EventClient::new(config.base_url.as_str(), &funs);
let mut event_conf = config.clone();
if event_conf.avatars.is_empty() {
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, tardis::pkg!()))
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, env!("CARGO_PKG_NAME")))
}
let resp = client.register(&event_conf.into()).await?;
let ws_client = TardisFuns::ws_client(&resp.ws_addr, |message| async move {
Expand Down
2 changes: 1 addition & 1 deletion backend/middlewares/flow/src/flow_initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ async fn init_ws_flow_client() -> Option<TardisWSClient> {
return None;
}
if event_conf.avatars.is_empty() {
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, tardis::pkg!()))
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, env!("CARGO_PKG_NAME")))
}
let default_avatar = event_conf.avatars[0].clone();
set_default_flow_avatar(default_avatar);
Expand Down
2 changes: 1 addition & 1 deletion backend/middlewares/schedule/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ git = "https://github.com/4t145/tokio-cron-scheduler.git"
branch = "time-local"
features = ["cron_local"]
[dev-dependencies]
tardis = { workspace = true, features = ["test", "ws-client", "build-info"] }
tardis = { workspace = true, features = ["test", "ws-client"] }
bios-basic = { path = "../../basic", features = ["default", "test"] }
bios-spi-kv = { path = "../../spi/spi-kv" }
bios-spi-log = { path = "../../spi/spi-log" }
2 changes: 1 addition & 1 deletion backend/middlewares/schedule/src/schedule_initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn init_ws_client() -> TardisWSClient {
let conf = funs.conf::<ScheduleConfig>();
let mut event_conf = conf.event.clone();
if event_conf.avatars.is_empty() {
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, tardis::pkg!()))
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, env!("CARGO_PKG_NAME")))
}
let default_avatar = event_conf.avatars[0].clone();
set_default_avatar(default_avatar);
Expand Down
2 changes: 1 addition & 1 deletion backend/services/bios-all/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ publish.workspace = true

[dependencies]
serde.workspace = true
tardis = { workspace = true, features = ["web-server", "conf-remote", "cluster", "k8s", "build-info"] }
tardis = { workspace = true, features = ["web-server", "conf-remote", "cluster", "k8s"] }
bios-iam = { path = "../../supports/iam", features = ["spi_search", "spi_kv"] }
bios-auth = { path = "../../supports/auth", features = ["web-server"] }
bios-reach = { path = "../../supports/reach" }
Expand Down
3 changes: 1 addition & 2 deletions backend/services/spacegate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ spacegate-shell = { workspace = true, features = [
"k8s",
"plugin-all",
"ext-redis",
"ext-axum",
"cache",
] }
tardis = { workerspace = true }
tardis = { workspace = true }
spacegate-plugins = { path = "../../gateways/spacegate-plugins" }
envy = "0.4"
[dev-dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bios_spi_conf::{
conf_constants::DOMAIN_CODE,
dto::conf_auth_dto::{RegisterRequest, RegisterResponse},
};
use tardis::web::reqwest::header::HeaderName;
use tardis::web::reqwest::{self, header::HeaderName};
use tardis::{
basic::{dto::TardisContext, field::TrimString, result::TardisResult},
log,
Expand Down
1 change: 0 additions & 1 deletion backend/spi/spi-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ serde.workspace = true
tardis = { workspace = true, features = [
"reldb-postgres",
"web-server",
"build-info"
] }
bios-basic = { path = "../../basic", features = ["default"] }
bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [
Expand Down
2 changes: 1 addition & 1 deletion backend/spi/spi-log/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub async fn start_log_event_service(config: &EventTopicConfig) -> TardisResult<
let client = event_client::EventClient::new(config.base_url.as_str(), &funs);
let mut event_conf = config.clone();
if event_conf.avatars.is_empty() {
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, tardis::pkg!()))
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, env!("CARGO_PKG_NAME")))
}
let resp = client.register(&event_conf.into()).await?;
let ws_client = TardisFuns::ws_client(&resp.ws_addr, |message| async move {
Expand Down
2 changes: 1 addition & 1 deletion backend/spi/spi-plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async-trait.workspace = true
tardis = { workspace = true, features = ["reldb-postgres", "web-server"] }
bios-basic = { path = "../../basic", features = ["default"] }
bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = ["default"] }
strum = { workerspace = true, features = ["derive"] }
strum = { workspace = true, features = ["derive"] }

[dev-dependencies]
tardis = { workspace = true, features = ["test", "ws-client"] }
Expand Down
3 changes: 1 addition & 2 deletions backend/spi/spi-search/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ tardis = { workspace = true, features = [
"web-server",
"web-client",
"openapi-rapidoc",
"build-info"
] }
bios-basic = { path = "../../basic", features = ["default"] }
strum = { workerspace = true, features = ["derive"] }
strum = { workspace = true, features = ["derive"] }
pinyin = { version = "0.10" }
bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [
"event",
Expand Down
2 changes: 1 addition & 1 deletion backend/spi/spi-search/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub async fn start_search_event_service(config: &EventTopicConfig) -> TardisResu
let client = event_client::EventClient::new(config.base_url.as_str(), &funs);
let mut event_conf = config.clone();
if event_conf.avatars.is_empty() {
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, tardis::pkg!()))
event_conf.avatars.push(format!("{}/{}", event_conf.topic_code, env!("CARGO_PKG_NAME")))
}
let resp = client.register(&event_conf.into()).await?;
let ws_client = TardisFuns::ws_client(&resp.ws_addr, |message| async move {
Expand Down
3 changes: 1 addition & 2 deletions backend/spi/spi-search/src/serv/pg/search_pg_item_serv.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::{HashMap};
use std::collections::HashMap;

use pinyin::{to_pinyin_vec, Pinyin};
use tardis::{
Expand Down Expand Up @@ -1339,7 +1339,6 @@ pub async fn query_metrics(query_req: &SearchQueryMetricsReq, funs: &TardisFunsI
let sql_part_orders = orders
.iter()
.map(|order| {

if order.in_ext.unwrap_or(true) {
format!("fact.ext ->> '{}' {}", order.code, if order.asc { "ASC" } else { "DESC" })
} else {
Expand Down
2 changes: 0 additions & 2 deletions backend/spi/spi-search/src/serv/search_item_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ use bios_basic::spi::spi_constants;
use bios_basic::spi::spi_funs::SpiBsInstExtractor;
use bios_basic::spi_dispatch_service;


use tardis::basic::result::TardisResult;
use tardis::web::web_resp::TardisPage;


use crate::dto::search_item_dto::{SearchItemAddReq, SearchItemModifyReq, SearchItemSearchReq, SearchItemSearchResp, SearchQueryMetricsReq, SearchQueryMetricsResp};
use crate::search_initializer;

Expand Down
2 changes: 1 addition & 1 deletion backend/spi/spi-stats/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ lazy_static.workspace = true
itertools.workspace = true
tardis = { workspace = true, features = ["reldb-postgres", "web-server"] }
serde_json = { workspace = true, features = ["preserve_order"] }
strum = { workerspace = true, features = ["derive"] }
strum = { workspace = true, features = ["derive"] }

[dev-dependencies]
tardis = { workspace = true, features = ["test"] }
Expand Down
3 changes: 1 addition & 2 deletions backend/supports/iam/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ tardis = { workspace = true, features = [
"web-client",
"mail",
"k8s",
"build-info"
] }
bios-basic = { path = "../../basic", features = ["default", "with-mq"] }
bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = ["default", "event"] }
Expand All @@ -46,8 +45,8 @@ tokio-util = { version = "0.7", optional = true }
ldap3 = { version = "0.11", optional = true }
# todo Wait for tardis field to upgrade during removal
nanoid = { version = "0.4" }
strum = { workerspace = true, features = ["derive"] }

strum = { workspace = true, features = ["derive"] }
[dev-dependencies]
tardis = { workspace = true, features = ["test"] }
bios-basic = { path = "../../basic", features = ["default", "test"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use tardis::{
basic::{dto::TardisContext, field::TrimString, result::TardisResult},
chrono::{DateTime, Utc},
serde_json::json,
tokio,
TardisFuns, TardisFunsInst,
tokio, TardisFuns, TardisFunsInst,
};

use crate::{
Expand Down
18 changes: 4 additions & 14 deletions backend/supports/iam/src/basic/serv/clients/iam_search_client.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
use std::collections::HashSet;

use bios_basic::{
rbum::{
dto::rbum_filer_dto::{RbumBasicFilterReq},
serv::{rbum_item_serv::RbumItemCrudOperation},
},
};
use bios_basic::rbum::{dto::rbum_filer_dto::RbumBasicFilterReq, serv::rbum_item_serv::RbumItemCrudOperation};
use bios_sdk_invoke::{
clients::spi_search_client::{SpiSearchClient, SpiSearchEventExt},
dto::search_item_dto::{SearchItemAddReq, SearchItemModifyReq, SearchItemVisitKeysReq},
invoke_config::InvokeConfigApi,
};
use itertools::Itertools;


use tardis::{
basic::{dto::TardisContext, field::TrimString, result::TardisResult},
serde_json::json,
Expand All @@ -26,14 +20,11 @@ use crate::{
iam_account_dto::IamAccountDetailAggResp,
iam_filer_dto::{IamAccountFilterReq, IamTenantFilterReq},
},
serv::{
iam_account_serv::IamAccountServ, iam_role_serv::IamRoleServ, iam_set_serv::IamSetServ,
iam_tenant_serv::IamTenantServ,
},
serv::{iam_account_serv::IamAccountServ, iam_role_serv::IamRoleServ, iam_set_serv::IamSetServ, iam_tenant_serv::IamTenantServ},
},
iam_config::IamConfig,
iam_constants,
iam_enumeration::{IamSetKind},
iam_enumeration::IamSetKind,
iam_initializer::{default_search_avatar, ws_search_client},
};
pub struct IamSearchClient;
Expand Down Expand Up @@ -148,8 +139,7 @@ impl IamSearchClient {
};
for set_id in set_ids {
let set_items = IamSetServ::find_set_items(Some(set_id), None, Some(account_id.to_string()), None, true, None, funs, &mock_ctx).await?;
account_resp_dept_id
.extend(set_items.iter().filter_map(|s| s.rel_rbum_set_cate_id.clone()).collect::<Vec<_>>());
account_resp_dept_id.extend(set_items.iter().filter_map(|s| s.rel_rbum_set_cate_id.clone()).collect::<Vec<_>>());
}

let tag = funs.conf::<IamConfig>().spi.search_account_tag.clone();
Expand Down
46 changes: 34 additions & 12 deletions backend/supports/iam/src/basic/serv/iam_open_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,18 +400,40 @@ impl IamOpenServ {
Ok(())
}

pub async fn get_rule_info(cert_id: String, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<IamOpenRuleResp> {
let ak = RbumCertServ::find_one_detail_rbum(
&RbumCertFilterReq {
id: Some(cert_id.to_string()),
..Default::default()
},
funs,
ctx,
)
.await?
.ok_or_else(|| funs.err().internal_error("iam_open", "get_rule_info", "cert not found", "404-iam-res-not-exist"))?
.ak;
pub async fn get_rule_info(cert_id_req: Option<String>, ak_req: Option<String>, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<IamOpenRuleResp> {
if cert_id_req.is_none() && ak_req.is_none() {
return Err(funs.err().internal_error("iam_open", "get_rule_info", "illegal response", "404-iam-res-not-exist"));
}
let cert_id = if let Some(cert_id) = cert_id_req.clone() {
cert_id
} else {
RbumCertServ::find_one_detail_rbum(
&RbumCertFilterReq {
ak: ak_req.clone(),
..Default::default()
},
funs,
ctx,
)
.await?
.ok_or_else(|| funs.err().internal_error("iam_open", "get_rule_info", "cert not found", "404-iam-res-not-exist"))?
.id
};
let ak = if let Some(ak) = ak_req.clone() {
ak
} else {
RbumCertServ::find_one_detail_rbum(
&RbumCertFilterReq {
id: cert_id_req.clone(),
..Default::default()
},
funs,
ctx,
)
.await?
.ok_or_else(|| funs.err().internal_error("iam_open", "get_rule_info", "cert not found", "404-iam-res-not-exist"))?
.ak
};
// let spec_id = IamRelServ::find_from_id_rels(&IamRelKind::IamCertSpec, false, &cert_id, None, None, funs, ctx).await?.pop().unwrap_or_default();
let spec_id = RbumRelServ::find_detail_rbums(
&RbumRelFilterReq {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use tardis::web::web_resp::{TardisApiResult, TardisResp};
use bios_basic::rbum::dto::rbum_filer_dto::{RbumBasicFilterReq, RbumSetItemFilterReq};
use bios_basic::rbum::dto::rbum_set_item_dto::RbumSetItemDetailResp;


use crate::basic::serv::iam_cert_serv::IamCertServ;
use crate::basic::serv::iam_set_serv::IamSetServ;
use crate::iam_constants;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ impl IamCiOpenApi {

/// Get account rule info / 获取账号规则信息
#[oai(path = "/", method = "get")]
async fn get_rule_info(&self, cert_id: Query<String>, mut ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<IamOpenRuleResp> {
async fn get_rule_info(&self, cert_id: Query<Option<String>>, ak: Query<Option<String>>, request: &Request) -> TardisApiResult<IamOpenRuleResp> {
let mut funs = iam_constants::get_tardis_inst();
unsafe_fill_ctx(request, &funs, &mut ctx.0)?;
add_remote_ip(request, &ctx.0).await?;
let global_ctx = TardisContext {
own_paths: "".to_string(),
..Default::default()
};
funs.begin().await?;
let result = IamOpenServ::get_rule_info(cert_id.0, &funs, &ctx.0).await?;
let result = IamOpenServ::get_rule_info(cert_id.0, ak.0, &funs, &global_ctx).await?;
funs.commit().await?;
ctx.0.execute_task().await?;
global_ctx.execute_task().await?;
TardisResp::ok(result)
}

Expand Down
Loading

0 comments on commit 4b1bee9

Please sign in to comment.