Skip to content

Commit

Permalink
Reach: modify name style (#492)
Browse files Browse the repository at this point in the history
* remove mq event listener and add ci web api

* make more fields have a default value

* rename files in reach

* delete duplicate file
  • Loading branch information
4t145 authored Oct 19, 2023
1 parent 2a84c35 commit 2699b3d
Show file tree
Hide file tree
Showing 40 changed files with 127 additions and 123 deletions.
6 changes: 3 additions & 3 deletions clients/hwsms/src/ext/reach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
4 changes: 2 additions & 2 deletions services/bios-all/src/initializer.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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?;

Expand Down
14 changes: 7 additions & 7 deletions support/reach/src/api/mod.rs → support/reach/src/api.rs
Original file line number Diff line number Diff line change
@@ -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<()> {
Expand Down
6 changes: 0 additions & 6 deletions support/reach/src/api/cc/mod.rs

This file was deleted.

2 changes: 0 additions & 2 deletions support/reach/src/api/ci/mod.rs

This file was deleted.

30 changes: 0 additions & 30 deletions support/reach/src/api/ct/mod.rs

This file was deleted.

6 changes: 6 additions & 0 deletions support/reach/src/api/reach_api_cc.rs
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 2 additions & 0 deletions support/reach/src/api/reach_api_ci.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod reach_api_ci_message;
pub use reach_api_ci_message::ReachMessageCiApi;
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
30 changes: 30 additions & 0 deletions support/reach/src/api/reach_api_ct.rs
Original file line number Diff line number Diff line change
@@ -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<bool> {
if e.code.contains("404") {
Ok(false)
} else {
Err(e)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
/// 用户触达消息-公共控制台
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion support/reach/src/config/mail.rs

This file was deleted.

File renamed without changes.
10 changes: 3 additions & 7 deletions support/reach/src/domain/message_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ impl From<&ReachMessageTemplateAddReq> for ActiveModel {
fill_by_add_req!(add_req => {
note,
icon,
code,
name,
scope_level,
sort,
disabled,
variables,
Expand All @@ -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
}
}
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions support/reach/src/dto/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions support/reach/src/dto/message/send_req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ use std::collections::HashMap;
#[derive(Debug, Serialize, Deserialize, poem_openapi::Object)]
pub struct ReachMsgSendReq {
pub scene_code: String,
#[oai(default)]
pub receives: Vec<ReachMsgReceive>,
pub rel_item_id: String,
#[oai(default)]
pub replace: HashMap<String, String>,
}

#[derive(Debug, Serialize, Deserialize, poem_openapi::Object)]
pub struct ReachMsgReceive {
pub receive_group_code: String,
pub receive_kind: ReachReceiveKind,
#[oai(default)]
pub receive_ids: Vec<String>,
}
26 changes: 18 additions & 8 deletions support/reach/src/dto/message/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ pub struct ReachMessageTemplateAddReq {
// pub create_time: DateTime<Utc>,
// pub update_time: DateTime<Utc>,
/// 用户触达等级类型
pub scope_level: Option<i16>,
#[oai(default)]
pub scope_level: i16,
/// 编码
#[oai(validator(max_length = "255"))]
pub code: Option<String>,
#[oai(validator(max_length = "255"), default)]
pub code: String,
/// 名称
#[oai(validator(max_length = "255"))]
pub name: Option<String>,
#[oai(validator(max_length = "255"), default)]
pub name: String,
/// 说明
#[oai(validator(max_length = "2000"), default)]
pub note: String,
Expand All @@ -37,6 +38,7 @@ pub struct ReachMessageTemplateAddReq {
/// 参数
#[oai(default)]
pub variables: String,
#[oai(default)]
/// 用户触达等级类型
pub level_kind: ReachLevelKind,
/// 主题
Expand All @@ -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"))]
Expand Down Expand Up @@ -95,6 +100,7 @@ pub struct ReachMessageTemplateModifyReq {
/// 参数
#[oai(default)]
pub variables: Option<String>,
#[oai(default)]
/// 用户触达等级类型
pub level_kind: Option<ReachLevelKind>,
/// 主题
Expand All @@ -103,22 +109,26 @@ pub struct ReachMessageTemplateModifyReq {
/// 内容
#[oai(validator(max_length = "2000"))]
pub content: Option<String>,
#[oai(default)]
/// 确认超时时间
pub timeout_sec: Option<i32>,
/// 确认超时策略
#[oai(default)]
pub timeout_strategy: Option<ReachTimeoutStrategyKind>,
#[oai(default)]
/// 关联的触达通道
pub rel_reach_channel: Option<ReachChannelKind>,
#[oai(default)]
/// 模板类型
pub kind: Option<ReachTemplateKind>,
/// 用户触达验证码策略Id
#[oai(validator(max_length = "255"))]
#[oai(validator(max_length = "255"), default)]
pub rel_reach_verify_code_strategy_id: Option<String>,
/// 第三方插件-模板Id
#[oai(validator(max_length = "255"))]
#[oai(validator(max_length = "255"), default)]
pub sms_template_id: Option<String>,
/// 第三方插件-签名
#[oai(validator(max_length = "255"))]
#[oai(validator(max_length = "255"), default)]
pub sms_signature: Option<String>,
/// 第三方插件-短信发送方的号码
#[oai(validator(max_length = "255"))]
Expand Down
1 change: 0 additions & 1 deletion support/reach/src/errors.rs

This file was deleted.

Loading

0 comments on commit 2699b3d

Please sign in to comment.