Skip to content

Commit

Permalink
Feat--sync-ldap-account-status (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
RWDai authored Aug 22, 2024
1 parent f70add9 commit 2d468b4
Show file tree
Hide file tree
Showing 18 changed files with 209 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"jscearcy.rust-doc-viewer",
"serayuzgur.crates",
"fill-labs.dependi",
"belfz.search-crates-io",
"vadimcn.vscode-lldb",
"swellaby.vscode-rust-test-adapter",
Expand Down
52 changes: 36 additions & 16 deletions backend/basic/src/rbum/serv/rbum_set_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,19 @@ impl RbumCrudOperation<rbum_set_cate::ActiveModel, RbumSetCateAddReq, RbumSetCat
..Default::default()
};
if let Some(rbum_parent_cate_id) = &modify_req.rbum_parent_cate_id {
if let Some(detail) = Self::find_one_detail_rbum(&RbumSetCateFilterReq {
basic: RbumBasicFilterReq {
ids: Some(vec![rbum_parent_cate_id.to_string()]),
if let Some(detail) = Self::find_one_detail_rbum(
&RbumSetCateFilterReq {
basic: RbumBasicFilterReq {
ids: Some(vec![rbum_parent_cate_id.to_string()]),
..Default::default()
},
..Default::default()
},
..Default::default()
}, funs, ctx).await? {
funs,
ctx,
)
.await?
{
let sys_code = Self::package_sys_code(&detail.rel_rbum_set_id, Some(rbum_parent_cate_id.as_str()), funs, ctx).await?;
rbum_set_cate.sys_code = Set(sys_code.to_string());
}
Expand Down Expand Up @@ -873,17 +879,31 @@ impl RbumSetCateServ {
funs,
ctx,
)
.await?.sys_code;
let set_item_ids = RbumSetItemServ::find_id_rbums(&RbumSetItemFilterReq {
sys_code_query_kind: Some(RbumSetCateLevelQueryKind::Current),
rel_rbum_set_cate_sys_codes: Some(vec![]),
..Default::default()
}, None, None, funs, ctx).await?;
.await?
.sys_code;
let set_item_ids = RbumSetItemServ::find_id_rbums(
&RbumSetItemFilterReq {
sys_code_query_kind: Some(RbumSetCateLevelQueryKind::Current),
rel_rbum_set_cate_sys_codes: Some(vec![]),
..Default::default()
},
None,
None,
funs,
ctx,
)
.await?;
for set_item_id in set_item_ids {
RbumSetItemServ::modify_rbum(&set_item_id, &mut RbumSetItemModifyReq {
rel_rbum_set_cate_id: Some(new_sys_code.clone()),
sort: None,
}, funs, ctx).await?;
RbumSetItemServ::modify_rbum(
&set_item_id,
&mut RbumSetItemModifyReq {
rel_rbum_set_cate_id: Some(new_sys_code.clone()),
sort: None,
},
funs,
ctx,
)
.await?;
}

let child_set_cates = Self::find_rbums(
Expand Down Expand Up @@ -975,7 +995,7 @@ impl RbumCrudOperation<rbum_set_item::ActiveModel, RbumSetItemAddReq, RbumSetIte
if let Some(rel_rbum_set_cate_id) = &modify_req.rel_rbum_set_cate_id {
rbum_set_item.rel_rbum_set_cate_code = Set(RbumSetCateServ::get_sys_code(rel_rbum_set_cate_id.as_str(), funs, ctx).await?);
}

Ok(rbum_set_item)
}

Expand Down
11 changes: 10 additions & 1 deletion backend/basic/tests/test_rbum_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,16 @@ async fn test_rbum_set_item(context: &TardisContext) -> TardisResult<()> {
assert_eq!(rbum.rel_rbum_item_name, "用户1");

info!("【test_rbum_set_item】 : Test Modify : RbumSetItemServ::modify_rbum");
RbumSetItemServ::modify_rbum(&id, &mut RbumSetItemModifyReq { sort: Some(10), rel_rbum_set_cate_id: None, }, &funs, context).await?;
RbumSetItemServ::modify_rbum(
&id,
&mut RbumSetItemModifyReq {
sort: Some(10),
rel_rbum_set_cate_id: None,
},
&funs,
context,
)
.await?;

info!("【test_rbum_set_item】 : Test Find : RbumSetItemServ::paginate_rbums");
let rbums = RbumSetItemServ::paginate_rbums(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ impl Plugin for RewriteNsPlugin {
}
impl RewriteNsPlugin {
fn req(&self, req: &mut SgRequest) -> Result<(), BoxError> {
let original_ip = req
.extract::<OriginalIpAddr>().into_inner();
let original_ip = req.extract::<OriginalIpAddr>().into_inner();
if self.ip_list.iter().any(|ipnet| ipnet.contains(&original_ip)) {
let defer = req.extensions_mut().get_or_insert_default::<spacegate_shell::kernel::extension::Defer>();
let target_ns = self.target_ns.clone();
Expand Down
23 changes: 16 additions & 7 deletions backend/middlewares/flow/src/api/cc/flow_cc_model_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,22 +373,31 @@ impl FlowCcModelApi {
let mut funs = flow_constants::get_tardis_inst();
let global_ctx = TardisContext::default();
funs.begin().await?;
let rels = RbumRelServ::find_rels(&RbumRelFilterReq {
basic: RbumBasicFilterReq {
with_sub_own_paths: true,
let rels = RbumRelServ::find_rels(
&RbumRelFilterReq {
basic: RbumBasicFilterReq {
with_sub_own_paths: true,
..Default::default()
},
tag: Some("FlowModelPath".to_string()),
..Default::default()
},
tag: Some("FlowModelPath".to_string()),
..Default::default()
}, None, None, &funs, &global_ctx).await?;
None,
None,
&funs,
&global_ctx,
)
.await?;
for rel in rels {
let ctx = TardisContext {
own_paths: rel.rel.own_paths,
owner: rel.rel.owner,
..Default::default()
};
let rel_model_id = rel.rel.from_rbum_id;
if let Some(template_id) = FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, &rel_model_id, None, None, &funs, &ctx).await?.pop().map(|rel| rel.rel_id) {
if let Some(template_id) =
FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, &rel_model_id, None, None, &funs, &ctx).await?.pop().map(|rel| rel.rel_id)
{
FlowRelServ::add_simple_rel(
&FlowRelKind::FlowAppTemplate,
&rel.rel.to_rbum_item_id.split('/').collect::<Vec<&str>>().last().map(|s| s.to_string()).unwrap_or_default(),
Expand Down
23 changes: 16 additions & 7 deletions backend/middlewares/flow/src/api/ci/flow_ci_model_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,22 +299,31 @@ impl FlowCiModelApi {
let mut funs = flow_constants::get_tardis_inst();
let global_ctx = TardisContext::default();
funs.begin().await?;
let rels = RbumRelServ::find_rels(&RbumRelFilterReq {
basic: RbumBasicFilterReq {
with_sub_own_paths: true,
let rels = RbumRelServ::find_rels(
&RbumRelFilterReq {
basic: RbumBasicFilterReq {
with_sub_own_paths: true,
..Default::default()
},
tag: Some("FlowModelPath".to_string()),
..Default::default()
},
tag: Some("FlowModelPath".to_string()),
..Default::default()
}, None, None, &funs, &global_ctx).await?;
None,
None,
&funs,
&global_ctx,
)
.await?;
for rel in rels {
let ctx = TardisContext {
own_paths: rel.rel.own_paths,
owner: rel.rel.owner,
..Default::default()
};
let rel_model_id = rel.rel.from_rbum_id;
if let Some(template_id) = FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, &rel_model_id, None, None, &funs, &ctx).await?.pop().map(|rel| rel.rel_id) {
if let Some(template_id) =
FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, &rel_model_id, None, None, &funs, &ctx).await?.pop().map(|rel| rel.rel_id)
{
FlowRelServ::add_simple_rel(
&FlowRelKind::FlowAppTemplate,
&rel.rel.to_rbum_item_id.split('/').collect::<Vec<&str>>().last().map(|s| s.to_string()).unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion backend/middlewares/flow/src/serv/flow_inst_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ impl FlowInstServ {
insts
.iter()
.map(|inst| async {
let mock_ctx = TardisContext{
let mock_ctx = TardisContext {
own_paths: inst.own_paths.clone(),
..ctx.clone()
};
Expand Down
35 changes: 31 additions & 4 deletions backend/middlewares/flow/src/serv/flow_model_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1109,8 +1109,18 @@ impl FlowModelServ {
)
.await?
} else {
if let Some(template_id) = FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, rel_model_id, None, None, funs, ctx).await?.pop().map(|rel| rel.rel_id) {
if !FlowRelServ::exist_rels(&FlowRelKind::FlowAppTemplate, &template_id, Self::get_app_id_by_ctx(ctx).unwrap_or_default().as_str(), funs, ctx).await? {
if let Some(template_id) =
FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, rel_model_id, None, None, funs, ctx).await?.pop().map(|rel| rel.rel_id)
{
if !FlowRelServ::exist_rels(
&FlowRelKind::FlowAppTemplate,
&template_id,
Self::get_app_id_by_ctx(ctx).unwrap_or_default().as_str(),
funs,
ctx,
)
.await?
{
FlowRelServ::add_simple_rel(
&FlowRelKind::FlowAppTemplate,
Self::get_app_id_by_ctx(&mock_ctx).unwrap_or_default().as_str(),
Expand Down Expand Up @@ -1671,8 +1681,25 @@ impl FlowModelServ {
}
} else {
// clean reference template rel
for rel in FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowAppTemplate, Self::get_app_id_by_ctx(&ctx).unwrap_or_default().as_str(), None, None, funs, &global_ctx).await?.into_iter() {
FlowRelServ::delete_simple_rel(&FlowRelKind::FlowAppTemplate, Self::get_app_id_by_ctx(&ctx).unwrap_or_default().as_str(), &rel.rel_id, funs, &global_ctx).await?;
for rel in FlowRelServ::find_from_simple_rels(
&FlowRelKind::FlowAppTemplate,
Self::get_app_id_by_ctx(ctx).unwrap_or_default().as_str(),
None,
None,
funs,
&global_ctx,
)
.await?
.into_iter()
{
FlowRelServ::delete_simple_rel(
&FlowRelKind::FlowAppTemplate,
Self::get_app_id_by_ctx(ctx).unwrap_or_default().as_str(),
&rel.rel_id,
funs,
&global_ctx,
)
.await?;
}
}
if ctx.own_paths == model.own_paths {
Expand Down
7 changes: 1 addition & 6 deletions backend/spi/spi-object/src/serv/obs/object_obs_obj_serv.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
use tardis::{
basic::{result::TardisResult},
os::{
os_client::TardisOSClient,
},
};
use tardis::{basic::result::TardisResult, os::os_client::TardisOSClient};

use crate::serv::s3::S3;

Expand Down
2 changes: 1 addition & 1 deletion backend/spi/spi-search/src/serv/pg/search_pg_item_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ pub async fn refresh_tsv(tag: &str, funs: &TardisFunsInst, ctx: &TardisContext,
let mut page = 0;
let page_size = 2000;
loop {
let current_result = &result[((page*page_size).min(max_size))..(((page+1)*page_size).min(max_size))];
let current_result = &result[((page * page_size).min(max_size))..(((page + 1) * page_size).min(max_size))];
if current_result.is_empty() {
break;
}
Expand Down
6 changes: 3 additions & 3 deletions backend/spi/spi-stats/src/dto/stats_record_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ pub struct StatsFactRecordLoadReq {

/// ignore updates
/// ps: If idempotent_id has a value and the record is hit, this field takes effect to ignore or update, default is true to ignore updates
///
///
/// 忽略更新
/// ps: 如果 idempotent_id 有值并且命中纪录,则该字段生效忽略或者进行更新,默认为 true 忽略更新
pub ignore_updates: Option<bool>,

/// Field data
/// 字段数据
///
Expand Down Expand Up @@ -57,7 +57,7 @@ pub struct StatsFactRecordsLoadReq {
pub idempotent_id: Option<String>,
/// ignore updates
/// ps: If idempotent_id has a value and the record is hit, this field takes effect to ignore or update, default is true to ignore updates
///
///
/// 忽略更新
/// ps: 如果 idempotent_id 有值并且命中纪录,则该字段生效忽略或者进行更新,默认为 true 忽略更新
pub ignore_updates: Option<bool>,
Expand Down
Loading

0 comments on commit 2d468b4

Please sign in to comment.