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
gudaoxuri committed May 9, 2024
2 parents 0d2cb64 + 0c7b3de commit cb27049
Show file tree
Hide file tree
Showing 42 changed files with 131 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ 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.13" }
tardis = { path = "../tardis/tardis" }
tardis = { version = "0.1.0-rc.15" }
# tardis = { path = "../tardis/tardis" }
# tardis = { git = "https://github.com/ideal-world/tardis.git", rev = "694ff92" }
#spacegate

Expand Down
3 changes: 3 additions & 0 deletions backend/middlewares/event/src/api/event_listener_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ use crate::serv::event_listener_serv;
pub struct EventListenerApi;

/// Event Listener API
///
/// 事件监听器API
#[poem_openapi::OpenApi(prefix_path = "/listener")]
impl EventListenerApi {

/// Register event listener
///
/// 注册事件监听器
#[oai(path = "/", method = "post")]
async fn register(&self, listener: Json<EventListenerRegisterReq>) -> TardisApiResult<EventListenerRegisterResp> {
Expand All @@ -24,6 +26,7 @@ impl EventListenerApi {
}

/// Remove event listener
///
/// 移除事件监听器
#[oai(path = "/:listener_code", method = "delete")]
async fn remove(&self, listener_code: Path<String>, token: Query<String>) -> TardisApiResult<Void> {
Expand Down
2 changes: 2 additions & 0 deletions backend/middlewares/event/src/api/event_proc_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ use crate::serv::event_proc_serv;
pub struct EventProcApi;

/// Event Process API
///
/// 事件处理API
#[poem_openapi::OpenApi(prefix_path = "/proc")]
impl EventProcApi {

/// Process event
///
/// 处理事件
#[oai(path = "/:listener_code", method = "get")]
async fn ws_process(&self, listener_code: Path<String>, token: Query<String>, websocket: WebSocket) -> BoxWebSocketUpgraded {
Expand Down
5 changes: 5 additions & 0 deletions backend/middlewares/event/src/api/event_topic_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ use crate::serv::event_topic_serv::EventDefServ;
pub struct EventTopicApi;

/// Event Topic API
///
/// 事件主题API
#[poem_openapi::OpenApi(prefix_path = "/topic")]
impl EventTopicApi {
/// Add Event Definition
///
/// 添加事件主题
#[oai(path = "/", method = "post")]
async fn add(&self, mut add_or_modify_req: Json<EventTopicAddOrModifyReq>, ctx: TardisContextExtractor) -> TardisApiResult<String> {
Expand All @@ -26,6 +28,7 @@ impl EventTopicApi {
}

/// Modify Event Definition
///
/// 修改事件主题
#[oai(path = "/:id", method = "put")]
async fn modify(&self, id: Path<String>, mut add_or_modify_req: Json<EventTopicAddOrModifyReq>, ctx: TardisContextExtractor) -> TardisApiResult<Void> {
Expand All @@ -35,6 +38,7 @@ impl EventTopicApi {
}

/// Delete Event Definition
///
/// 删除事件主题
#[oai(path = "/:id", method = "delete")]
async fn delete(&self, id: Path<String>, ctx: TardisContextExtractor) -> TardisApiResult<Void> {
Expand All @@ -44,6 +48,7 @@ impl EventTopicApi {
}

/// Find Event Definitions
///
/// 查找事件主题
#[oai(path = "/", method = "get")]
async fn paginate(
Expand Down
13 changes: 9 additions & 4 deletions backend/middlewares/event/src/domain/event_topic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,29 @@ use tardis::db::sea_orm::sea_query::{ColumnDef, IndexCreateStatement, Table, Tab
use tardis::db::sea_orm::*;

/// Event Topic model
///
/// 事件主题模型
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "event_topic")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
/// 是否保存消息
/// Whether to save messages
///
/// 是否保存消息
pub save_message: bool,
/// 是否需要管理节点
/// Whether a management node is required
///
/// 是否需要管理节点
pub need_mgr: bool,
pub queue_size: i32,
/// 如果 need_mgr 为 false,则在注册时使用该sk
/// If need_mgr is false, this field is used when registering
///
/// 如果 need_mgr 为 false,则在注册时使用该sk
pub use_sk: String,
/// 如果 need_mgr 为 true,则在注册时使用该sk
/// If need_mgr is true, this field is used when registering
///
/// 如果 need_mgr 为 true,则在注册时使用该sk
pub mgr_sk: String,

pub own_paths: String,
Expand Down
6 changes: 3 additions & 3 deletions backend/middlewares/schedule/src/serv/schedule_job_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ fn service() -> Arc<OwnedScheduleTaskServ> {
/// still not good, should manage to merge it with `OwnedScheduleTaskServ::add`
/// same as `delete`
pub(crate) async fn add_or_modify(add_or_modify: ScheduleJobAddOrModifyReq, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> {
let code = &add_or_modify.code.to_string();
let code = add_or_modify.code.to_string();
// if exist delete it first
// 如果存在,先删除
if service().code_uuid.write().await.get(code).is_some() {
delete(code, funs, ctx).await?;
if service().code_uuid.write().await.get(&code).is_some() {
delete(&code, funs, ctx).await?;
}
// 1. log add operation
// 1. 记录添加操作
Expand Down
18 changes: 14 additions & 4 deletions backend/supports/iam/src/basic/domain/iam_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,26 @@ pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
pub icon: String,
// 状态
/// [data type Kind](crate::iam_enumeration::IamAccountStatusKind)
pub status: i16,
/// Marking of temporary status / 临时状态的标记
/// Marking of temporary status
///
/// 临时状态的标记
pub temporary: bool,
/// [data type Kind](crate::iam_enumeration::IamAccountLockStateKind)
pub lock_status: i16,
/// Expanded fields with index / 索引扩展字段 idx 1-3
/// Expanded fields with index
///
/// 索引扩展字段 idx 1-3
#[index]
pub ext1_idx: String,
#[index]
pub ext2_idx: String,
#[index]
pub ext3_idx: String,
/// Expanded fields / 普通扩展字段 4-9
/// Expanded fields
///
/// 普通扩展字段 4-9
pub ext4: String,
pub ext5: String,
pub ext6: String,
Expand All @@ -33,6 +38,11 @@ pub struct Model {
#[sea_orm(extra = "DEFAULT CURRENT_TIMESTAMP")]
pub effective_time: chrono::DateTime<Utc>,

#[sea_orm(extra = "DEFAULT CURRENT_TIMESTAMP")]
pub logout_time: chrono::DateTime<Utc>,
/// [data type Kind](crate::iam_enumeration::IamAccountLogoutTypeKind)
pub logout_type: String,

#[fill_ctx(fill = "own_paths")]
pub own_paths: String,
}
17 changes: 15 additions & 2 deletions backend/supports/iam/src/basic/dto/iam_account_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use std::collections::HashMap;

use serde::{Deserialize, Serialize};
use tardis::basic::field::TrimString;
use tardis::chrono::{DateTime, Utc};
use tardis::chrono::{self, DateTime, Utc};
use tardis::db::sea_orm;
use tardis::web::poem_openapi;

use crate::basic::dto::iam_cert_conf_dto::IamCertConfLdapResp;
use crate::basic::serv::iam_cert_ldap_serv::ldap::LdapSearchResp;
use crate::iam_enumeration::{IamAccountLockStateKind, IamAccountStatusKind};
use crate::iam_enumeration::{IamAccountLockStateKind, IamAccountLogoutTypeKind, IamAccountStatusKind};
use bios_basic::rbum::rbum_enumeration::{RbumCertStatusKind, RbumScopeLevelKind};

#[derive(poem_openapi::Object, Serialize, Deserialize, Debug)]
Expand All @@ -31,6 +31,7 @@ pub struct IamAccountAggAddReq {

pub scope_level: Option<RbumScopeLevelKind>,
pub disabled: Option<bool>,
pub logout_type: Option<IamAccountLogoutTypeKind>,

pub temporary: Option<bool>,

Expand All @@ -48,6 +49,7 @@ pub struct IamAccountAddReq {
pub name: TrimString,
pub scope_level: Option<RbumScopeLevelKind>,
pub disabled: Option<bool>,
pub logout_type: Option<IamAccountLogoutTypeKind>,
pub temporary: Option<bool>,
pub lock_status: Option<IamAccountLockStateKind>,
pub status: Option<IamAccountStatusKind>,
Expand All @@ -61,6 +63,7 @@ pub struct IamAccountAggModifyReq {
pub name: Option<TrimString>,
pub scope_level: Option<RbumScopeLevelKind>,
pub disabled: Option<bool>,
pub logout_type: Option<IamAccountLogoutTypeKind>,
pub temporary: Option<bool>,
pub status: Option<IamAccountStatusKind>,
#[oai(validator(min_length = "2", max_length = "1000"))]
Expand All @@ -83,6 +86,7 @@ pub struct IamAccountModifyReq {
pub name: Option<TrimString>,
pub scope_level: Option<RbumScopeLevelKind>,
pub disabled: Option<bool>,
pub logout_type: Option<IamAccountLogoutTypeKind>,
pub temporary: Option<bool>,
pub lock_status: Option<IamAccountLockStateKind>,

Expand All @@ -97,6 +101,7 @@ pub struct IamAccountSelfModifyReq {
#[oai(validator(min_length = "2", max_length = "255"))]
pub name: Option<TrimString>,
pub disabled: Option<bool>,
pub logout_type: Option<IamAccountLogoutTypeKind>,
// #[oai(validator(min_length = "2", max_length = "1000"))]
pub icon: Option<String>,

Expand All @@ -123,6 +128,8 @@ pub struct IamAccountSummaryResp {

pub scope_level: RbumScopeLevelKind,
pub disabled: bool,
pub logout_time: chrono::DateTime<Utc>,
pub logout_type: String,

pub temporary: bool,
pub lock_status: IamAccountLockStateKind,
Expand All @@ -144,6 +151,8 @@ pub struct IamAccountDetailResp {

pub scope_level: RbumScopeLevelKind,
pub disabled: bool,
pub logout_time: chrono::DateTime<Utc>,
pub logout_type: String,

pub temporary: bool,
pub lock_status: IamAccountLockStateKind,
Expand All @@ -160,6 +169,8 @@ pub struct IamAccountSummaryAggResp {
pub create_time: DateTime<Utc>,
pub update_time: DateTime<Utc>,
pub effective_time: DateTime<Utc>,
pub logout_time: chrono::DateTime<Utc>,
pub logout_type: String,

pub scope_level: RbumScopeLevelKind,
pub disabled: bool,
Expand All @@ -186,6 +197,8 @@ pub struct IamAccountDetailAggResp {
pub create_time: DateTime<Utc>,
pub update_time: DateTime<Utc>,
pub effective_time: DateTime<Utc>,
pub logout_time: chrono::DateTime<Utc>,
pub logout_type: String,

pub scope_level: RbumScopeLevelKind,
pub disabled: bool,
Expand Down
4 changes: 1 addition & 3 deletions backend/supports/iam/src/basic/middleware/encrypt_mw.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashMap;

use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use tardis::web::poem_openapi;
use tardis::{
Expand All @@ -27,13 +26,12 @@ impl Middleware<BoxEndpoint<'static>> for EncryptMW {
type Output = BoxEndpoint<'static>;

fn transform(&self, ep: BoxEndpoint<'static>) -> Self::Output {
Box::new(EncryptMWImpl(ep))
Box::new(poem::endpoint::ToDynEndpoint(EncryptMWImpl(ep)))
}
}

pub struct EncryptMWImpl<E>(E);

#[async_trait]
impl<E: Endpoint> Endpoint for EncryptMWImpl<E> {
type Output = Response;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl IamLogClient {
ctx: &TardisContext,
) -> TardisResult<()> {
let mut content = content.clone();
// find operater info
// find operates info
if let Ok(cert) = IamCertServ::get_cert_detail_by_id_and_kind(ctx.owner.as_str(), &IamCertKernelKind::UserPwd, funs, ctx).await {
content.ak = cert.ak;
content.name = cert.owner_name.unwrap_or("".to_string());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use itertools::Itertools;

use tardis::{
basic::{dto::TardisContext, field::TrimString, result::TardisResult},
chrono::Utc,
db::sea_orm::prelude::DateTimeUtc,
serde_json::json,
tokio, TardisFunsInst,
};
Expand Down Expand Up @@ -180,6 +182,8 @@ impl IamSearchClient {
"icon":account_resp.icon,
"logout_msg":logout_msg,
"disabled":account_resp.disabled,
"logout_time":account_resp.logout_time,
"logout_type":account_resp.logout_type,
"scope_level":account_resp.scope_level
})),
ext_override: Some(true),
Expand Down Expand Up @@ -224,6 +228,8 @@ impl IamSearchClient {
"icon":account_resp.icon,
"logout_msg":logout_msg,
"disabled":account_resp.disabled,
"logout_time":account_resp.logout_time,
"logout_type":account_resp.logout_type,
"scope_level":account_resp.scope_level
})),
visit_keys: Some(SearchItemVisitKeysReq {
Expand Down
Loading

0 comments on commit cb27049

Please sign in to comment.