Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ljl committed Nov 22, 2023
2 parents e22359d + f7960a7 commit 16da6f3
Show file tree
Hide file tree
Showing 52 changed files with 785 additions and 216 deletions.
3 changes: 3 additions & 0 deletions basic/src/rbum/domain/rbum_cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub struct Model {
/// Cert key \
/// E.g. password, token, secret key
pub sk: String,
/// Whether the key is visible \
pub sk_invisible: bool,
/// Extend information \
/// The content and format are set by the upper service itself
pub ext: String,
Expand Down Expand Up @@ -79,6 +81,7 @@ impl TardisActiveModel for ActiveModel {
.col(ColumnDef::new(Column::Supplier).not_null().string())
.col(ColumnDef::new(Column::Ak).not_null().string())
.col(ColumnDef::new(Column::Sk).not_null().string())
.col(ColumnDef::new(Column::SkInvisible).not_null().boolean().default(false))
.col(ColumnDef::new(Column::Ext).not_null().string())
.col(ColumnDef::new(Column::ConnUri).not_null().string())
.col(ColumnDef::new(Column::RelRbumCertConfId).not_null().string())
Expand Down
4 changes: 4 additions & 0 deletions basic/src/rbum/dto/rbum_cert_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct RbumCertAddReq {
pub ak: TrimString,
#[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "10000")))]
pub sk: Option<TrimString>,
pub sk_invisible: Option<bool>,
pub is_ignore_check_sk: bool,
pub kind: Option<String>,
pub supplier: Option<String>,
Expand Down Expand Up @@ -43,6 +44,7 @@ pub struct RbumCertModifyReq {
pub ak: Option<TrimString>,
#[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "10000")))]
pub sk: Option<TrimString>,
pub sk_invisible: Option<bool>,
pub is_ignore_check_sk: bool,
#[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))]
pub ext: Option<String>,
Expand Down Expand Up @@ -83,6 +85,7 @@ pub struct RbumCertSummaryWithSkResp {
pub id: String,
pub ak: String,
pub sk: String,
pub sk_invisible: bool,
pub ext: String,
pub conn_uri: String,
pub start_time: DateTime<Utc>,
Expand All @@ -108,6 +111,7 @@ pub struct RbumCertSummaryWithSkResp {
pub struct RbumCertDetailResp {
pub id: String,
pub ak: String,
pub sk_invisible: bool,
pub ext: String,
pub start_time: DateTime<Utc>,
pub end_time: DateTime<Utc>,
Expand Down
2 changes: 2 additions & 0 deletions basic/src/rbum/serv/rbum_cert_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ impl RbumCrudOperation<rbum_cert::ActiveModel, RbumCertAddReq, RbumCertModifyReq
id: Set(TardisFuns::field.nanoid()),
ak: Set(add_req.ak.to_string()),
sk: Set(add_req.sk.as_ref().unwrap_or(&TrimString("".to_string())).to_string()),
sk_invisible: Set(add_req.sk_invisible.unwrap_or(false)),
kind: Set(add_req.kind.as_ref().unwrap_or(&"".to_string()).to_string()),
supplier: Set(add_req.supplier.as_ref().unwrap_or(&"".to_string()).to_string()),
ext: Set(add_req.ext.as_ref().unwrap_or(&"".to_string()).to_string()),
Expand Down Expand Up @@ -598,6 +599,7 @@ impl RbumCrudOperation<rbum_cert::ActiveModel, RbumCertAddReq, RbumCertModifyReq
(rbum_cert::Entity, rbum_cert::Column::Kind),
(rbum_cert::Entity, rbum_cert::Column::Supplier),
(rbum_cert::Entity, rbum_cert::Column::Ak),
(rbum_cert::Entity, rbum_cert::Column::SkInvisible),
(rbum_cert::Entity, rbum_cert::Column::Ext),
(rbum_cert::Entity, rbum_cert::Column::StartTime),
(rbum_cert::Entity, rbum_cert::Column::EndTime),
Expand Down
3 changes: 3 additions & 0 deletions basic/src/spi/serv/spi_bs_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl RbumItemCrudOperation<spi_bs::ActiveModel, SpiBsAddReq, SpiBsModifyReq, Spi
&mut RbumCertAddReq {
ak: add_req.ak.clone(),
sk: Some(add_req.sk.clone()),
sk_invisible: Some(false),
kind: Some(SPI_CERT_KIND.to_string()),
supplier: Some(id.to_string()),
conn_uri: Some(add_req.conn_uri.clone()),
Expand Down Expand Up @@ -142,6 +143,7 @@ impl RbumItemCrudOperation<spi_bs::ActiveModel, SpiBsAddReq, SpiBsModifyReq, Spi
status: None,
start_time: None,
end_time: None,
sk_invisible: None,
},
funs,
ctx,
Expand All @@ -160,6 +162,7 @@ impl RbumItemCrudOperation<spi_bs::ActiveModel, SpiBsAddReq, SpiBsModifyReq, Spi
.column((rbum_cert::Entity, rbum_cert::Column::ConnUri))
.column((rbum_cert::Entity, rbum_cert::Column::Ak))
.column((rbum_cert::Entity, rbum_cert::Column::Sk))
.column((rbum_cert::Entity, rbum_cert::Column::SkInvisible))
.column((rbum_cert::Entity, rbum_cert::Column::Ext))
.left_join(
rbum_kind::Entity,
Expand Down
21 changes: 19 additions & 2 deletions basic/tests/test_rbum_cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ async fn test_rbum_cert_conf_is_ak_repeatable(context: &TardisContext) -> Tardis
rel_rbum_id: context.owner.to_string(),
is_outside: false,
is_ignore_check_sk: false,
sk_invisible: None,
},
&funs,
context,
Expand All @@ -336,6 +337,7 @@ async fn test_rbum_cert_conf_is_ak_repeatable(context: &TardisContext) -> Tardis
rel_rbum_id: context.owner.to_string(),
is_outside: false,
is_ignore_check_sk: false,
sk_invisible: None,
},
&funs,
context,
Expand All @@ -347,6 +349,7 @@ async fn test_rbum_cert_conf_is_ak_repeatable(context: &TardisContext) -> Tardis
&mut RbumCertModifyReq {
ak: Some("test".into()),
sk: None,
sk_invisible: None,
ext: None,
start_time: None,
end_time: None,
Expand Down Expand Up @@ -410,6 +413,7 @@ async fn test_rbum_cert_conf_is_ak_repeatable(context: &TardisContext) -> Tardis
kind: None,
supplier: None,
is_ignore_check_sk: false,
sk_invisible: None,
},
&funs,
context,
Expand All @@ -432,7 +436,8 @@ async fn test_rbum_cert_conf_is_ak_repeatable(context: &TardisContext) -> Tardis
is_outside: false,
kind: None,
supplier: None,
is_ignore_check_sk: false
is_ignore_check_sk: false,
sk_invisible: None,
},
&funs,
context,
Expand All @@ -445,6 +450,7 @@ async fn test_rbum_cert_conf_is_ak_repeatable(context: &TardisContext) -> Tardis
&mut RbumCertModifyReq {
ak: Some("test".into()),
sk: None,
sk_invisible: None,
ext: None,
start_time: None,
end_time: None,
Expand Down Expand Up @@ -580,7 +586,8 @@ async fn test_rbum_cert_basic(context: &TardisContext) -> TardisResult<()> {
is_outside: false,
kind: None,
supplier: None,
is_ignore_check_sk: false
is_ignore_check_sk: false,
sk_invisible: None,
},
&funs,
context,
Expand All @@ -593,6 +600,7 @@ async fn test_rbum_cert_basic(context: &TardisContext) -> TardisResult<()> {
&mut RbumCertAddReq {
ak: TrimString("gudaoxuri".to_string()),
sk: None,
sk_invisible: None,
ext: None,
vcode: None,
start_time: None,
Expand All @@ -618,6 +626,7 @@ async fn test_rbum_cert_basic(context: &TardisContext) -> TardisResult<()> {
&mut RbumCertAddReq {
ak: TrimString("gudaoxuri".to_string()),
sk: Some(TrimString("aa".to_string())),
sk_invisible: None,
vcode: None,
ext: None,
start_time: None,
Expand All @@ -643,6 +652,7 @@ async fn test_rbum_cert_basic(context: &TardisContext) -> TardisResult<()> {
&mut RbumCertAddReq {
ak: TrimString("gudaoxuri".to_string()),
sk: Some(TrimString("12345678".to_string())),
sk_invisible: None,
vcode: None,
ext: None,
start_time: None,
Expand All @@ -668,6 +678,7 @@ async fn test_rbum_cert_basic(context: &TardisContext) -> TardisResult<()> {
&mut RbumCertAddReq {
ak: TrimString("gudaoxuri".to_string()),
sk: Some(TrimString("12345678".to_string())),
sk_invisible: None,
vcode: None,
ext: None,
start_time: None,
Expand All @@ -692,6 +703,7 @@ async fn test_rbum_cert_basic(context: &TardisContext) -> TardisResult<()> {
&mut RbumCertAddReq {
ak: TrimString("gudaoxuri".to_string()),
sk: Some(TrimString("12345678".to_string())),
sk_invisible: None,
vcode: None,
ext: None,
start_time: None,
Expand All @@ -716,6 +728,7 @@ async fn test_rbum_cert_basic(context: &TardisContext) -> TardisResult<()> {
&mut RbumCertAddReq {
ak: TrimString("gudaoxuri".to_string()),
sk: Some(TrimString("12345678".to_string())),
sk_invisible: None,
vcode: None,
ext: None,
start_time: None,
Expand All @@ -740,6 +753,7 @@ async fn test_rbum_cert_basic(context: &TardisContext) -> TardisResult<()> {
&mut RbumCertAddReq {
ak: TrimString("root".to_string()),
sk: Some(TrimString("12345678".to_string())),
sk_invisible: None,
vcode: None,
ext: None,
start_time: None,
Expand Down Expand Up @@ -776,6 +790,7 @@ async fn test_rbum_cert_basic(context: &TardisContext) -> TardisResult<()> {
ext: Some("ext".to_string()),
ak: None,
sk: None,
sk_invisible: None,
start_time: None,
end_time: None,
conn_uri: None,
Expand All @@ -794,6 +809,7 @@ async fn test_rbum_cert_basic(context: &TardisContext) -> TardisResult<()> {
ext: Some("ext".to_string()),
ak: None,
sk: None,
sk_invisible: None,
start_time: None,
end_time: None,
conn_uri: None,
Expand Down Expand Up @@ -921,6 +937,7 @@ async fn test_rbum_cert_sk_dynamic(context: &TardisContext) -> TardisResult<()>
&mut RbumCertAddReq {
ak: TrimString("i@sunisle.org".to_string()),
sk: None,
sk_invisible: None,
vcode: Some(TrimString("123456".to_string())),
ext: None,
start_time: None,
Expand Down
2 changes: 2 additions & 0 deletions middleware/flow/src/domain/flow_transition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ pub struct Model {
/// TODO FlowTransitionDoubleCheckInfo
pub double_check: Json,

pub is_notify: bool,

pub rel_flow_model_id: String,

pub sort: i64,
Expand Down
3 changes: 2 additions & 1 deletion middleware/flow/src/dto/flow_external_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tardis::web::poem_openapi::{
types::{ParseFromJSON, ToJSON},
};

use super::flow_state_dto::FlowSysStateKind;
use super::{flow_state_dto::FlowSysStateKind, flow_transition_dto::FlowTransitionActionByVarChangeInfoChangedKind};

#[derive(Serialize, Deserialize, Debug, Default, poem_openapi::Object)]
pub struct FlowExternalReq {
Expand Down Expand Up @@ -38,6 +38,7 @@ pub struct FlowExternalParams {
pub var_id: Option<String>,
pub var_name: Option<String>,
pub value: Option<Value>,
pub changed_kind: Option<FlowTransitionActionByVarChangeInfoChangedKind>,
}

#[derive(Default, Serialize, Deserialize, Debug, poem_openapi::Object)]
Expand Down
5 changes: 5 additions & 0 deletions middleware/flow/src/dto/flow_transition_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct FlowTransitionAddReq {

pub double_check: Option<FlowTransitionDoubleCheckInfo>,
pub vars_collect: Option<Vec<FlowVarInfo>>,
pub is_notify: Option<bool>,

pub action_by_pre_callback: Option<String>,
pub action_by_post_callback: Option<String>,
Expand Down Expand Up @@ -62,6 +63,7 @@ pub struct FlowTransitionModifyReq {

pub vars_collect: Option<Vec<FlowVarInfo>>,
pub double_check: Option<FlowTransitionDoubleCheckInfo>,
pub is_notify: Option<bool>,

pub action_by_pre_callback: Option<String>,
pub action_by_post_callback: Option<String>,
Expand Down Expand Up @@ -97,6 +99,7 @@ pub struct FlowTransitionDetailResp {

pub vars_collect: Value,
pub double_check: Value,
pub is_notify: bool,

pub action_by_pre_callback: String,
pub action_by_post_callback: String,
Expand Down Expand Up @@ -175,6 +178,7 @@ impl From<FlowTransitionDetailResp> for FlowTransitionAddReq {
action_by_post_changes: Some(action_by_post_changes),
action_by_front_changes: Some(action_by_front_changes),
double_check,
is_notify: Some(value.is_notify),
sort: Some(value.sort),
}
}
Expand Down Expand Up @@ -347,6 +351,7 @@ pub struct FlowTransitionInitInfo {

pub vars_collect: Option<Vec<FlowVarInfo>>,
pub double_check: Option<FlowTransitionDoubleCheckInfo>,
pub is_notify: bool,

pub action_by_pre_callback: Option<String>,
pub action_by_post_callback: Option<String>,
Expand Down
19 changes: 18 additions & 1 deletion middleware/flow/src/serv/flow_external_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use crate::{
FlowExternalFetchRelObjResp, FlowExternalKind, FlowExternalModifyFieldResp, FlowExternalNotifyChangesResp, FlowExternalParams, FlowExternalQueryFieldResp,
FlowExternalReq, FlowExternalResp,
},
flow_state_dto::FlowSysStateKind, flow_transition_dto::TagRelKind,
flow_state_dto::FlowSysStateKind,
flow_transition_dto::{FlowTransitionActionByVarChangeInfoChangedKind, TagRelKind},
},
flow_config::FlowConfig,
flow_constants,
Expand Down Expand Up @@ -45,6 +46,7 @@ impl FlowExternalServ {
var_id: None,
var_name: None,
value: None,
changed_kind: None,
})
.collect_vec(),
..Default::default()
Expand Down Expand Up @@ -83,6 +85,21 @@ impl FlowExternalServ {
return Ok(FlowExternalModifyFieldResp {});
}

// complete changed_kind
let params = params
.into_iter()
.map(|mut param| {
if param.changed_kind.is_none() {
if param.value.clone().unwrap_or_default().to_string().is_empty() {
param.changed_kind = Some(FlowTransitionActionByVarChangeInfoChangedKind::Clean);
} else {
param.changed_kind = Some(FlowTransitionActionByVarChangeInfoChangedKind::ChangeContent);
}
}
param
})
.collect_vec();

let header = Self::headers(None, funs, ctx).await?;
let body = FlowExternalReq {
kind: FlowExternalKind::ModifyField,
Expand Down
Loading

0 comments on commit 16da6f3

Please sign in to comment.