From 2699b3d5bfdbfcde4acaa8896be3feb73e9f4102 Mon Sep 17 00:00:00 2001 From: 4t145 Date: Thu, 19 Oct 2023 09:51:33 +0800 Subject: [PATCH] Reach: modify name style (#492) * remove mq event listener and add ci web api * make more fields have a default value * rename files in reach * delete duplicate file --- clients/hwsms/src/ext/reach.rs | 6 ++-- services/bios-all/src/initializer.rs | 4 +-- support/reach/src/{api/mod.rs => api.rs} | 14 ++++----- support/reach/src/api/cc/mod.rs | 6 ---- support/reach/src/api/ci/mod.rs | 2 -- support/reach/src/api/ct/mod.rs | 30 ------------------- support/reach/src/api/reach_api_cc.rs | 6 ++++ .../reach_api_cc_message.rs} | 10 +++---- .../reach_api_cc_trigger_scene.rs} | 4 +-- support/reach/src/api/reach_api_ci.rs | 2 ++ .../reach_api_ci_message.rs} | 4 +-- support/reach/src/api/reach_api_ct.rs | 30 +++++++++++++++++++ .../reach_api_ct_message.rs} | 4 +-- .../reach_api_ct_msg_log.rs} | 4 +-- .../reach_api_ct_msg_signature.rs} | 4 +-- .../reach_api_ct_msg_template.rs} | 4 +-- .../reach_api_ct_trigger_global.rs} | 4 +-- .../reach_api_ct_trigger_instance.rs} | 4 +-- support/reach/src/config/mail.rs | 1 - .../reach/src/{domain/mod.rs => domain.rs} | 0 support/reach/src/domain/message_template.rs | 10 ++----- support/reach/src/{dto/mod.rs => dto.rs} | 0 support/reach/src/dto/message/mod.rs | 1 + support/reach/src/dto/message/send_req.rs | 3 ++ support/reach/src/dto/message/template.rs | 26 +++++++++++----- support/reach/src/errors.rs | 1 - support/reach/src/lib.rs | 15 +++++----- .../src/{config/mod.rs => reach_config.rs} | 6 ++-- .../reach_config_sms.rs} | 0 .../reach/src/{consts.rs => reach_consts.rs} | 0 support/reach/src/{init.rs => reach_init.rs} | 6 ++-- .../reach/src/{invoke.rs => reach_invoke.rs} | 2 +- .../src/{client.rs => reach_send_channel.rs} | 2 +- support/reach/src/{serv/mod.rs => serv.rs} | 0 support/reach/src/serv/message_send.rs | 13 ++++---- support/reach/src/{task/mod.rs => task.rs} | 0 .../reach/src/task/message_send_listener.rs | 2 +- support/reach/tests/test_message_send.rs | 10 +++---- support/reach/tests/test_reach_common.rs | 4 +-- support/reach/tests/test_send_client.rs | 6 ++-- 40 files changed, 127 insertions(+), 123 deletions(-) rename support/reach/src/{api/mod.rs => api.rs} (63%) delete mode 100644 support/reach/src/api/cc/mod.rs delete mode 100644 support/reach/src/api/ci/mod.rs delete mode 100644 support/reach/src/api/ct/mod.rs create mode 100644 support/reach/src/api/reach_api_cc.rs rename support/reach/src/api/{cc/message.rs => reach_api_cc/reach_api_cc_message.rs} (95%) rename support/reach/src/api/{cc/trigger_scene.rs => reach_api_cc/reach_api_cc_trigger_scene.rs} (96%) create mode 100644 support/reach/src/api/reach_api_ci.rs rename support/reach/src/api/{ci/message.rs => reach_api_ci/reach_api_ci_message.rs} (94%) create mode 100644 support/reach/src/api/reach_api_ct.rs rename support/reach/src/api/{ct/message.rs => reach_api_ct/reach_api_ct_message.rs} (97%) rename support/reach/src/api/{ct/msg_log.rs => reach_api_ct/reach_api_ct_msg_log.rs} (94%) rename support/reach/src/api/{ct/msg_signature.rs => reach_api_ct/reach_api_ct_msg_signature.rs} (98%) rename support/reach/src/api/{ct/msg_template.rs => reach_api_ct/reach_api_ct_msg_template.rs} (98%) rename support/reach/src/api/{ct/trigger_global.rs => reach_api_ct/reach_api_ct_trigger_global.rs} (95%) rename support/reach/src/api/{ct/trigger_instance.rs => reach_api_ct/reach_api_ct_trigger_instance.rs} (96%) delete mode 100644 support/reach/src/config/mail.rs rename support/reach/src/{domain/mod.rs => domain.rs} (100%) rename support/reach/src/{dto/mod.rs => dto.rs} (100%) delete mode 100644 support/reach/src/errors.rs rename support/reach/src/{config/mod.rs => reach_config.rs} (83%) rename support/reach/src/{config/sms.rs => reach_config/reach_config_sms.rs} (100%) rename support/reach/src/{consts.rs => reach_consts.rs} (100%) rename support/reach/src/{init.rs => reach_init.rs} (94%) rename support/reach/src/{invoke.rs => reach_invoke.rs} (89%) rename support/reach/src/{client.rs => reach_send_channel.rs} (98%) rename support/reach/src/{serv/mod.rs => serv.rs} (100%) rename support/reach/src/{task/mod.rs => task.rs} (100%) diff --git a/clients/hwsms/src/ext/reach.rs b/clients/hwsms/src/ext/reach.rs index 5dad34430..0e323b3ea 100644 --- a/clients/hwsms/src/ext/reach.rs +++ b/clients/hwsms/src/ext/reach.rs @@ -4,9 +4,9 @@ use std::{ }; use bios_reach::{ - client::{GenericTemplate, SendChannel}, - config::ReachConfig, - consts::MODULE_CODE, + reach_send_channel::{GenericTemplate, SendChannel}, + reach_config::ReachConfig, + reach_consts::MODULE_CODE, dto::{ContentReplace, ReachChannelKind}, }; use tardis::{ diff --git a/services/bios-all/src/initializer.rs b/services/bios-all/src/initializer.rs index 75f49c2e3..3e2cdf8db 100644 --- a/services/bios-all/src/initializer.rs +++ b/services/bios-all/src/initializer.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bios_reach::client::SendChannelMap; +use bios_reach::reach_send_channel::SendChannelMap; use tardis::basic::result::TardisResult; use tardis::web::web_server::TardisWebServer; @@ -11,7 +11,7 @@ pub async fn init(web_server: &TardisWebServer) -> TardisResult<()> { web_server, SendChannelMap::new() .with_arc_channel(bios_client_hwsms::SmsClient::from_reach_config()) - .with_arc_channel(Arc::new(tardis::TardisFuns::mail_by_module(bios_reach::consts::MODULE_CODE))), + .with_arc_channel(Arc::new(tardis::TardisFuns::mail_by_module(bios_reach::reach_consts::MODULE_CODE))), ) .await?; diff --git a/support/reach/src/api/mod.rs b/support/reach/src/api.rs similarity index 63% rename from support/reach/src/api/mod.rs rename to support/reach/src/api.rs index a4c2f4860..4fc0cc579 100644 --- a/support/reach/src/api/mod.rs +++ b/support/reach/src/api.rs @@ -1,15 +1,15 @@ -mod cc; +mod reach_api_cc; -pub use cc::*; +pub use reach_api_cc::*; -mod ct; -pub use ct::*; +mod reach_api_ct; +pub use reach_api_ct::*; -mod ci; -pub use ci::*; +mod reach_api_ci; +pub use reach_api_ci::*; use tardis::{basic::result::TardisResult, web::web_server::TardisWebServer}; -use crate::consts::DOMAIN_CODE; +use crate::reach_consts::DOMAIN_CODE; pub type ReachApi = (ReachCcApi, ReachCtApi, ReachMessageCiApi); pub async fn init(web_server: &TardisWebServer) -> TardisResult<()> { diff --git a/support/reach/src/api/cc/mod.rs b/support/reach/src/api/cc/mod.rs deleted file mode 100644 index e3123bb2a..000000000 --- a/support/reach/src/api/cc/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod message; -pub use message::ReachMessageCcApi; -mod trigger_scene; -pub use trigger_scene::ReachTriggerSceneCcApi; - -pub type ReachCcApi = (ReachTriggerSceneCcApi, ReachMessageCcApi); diff --git a/support/reach/src/api/ci/mod.rs b/support/reach/src/api/ci/mod.rs deleted file mode 100644 index b1bd3227e..000000000 --- a/support/reach/src/api/ci/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod message; -pub use message::ReachMessageCiApi; diff --git a/support/reach/src/api/ct/mod.rs b/support/reach/src/api/ct/mod.rs deleted file mode 100644 index fb99b0fff..000000000 --- a/support/reach/src/api/ct/mod.rs +++ /dev/null @@ -1,30 +0,0 @@ -mod message; -pub use message::ReachMessageCtApi; -mod msg_log; -pub use msg_log::ReachMsgLogCtApi; -mod msg_signature; -pub use msg_signature::ReachMsgSignatureCtApi; -mod msg_template; -pub use msg_template::ReachMessageTemplateCtApi; -mod trigger_global; -use tardis::basic::{error::TardisError, result::TardisResult}; -pub use trigger_global::ReachTriggerGlobalConfigCtApi; -mod trigger_instance; -pub use trigger_instance::ReachTriggerInstanceConfigCtApi; - -pub type ReachCtApi = ( - ReachMessageCtApi, - ReachMsgSignatureCtApi, - ReachMsgLogCtApi, - ReachMessageTemplateCtApi, - ReachTriggerGlobalConfigCtApi, - ReachTriggerInstanceConfigCtApi, -); - -fn map_notfound_to_false(e: TardisError) -> TardisResult { - if e.code.contains("404") { - Ok(false) - } else { - Err(e) - } -} diff --git a/support/reach/src/api/reach_api_cc.rs b/support/reach/src/api/reach_api_cc.rs new file mode 100644 index 000000000..5718dff55 --- /dev/null +++ b/support/reach/src/api/reach_api_cc.rs @@ -0,0 +1,6 @@ +mod reach_api_cc_message; +pub use reach_api_cc_message::ReachMessageCcApi; +mod reach_api_cc_trigger_scene; +pub use reach_api_cc_trigger_scene::ReachTriggerSceneCcApi; + +pub type ReachCcApi = (ReachTriggerSceneCcApi, ReachMessageCcApi); diff --git a/support/reach/src/api/cc/message.rs b/support/reach/src/api/reach_api_cc/reach_api_cc_message.rs similarity index 95% rename from support/reach/src/api/cc/message.rs rename to support/reach/src/api/reach_api_cc/reach_api_cc_message.rs index c09f0f2c1..3b5b0d9cb 100644 --- a/support/reach/src/api/cc/message.rs +++ b/support/reach/src/api/reach_api_cc/reach_api_cc_message.rs @@ -9,13 +9,13 @@ use tardis::web::poem_openapi; use tardis::web::poem_openapi::payload::Json; use tardis::web::web_resp::{TardisApiResult, TardisResp, Void}; -use crate::client::{GenericTemplate, SendChannelMap}; -use crate::config::ReachConfig; -use crate::consts::*; +use crate::reach_send_channel::{GenericTemplate, SendChannelMap}; +use crate::reach_config::ReachConfig; +use crate::reach_consts::*; use crate::dto::*; -use crate::init::REACH_SEND_CHANNEL_MAP; +use crate::reach_init::REACH_SEND_CHANNEL_MAP; #[cfg(feature = "simple-client")] -use crate::invoke::Client; +use crate::reach_invoke::Client; use crate::serv::*; #[derive(Clone)] diff --git a/support/reach/src/api/cc/trigger_scene.rs b/support/reach/src/api/reach_api_cc/reach_api_cc_trigger_scene.rs similarity index 96% rename from support/reach/src/api/cc/trigger_scene.rs rename to support/reach/src/api/reach_api_cc/reach_api_cc_trigger_scene.rs index 2b011395a..44bb7ff80 100644 --- a/support/reach/src/api/cc/trigger_scene.rs +++ b/support/reach/src/api/reach_api_cc/reach_api_cc_trigger_scene.rs @@ -6,10 +6,10 @@ use tardis::web::poem_openapi; use tardis::web::poem_openapi::param::Query; use tardis::web::web_resp::{TardisApiResult, TardisResp}; -use crate::consts::get_tardis_inst; +use crate::reach_consts::get_tardis_inst; use crate::dto::*; #[cfg(feature = "simple-client")] -use crate::invoke::Client; +use crate::reach_invoke::Client; use crate::serv::*; #[derive(Clone, Default)] diff --git a/support/reach/src/api/reach_api_ci.rs b/support/reach/src/api/reach_api_ci.rs new file mode 100644 index 000000000..90898347a --- /dev/null +++ b/support/reach/src/api/reach_api_ci.rs @@ -0,0 +1,2 @@ +mod reach_api_ci_message; +pub use reach_api_ci_message::ReachMessageCiApi; diff --git a/support/reach/src/api/ci/message.rs b/support/reach/src/api/reach_api_ci/reach_api_ci_message.rs similarity index 94% rename from support/reach/src/api/ci/message.rs rename to support/reach/src/api/reach_api_ci/reach_api_ci_message.rs index 26af7b1fa..bbef6e331 100644 --- a/support/reach/src/api/ci/message.rs +++ b/support/reach/src/api/reach_api_ci/reach_api_ci_message.rs @@ -6,10 +6,10 @@ use tardis::web::poem_openapi; use tardis::web::poem_openapi::payload::Json; use tardis::web::web_resp::{TardisApiResult, TardisResp, Void}; -use crate::consts::*; +use crate::reach_consts::*; use crate::dto::*; #[cfg(feature = "simple-client")] -use crate::invoke::Client; +use crate::reach_invoke::Client; use crate::serv::*; #[derive(Debug, Default, Clone)] diff --git a/support/reach/src/api/reach_api_ct.rs b/support/reach/src/api/reach_api_ct.rs new file mode 100644 index 000000000..7d4ed9dd3 --- /dev/null +++ b/support/reach/src/api/reach_api_ct.rs @@ -0,0 +1,30 @@ +mod reach_api_ct_message; +pub use reach_api_ct_message::ReachMessageCtApi; +mod reach_api_ct_msg_log; +pub use reach_api_ct_msg_log::ReachMsgLogCtApi; +mod reach_api_ct_msg_signature; +pub use reach_api_ct_msg_signature::ReachMsgSignatureCtApi; +mod reach_api_ct_msg_template; +pub use reach_api_ct_msg_template::ReachMessageTemplateCtApi; +mod reach_api_ct_trigger_global; +use tardis::basic::{error::TardisError, result::TardisResult}; +pub use reach_api_ct_trigger_global::ReachTriggerGlobalConfigCtApi; +mod reach_api_ct_trigger_instance; +pub use reach_api_ct_trigger_instance::ReachTriggerInstanceConfigCtApi; + +pub type ReachCtApi = ( + ReachMessageCtApi, + ReachMsgSignatureCtApi, + ReachMsgLogCtApi, + ReachMessageTemplateCtApi, + ReachTriggerGlobalConfigCtApi, + ReachTriggerInstanceConfigCtApi, +); + +fn map_notfound_to_false(e: TardisError) -> TardisResult { + if e.code.contains("404") { + Ok(false) + } else { + Err(e) + } +} diff --git a/support/reach/src/api/ct/message.rs b/support/reach/src/api/reach_api_ct/reach_api_ct_message.rs similarity index 97% rename from support/reach/src/api/ct/message.rs rename to support/reach/src/api/reach_api_ct/reach_api_ct_message.rs index 39fc69a5f..7e83c817b 100644 --- a/support/reach/src/api/ct/message.rs +++ b/support/reach/src/api/reach_api_ct/reach_api_ct_message.rs @@ -7,10 +7,10 @@ use tardis::web::poem_openapi::param::{Path, Query}; use tardis::web::poem_openapi::payload::Json; use tardis::web::web_resp::{TardisApiResult, TardisPage, TardisResp}; -use crate::consts::get_tardis_inst; +use crate::reach_consts::get_tardis_inst; use crate::dto::*; #[cfg(feature = "simple-client")] -use crate::invoke::Client; +use crate::reach_invoke::Client; use crate::serv::*; #[derive(Clone, Default)] /// 用户触达消息-公共控制台 diff --git a/support/reach/src/api/ct/msg_log.rs b/support/reach/src/api/reach_api_ct/reach_api_ct_msg_log.rs similarity index 94% rename from support/reach/src/api/ct/msg_log.rs rename to support/reach/src/api/reach_api_ct/reach_api_ct_msg_log.rs index ce1438488..fb5dfc55e 100644 --- a/support/reach/src/api/ct/msg_log.rs +++ b/support/reach/src/api/reach_api_ct/reach_api_ct_msg_log.rs @@ -1,7 +1,7 @@ -use crate::consts::get_tardis_inst; +use crate::reach_consts::get_tardis_inst; use crate::dto::*; #[cfg(feature = "simple-client")] -use crate::invoke::Client; +use crate::reach_invoke::Client; use crate::serv::*; use bios_basic::rbum::serv::rbum_crud_serv::RbumCrudOperation; use bios_sdk_invoke::simple_invoke_client; diff --git a/support/reach/src/api/ct/msg_signature.rs b/support/reach/src/api/reach_api_ct/reach_api_ct_msg_signature.rs similarity index 98% rename from support/reach/src/api/ct/msg_signature.rs rename to support/reach/src/api/reach_api_ct/reach_api_ct_msg_signature.rs index c98274608..9db69467b 100644 --- a/support/reach/src/api/ct/msg_signature.rs +++ b/support/reach/src/api/reach_api_ct/reach_api_ct_msg_signature.rs @@ -7,12 +7,12 @@ use tardis::web::poem_openapi::payload::Json; use tardis::web::poem_openapi; use tardis::web::web_resp::{TardisApiResult, TardisPage, TardisResp}; -use crate::consts::get_tardis_inst; +use crate::reach_consts::get_tardis_inst; use crate::dto::*; use crate::serv::*; #[cfg(feature = "simple-client")] -use crate::invoke::Client; +use crate::reach_invoke::Client; use super::map_notfound_to_false; #[derive(Clone, Default)] diff --git a/support/reach/src/api/ct/msg_template.rs b/support/reach/src/api/reach_api_ct/reach_api_ct_msg_template.rs similarity index 98% rename from support/reach/src/api/ct/msg_template.rs rename to support/reach/src/api/reach_api_ct/reach_api_ct_msg_template.rs index 195ecb5ff..c34ed5c88 100644 --- a/support/reach/src/api/ct/msg_template.rs +++ b/support/reach/src/api/reach_api_ct/reach_api_ct_msg_template.rs @@ -7,12 +7,12 @@ use tardis::web::poem_openapi::payload::Json; use tardis::web::poem_openapi; use tardis::web::web_resp::{TardisApiResult, TardisPage, TardisResp}; -use crate::consts::get_tardis_inst; +use crate::reach_consts::get_tardis_inst; use crate::dto::*; use crate::serv::*; #[cfg(feature = "simple-client")] -use crate::invoke::Client; +use crate::reach_invoke::Client; use super::map_notfound_to_false; #[derive(Clone, Default)] diff --git a/support/reach/src/api/ct/trigger_global.rs b/support/reach/src/api/reach_api_ct/reach_api_ct_trigger_global.rs similarity index 95% rename from support/reach/src/api/ct/trigger_global.rs rename to support/reach/src/api/reach_api_ct/reach_api_ct_trigger_global.rs index 561a3755e..ee1d481ba 100644 --- a/support/reach/src/api/ct/trigger_global.rs +++ b/support/reach/src/api/reach_api_ct/reach_api_ct_trigger_global.rs @@ -6,12 +6,12 @@ use tardis::web::poem::web::Json; use tardis::web::poem_openapi; use tardis::web::web_resp::{TardisApiResult, TardisResp, Void}; -use crate::consts::get_tardis_inst; +use crate::reach_consts::get_tardis_inst; use crate::dto::*; use crate::serv::*; #[cfg(feature = "simple-client")] -use crate::invoke::Client; +use crate::reach_invoke::Client; #[derive(Clone, Default)] /// 用户触达触发全局配置-租户控制台 pub struct ReachTriggerGlobalConfigCtApi; diff --git a/support/reach/src/api/ct/trigger_instance.rs b/support/reach/src/api/reach_api_ct/reach_api_ct_trigger_instance.rs similarity index 96% rename from support/reach/src/api/ct/trigger_instance.rs rename to support/reach/src/api/reach_api_ct/reach_api_ct_trigger_instance.rs index a2d7b2bd7..4175ed694 100644 --- a/support/reach/src/api/ct/trigger_instance.rs +++ b/support/reach/src/api/reach_api_ct/reach_api_ct_trigger_instance.rs @@ -7,12 +7,12 @@ use tardis::web::poem_openapi::param::Query; use tardis::web::poem_openapi::payload::Json; use tardis::web::web_resp::{TardisApiResult, TardisResp, Void}; -use crate::consts::get_tardis_inst; +use crate::reach_consts::get_tardis_inst; use crate::dto::*; use crate::serv::*; #[cfg(feature = "simple-client")] -use crate::invoke::Client; +use crate::reach_invoke::Client; #[derive(Clone, Default)] /// 用户触达触发实例配置-租户控制台 pub struct ReachTriggerInstanceConfigCtApi; diff --git a/support/reach/src/config/mail.rs b/support/reach/src/config/mail.rs deleted file mode 100644 index 8b1378917..000000000 --- a/support/reach/src/config/mail.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/support/reach/src/domain/mod.rs b/support/reach/src/domain.rs similarity index 100% rename from support/reach/src/domain/mod.rs rename to support/reach/src/domain.rs diff --git a/support/reach/src/domain/message_template.rs b/support/reach/src/domain/message_template.rs index 89cff165d..8239e751d 100644 --- a/support/reach/src/domain/message_template.rs +++ b/support/reach/src/domain/message_template.rs @@ -96,6 +96,9 @@ impl From<&ReachMessageTemplateAddReq> for ActiveModel { fill_by_add_req!(add_req => { note, icon, + code, + name, + scope_level, sort, disabled, variables, @@ -111,13 +114,6 @@ impl From<&ReachMessageTemplateAddReq> for ActiveModel { sms_signature, sms_from, } model); - fill_by_mod_req! { - add_req => { - code, - name, - scope_level, - } model - } model } } diff --git a/support/reach/src/dto/mod.rs b/support/reach/src/dto.rs similarity index 100% rename from support/reach/src/dto/mod.rs rename to support/reach/src/dto.rs diff --git a/support/reach/src/dto/message/mod.rs b/support/reach/src/dto/message/mod.rs index be7d50204..114f8aeec 100644 --- a/support/reach/src/dto/message/mod.rs +++ b/support/reach/src/dto/message/mod.rs @@ -97,6 +97,7 @@ pub struct ReachMessageSummaryResp { pub rel_reach_msg_signature_id: String, #[oai(validator(max_length = "255"))] pub rel_reach_msg_template_id: String, + #[oai(default)] pub reach_status: ReachStatusKind, pub content_replace: String, pub template_content: String, diff --git a/support/reach/src/dto/message/send_req.rs b/support/reach/src/dto/message/send_req.rs index 6cfdad39d..f274c6dc0 100644 --- a/support/reach/src/dto/message/send_req.rs +++ b/support/reach/src/dto/message/send_req.rs @@ -5,8 +5,10 @@ use std::collections::HashMap; #[derive(Debug, Serialize, Deserialize, poem_openapi::Object)] pub struct ReachMsgSendReq { pub scene_code: String, + #[oai(default)] pub receives: Vec, pub rel_item_id: String, + #[oai(default)] pub replace: HashMap, } @@ -14,5 +16,6 @@ pub struct ReachMsgSendReq { pub struct ReachMsgReceive { pub receive_group_code: String, pub receive_kind: ReachReceiveKind, + #[oai(default)] pub receive_ids: Vec, } diff --git a/support/reach/src/dto/message/template.rs b/support/reach/src/dto/message/template.rs index ea9b5e869..b407a84fb 100644 --- a/support/reach/src/dto/message/template.rs +++ b/support/reach/src/dto/message/template.rs @@ -15,13 +15,14 @@ pub struct ReachMessageTemplateAddReq { // pub create_time: DateTime, // pub update_time: DateTime, /// 用户触达等级类型 - pub scope_level: Option, + #[oai(default)] + pub scope_level: i16, /// 编码 - #[oai(validator(max_length = "255"))] - pub code: Option, + #[oai(validator(max_length = "255"), default)] + pub code: String, /// 名称 - #[oai(validator(max_length = "255"))] - pub name: Option, + #[oai(validator(max_length = "255"), default)] + pub name: String, /// 说明 #[oai(validator(max_length = "2000"), default)] pub note: String, @@ -37,6 +38,7 @@ pub struct ReachMessageTemplateAddReq { /// 参数 #[oai(default)] pub variables: String, + #[oai(default)] /// 用户触达等级类型 pub level_kind: ReachLevelKind, /// 主题 @@ -48,10 +50,13 @@ pub struct ReachMessageTemplateAddReq { /// 确认超时时间 pub timeout_sec: i32, /// 确认超时策略 + #[oai(default)] pub timeout_strategy: ReachTimeoutStrategyKind, /// 关联的触达通道 + #[oai(default)] pub rel_reach_channel: ReachChannelKind, /// 模板类型 + #[oai(default)] pub kind: ReachTemplateKind, /// 用户触达验证码策略Id #[oai(validator(max_length = "255"))] @@ -95,6 +100,7 @@ pub struct ReachMessageTemplateModifyReq { /// 参数 #[oai(default)] pub variables: Option, + #[oai(default)] /// 用户触达等级类型 pub level_kind: Option, /// 主题 @@ -103,22 +109,26 @@ pub struct ReachMessageTemplateModifyReq { /// 内容 #[oai(validator(max_length = "2000"))] pub content: Option, + #[oai(default)] /// 确认超时时间 pub timeout_sec: Option, /// 确认超时策略 + #[oai(default)] pub timeout_strategy: Option, + #[oai(default)] /// 关联的触达通道 pub rel_reach_channel: Option, + #[oai(default)] /// 模板类型 pub kind: Option, /// 用户触达验证码策略Id - #[oai(validator(max_length = "255"))] + #[oai(validator(max_length = "255"), default)] pub rel_reach_verify_code_strategy_id: Option, /// 第三方插件-模板Id - #[oai(validator(max_length = "255"))] + #[oai(validator(max_length = "255"), default)] pub sms_template_id: Option, /// 第三方插件-签名 - #[oai(validator(max_length = "255"))] + #[oai(validator(max_length = "255"), default)] pub sms_signature: Option, /// 第三方插件-短信发送方的号码 #[oai(validator(max_length = "255"))] diff --git a/support/reach/src/errors.rs b/support/reach/src/errors.rs deleted file mode 100644 index 8b1378917..000000000 --- a/support/reach/src/errors.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/support/reach/src/lib.rs b/support/reach/src/lib.rs index 3156fb479..dd673ccfa 100644 --- a/support/reach/src/lib.rs +++ b/support/reach/src/lib.rs @@ -1,19 +1,18 @@ #![warn(clippy::dbg_macro)] #![warn(clippy::unwrap_used)] -pub mod api; -pub mod client; -pub mod config; -pub mod consts; +mod api; +pub mod reach_send_channel; +pub mod reach_config; +pub mod reach_consts; mod domain; pub mod dto; -mod errors; -mod init; +mod reach_init; #[cfg(feature = "simple-client")] -pub mod invoke; +pub mod reach_invoke; mod task; -pub use init::init; +pub use reach_init::init; pub mod reach_initializer { pub use crate::init; } diff --git a/support/reach/src/config/mod.rs b/support/reach/src/reach_config.rs similarity index 83% rename from support/reach/src/config/mod.rs rename to support/reach/src/reach_config.rs index f58f1ea95..c959fd69c 100644 --- a/support/reach/src/config/mod.rs +++ b/support/reach/src/reach_config.rs @@ -1,14 +1,12 @@ use bios_basic::rbum::rbum_config::RbumConfig; use bios_sdk_invoke::invoke_config::InvokeConfig; use serde::{Deserialize, Serialize}; - -mod mail; -mod sms; +mod reach_config_sms; #[derive(Debug, Serialize, Deserialize, Clone, Default)] #[serde(default)] pub struct ReachConfig { - pub sms: sms::SmsConfig, + pub sms: reach_config_sms::SmsConfig, pub rbum: RbumConfig, pub invoke: InvokeConfig, pub iam_get_account: String, diff --git a/support/reach/src/config/sms.rs b/support/reach/src/reach_config/reach_config_sms.rs similarity index 100% rename from support/reach/src/config/sms.rs rename to support/reach/src/reach_config/reach_config_sms.rs diff --git a/support/reach/src/consts.rs b/support/reach/src/reach_consts.rs similarity index 100% rename from support/reach/src/consts.rs rename to support/reach/src/reach_consts.rs diff --git a/support/reach/src/init.rs b/support/reach/src/reach_init.rs similarity index 94% rename from support/reach/src/init.rs rename to support/reach/src/reach_init.rs index 2cb357e6c..69cf51154 100644 --- a/support/reach/src/init.rs +++ b/support/reach/src/reach_init.rs @@ -14,9 +14,9 @@ use tardis::{ use crate::{ api, - client::SendChannelMap, - config::ReachConfig, - consts::{get_tardis_inst, DOMAIN_CODE, DOMAIN_REACH_ID, RBUM_EXT_TABLE_REACH_MESSAGE, RBUM_KIND_CODE_REACH_MESSAGE, REACH_INIT_OWNER}, + reach_send_channel::SendChannelMap, + reach_config::ReachConfig, + reach_consts::{get_tardis_inst, DOMAIN_CODE, DOMAIN_REACH_ID, RBUM_EXT_TABLE_REACH_MESSAGE, RBUM_KIND_CODE_REACH_MESSAGE, REACH_INIT_OWNER}, serv::ReachTriggerSceneService, task, }; diff --git a/support/reach/src/invoke.rs b/support/reach/src/reach_invoke.rs similarity index 89% rename from support/reach/src/invoke.rs rename to support/reach/src/reach_invoke.rs index ad6395265..f320f15b7 100644 --- a/support/reach/src/invoke.rs +++ b/support/reach/src/reach_invoke.rs @@ -14,7 +14,7 @@ impl<'a> Client<'a> { } impl SimpleInvokeClient for Client<'_> { - const DOMAIN_CODE: &'static str = crate::consts::DOMAIN_CODE; + const DOMAIN_CODE: &'static str = crate::reach_consts::DOMAIN_CODE; fn get_ctx(&self) -> &tardis::basic::dto::TardisContext { self.ctx diff --git a/support/reach/src/client.rs b/support/reach/src/reach_send_channel.rs similarity index 98% rename from support/reach/src/client.rs rename to support/reach/src/reach_send_channel.rs index 53138b341..42c3dba50 100644 --- a/support/reach/src/client.rs +++ b/support/reach/src/reach_send_channel.rs @@ -9,7 +9,7 @@ use tardis::{ mail::mail_client::TardisMailSendReq, }; -use crate::{config::ReachConfig, domain::message_template, dto::*}; +use crate::{reach_config::ReachConfig, domain::message_template, dto::*}; #[derive(Default, Debug)] pub struct GenericTemplate<'t> { diff --git a/support/reach/src/serv/mod.rs b/support/reach/src/serv.rs similarity index 100% rename from support/reach/src/serv/mod.rs rename to support/reach/src/serv.rs diff --git a/support/reach/src/serv/message_send.rs b/support/reach/src/serv/message_send.rs index 07ba84c71..58208a411 100644 --- a/support/reach/src/serv/message_send.rs +++ b/support/reach/src/serv/message_send.rs @@ -2,12 +2,12 @@ use std::collections::{HashMap, HashSet}; use bios_basic::rbum::{dto::rbum_item_dto::RbumItemAddReq, serv::rbum_crud_serv::RbumCrudOperation}; use tardis::{ - basic::{dto::TardisContext, result::TardisResult}, + basic::{result::TardisResult, dto::TardisContext}, db::sea_orm::{sea_query::Query, ColumnTrait, Iterable}, TardisFunsInst, }; -use crate::{consts::*, domain, dto::*, serv::*}; +use crate::{reach_consts::*, domain, dto::*, serv::*}; pub async fn message_send(send_req: ReachMsgSendReq, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { let err = |msg: &str| funs.err().not_found("reach", "event_listener", msg, ""); @@ -55,11 +55,10 @@ pub async fn message_send(send_req: ReachMsgSendReq, funs: &TardisFunsInst, ctx: map }); - let mut instance_group_code = - instances.into_iter().filter(|inst| receive_group_code.contains_key(&inst.receive_group_code.clone())).fold(HashMap::>::new(), |mut map, item| { - map.entry(item.receive_group_code.clone()).or_default().push(item); - map - }); + let mut instance_group_code = instances.into_iter().filter(|inst| receive_group_code.contains_key(&inst.receive_group_code.clone())).fold(HashMap::>::new(), |mut map, item| { + map.entry(item.receive_group_code.clone()).or_default().push(item); + map + }); if instance_group_code.is_empty() { return Ok(()); diff --git a/support/reach/src/task/mod.rs b/support/reach/src/task.rs similarity index 100% rename from support/reach/src/task/mod.rs rename to support/reach/src/task.rs diff --git a/support/reach/src/task/message_send_listener.rs b/support/reach/src/task/message_send_listener.rs index a9919d6ce..d92864122 100644 --- a/support/reach/src/task/message_send_listener.rs +++ b/support/reach/src/task/message_send_listener.rs @@ -1,6 +1,6 @@ use std::{collections::HashSet, sync::Arc}; -use crate::{client::*, config::ReachConfig, consts::*, domain::*, dto::*, init::get_reach_send_channel_map, serv::*}; +use crate::{reach_send_channel::*, reach_config::ReachConfig, reach_consts::*, domain::*, dto::*, reach_init::get_reach_send_channel_map, serv::*}; use bios_basic::rbum::helper::rbum_scope_helper; use bios_sdk_invoke::clients::iam_client::IamClient; use tardis::{ diff --git a/support/reach/tests/test_message_send.rs b/support/reach/tests/test_message_send.rs index 427099b45..f3a0c7d04 100644 --- a/support/reach/tests/test_message_send.rs +++ b/support/reach/tests/test_message_send.rs @@ -2,7 +2,7 @@ use bios_basic::rbum::dto::rbum_item_dto::RbumItemAddReq; use tardis::{basic::result::TardisResult, log, serde_json::json, testcontainers, tokio}; mod test_reach_common; -use bios_reach::{consts::*, dto::*, invoke}; +use bios_reach::{reach_consts::*, dto::*, reach_invoke}; use test_reach_common::*; #[tokio::test(flavor = "multi_thread")] pub async fn test_ct_api() -> TardisResult<()> { @@ -14,7 +14,7 @@ pub async fn test_ct_api() -> TardisResult<()> { let holder = init_tardis(&docker).await?; let ctx = get_test_ctx(); let funs = get_tardis_inst(); - let client = invoke::Client::new("http://localhost:8080/reach", ctx, &funs); + let client = reach_invoke::Client::new("http://localhost:8080/reach", ctx, &funs); const CONTENT_TEMPLATE: &str = "hello {name}, your code is {code}"; let template_name = random_string(16); fn expected_content(name: &str, code: &str) -> String { @@ -37,9 +37,9 @@ pub async fn test_ct_api() -> TardisResult<()> { sms_template_id: "sms-tempalte-id".into(), sms_signature: "sms-signature".into(), sms_from: "reach@bios.dev".into(), - scope_level: Some(0), - code: Some("test-code".into()), - name: Some(template_name.clone()), + scope_level: 0, + code: "test-code".into(), + name: template_name.clone(), note: "test-note".into(), icon: "test-icon".into(), ..Default::default() diff --git a/support/reach/tests/test_reach_common.rs b/support/reach/tests/test_reach_common.rs index bebcc3b3b..b680414f7 100644 --- a/support/reach/tests/test_reach_common.rs +++ b/support/reach/tests/test_reach_common.rs @@ -7,8 +7,8 @@ use bios_basic::rbum::serv::rbum_item_serv::RbumItemServ; use bios_basic::rbum::serv::rbum_kind_serv::RbumKindServ; use bios_basic::{rbum::rbum_config::RbumConfig, test::test_http_client::TestHttpClient}; use bios_client_hwsms::{SmsId, SmsResponse}; -use bios_reach::client::SendChannelMap; -use bios_reach::consts::{get_tardis_inst, DOMAIN_CODE, IAM_KEY_PHONE_V_CODE, RBUM_KIND_CODE_REACH_MESSAGE, REACH_INIT_OWNER}; +use bios_reach::reach_send_channel::SendChannelMap; +use bios_reach::reach_consts::{get_tardis_inst, DOMAIN_CODE, IAM_KEY_PHONE_V_CODE, RBUM_KIND_CODE_REACH_MESSAGE, REACH_INIT_OWNER}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::sync::{Arc, OnceLock}; diff --git a/support/reach/tests/test_send_client.rs b/support/reach/tests/test_send_client.rs index cb4de974d..2bfaa31f8 100644 --- a/support/reach/tests/test_send_client.rs +++ b/support/reach/tests/test_send_client.rs @@ -4,7 +4,7 @@ use std::time::Duration; use tardis::{basic::result::TardisResult, testcontainers, tokio}; mod test_reach_common; -use bios_reach::{consts::*, invoke}; +use bios_reach::{reach_consts::*, reach_invoke}; use test_reach_common::*; #[derive(Deserialize)] pub struct TestConfig { @@ -30,7 +30,7 @@ pub async fn test_hw_sms() -> TardisResult<()> { let holder = init_tardis(&docker).await?; let ctx = get_test_ctx(); let funs = get_tardis_inst(); - let client = invoke::Client::new("http://localhost:8080/reach", ctx, &funs); + let client = reach_invoke::Client::new("http://localhost:8080/reach", ctx, &funs); // client.pwd_send(&phone, &code, &()).await?; client.vcode_send(&phone, &code, &()).await?; @@ -50,7 +50,7 @@ pub async fn test_mail() -> TardisResult<()> { let holder = init_tardis(&docker).await?; let ctx = get_test_ctx(); let funs = get_tardis_inst(); - let client = invoke::Client::new("http://localhost:8080/reach", ctx, &funs); + let client = reach_invoke::Client::new("http://localhost:8080/reach", ctx, &funs); client.mail_pwd_send(&mail, &content, "测试", &()).await?; // wait for send tokio::time::sleep(Duration::from_secs(10)).await;