diff --git a/.github/workflows/iam-release.yml b/.github/workflows/iam-release.yml new file mode 100644 index 000000000..29f1979bf --- /dev/null +++ b/.github/workflows/iam-release.yml @@ -0,0 +1,65 @@ +name: Publish bios-iam crate + +on: + push: + tags: + - 'release-*' + +jobs: + release-all: + runs-on: ubuntu-22.04 + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Init rust environment + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt, clippy + - uses: davidB/rust-cargo-make@v1 + + - name: Cache rust + uses: Swatinem/rust-cache@v2 + + - name: Check format bios-basic + run: cargo fmt -p bios-basic -- --check + - name: Check format bios-iam + run: cargo fmt -p bios-iam -- --check + - name: Check clippy bios-basic + run: cargo clippy -p bios-basic --all-features + - name: Check clippy bios-basic + run: cargo clippy -p bios-basic --no-default-features + - name: Check clippy bios-iam + run: cargo clippy -p bios-iam --all-features + - name: Cargo login z + run: cargo login ${{ secrets.CRATES_TOKEN }} + - name: Package and Release + if: ${{ startsWith(github.ref, 'refs/tags/release') }} + run: cargo make publish-bios-iam + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # if set to "true" but frees about 6 GB + tool-cache: false + + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + docker-images: false + swap-storage: false + android: true + dotnet: true + haskell: true + large-packages: true + + - name: Upload to codecov.io + uses: codecov/codecov-action@v2 + with: + token: ${{secrets.CODECOV_TOKEN}} + + - name: Archive code coverage results + uses: actions/upload-artifact@v3 + with: + name: code-coverage-report + path: cobertura.xml diff --git a/Cargo.toml b/Cargo.toml index bb481df29..5202325f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ members = [ ] resolver = "2" [workspace.package] -version = "0.1.0" +version = "0.2.0" authors = [ "gudaoxuri ", "hermitCode <17743125563@163.com>", @@ -54,7 +54,7 @@ serde = { version = "1", features = ["derive"] } serde_json = { version = "1" } async-trait = { version = "0.1" } lazy_static = { version = "1" } -itertools = { version = "0" } +itertools = { version = "0.13" } fancy-regex = { version = "0" } run_script = { version = "0.10" } rust_decimal = { version = "1" } @@ -63,19 +63,21 @@ testcontainers-modules = { version = "0.11", features = ["redis"] } strum = { version = "0.26", features = ["derive"] } # tardis tardis = { version = "0.1.0-rc.17" } -# tardis = { path = "../tardis/tardis" } +# tardis = { version = "0.2.0", path = "../tardis/tardis" } # tardis = { git = "https://github.com/ideal-world/tardis.git", rev = "9cc9b3e" } # asteroid-mq = { git = "https://github.com/4t145/asteroid-mq.git", rev = "d59c64d" } -asteroid-mq = { git = "https://github.com/4t145/asteroid-mq.git", rev = "83a6643" } -asteroid-mq-sdk = { git = "https://github.com/4t145/asteroid-mq.git", rev = "83a6643" } +# asteroid-mq = { git = "https://github.com/4t145/asteroid-mq.git", rev = "83a6643" } +asteroid-mq = { version = "0.1.0-alpha.3" } +# asteroid-mq-sdk = { git = "https://github.com/4t145/asteroid-mq.git", rev = "83a6643" } +asteroid-mq-sdk = { version = "0.1.0-alpha.3" } #spacegate -# spacegate-shell = { path = "../spacegate/crates/shell", features = [ +# spacegate-shell = { version = "0.2.0", path = "../spacegate/crates/shell", features = [ # "cache", # "k8s", # "ext-axum", # ] } -spacegate-shell = { git = "https://github.com/ideal-world/spacegate.git", branch = "master", features = [ +spacegate-shell = { version="0.2.0-alpha.2", features = [ "cache", "k8s", "ext-axum", diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 000000000..0a369262d --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,59 @@ +# ref: https://sagiegurari.github.io/cargo-make/ +[env] +CARGO_MAKE_PROJECT_VERSION = "0.2.0" +PUBLISH_SCRIPT = "build-scripts/publish.sh" + +[tasks.package-bios-basic] +workspace = false +command = "cargo" +args = ["package", "-p", "bios-basic"] + +[tasks.publish-bios-basic] +dependencies = ["publish-bios-sdk-invoke", "package-bios-basic"] +workspace = false +command = "bash" +args = ["${PUBLISH_SCRIPT}", "${CARGO_MAKE_PROJECT_VERSION}", "bios-basic"] + +[tasks.package-bios-iam] +workspace = false +command = "cargo" +args = ["package", "-p", "bios-iam"] + +[tasks.publish-bios-iam] +dependencies = ["publish-bios-basic"] +workspace = false +command = "bash" +args = ["${PUBLISH_SCRIPT}", "${CARGO_MAKE_PROJECT_VERSION}", "bios-iam"] + + +[tasks.package-simple-invoke-client-macro] +workspace = false +command = "cargo" +args = ["package", "-p", "simple-invoke-client-macro"] + +[tasks.publish-simple-invoke-client-macro] +workspace = false +command = "bash" +args = [ + "${PUBLISH_SCRIPT}", + "${CARGO_MAKE_PROJECT_VERSION}", + "simple-invoke-client-macro", +] + +[tasks.package-bios-sdk-invoke] +workspace = false +command = "cargo" +args = ["package", "-p", "bios-sdk-invoke"] + +[tasks.publish-bios-sdk-invoke] +dependencies = ["publish-simple-invoke-client-macro"] +workspace = false +command = "bash" +args = ["${PUBLISH_SCRIPT}", "${CARGO_MAKE_PROJECT_VERSION}", "bios-sdk-invoke"] + + +[tasks.publish] +dependencies = ["publish-bios-iam"] +workspace = false +command = "echo" +args = ["Publishing completed!"] \ No newline at end of file diff --git a/backend/basic/Cargo.toml b/backend/basic/Cargo.toml index 9931aa0ac..703e0d3e7 100644 --- a/backend/basic/Cargo.toml +++ b/backend/basic/Cargo.toml @@ -15,19 +15,11 @@ name = "bios_basic" path = "src/lib.rs" [features] -default = [ - "tardis", - "tardis/crypto", - "tardis/web-server", - "tardis/web-client", - "tardis/reldb-postgres", - "tardis/cache", - "tardis/mq", -] +default = [] # TODO remvoe -with-mq = ["tardis/mq"] -sdk = ["tardis", "tardis/web-client"] -test = ["tardis/test"] +with-mq = ["tardis/mq", "bios-sdk-invoke"] +sdk = ["tardis/web-client"] +test = ["tardis/test", "testcontainers-modules"] [dependencies] serde.workspace = true @@ -36,14 +28,14 @@ async-recursion.workspace = true lazy_static.workspace = true itertools.workspace = true fancy-regex.workspace = true -tardis = { workspace = true, optional = true } +tardis = { workspace = true, features = ["crypto", "reldb-postgres", "cache", "web-server", "web-client"] } strum = { workspace = true } -testcontainers-modules = { workspace = true, features = ["redis"] } -bios-sdk-invoke = { path = "../../frontend/sdks/invoke", features = ["default"] } +testcontainers-modules = { workspace = true, features = ["redis"], optional = true } +bios-sdk-invoke = { version = "0.2.0", path = "../../frontend/sdks/invoke", features = ["default"], optional = true } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -bios-sdk-invoke = { path = "../../frontend/sdks/invoke", features = ["default"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../frontend/sdks/invoke", features = ["default"] } [[test]] name = "test_rbum" diff --git a/backend/basic/src/dto.rs b/backend/basic/src/dto.rs index 8eff5b819..4731529bd 100644 --- a/backend/basic/src/dto.rs +++ b/backend/basic/src/dto.rs @@ -7,14 +7,14 @@ use serde::{Deserialize, Serialize}; use tardis::{basic::result::TardisResult, serde_json::Value}; use crate::enumeration::BasicQueryOpKind; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; /// Basic query condition object /// /// 基础的查询条件对象 #[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct BasicQueryCondInfo { /// Query field #[oai(validator(min_length = "1"))] diff --git a/backend/basic/src/enumeration.rs b/backend/basic/src/enumeration.rs index d963288a3..1d669c537 100644 --- a/backend/basic/src/enumeration.rs +++ b/backend/basic/src/enumeration.rs @@ -1,14 +1,14 @@ //! Basic enumerations use serde::{Deserialize, Serialize}; use strum::Display; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; /// API classification /// /// API分类 #[derive(Display, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Tags))] +#[derive(poem_openapi::Tags)] pub enum ApiTag { /// Common Console, mostly starting with ``cc``, generally do not require authentication. /// @@ -46,7 +46,7 @@ pub enum ApiTag { /// /// 基础查询操作符 #[derive(Display, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "default", derive(poem_openapi::Enum))] +#[derive(poem_openapi::Enum)] pub enum BasicQueryOpKind { #[oai(rename = "=")] Eq, diff --git a/backend/basic/src/helper.rs b/backend/basic/src/helper.rs index 4e5b9ea35..a252922d9 100644 --- a/backend/basic/src/helper.rs +++ b/backend/basic/src/helper.rs @@ -1,4 +1,4 @@ -#[cfg(feature = "default")] + pub mod db_helper; -#[cfg(feature = "default")] + pub mod request_helper; diff --git a/backend/basic/src/lib.rs b/backend/basic/src/lib.rs index c77384a88..bb6ea9c77 100644 --- a/backend/basic/src/lib.rs +++ b/backend/basic/src/lib.rs @@ -45,7 +45,7 @@ pub trait TardisFunInstExtractor { /// otherwise use the default configuration parameter. /// /// 从请求路径中找到第一个路径段作为服务域名,如果存在与该服务域名同名的配置参数 ``csm.X``, 则使用该配置参数,否则使用默认配置参数. -#[cfg(feature = "default")] + impl TardisFunInstExtractor for tardis::web::poem::Request { fn tardis_fun_inst(&self) -> TardisFunsInst { let serv_domain = self.original_uri().path().split('/').collect::>()[1]; diff --git a/backend/basic/src/process/task_processor.rs b/backend/basic/src/process/task_processor.rs index 14cf8eda0..f8b854e76 100644 --- a/backend/basic/src/process/task_processor.rs +++ b/backend/basic/src/process/task_processor.rs @@ -1,14 +1,14 @@ //! Async task processor //! //! 异步任务处理器 -use std::{collections::HashMap, future::Future, sync::Arc}; - +#[cfg(feature = "with-mq")] use bios_sdk_invoke::clients::event_client::{ asteroid_mq::prelude::{EventAttribute, Subject, TopicCode}, - get_topic, EventAttributeExt, + get_topic, }; use lazy_static::lazy_static; -use serde::{Deserialize, Serialize}; + +use std::{collections::HashMap, future::Future, sync::Arc}; use tardis::{ basic::{dto::TardisContext, error::TardisError, result::TardisResult}, cache::cache_client::TardisCacheClient, @@ -24,6 +24,7 @@ lazy_static! { } const TASK_PROCESSOR_DATA_EX_SEC: u64 = 60 * 60 * 24; const TASK_IN_CTX_FLAG: &str = "task_id"; +#[cfg(feature = "with-mq")] const TASK_TOPIC: TopicCode = TopicCode::const_new("task"); /// Set task status event flag /// 设置任务状态事件标识 @@ -101,11 +102,12 @@ impl TaskProcessor { task_id: u64, status: bool, cache_client: &TardisCacheClient, - from_avatar: String, - to_avatars: Option>, + _from_avatar: String, + _to_avatars: Option>, ) -> TardisResult<()> { Self::set_status(cache_key, task_id, status, cache_client).await?; - if let Some(topic) = get_topic(&TASK_TOPIC) { + #[cfg(feature = "with-mq")] + if let Some(_topic) = get_topic(&TASK_TOPIC) { // todo: broadcast event to users // topic // .send_event( @@ -138,11 +140,12 @@ impl TaskProcessor { task_id: u64, data: Value, cache_client: &TardisCacheClient, - from_avatar: String, - to_avatars: Option>, + _from_avatar: String, + _to_avatars: Option>, ) -> TardisResult<()> { Self::set_process_data(cache_key, task_id, data.clone(), cache_client).await?; - if let Some(topic) = get_topic(&TASK_TOPIC) { + #[cfg(feature = "with-mq")] + if let Some(_topic) = get_topic(&TASK_TOPIC) { // todo: broadcast event to users } Ok(()) @@ -203,8 +206,8 @@ impl TaskProcessor { let cache_client_clone = cache_client.clone(); let task_id = TaskProcessor::init_status(cache_key, None, cache_client).await?; let cache_key = cache_key.to_string(); - let from_avatar_clone = from_avatar.clone(); - let to_avatars_clone = to_avatars.clone(); + let _from_avatar_clone = from_avatar.clone(); + let _to_avatars_clone = to_avatars.clone(); let handle = tardis::tokio::spawn(async move { let result = process_fun(task_id).await; match result { @@ -218,7 +221,8 @@ impl TaskProcessor { } }); TASK_HANDLE.write().await.insert(task_id, handle); - if let Some(topic) = get_topic(&TASK_TOPIC) { + #[cfg(feature = "with-mq")] + if let Some(_topic) = get_topic(&TASK_TOPIC) { // todo: broadcast event to users } if let Some(ctx) = ctx { @@ -238,11 +242,12 @@ impl TaskProcessor { cache_key: &str, task_id: u64, cache_client: &Arc, - from_avatar: String, - to_avatars: Option>, + _from_avatar: String, + _to_avatars: Option>, ) -> TardisResult { let task_id = TaskProcessor::init_status(cache_key, Some(task_id), cache_client).await?; - if let Some(topic) = get_topic(&TASK_TOPIC) { + #[cfg(feature = "with-mq")] + if let Some(_topic) = get_topic(&TASK_TOPIC) { // todo: broadcast event to users } Ok(task_id) @@ -289,34 +294,37 @@ impl TaskProcessor { ctx.get_ext(TASK_IN_CTX_FLAG).await } } - -#[derive(Clone, Debug, Deserialize, Serialize)] +#[cfg(feature = "with-mq")] +#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] struct TaskSetStatusEventReq { pub task_id: u64, pub data: bool, pub msg: String, } - -#[derive(Clone, Debug, Deserialize, Serialize)] +#[cfg(feature = "with-mq")] +#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] struct TaskSetProcessDataEventReq { pub task_id: u64, pub data: Value, pub msg: String, } - -#[derive(Clone, Debug, Deserialize, Serialize)] +#[cfg(feature = "with-mq")] +#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] struct TaskExecuteEventReq { pub task_id: u64, pub msg: String, } +#[cfg(feature = "with-mq")] impl EventAttribute for TaskSetStatusEventReq { const SUBJECT: Subject = Subject::const_new(EVENT_SET_TASK_STATUS_FLAG); } +#[cfg(feature = "with-mq")] impl EventAttribute for TaskSetProcessDataEventReq { const SUBJECT: Subject = Subject::const_new(EVENT_SET_TASK_PROCESS_DATA_FLAG); } +#[cfg(feature = "with-mq")] impl EventAttribute for TaskExecuteEventReq { const SUBJECT: Subject = Subject::const_new(EVENT_EXECUTE_TASK_FLAG); diff --git a/backend/basic/src/rbum.rs b/backend/basic/src/rbum.rs index 605141c50..c3973cbc3 100644 --- a/backend/basic/src/rbum.rs +++ b/backend/basic/src/rbum.rs @@ -1,10 +1,10 @@ -#[cfg(feature = "default")] + pub(crate) mod domain; pub mod dto; pub mod helper; pub mod rbum_config; pub mod rbum_enumeration; -#[cfg(feature = "default")] + pub mod rbum_initializer; -#[cfg(feature = "default")] + pub mod serv; diff --git a/backend/basic/src/rbum/dto/rbum_cert_conf_dto.rs b/backend/basic/src/rbum/dto/rbum_cert_conf_dto.rs index 56132d4cc..7f35b4cae 100644 --- a/backend/basic/src/rbum/dto/rbum_cert_conf_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_cert_conf_dto.rs @@ -1,9 +1,9 @@ use serde::{Deserialize, Serialize}; use tardis::basic::field::TrimString; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::RbumCertConfStatusKind; @@ -12,7 +12,7 @@ use crate::rbum::rbum_enumeration::RbumCertConfStatusKind; /// /// 凭证配置添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumCertConfAddReq { /// Certificate configuration type /// @@ -21,7 +21,7 @@ pub struct RbumCertConfAddReq { /// Used for the classification of certificates, such as: ldap, userpwd, token, oauth2, etc. /// /// 用于凭证的分类,比如:ldap、userpwd、token、oauth2等。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub kind: TrimString, /// Certificate configuration supplier /// @@ -31,17 +31,17 @@ pub struct RbumCertConfAddReq { /// For example, the certificate of type oauth2 can be further refined into WeChat oauth2, QQ oauth2, Weibo oauth2, etc. /// /// 一种凭证类型可以有多个供应商。比如 oauth2 类型的凭证,可以进一步细化成 微信oauth2、QQ oauth2、微博 oauth2 等。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub supplier: Option, /// Certificate configuration name /// /// 凭证配置名称 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: TrimString, /// Certificate configuration description /// /// 凭证配置描述 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub note: Option, /// Certificate configuration ak rule(verification regular expression) /// @@ -57,12 +57,12 @@ pub struct RbumCertConfAddReq { /// # 什么是``AK`` /// /// 对于用户名密码类型的凭证,``AK``指的是用户名;对于token类型的凭证,``AK``为空;对于oauth2类型(授权码模式)的凭证,``AK``指的是client_id值;对于手机号验证码类型的凭证,``AK``指的是手机号等。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub ak_rule: Option, /// Certificate configuration ak rule description /// /// 凭证配置ak规则的描述 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub ak_note: Option, /// Certificate configuration sk rule(verification regular expression) /// @@ -78,12 +78,12 @@ pub struct RbumCertConfAddReq { /// # 什么是``SK`` /// /// 对于用户名密码类型的凭证,``SK``指的是用户名;对于token类型的凭证,``SK``指的是token值;对于oauth2类型(授权码模式)的凭证,``SK``为access token值;对于手机号验证码类型的凭证,``SK``为空等。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub sk_rule: Option, /// Certificate configuration sk rule description /// /// 凭证配置sk规则的描述 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub sk_note: Option, /// Certificate configuration extension information /// @@ -173,7 +173,7 @@ pub struct RbumCertConfAddReq { /// Multiple values are separated by commas. /// /// 多个值用逗号分隔。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub rest_by_kinds: Option, /// The expiration time of the sk /// @@ -182,7 +182,7 @@ pub struct RbumCertConfAddReq { /// Default is ``1 year`` /// /// 默认为 ``1年`` - #[cfg_attr(feature = "default", oai(validator(minimum(value = "1", exclusive = "false"))))] + #[oai(validator(minimum(value = "1", exclusive = "false")))] pub expire_sec: Option, /// The maximum number of errors that sk can be locked, and it will be locked if it exceeds this number /// @@ -195,7 +195,7 @@ pub struct RbumCertConfAddReq { /// WARING: If an object (such as a user) is bound to multiple credential configurations, and these credential configurations have different sk_lock_err_times, it may be based on the maximum. /// /// WARING: 如果某个对象(比如用户)绑定了多个凭证配置,且这些凭证配置了不同的sk_lock_err_times,那有可能会以最大的为准。 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))] + #[oai(validator(minimum(value = "0", exclusive = "false")))] pub sk_lock_err_times: Option, /// sk lock duration /// @@ -204,7 +204,7 @@ pub struct RbumCertConfAddReq { /// Only valid when ``sk_lock_err_times`` is greater than ``0`` . /// /// 仅在``sk_lock_err_times``大于 ``0`` 时有效。 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "1", exclusive = "false"))))] + #[oai(validator(minimum(value = "1", exclusive = "false")))] pub sk_lock_duration_sec: Option, /// sk validation error count cycle /// @@ -217,7 +217,7 @@ pub struct RbumCertConfAddReq { /// Only valid when ``sk_lock_err_times`` is greater than ``0`` . /// /// 仅在``sk_lock_err_times``大于 ``0`` 时有效。 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "1", exclusive = "false"))))] + #[oai(validator(minimum(value = "1", exclusive = "false")))] pub sk_lock_cycle_sec: Option, /// The number of certificates in effect at the same time /// @@ -247,7 +247,7 @@ pub struct RbumCertConfAddReq { /// For example, the authentication address of oauth2, the database connection address, etc. /// /// 比如oauth2的认证地址、数据库连接地址等。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub conn_uri: Option, /// Credential configuration status /// @@ -256,12 +256,12 @@ pub struct RbumCertConfAddReq { /// Associated [resource domain](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id /// /// 关联的[资源域](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_domain_id: String, /// Associated [resource item](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id /// /// 关联的[资源项](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_item_id: Option, } @@ -269,17 +269,17 @@ pub struct RbumCertConfAddReq { /// /// 凭证配置修改请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumCertConfModifyReq { /// Certificate configuration name /// /// 凭证配置名称 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: Option, /// Certificate configuration description /// /// 凭证配置描述 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub note: Option, /// Certificate configuration ak rule(verification regular expression) /// @@ -295,12 +295,12 @@ pub struct RbumCertConfModifyReq { /// # 什么是``AK`` /// /// 对于用户名密码类型的凭证,``AK``指的是用户名;对于token类型的凭证,``AK``为空;对于oauth2类型(授权码模式)的凭证,``AK``指的是client_id值;对于手机号验证码类型的凭证,``AK``指的是手机号等。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub ak_rule: Option, /// Certificate configuration ak rule description /// /// 凭证配置ak规则的描述 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub ak_note: Option, /// Certificate configuration sk rule(verification regular expression) /// @@ -316,12 +316,12 @@ pub struct RbumCertConfModifyReq { /// # 什么是``SK`` /// /// 对于用户名密码类型的凭证,``SK``指的是用户名;对于token类型的凭证,``SK``指的是token值;对于oauth2类型(授权码模式)的凭证,``SK``为access token值;对于手机号验证码类型的凭证,``SK``为空等。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub sk_rule: Option, /// Certificate configuration sk rule description /// /// 凭证配置sk规则的描述 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub sk_note: Option, /// Certificate configuration extension information /// @@ -375,12 +375,12 @@ pub struct RbumCertConfModifyReq { /// Multiple values are separated by commas. /// /// 多个值用逗号分隔。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub rest_by_kinds: Option, /// The expiration time of the sk /// /// sk的过期时间 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "1", exclusive = "false"))))] + #[oai(validator(minimum(value = "1", exclusive = "false")))] pub expire_sec: Option, /// The maximum number of errors that sk can be locked, and it will be locked if it exceeds this number /// @@ -389,12 +389,12 @@ pub struct RbumCertConfModifyReq { /// WARING: If an object (such as a user) is bound to multiple credential configurations, and these credential configurations have different sk_lock_err_times, it may be based on the maximum. /// /// WARING: 如果某个对象(比如用户)绑定了多个凭证配置,且这些凭证配置了不同的sk_lock_err_times,那有可能会以最大的为准。 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))] + #[oai(validator(minimum(value = "0", exclusive = "false")))] pub sk_lock_err_times: Option, /// sk lock duration /// /// sk被锁定的持续时间 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "1", exclusive = "false"))))] + #[oai(validator(minimum(value = "1", exclusive = "false")))] pub sk_lock_duration_sec: Option, /// sk validation error count cycle /// @@ -403,7 +403,7 @@ pub struct RbumCertConfModifyReq { /// If the time of the last error is greater than this cycle, the count is reset. /// /// 如果上次发生错误的时间大于此周期,则重新计数。 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "1", exclusive = "false"))))] + #[oai(validator(minimum(value = "1", exclusive = "false")))] pub sk_lock_cycle_sec: Option, /// The number of certificates in effect at the same time /// @@ -429,7 +429,7 @@ pub struct RbumCertConfModifyReq { /// For example, the authentication address of oauth2, the database connection address, etc. /// /// 比如oauth2的认证地址、数据库连接地址等。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub conn_uri: Option, /// Credential configuration status /// @@ -443,7 +443,7 @@ pub struct RbumCertConfModifyReq { /// /// 凭证配置概要信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumCertConfSummaryResp { /// Certificate configuration id /// @@ -544,7 +544,7 @@ pub struct RbumCertConfSummaryResp { /// /// 凭证配置详细信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumCertConfDetailResp { /// Certificate configuration id /// @@ -663,7 +663,7 @@ pub struct RbumCertConfDetailResp { /// /// 凭证配置id和扩展信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumCertConfIdAndExtResp { /// Certificate configuration id /// diff --git a/backend/basic/src/rbum/dto/rbum_cert_dto.rs b/backend/basic/src/rbum/dto/rbum_cert_dto.rs index a6d4b685c..b4ad44b70 100644 --- a/backend/basic/src/rbum/dto/rbum_cert_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_cert_dto.rs @@ -1,9 +1,9 @@ use serde::{Deserialize, Serialize}; use tardis::basic::field::TrimString; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::{RbumCertRelKind, RbumCertStatusKind}; @@ -12,21 +12,21 @@ use crate::rbum::rbum_enumeration::{RbumCertRelKind, RbumCertStatusKind}; /// /// 凭证添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumCertAddReq { /// Certification access key /// /// 凭证名 /// /// see [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfAddReq::ak_rule`] - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub ak: TrimString, /// Certification secret key /// /// 凭证密钥 /// /// see [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfAddReq::sk_rule`] - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "10000")))] + #[oai(validator(min_length = "2", max_length = "10000"))] pub sk: Option, /// Whether to hide the sk /// @@ -75,7 +75,7 @@ pub struct RbumCertAddReq { /// Different from [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfAddReq::ext`], this field is used to identify the specific extension information of the certificate. /// /// 与 [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfAddReq::ext`] 不同,此字段用于标识该条凭证的特有的扩展信息。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub ext: Option, /// Certificate effective time /// @@ -103,7 +103,7 @@ pub struct RbumCertAddReq { /// Different from [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfAddReq::conn_uri`], this field is used to identify the specific connection address of the certificate. /// /// 与 [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfAddReq::conn_uri`] 不同,此字段用于标识该条凭证的特有的连接地址。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub conn_uri: Option, /// Credential status /// @@ -121,13 +121,13 @@ pub struct RbumCertAddReq { /// NOTE: 仅当 [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfAddReq::sk_dynamic`] 为 ``true`` 时有效。 /// /// NOTE: 此字段不可与 ``sk`` 字段同时存在。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub vcode: Option, /// Associated [cert configuration](crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfDetailResp) id /// /// 关联的[凭证配置](crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfDetailResp)id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_cert_conf_id: Option, /// Associated [resource kind](crate::rbum::rbum_enumeration::RbumCertRelKind) /// @@ -160,7 +160,7 @@ pub struct RbumCertAddReq { /// /// * 如果 rel_rbum_kind == Rel /// - 在 CMDB 服务中,一个资源可以被切片(比如 DB 实例),我们可以指定关联的切片信息 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_id: String, /// Whether ``rel_rbum_id`` is an external value /// @@ -176,21 +176,21 @@ pub struct RbumCertAddReq { /// /// 凭证修改请求 #[derive(Serialize, Deserialize, Debug, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumCertModifyReq { /// Certification access key /// /// 凭证名 /// /// see [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfModifyReq::ak_rule`] - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub ak: Option, /// Certification secret key /// /// 凭证密钥 /// /// see [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfAddReq::sk_rule`] - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "10000")))] + #[oai(validator(min_length = "2", max_length = "10000"))] pub sk: Option, /// Whether to hide the sk /// @@ -219,7 +219,7 @@ pub struct RbumCertModifyReq { /// Different from [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfModifyReq::ext`], this field is used to identify the specific extension information of the certificate. /// /// 与 [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfModifyReq::ext`] 不同,此字段用于标识该条凭证的特有的扩展信息。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub ext: Option, /// Certificate effective time /// @@ -236,7 +236,7 @@ pub struct RbumCertModifyReq { /// Different from [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfModifyReq::conn_uri`], this field is used to identify the specific connection address of the certificate. /// /// 与 [`crate::rbum::dto::rbum_cert_conf_dto::RbumCertConfModifyReq::conn_uri`] 不同,此字段用于标识该条凭证的特有的连接地址。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub conn_uri: Option, /// Credential status /// @@ -248,7 +248,7 @@ pub struct RbumCertModifyReq { /// /// 凭证概要信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumCertSummaryResp { /// Certification id /// @@ -310,7 +310,7 @@ pub struct RbumCertSummaryResp { /// /// 带有密钥的凭证概要信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumCertSummaryWithSkResp { /// Certification id /// @@ -384,7 +384,7 @@ pub struct RbumCertSummaryWithSkResp { /// /// 凭证详细信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumCertDetailResp { /// Certification id /// diff --git a/backend/basic/src/rbum/dto/rbum_domain_dto.rs b/backend/basic/src/rbum/dto/rbum_domain_dto.rs index 69d19fe93..7c316a156 100644 --- a/backend/basic/src/rbum/dto/rbum_domain_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_domain_dto.rs @@ -1,9 +1,9 @@ use serde::{Deserialize, Serialize}; use tardis::basic::field::TrimString; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::RbumScopeLevelKind; @@ -12,7 +12,7 @@ use crate::rbum::rbum_enumeration::RbumScopeLevelKind; /// /// 资源域添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumDomainAddReq { /// Resource domain code /// @@ -25,22 +25,22 @@ pub struct RbumDomainAddReq { /// Which is required to conform to the host specification in the uri, matching the regular: ^[a-z0-9-.]+$. /// /// 需要符合uri中的host规范,匹配正则:^[a-z0-9-.]+$。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub code: TrimString, /// Resource domain name /// /// 资源域名称 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: TrimString, /// Resource domain note /// /// 资源域备注 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub note: Option, /// Resource domain icon /// /// 资源域图标 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub icon: Option, /// Resource domain sort /// @@ -54,22 +54,22 @@ pub struct RbumDomainAddReq { /// /// 资源域修改请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumDomainModifyReq { /// Resource domain name /// /// 资源域名称 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: Option, /// Resource domain note /// /// 资源域备注 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub note: Option, /// Resource domain icon /// /// 资源域图标 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub icon: Option, /// Resource domain sort /// @@ -89,7 +89,7 @@ pub struct RbumDomainModifyReq { /// /// 资源域概要信息 #[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumDomainSummaryResp { /// Resource domain id /// @@ -124,7 +124,7 @@ pub struct RbumDomainSummaryResp { /// /// 资源域详细信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumDomainDetailResp { /// Resource domain id /// diff --git a/backend/basic/src/rbum/dto/rbum_filer_dto.rs b/backend/basic/src/rbum/dto/rbum_filer_dto.rs index 8a416fd19..31f86f24c 100644 --- a/backend/basic/src/rbum/dto/rbum_filer_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_filer_dto.rs @@ -3,7 +3,7 @@ use std::default::Default; use serde::{Deserialize, Serialize}; use tardis::basic::field::TrimString; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::{RbumCertConfStatusKind, RbumCertRelKind, RbumCertStatusKind, RbumRelFromKind, RbumScopeLevelKind, RbumSetCateLevelQueryKind}; @@ -12,7 +12,7 @@ use crate::rbum::rbum_enumeration::{RbumCertConfStatusKind, RbumCertRelKind, Rbu /// /// 资源基础过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumBasicFilterReq { /// Whether to ignore the scope @@ -81,7 +81,7 @@ pub struct RbumBasicFilterReq { /// /// 资源凭证配置过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumCertConfFilterReq { /// Basic filter @@ -114,7 +114,7 @@ pub struct RbumCertConfFilterReq { /// /// 资源凭证过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumCertFilterReq { /// Basic filter @@ -175,7 +175,7 @@ pub struct RbumCertFilterReq { /// /// 资源类型过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumKindFilterReq { /// Basic filter @@ -192,7 +192,7 @@ pub struct RbumKindFilterReq { /// /// 资源类型属性过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumKindAttrFilterReq { /// Basic filter @@ -213,7 +213,7 @@ pub struct RbumKindAttrFilterReq { /// /// 资源项属性过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumItemAttrFilterReq { /// Basic filter @@ -234,7 +234,7 @@ pub struct RbumItemAttrFilterReq { /// /// 资源关联过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumRelFilterReq { /// Basic filter @@ -283,7 +283,7 @@ pub struct RbumRelFilterReq { /// /// 资源关联扩展过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumRelExtFilterReq { /// Basic filter @@ -300,7 +300,7 @@ pub struct RbumRelExtFilterReq { /// /// 资源集过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetFilterReq { /// Basic filter /// @@ -320,7 +320,7 @@ pub struct RbumSetFilterReq { /// /// 资源集分类(节点)过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetCateFilterReq { /// Basic filter /// @@ -364,7 +364,7 @@ pub struct RbumSetCateFilterReq { /// /// 资源集分类(节点)挂载资源项的过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetItemFilterReq { /// Basic filter /// @@ -435,7 +435,7 @@ pub struct RbumSetItemFilterReq { /// /// 资源集过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetTreeFilterReq { /// Resource category (node) sys_codes /// @@ -510,7 +510,8 @@ pub struct RbumSetTreeFilterReq { /// Resource set category (node) associated filter for mounted resource items /// /// 资源集分类(节点)挂载资源项的关联过滤器 -#[derive(poem_openapi::Object, Serialize, Deserialize, Debug, Clone, Default)] +#[derive(Serialize, Deserialize, Debug, Clone, Default)] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumSetItemRelFilterReq { /// Resource set id and resource category (node) id set @@ -535,7 +536,7 @@ pub struct RbumSetItemRelFilterReq { /// /// 简单的资源项关联过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumItemRelSimpleFilterReq { /// Whether the related party is a ``from`` party @@ -560,7 +561,7 @@ pub struct RbumItemRelSimpleFilterReq { /// /// 资源项关联过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumItemRelFilterReq { /// Is it optional @@ -625,7 +626,7 @@ pub trait RbumItemFilterFetcher { /// /// 资源项基础过滤器 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumItemBasicFilterReq { /// Basic filter diff --git a/backend/basic/src/rbum/dto/rbum_item_attr_dto.rs b/backend/basic/src/rbum/dto/rbum_item_attr_dto.rs index aa10c33ba..bdbd16c2b 100644 --- a/backend/basic/src/rbum/dto/rbum_item_attr_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_item_attr_dto.rs @@ -2,31 +2,31 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; /// Add request for resource item extended attribute value /// /// 资源项扩展属性值添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumItemAttrAddReq { /// Extended attribute value /// /// 扩展属性值 - #[cfg_attr(feature = "default", oai(validator(min_length = "1", max_length = "2000")))] + #[oai(validator(min_length = "1", max_length = "2000"))] pub value: String, /// Associated [resource item](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id /// /// 关联的[资源项](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_item_id: String, /// Associated [resource kind attribute definition](crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp) id /// /// 关联的[资源类型属性定义](crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_kind_attr_id: String, } @@ -34,12 +34,12 @@ pub struct RbumItemAttrAddReq { /// /// 资源项扩展属性值修改请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumItemAttrModifyReq { /// Extended attribute value /// /// 扩展属性值 - #[cfg_attr(feature = "default", oai(validator(min_length = "1", max_length = "2000")))] + #[oai(validator(min_length = "1", max_length = "2000"))] pub value: String, } @@ -47,7 +47,7 @@ pub struct RbumItemAttrModifyReq { /// /// 批量添加或修改资源项扩展属性值请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumItemAttrsAddOrModifyReq { /// Add or modify value collection /// @@ -60,7 +60,7 @@ pub struct RbumItemAttrsAddOrModifyReq { /// Associated [resource item](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id /// /// 关联的[资源项](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_item_id: String, } @@ -68,7 +68,7 @@ pub struct RbumItemAttrsAddOrModifyReq { /// /// 源项扩展属性值概要信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumItemAttrSummaryResp { /// Extended attribute value id /// @@ -101,7 +101,7 @@ pub struct RbumItemAttrSummaryResp { /// /// 源项扩展属性值详细信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumItemAttrDetailResp { /// Extended attribute value id /// diff --git a/backend/basic/src/rbum/dto/rbum_item_dto.rs b/backend/basic/src/rbum/dto/rbum_item_dto.rs index b40963756..6509e9def 100644 --- a/backend/basic/src/rbum/dto/rbum_item_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_item_dto.rs @@ -1,9 +1,9 @@ use serde::{Deserialize, Serialize}; use tardis::basic::field::TrimString; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::RbumScopeLevelKind; @@ -12,32 +12,32 @@ use crate::rbum::rbum_enumeration::RbumScopeLevelKind; /// /// 资源项添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumItemAddReq { /// Resource item id /// /// 资源项id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub id: Option, /// Resource item code /// /// 资源项编码 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub code: Option, /// Resource item name /// /// 资源项名称 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: TrimString, /// Associated [resource kind](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id /// /// 关联的[资源类型](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_kind_id: String, /// Associated [resource domain](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id /// /// 关联的[资源域](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_domain_id: String, pub scope_level: Option, @@ -140,7 +140,7 @@ pub struct RbumItemKernelModifyReq { /// /// 资源项概要信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumItemSummaryResp { /// Resource item id /// @@ -176,7 +176,7 @@ pub struct RbumItemSummaryResp { /// /// 资源项详细信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumItemDetailResp { /// Resource item id /// diff --git a/backend/basic/src/rbum/dto/rbum_kind_attr_dto.rs b/backend/basic/src/rbum/dto/rbum_kind_attr_dto.rs index 1872546d0..46e4d90c5 100644 --- a/backend/basic/src/rbum/dto/rbum_kind_attr_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_kind_attr_dto.rs @@ -1,9 +1,9 @@ use serde::{Deserialize, Serialize}; use tardis::basic::field::TrimString; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::{RbumDataTypeKind, RbumScopeLevelKind, RbumWidgetTypeKind}; @@ -12,7 +12,7 @@ use crate::rbum::rbum_enumeration::{RbumDataTypeKind, RbumScopeLevelKind, RbumWi /// /// 资源类型属性定义添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumKindAttrAddReq { /// Attribute definition module /// @@ -26,7 +26,7 @@ pub struct RbumKindAttrAddReq { /// For example, the ``user`` kind resource, different tenants can have different Attribute definitions. /// /// 用于区别使用同一资源类型的不同实例。比如 ``用户`` 类型的资源,不同的租户可以有不同的属性定义。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub module: Option, /// Attribute definition name /// @@ -35,7 +35,7 @@ pub struct RbumKindAttrAddReq { /// Corresponds to the field name, such as ```` . /// /// 多对应于字段名,如 ```` 。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: TrimString, /// Attribute definition label /// @@ -44,12 +44,12 @@ pub struct RbumKindAttrAddReq { /// Corresponds to the field label, such as ```` . /// /// 多对应于字段标签,如 ```` 。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub label: String, /// Attribute definition note /// /// 属性定义备注 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub note: Option, /// Attribute definition sort /// @@ -149,7 +149,7 @@ pub struct RbumKindAttrAddReq { /// Default is ``0``, indicating self-adaptation /// /// 默认为 ``0`` , 表示自适应 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))] + #[oai(validator(minimum(value = "0", exclusive = "false")))] pub widget_columns: Option, /// Whether to hide by default /// @@ -176,7 +176,7 @@ pub struct RbumKindAttrAddReq { /// Fixed default value /// /// 固定默认值 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub default_value: Option, /// Dynamic default value /// @@ -231,7 +231,7 @@ pub struct RbumKindAttrAddReq { /// Default is ``0``, indicating no limit /// /// 默认为 ``0`` , 表示不限制 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))] + #[oai(validator(minimum(value = "0", exclusive = "false")))] pub min_length: Option, /// Maximum length /// @@ -240,7 +240,7 @@ pub struct RbumKindAttrAddReq { /// Default is ``0``, indicating no limit /// /// 默认为 ``0`` , 表示不限制 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))] + #[oai(validator(minimum(value = "0", exclusive = "false")))] pub max_length: Option, /// Parent attribute name /// @@ -259,17 +259,17 @@ pub struct RbumKindAttrAddReq { /// /// 例如:用户选择函数、角色选择函数等。 /// 自定义行为需要绑定到对应的函数代码。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub action: Option, /// Extension information /// /// 扩展信息 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub ext: Option, /// Associated [resource kind](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id /// /// 关联的 [资源类型](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_kind_id: String, pub scope_level: Option, @@ -279,7 +279,7 @@ pub struct RbumKindAttrAddReq { /// /// 资源类型属性定义修改请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumKindAttrModifyReq { /// Attribute definition label /// @@ -288,12 +288,12 @@ pub struct RbumKindAttrModifyReq { /// Corresponds to the field label, such as ```` . /// /// 多对应于字段标签,如 ```` 。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub label: Option, /// Attribute definition note /// /// 属性定义备注 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub note: Option, /// Attribute definition sort /// @@ -369,7 +369,7 @@ pub struct RbumKindAttrModifyReq { /// Default is ``0``, indicating self-adaptation /// /// 默认为 ``0`` , 表示自适应 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))] + #[oai(validator(minimum(value = "0", exclusive = "false")))] pub widget_columns: Option, /// Whether to hide by default /// @@ -392,7 +392,7 @@ pub struct RbumKindAttrModifyReq { /// Fixed default value /// /// 固定默认值 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub default_value: Option, /// Dynamic default value /// @@ -439,12 +439,12 @@ pub struct RbumKindAttrModifyReq { /// Minimum length /// /// 最小长度 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))] + #[oai(validator(minimum(value = "0", exclusive = "false")))] pub min_length: Option, /// Maximum length /// /// 最大长度 - #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))] + #[oai(validator(minimum(value = "0", exclusive = "false")))] pub max_length: Option, /// Parent attribute name /// @@ -463,12 +463,12 @@ pub struct RbumKindAttrModifyReq { /// /// 例如:用户选择函数、角色选择函数等。 /// 自定义行为需要绑定到对应的函数代码。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub action: Option, /// Extension information /// /// 扩展信息 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub ext: Option, pub scope_level: Option, @@ -478,7 +478,7 @@ pub struct RbumKindAttrModifyReq { /// /// 资源类型属性定义概要信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumKindAttrSummaryResp { /// Attribute definition id /// @@ -634,7 +634,7 @@ pub struct RbumKindAttrSummaryResp { /// /// 资源类型属性定义详细信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumKindAttrDetailResp { /// Attribute definition id /// diff --git a/backend/basic/src/rbum/dto/rbum_kind_dto.rs b/backend/basic/src/rbum/dto/rbum_kind_dto.rs index ac75f7c2c..5d2c6b70a 100644 --- a/backend/basic/src/rbum/dto/rbum_kind_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_kind_dto.rs @@ -1,9 +1,9 @@ use serde::{Deserialize, Serialize}; use tardis::basic::field::TrimString; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::RbumScopeLevelKind; @@ -12,7 +12,7 @@ use crate::rbum::rbum_enumeration::RbumScopeLevelKind; /// /// 资源类型添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumKindAddReq { /// Resource kind module /// @@ -25,7 +25,7 @@ pub struct RbumKindAddReq { /// Used to further divide the resource kind. For example, there are multiple resource kinds under the ``cmdb compute`` module, such as ``ecs, ec2, k8s``. /// /// 用于对资源类型做简单的分类。比如 ``cmdb计算`` 模块下可以有 ``ecs、ec2、k8s`` 等多个资源类型。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub module: Option, /// Resource kind code /// @@ -34,22 +34,22 @@ pub struct RbumKindAddReq { /// Resource kind code, which is required to conform to the scheme specification in the uri, matching the regular: ``^[a-z0-9-.]+$`` . /// /// 资源类型编码,需要符合uri中的scheme规范,匹配正则:``^[a-z0-9-.]+$`` 。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub code: TrimString, /// Resource kind name /// /// 资源类型名称 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: TrimString, /// Resource kind note /// /// 资源类型备注 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub note: Option, /// Resource kind icon /// /// 资源类型图标 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub icon: Option, /// Resource kind sort /// @@ -62,7 +62,7 @@ pub struct RbumKindAddReq { /// Each resource kind can specify an extension table for storing customized data. /// /// 每个资源类型可以指定一个扩展表用于存储自定义数据。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub ext_table_name: Option, pub scope_level: Option, @@ -72,7 +72,7 @@ pub struct RbumKindAddReq { /// /// 资源类型修改请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumKindModifyReq { /// Resource kind module /// @@ -81,22 +81,22 @@ pub struct RbumKindModifyReq { /// Used to further divide the resource kind. For example, there are multiple resource kinds under the ``cmdb compute`` module, such as ``ecs, ec2, k8s``. /// /// 用于对资源类型做简单的分类。比如 ``cmdb计算`` 模块下可以有 ``ecs、ec2、k8s`` 等多个资源类型。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub module: Option, /// Resource kind name /// /// 资源类型名称 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: Option, /// Resource kind note /// /// 资源类型备注 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub note: Option, /// Resource kind icon /// /// 资源类型图标 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub icon: Option, /// Resource kind sort /// @@ -109,7 +109,7 @@ pub struct RbumKindModifyReq { /// Each resource kind can specify an extension table for storing customized data. /// /// 每个资源类型可以指定一个扩展表用于存储自定义数据。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub ext_table_name: Option, pub scope_level: Option, @@ -119,7 +119,7 @@ pub struct RbumKindModifyReq { /// /// 资源类型概要信息 #[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumKindSummaryResp { /// Resource kind id /// @@ -162,7 +162,7 @@ pub struct RbumKindSummaryResp { /// /// 资源类型详细信息 #[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumKindDetailResp { /// Resource kind id /// diff --git a/backend/basic/src/rbum/dto/rbum_rel_agg_dto.rs b/backend/basic/src/rbum/dto/rbum_rel_agg_dto.rs index 2166547d4..9f37a83d0 100644 --- a/backend/basic/src/rbum/dto/rbum_rel_agg_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_rel_agg_dto.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::dto::rbum_rel_attr_dto::RbumRelAttrDetailResp; @@ -11,7 +11,7 @@ use crate::rbum::rbum_enumeration::RbumRelEnvKind; /// /// 资源关联聚合添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelAggAddReq { /// Relationship information /// @@ -31,7 +31,7 @@ pub struct RbumRelAggAddReq { /// /// 资源关联属性聚合添加请求 #[derive(Serialize, Deserialize, Clone, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelAttrAggAddReq { /// Condition qualifier /// @@ -45,7 +45,7 @@ pub struct RbumRelAttrAggAddReq { /// Relationship attribute value /// /// 关联属性值 - #[cfg_attr(feature = "default", oai(validator(min_length = "0", max_length = "2000")))] + #[oai(validator(min_length = "0", max_length = "2000"))] pub value: String, /// Relationship attribute name /// @@ -54,7 +54,7 @@ pub struct RbumRelAttrAggAddReq { /// When ``rel_rbum_kind_attr_id`` exists, use the corresponding [`crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp::name`], otherwise this field is not empty. /// /// 当 ``rel_rbum_kind_attr_id`` 存在时使用其对应的 [`crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp::name`],否则此字段不为空。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: Option, /// Whether to only record /// @@ -67,7 +67,7 @@ pub struct RbumRelAttrAggAddReq { /// Associated [resource kind attribute](crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp) id /// /// 关联的[资源类型属性](crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_kind_attr_id: Option, } @@ -75,7 +75,7 @@ pub struct RbumRelAttrAggAddReq { /// /// 资源关联环境聚合添加请求 #[derive(Serialize, Deserialize, Clone, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelEnvAggAddReq { /// Relationship environment type /// @@ -84,12 +84,12 @@ pub struct RbumRelEnvAggAddReq { /// Relationship environment value1 /// /// 关联环境值1 - #[cfg_attr(feature = "default", oai(validator(min_length = "1", max_length = "2000")))] + #[oai(validator(min_length = "1", max_length = "2000"))] pub value1: String, /// Relationship environment value2 /// /// 关联环境值2 - #[cfg_attr(feature = "default", oai(validator(min_length = "1", max_length = "2000")))] + #[oai(validator(min_length = "1", max_length = "2000"))] pub value2: Option, } @@ -97,7 +97,7 @@ pub struct RbumRelEnvAggAddReq { /// /// 资源关联聚合详细信息 #[derive(Serialize, Deserialize, Clone, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelAggResp { /// Relationship information /// diff --git a/backend/basic/src/rbum/dto/rbum_rel_attr_dto.rs b/backend/basic/src/rbum/dto/rbum_rel_attr_dto.rs index 3248db002..8f3f45d37 100644 --- a/backend/basic/src/rbum/dto/rbum_rel_attr_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_rel_attr_dto.rs @@ -1,15 +1,15 @@ use serde::{Deserialize, Serialize}; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; /// Add request for resource relationship attribute condition /// /// 资源关联属性条件添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelAttrAddReq { /// Condition qualifier /// @@ -27,12 +27,12 @@ pub struct RbumRelAttrAddReq { /// When ``rel_rbum_kind_attr_id`` exists, use the corresponding [`crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp::name`], otherwise this field is not empty. /// /// 当 ``rel_rbum_kind_attr_id`` 存在时使用其对应的 [`crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp::name`],否则此字段不为空。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: Option, /// Relationship attribute value /// /// 关联属性值 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub value: String, /// Whether to only record /// @@ -45,12 +45,12 @@ pub struct RbumRelAttrAddReq { /// Associated [resource kind attribute](crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp) id /// /// 关联的[资源类型属性](crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_kind_attr_id: Option, /// Associated [relationship](crate::rbum::dto::rbum_rel_dto::RbumRelDetailResp) id /// /// 关联的[资源关联](crate::rbum::dto::rbum_rel_dto::RbumRelDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_rel_id: String, } @@ -58,12 +58,12 @@ pub struct RbumRelAttrAddReq { /// /// 资源关联属性条件修改请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelAttrModifyReq { /// Relationship attribute value /// /// 关联属性值 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub value: String, } @@ -71,7 +71,7 @@ pub struct RbumRelAttrModifyReq { /// /// 资源关联属性条件详细信息 #[derive(Serialize, Deserialize, Clone, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumRelAttrDetailResp { /// Relationship attribute id /// diff --git a/backend/basic/src/rbum/dto/rbum_rel_dto.rs b/backend/basic/src/rbum/dto/rbum_rel_dto.rs index 2676c3328..5fd88c49b 100644 --- a/backend/basic/src/rbum/dto/rbum_rel_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_rel_dto.rs @@ -2,9 +2,9 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::default::Default; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::{RbumRelEnvKind, RbumRelFromKind}; @@ -13,7 +13,7 @@ use crate::rbum::rbum_enumeration::{RbumRelEnvKind, RbumRelFromKind}; /// /// 资源关联添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelAddReq { /// Relationship tag /// @@ -22,12 +22,12 @@ pub struct RbumRelAddReq { /// Used to distinguish different relationships. /// /// 用于区分不同的关联关系。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub tag: String, /// Relationship note /// /// 关联备注 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub note: Option, /// Relationship source type /// @@ -36,17 +36,17 @@ pub struct RbumRelAddReq { /// Relationship source id /// /// 关联来源方的id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub from_rbum_id: String, /// Relationship target id /// /// 关联目标方的id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub to_rbum_item_id: String, /// Relationship target ownership path /// /// 关联目标方的所有权路径 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub to_own_paths: String, /// Relationship extension information /// @@ -56,7 +56,7 @@ pub struct RbumRelAddReq { /// you can redundantly add the required information to this field. /// /// 例如:记录来源或目标在另一个服务中,为避免远程调用,可以将所需信息冗余添加到此字段。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub ext: Option, /// Whether the target is an external object /// @@ -72,7 +72,7 @@ pub struct RbumRelAddReq { /// /// 资源关联修改请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelModifyReq { /// Relationship tag /// @@ -81,12 +81,12 @@ pub struct RbumRelModifyReq { /// Used to distinguish different relationships. /// /// 用于区分不同的关联关系。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub tag: Option, /// Relationship note /// /// 关联备注 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub note: Option, /// Relationship extension information /// @@ -96,7 +96,7 @@ pub struct RbumRelModifyReq { /// you can redundantly add the required information to this field. /// /// 例如:记录来源或目标在另一个服务中,为避免远程调用,可以将所需信息冗余添加到此字段。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub ext: Option, } @@ -104,7 +104,7 @@ pub struct RbumRelModifyReq { /// /// 资源关联简单查找请求 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct RbumRelSimpleFindReq { /// Relationship tag @@ -114,7 +114,7 @@ pub struct RbumRelSimpleFindReq { /// Used to distinguish different relationships. /// /// 用于区分不同的关联关系。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub tag: Option, /// Relationship source type /// @@ -123,22 +123,22 @@ pub struct RbumRelSimpleFindReq { /// Relationship source id /// /// 关联来源方的id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub from_rbum_id: Option, /// Relationship target id /// /// 关联目标方的id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub to_rbum_item_id: Option, /// Relationship source ownership path /// /// 关联来源方的所有权路径 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub from_own_paths: Option, /// Relationship target ownership path /// /// 关联目标方的所有权路径 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub to_rbum_own_paths: Option, } @@ -146,7 +146,7 @@ pub struct RbumRelSimpleFindReq { /// /// 资源关联检查请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelCheckReq { /// Relationship tag /// @@ -155,7 +155,7 @@ pub struct RbumRelCheckReq { /// Used to distinguish different relationships. /// /// 用于区分不同的关联关系。 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub tag: String, /// Relationship source type /// @@ -164,12 +164,12 @@ pub struct RbumRelCheckReq { /// Relationship source id /// /// 关联来源方的id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub from_rbum_id: String, /// Relationship target id /// /// 关联目标方的id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub to_rbum_item_id: String, /// Limit the attributes of the relationship source /// @@ -197,7 +197,7 @@ pub struct RbumRelCheckReq { /// /// 资源关联环境检查请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelEnvCheckReq { /// Relationship environment type /// @@ -213,7 +213,7 @@ pub struct RbumRelEnvCheckReq { /// /// 资源关联骨干信息 #[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumRelBoneResp { /// Relationship tag /// @@ -301,7 +301,7 @@ impl RbumRelBoneResp { /// /// 资源关联详细信息 #[derive(Serialize, Deserialize, Clone, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumRelDetailResp { /// Relationship id /// diff --git a/backend/basic/src/rbum/dto/rbum_rel_env_dto.rs b/backend/basic/src/rbum/dto/rbum_rel_env_dto.rs index f3e4ba737..3c764bfbe 100644 --- a/backend/basic/src/rbum/dto/rbum_rel_env_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_rel_env_dto.rs @@ -1,8 +1,8 @@ use serde::{Deserialize, Serialize}; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::RbumRelEnvKind; @@ -11,7 +11,7 @@ use crate::rbum::rbum_enumeration::RbumRelEnvKind; /// /// 资源关联环境条件添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelEnvAddReq { /// Relationship environment type /// @@ -20,17 +20,17 @@ pub struct RbumRelEnvAddReq { /// Relationship environment value1 /// /// 关联环境值1 - #[cfg_attr(feature = "default", oai(validator(min_length = "1", max_length = "2000")))] + #[oai(validator(min_length = "1", max_length = "2000"))] pub value1: String, /// Relationship environment value2 /// /// 关联环境值2 - #[cfg_attr(feature = "default", oai(validator(min_length = "1", max_length = "2000")))] + #[oai(validator(min_length = "1", max_length = "2000"))] pub value2: Option, /// Associated [relationship](crate::rbum::dto::rbum_rel_dto::RbumRelDetailResp) id /// /// 关联的[资源关联](crate::rbum::dto::rbum_rel_dto::RbumRelDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_rel_id: String, } @@ -38,17 +38,17 @@ pub struct RbumRelEnvAddReq { /// /// 资源关联环境条件修改请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumRelEnvModifyReq { /// Relationship environment value1 /// /// 关联环境值1 - #[cfg_attr(feature = "default", oai(validator(min_length = "1", max_length = "2000")))] + #[oai(validator(min_length = "1", max_length = "2000"))] pub value1: Option, /// Relationship environment value2 /// /// 关联环境值2 - #[cfg_attr(feature = "default", oai(validator(min_length = "1", max_length = "2000")))] + #[oai(validator(min_length = "1", max_length = "2000"))] pub value2: Option, } @@ -56,7 +56,7 @@ pub struct RbumRelEnvModifyReq { /// /// 资源关联环境条件详细信息 #[derive(Serialize, Deserialize, Clone, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumRelEnvDetailResp { /// Relationship environment id /// diff --git a/backend/basic/src/rbum/dto/rbum_set_cate_dto.rs b/backend/basic/src/rbum/dto/rbum_set_cate_dto.rs index 3b938dcb6..61cc147c2 100644 --- a/backend/basic/src/rbum/dto/rbum_set_cate_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_set_cate_dto.rs @@ -1,9 +1,9 @@ use serde::{Deserialize, Serialize}; use tardis::basic::field::TrimString; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::RbumScopeLevelKind; @@ -12,22 +12,22 @@ use crate::rbum::rbum_enumeration::RbumScopeLevelKind; /// /// 资源集分类(节点)添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetCateAddReq { /// Business code for custom /// /// 自定义业务编码 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub bus_code: TrimString, /// Node name /// /// 节点名称 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: TrimString, /// Node icon /// /// 节点图标 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub icon: Option, /// Node sort /// @@ -36,17 +36,17 @@ pub struct RbumSetCateAddReq { /// Node extension information /// /// 节点扩展信息 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub ext: Option, /// Associated [resource set](crate::rbum::dto::rbum_set_dto::RbumSetDetailResp) id /// /// 关联[资源集](crate::rbum::dto::rbum_set_dto::RbumSetDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_set_id: String, /// Parent node id /// /// 父节点id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub rbum_parent_cate_id: Option, pub scope_level: Option, @@ -56,22 +56,22 @@ pub struct RbumSetCateAddReq { /// /// 资源集分类(节点)修改请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetCateModifyReq { /// Business code for custom /// /// 自定义业务编码 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub bus_code: Option, /// Node name /// /// 节点名称 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: Option, /// Node icon /// /// 节点图标 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub icon: Option, /// Node sort /// @@ -80,13 +80,13 @@ pub struct RbumSetCateModifyReq { /// Node extension information /// /// 节点扩展信息 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub ext: Option, /// Parent node id /// /// 父节点id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub rbum_parent_cate_id: Option, pub scope_level: Option, @@ -96,7 +96,7 @@ pub struct RbumSetCateModifyReq { /// /// 资源集分类(节点)概要信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumSetCateSummaryResp { /// Node id /// @@ -147,7 +147,7 @@ pub struct RbumSetCateSummaryResp { /// /// 资源集分类(节点)详细信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumSetCateDetailResp { /// Node id /// diff --git a/backend/basic/src/rbum/dto/rbum_set_dto.rs b/backend/basic/src/rbum/dto/rbum_set_dto.rs index 1eb43eb15..edb09cbea 100644 --- a/backend/basic/src/rbum/dto/rbum_set_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_set_dto.rs @@ -5,9 +5,9 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; use tardis::basic::field::TrimString; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::RbumScopeLevelKind; @@ -16,32 +16,32 @@ use crate::rbum::rbum_enumeration::RbumScopeLevelKind; /// /// 资源集添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetAddReq { /// Resource set code /// /// 资源集编码 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub code: TrimString, /// Resource set kind /// /// 资源集类型 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub kind: TrimString, /// Resource set name /// /// 资源集名称 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: TrimString, /// Resource set note /// /// 资源集备注 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub note: Option, /// Resource set icon /// /// 资源集图标 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub icon: Option, /// Resource set sort /// @@ -50,7 +50,7 @@ pub struct RbumSetAddReq { /// Resource set extension information /// /// 资源集扩展信息 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub ext: Option, pub scope_level: Option, @@ -61,22 +61,22 @@ pub struct RbumSetAddReq { /// /// 资源集修改请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetModifyReq { /// Resource set name /// /// 资源集名称 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub name: Option, /// Resource set note /// /// 资源集备注 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))] + #[oai(validator(min_length = "2", max_length = "2000"))] pub note: Option, /// Resource set icon /// /// 资源集图标 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub icon: Option, /// Resource set sort /// @@ -85,7 +85,7 @@ pub struct RbumSetModifyReq { /// Resource set extension information /// /// 资源集扩展信息 - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))] + #[oai(validator(min_length = "2", max_length = "1000"))] pub ext: Option, pub scope_level: Option, @@ -96,7 +96,7 @@ pub struct RbumSetModifyReq { /// /// 资源集概要信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumSetSummaryResp { /// Resource set id /// @@ -140,7 +140,7 @@ pub struct RbumSetSummaryResp { /// /// 资源集详细信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumSetDetailResp { /// Resource set id /// @@ -189,7 +189,7 @@ pub struct RbumSetDetailResp { /// /// 资源集路径信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumSetPathResp { /// Node id /// @@ -207,7 +207,7 @@ pub struct RbumSetPathResp { /// /// 资源树信息 #[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetTreeResp { /// Resource tree node information /// @@ -285,7 +285,7 @@ impl RbumSetTreeResp { /// /// 资源树节点信息 #[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetTreeNodeResp { /// Node id /// @@ -344,7 +344,7 @@ pub struct RbumSetTreeNodeResp { /// /// 资源树扩展信息 #[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetTreeExtResp { /// 节点与资源项的关联信息 /// @@ -376,7 +376,7 @@ pub struct RbumSetTreeExtResp { /// /// 资源目录树信息 #[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetTreeCateResp { /// Resource cate tree node information /// @@ -389,7 +389,7 @@ pub struct RbumSetTreeCateResp { } #[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] /// Resource tree cate structure information /// /// 资源树目录结构信息 diff --git a/backend/basic/src/rbum/dto/rbum_set_item_dto.rs b/backend/basic/src/rbum/dto/rbum_set_item_dto.rs index 650af7108..581ca840e 100644 --- a/backend/basic/src/rbum/dto/rbum_set_item_dto.rs +++ b/backend/basic/src/rbum/dto/rbum_set_item_dto.rs @@ -1,8 +1,8 @@ use serde::{Deserialize, Serialize}; use tardis::chrono::{DateTime, Utc}; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use crate::rbum::rbum_enumeration::RbumScopeLevelKind; @@ -11,7 +11,7 @@ use crate::rbum::rbum_enumeration::RbumScopeLevelKind; /// /// 添加资源集分类(节点)挂载资源项的关联的请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetItemAddReq { /// Association sort /// @@ -20,17 +20,17 @@ pub struct RbumSetItemAddReq { /// Associated [resource set](crate::rbum::dto::rbum_set_dto::RbumSetDetailResp) id /// /// 关联[资源集](crate::rbum::dto::rbum_set_dto::RbumSetDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_set_id: String, /// Associated [resource set category(node)](crate::rbum::dto::rbum_set_cate_dto::RbumSetCateDetailResp) id /// /// 关联[资源集分类(节点)](crate::rbum::dto::rbum_set_cate_dto::RbumSetCateDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_set_cate_id: String, /// Associated [resource item](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id /// /// 关联[资源项](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_item_id: String, } @@ -38,12 +38,12 @@ pub struct RbumSetItemAddReq { /// /// 修改资源集分类(节点)挂载资源项的关联的请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct RbumSetItemModifyReq { /// Associated [resource set category(node)](crate::rbum::dto::rbum_set_cate_dto::RbumSetCateDetailResp) id /// /// 关联[资源集分类(节点)](crate::rbum::dto::rbum_set_cate_dto::RbumSetCateDetailResp) id - #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))] + #[oai(validator(min_length = "2", max_length = "255"))] pub rel_rbum_set_cate_id: Option, /// Association sort /// @@ -55,7 +55,7 @@ pub struct RbumSetItemModifyReq { /// /// 资源集分类(节点)挂载资源项的关联的概要信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumSetItemSummaryResp { /// Association id /// @@ -100,7 +100,7 @@ pub struct RbumSetItemSummaryResp { /// /// 资源集分类(节点)挂载资源项的关联的资源项信息 #[derive(Serialize, Deserialize, Debug, Clone)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumSetItemRelInfoResp { /// Association id /// @@ -159,7 +159,7 @@ pub struct RbumSetItemRelInfoResp { /// /// 资源集分类(节点)挂载资源项的关联的详细信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct RbumSetItemDetailResp { /// Association id /// diff --git a/backend/basic/src/rbum/helper/rbum_scope_helper.rs b/backend/basic/src/rbum/helper/rbum_scope_helper.rs index 61067f02a..e19dd9b5a 100644 --- a/backend/basic/src/rbum/helper/rbum_scope_helper.rs +++ b/backend/basic/src/rbum/helper/rbum_scope_helper.rs @@ -216,12 +216,12 @@ pub fn check_scope(record_own_paths: &str, record_scope_level: Option, filt /// This method will fetch the context from the request header (default: 'Bios-Ctx') and fill the current context. /// /// Warning: This operation is unsafe, and it should only be used in scenarios where there is no security risk. -#[cfg(feature = "default")] + fn do_unsafe_fill_ctx(request: &tardis::web::poem::Request, f: F, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> where F: FnOnce(TardisContext, &mut TardisContext), { - let bios_ctx = if let Some(bios_ctx) = request.header(&funs.rbum_head_key_bios_ctx()).or_else(|| request.header(funs.rbum_head_key_bios_ctx().to_lowercase())) { + let bios_ctx = if let Some(bios_ctx) = request.header(funs.rbum_head_key_bios_ctx()).or_else(|| request.header(funs.rbum_head_key_bios_ctx().to_lowercase())) { TardisFuns::json.str_to_obj::(&TardisFuns::crypto.base64.decode_to_string(bios_ctx)?)? } else if ctx.owner.is_empty() && ctx.ak.is_empty() && ctx.own_paths.is_empty() && ctx.roles.is_empty() && ctx.groups.is_empty() { return Err(TardisError::unauthorized( @@ -252,7 +252,7 @@ where /// This method will fetch the context from the request header (default: 'Bios-Ctx') and fill the current context. /// /// Warning: This operation is unsafe, and it should only be used in scenarios where there is no security risk. -#[cfg(feature = "default")] + pub fn check_without_owner_and_unsafe_fill_ctx(request: &tardis::web::poem::Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { if ctx.ak.is_empty() { return Err(TardisError::forbidden("[Basic] Request contex ak is not empty", "403-rbum-req-ctx-ak-is-not-empty")); @@ -265,7 +265,7 @@ pub fn check_without_owner_and_unsafe_fill_ctx(request: &tardis::web::poem::Requ /// This method will fetch the context from the request header (default: 'Bios-Ctx') and fill the current context. /// /// Warning: This operation is unsafe, and it should only be used in scenarios where there is no security risk. -#[cfg(feature = "default")] + pub fn unsafe_fill_ctx(request: &tardis::web::poem::Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { do_unsafe_fill_ctx( request, @@ -292,7 +292,7 @@ pub fn unsafe_fill_ctx(request: &tardis::web::poem::Request, funs: &TardisFunsIn /// This method will fetch the context from the request header (default: 'Bios-Ctx') and fill the current context. /// /// Warning: This operation is unsafe, and it should only be used in scenarios where there is no security risk. -#[cfg(feature = "default")] + pub fn unsafe_fill_owner_only(request: &tardis::web::poem::Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { do_unsafe_fill_ctx( request, @@ -309,7 +309,7 @@ pub fn unsafe_fill_owner_only(request: &tardis::web::poem::Request, funs: &Tardi /// This method will fetch the context from the request header (default: 'Bios-Ctx') and fill the current context. /// /// Warning: This operation is unsafe, and it should only be used in scenarios where there is no security risk. -#[cfg(feature = "default")] + pub fn unsafe_fill_own_paths_only(request: &tardis::web::poem::Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { do_unsafe_fill_ctx( request, @@ -326,7 +326,7 @@ pub fn unsafe_fill_own_paths_only(request: &tardis::web::poem::Request, funs: &T /// This method will fetch the context from the request header (default: 'Bios-Ctx') and fill the current context. /// /// Warning: This operation is unsafe, and it should only be used in scenarios where there is no security risk. -#[cfg(feature = "default")] + pub fn unsafe_fill_roles_only(request: &tardis::web::poem::Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { do_unsafe_fill_ctx( request, @@ -350,7 +350,7 @@ pub fn unsafe_fill_roles_only(request: &tardis::web::poem::Request, funs: &Tardi /// This method will fetch the context from the request header (default: 'Bios-Ctx') and fill the current context. /// /// Warning: This operation is unsafe, and it should only be used in scenarios where there is no security risk. -#[cfg(feature = "default")] + pub fn unsafe_fill_groups_only(request: &tardis::web::poem::Request, funs: &TardisFunsInst, ctx: &mut TardisContext) -> TardisResult<()> { do_unsafe_fill_ctx( request, diff --git a/backend/basic/src/rbum/rbum_enumeration.rs b/backend/basic/src/rbum/rbum_enumeration.rs index d2dfdf774..0f35c924e 100644 --- a/backend/basic/src/rbum/rbum_enumeration.rs +++ b/backend/basic/src/rbum/rbum_enumeration.rs @@ -4,18 +4,18 @@ use serde::{Deserialize, Serialize}; use strum::Display; use tardis::basic::error::TardisError; use tardis::basic::result::TardisResult; -#[cfg(feature = "default")] + use tardis::db::sea_orm; -#[cfg(feature = "default")] + use tardis::db::sea_orm::{DbErr, QueryResult, TryGetError, TryGetable}; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; /// Scope level kind /// /// 作用域层级类型 #[derive(Display, Clone, Debug, PartialEq, Eq, Serialize)] -#[cfg_attr(feature = "default", derive(poem_openapi::Enum))] +#[derive(poem_openapi::Enum)] pub enum RbumScopeLevelKind { /// Private /// @@ -90,7 +90,7 @@ impl RbumScopeLevelKind { } } -#[cfg(feature = "default")] + impl TryGetable for RbumScopeLevelKind { fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result { let s = i16::try_get(res, pre, col)?; @@ -107,7 +107,7 @@ impl TryGetable for RbumScopeLevelKind { /// /// 凭证关联的类型 #[derive(Display, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "default", derive(poem_openapi::Enum))] +#[derive(poem_openapi::Enum)] pub enum RbumCertRelKind { /// Resource item /// @@ -142,7 +142,7 @@ impl RbumCertRelKind { } } -#[cfg(feature = "default")] + impl TryGetable for RbumCertRelKind { fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result { let s = i16::try_get(res, pre, col)?; @@ -158,7 +158,7 @@ impl TryGetable for RbumCertRelKind { /// /// 资源凭证配置状态类型 #[derive(Display, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "default", derive(poem_openapi::Enum))] +#[derive(poem_openapi::Enum)] pub enum RbumCertConfStatusKind { /// Disabled /// @@ -191,7 +191,7 @@ impl RbumCertConfStatusKind { /// /// 资源凭证状态类型 #[derive(Display, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "default", derive(poem_openapi::Enum))] +#[derive(poem_openapi::Enum)] pub enum RbumCertStatusKind { /// Disabled /// @@ -226,7 +226,7 @@ impl RbumCertStatusKind { } } -#[cfg(feature = "default")] + impl TryGetable for RbumCertStatusKind { fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result { let s = i16::try_get(res, pre, col)?; @@ -242,7 +242,7 @@ impl TryGetable for RbumCertStatusKind { /// /// 资源关联的类型 #[derive(Display, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "default", derive(poem_openapi::Enum))] +#[derive(poem_openapi::Enum)] pub enum RbumRelFromKind { /// Resource item /// @@ -283,7 +283,7 @@ impl RbumRelFromKind { } } -#[cfg(feature = "default")] + impl TryGetable for RbumRelFromKind { fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result { let s = i16::try_get(res, pre, col)?; @@ -303,7 +303,7 @@ impl TryGetable for RbumRelFromKind { /// /// 用于给资源关联加上限制条件。 #[derive(Display, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "default", derive(poem_openapi::Enum))] +#[derive(poem_openapi::Enum)] pub enum RbumRelEnvKind { /// Datetime range /// @@ -368,7 +368,7 @@ impl RbumRelEnvKind { } } -#[cfg(feature = "default")] + impl TryGetable for RbumRelEnvKind { fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result { let s = i16::try_get(res, pre, col)?; @@ -384,7 +384,7 @@ impl TryGetable for RbumRelEnvKind { /// /// 资源集分类(节点)的查询类型 #[derive(Display, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "default", derive(poem_openapi::Enum))] +#[derive(poem_openapi::Enum)] pub enum RbumSetCateLevelQueryKind { /// Current layer and descendant layer /// @@ -412,7 +412,7 @@ pub enum RbumSetCateLevelQueryKind { /// /// 数据类型 #[derive(Display, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "default", derive(poem_openapi::Enum, strum::EnumString))] +#[derive(poem_openapi::Enum, strum::EnumString)] pub enum RbumDataTypeKind { String, Number, @@ -429,7 +429,7 @@ pub enum RbumDataTypeKind { Label, } -#[cfg(feature = "default")] + impl TryGetable for RbumDataTypeKind { fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result { let s = String::try_get(res, pre, col)?; @@ -445,7 +445,7 @@ impl TryGetable for RbumDataTypeKind { /// /// (前端)控件类型 #[derive(Display, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "default", derive(poem_openapi::Enum, strum::EnumString))] +#[derive(poem_openapi::Enum, strum::EnumString)] pub enum RbumWidgetTypeKind { Input, InputTxt, @@ -477,7 +477,7 @@ pub enum RbumWidgetTypeKind { Group, } -#[cfg(feature = "default")] + impl TryGetable for RbumWidgetTypeKind { fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result { let s = String::try_get(res, pre, col)?; diff --git a/backend/basic/src/rbum/serv/rbum_crud_serv.rs b/backend/basic/src/rbum/serv/rbum_crud_serv.rs index 62e065e7b..1beeef304 100644 --- a/backend/basic/src/rbum/serv/rbum_crud_serv.rs +++ b/backend/basic/src/rbum/serv/rbum_crud_serv.rs @@ -10,7 +10,7 @@ use tardis::db::reldb_client::{IdResp, TardisActiveModel}; use tardis::db::sea_orm::sea_query::{Alias, Cond, Expr, Func, IntoValueTuple, JoinType, Order, Query, SelectStatement, Value, ValueTuple}; use tardis::db::sea_orm::{self, Condition, EntityTrait, FromQueryResult, QueryFilter}; use tardis::regex::Regex; -#[cfg(feature = "default")] + use tardis::web::poem_openapi; use tardis::web::poem_openapi::types::{ParseFromJSON, ToJSON}; use tardis::web::web_resp::TardisPage; @@ -1122,7 +1122,7 @@ pub struct NameResp { } #[derive(Debug, Serialize, Deserialize, sea_orm::FromQueryResult)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct IdNameResp { pub id: String, pub name: String, diff --git a/backend/basic/src/rbum/serv/rbum_set_serv.rs b/backend/basic/src/rbum/serv/rbum_set_serv.rs index 25e1fca5c..28fbf08c7 100644 --- a/backend/basic/src/rbum/serv/rbum_set_serv.rs +++ b/backend/basic/src/rbum/serv/rbum_set_serv.rs @@ -1,17 +1,6 @@ use std::collections::{HashMap, HashSet}; use std::time::Duration; -use async_recursion::async_recursion; -use async_trait::async_trait; -use itertools::Itertools; -use tardis::basic::dto::TardisContext; -use tardis::basic::result::TardisResult; -use tardis::db::sea_orm::sea_query::*; -use tardis::db::sea_orm::*; -use tardis::db::sea_orm::{self, IdenStatic}; -use tardis::tokio::time::sleep; -use tardis::{TardisFuns, TardisFunsInst}; - use crate::rbum::domain::{rbum_cert, rbum_item, rbum_rel, rbum_set, rbum_set_cate, rbum_set_item}; use crate::rbum::dto::rbum_filer_dto::{RbumBasicFilterReq, RbumKindFilterReq, RbumSetCateFilterReq, RbumSetFilterReq, RbumSetItemFilterReq, RbumSetTreeFilterReq}; use crate::rbum::dto::rbum_set_cate_dto::{RbumSetCateAddReq, RbumSetCateDetailResp, RbumSetCateModifyReq, RbumSetCateSummaryResp}; @@ -27,6 +16,16 @@ use crate::rbum::serv::rbum_domain_serv::RbumDomainServ; use crate::rbum::serv::rbum_item_serv::RbumItemServ; use crate::rbum::serv::rbum_kind_serv::RbumKindServ; use crate::rbum::serv::rbum_rel_serv::RbumRelServ; +use async_recursion::async_recursion; +use async_trait::async_trait; +use itertools::Itertools; +use tardis::basic::dto::TardisContext; +use tardis::basic::result::TardisResult; +use tardis::db::sea_orm::sea_query::*; +use tardis::db::sea_orm::*; +use tardis::db::sea_orm::{self, IdenStatic}; +use tardis::tokio::time::sleep; +use tardis::{TardisFuns, TardisFunsInst}; pub struct RbumSetServ; diff --git a/backend/basic/src/spi.rs b/backend/basic/src/spi.rs index 1c452c7cb..cc308a424 100644 --- a/backend/basic/src/spi.rs +++ b/backend/basic/src/spi.rs @@ -67,13 +67,13 @@ //! 1. 每个SPI后端实现的要绑定给对应的租户或应用后才能使用,绑定关系存储于``rbum_rel``,tag为``spi_ident`` //! 1. 不做请求认证。SPI服务信任请求带来的认证信息(``TardisContext``中的``ak``,对应于租户或应用的Id)。认证的逻辑将由网关统一实现 //! 1. 延时初始化。SPI服务的每个后端实现只有在第一次调用时才会初始化(生成client),以减少启动时的资源消耗。详见 [`crate::spi::spi_funs::SpiBsInst`] -#[cfg(feature = "default")] + pub mod api; -#[cfg(feature = "default")] + mod domain; pub mod dto; pub mod macros; -#[cfg(feature = "default")] + pub mod serv; pub mod spi_constants; pub mod spi_funs; diff --git a/backend/basic/src/spi/dto/spi_bs_dto.rs b/backend/basic/src/spi/dto/spi_bs_dto.rs index e6d688fbd..52e3ba7c0 100644 --- a/backend/basic/src/spi/dto/spi_bs_dto.rs +++ b/backend/basic/src/spi/dto/spi_bs_dto.rs @@ -12,7 +12,7 @@ use crate::spi::spi_funs; /// /// 后端服务添加请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct SpiBsAddReq { /// Service name /// @@ -55,7 +55,7 @@ pub struct SpiBsAddReq { /// /// 后端服务修改请求 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] pub struct SpiBsModifyReq { /// Service name /// @@ -100,7 +100,7 @@ pub struct SpiBsModifyReq { /// /// 后端服务概要信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct SpiBsSummaryResp { /// Service Id /// @@ -160,7 +160,7 @@ pub struct SpiBsSummaryResp { /// /// 后端服务详细信息 #[derive(Serialize, Deserialize, Debug)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))] +#[derive(poem_openapi::Object, sea_orm::FromQueryResult)] pub struct SpiBsDetailResp { /// Service Id /// @@ -261,7 +261,7 @@ impl SpiBsCertResp { /// /// 后端服务的查询过滤请求 #[derive(Serialize, Deserialize, Debug, Clone, Default)] -#[cfg_attr(feature = "default", derive(poem_openapi::Object))] +#[derive(poem_openapi::Object)] #[serde(default)] pub struct SpiBsFilterReq { /// Basic filter diff --git a/backend/basic/src/spi/spi_initializer.rs b/backend/basic/src/spi/spi_initializer.rs index 630c5dd23..b1095aa89 100644 --- a/backend/basic/src/spi/spi_initializer.rs +++ b/backend/basic/src/spi/spi_initializer.rs @@ -182,7 +182,7 @@ pub mod common_pg { /// 根据入参生成对应表全限定名 pub fn get_table_full_name(ext: &HashMap, table_flag: String, tag: String) -> String { let schema_name = get_schema_name_from_ext(ext).expect("ignore"); - return format!("{schema_name}.{GLOBAL_STORAGE_FLAG}_{table_flag}_{tag}"); + format!("{schema_name}.{GLOBAL_STORAGE_FLAG}_{table_flag}_{tag}") } /// Check if the schema exists diff --git a/backend/basic/src/test.rs b/backend/basic/src/test.rs index 0fbd25194..1fd8d3cff 100644 --- a/backend/basic/src/test.rs +++ b/backend/basic/src/test.rs @@ -1,4 +1,4 @@ -#[cfg(feature = "default")] + pub mod init_test_container; -#[cfg(feature = "default")] + pub mod test_http_client; diff --git a/backend/gateways/spacegate-plugins/Cargo.toml b/backend/gateways/spacegate-plugins/Cargo.toml index ea0996ab2..fd89176a4 100644 --- a/backend/gateways/spacegate-plugins/Cargo.toml +++ b/backend/gateways/spacegate-plugins/Cargo.toml @@ -24,13 +24,13 @@ spacegate-shell = { workspace = true, features = [ "plugin-east-west-traffic-white-list", ] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [ +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = [ "spi_log", ], default-features = false } jsonpath-rust = "0.3.1" -bios-auth = { path = "../../supports/auth", default-features = false } +bios-auth = { version = "0.2.0", path = "../../supports/auth", default-features = false } tardis = { workspace = true, features = ["web-client"] } ipnet = "2.8.0" diff --git a/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs b/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs index e2a2511d6..becbe7bd8 100644 --- a/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs +++ b/backend/gateways/spacegate-plugins/src/plugin/anti_replay.rs @@ -7,7 +7,7 @@ use spacegate_shell::hyper::{Request, Response, StatusCode}; use spacegate_shell::kernel::extension::PeerAddr; use spacegate_shell::kernel::helper_layers::function::Inner; use spacegate_shell::plugin::{schemars, Plugin, PluginError}; -use spacegate_shell::{BoxError, SgBody, SgRequestExt, SgResponseExt}; +use spacegate_shell::{BoxError, BoxResult, SgBody, SgRequestExt, SgResponseExt}; use tardis::serde_json; use tardis::{basic::result::TardisResult, tokio}; @@ -55,7 +55,7 @@ fn get_md5(req: &Request) -> TardisResult { tardis::crypto::crypto_digest::TardisCryptoDigest {}.md5(data) } -async fn set_status(md5: &str, cache_key: &str, status: bool, cache_client: &RedisClient) -> TardisResult<()> { +async fn set_status(md5: &str, cache_key: &str, status: bool, cache_client: &RedisClient) -> BoxResult<()> { let (split1, split2) = md5.split_at(16); let split1 = u128::from_str_radix(split1, 16)? as u32; let split2 = u128::from_str_radix(split2, 16)? as u32; @@ -65,7 +65,7 @@ async fn set_status(md5: &str, cache_key: &str, status: bool, cache_client: &Red Ok(()) } -async fn get_status(md5: &str, cache_key: &str, cache_client: &RedisClient) -> TardisResult { +async fn get_status(md5: &str, cache_key: &str, cache_client: &RedisClient) -> BoxResult { let (split1, split2) = md5.split_at(16); let split1 = u128::from_str_radix(split1, 16)? as u32; let split2 = u128::from_str_radix(split2, 16)? as u32; @@ -95,13 +95,13 @@ impl Plugin for AntiReplayPlugin { md5: Arc::from(md5), client: client.clone(), }; - if get_status(&digest.md5, &self.cache_key, &client).await.map_err(PluginError::internal_error::)? { + if get_status(&digest.md5, &self.cache_key, &client).await? { return Ok(Response::with_code_message( StatusCode::TOO_MANY_REQUESTS, "[SG.Plugin.Anti_Replay] Request denied due to replay attack. Please refresh and resubmit the request.", )); } else { - set_status(&digest.md5, &self.cache_key, true, &client).await.map_err(PluginError::internal_error::)?; + set_status(&digest.md5, &self.cache_key, true, &client).await?; } let resp = inner.call(req).await; let time = self.time; diff --git a/backend/gateways/spacegate-plugins/src/plugin/op_redis_publisher.rs b/backend/gateways/spacegate-plugins/src/plugin/op_redis_publisher.rs index 4a3ac9e75..2b849059b 100644 --- a/backend/gateways/spacegate-plugins/src/plugin/op_redis_publisher.rs +++ b/backend/gateways/spacegate-plugins/src/plugin/op_redis_publisher.rs @@ -4,12 +4,12 @@ use http::Response; use jsonpath_rust::JsonPathInst; use serde::{Deserialize, Serialize}; use spacegate_shell::{ + ext_redis::redis::Script, kernel::{extension::EnterTime, SgRequest, SgResponse}, plugin::{Inner, Plugin, PluginConfig}, BoxError, SgRequestExt as _, }; use tardis::{ - cache::Script, log::{self, warn}, serde_json::{self, Value}, tokio, diff --git a/backend/middlewares/event/Cargo.toml b/backend/middlewares/event/Cargo.toml index 1bd3118e8..d7313acd9 100644 --- a/backend/middlewares/event/Cargo.toml +++ b/backend/middlewares/event/Cargo.toml @@ -24,8 +24,8 @@ tardis = { workspace = true, features = [ "ws-client", "cluster", ] } -bios-basic = { path = "../../basic", features = ["default"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [ +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = [ "spi_log", "event", ], default-features = false } @@ -39,6 +39,6 @@ tardis = { workspace = true, features = [ "cluster", "web-server", ] } -bios-basic = { path = "../../basic", features = ["default", "test"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } tokio = { version = "1", features = ["full"] } asteroid-mq-sdk = { workspace = true } \ No newline at end of file diff --git a/backend/middlewares/event/src/domain.rs b/backend/middlewares/event/src/domain.rs index 58f80add1..d9b75904e 100644 --- a/backend/middlewares/event/src/domain.rs +++ b/backend/middlewares/event/src/domain.rs @@ -1,4 +1,3 @@ pub mod event_auth; pub mod event_message; -pub mod event_persistent; pub mod event_topic; diff --git a/backend/middlewares/event/src/domain/event_persistent.rs b/backend/middlewares/event/src/domain/event_persistent.rs deleted file mode 100644 index b8e82302c..000000000 --- a/backend/middlewares/event/src/domain/event_persistent.rs +++ /dev/null @@ -1,68 +0,0 @@ -use serde::{Deserialize, Serialize}; -use tardis::chrono::Utc; -use tardis::db::sea_orm::{self, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EntityName, EntityTrait, EnumIter, PrimaryKeyTrait}; -use tardis::serde_json::Value; -use tardis::{chrono, TardisCreateEntity, TardisEmptyBehavior, TardisEmptyRelation}; -/// Event Topic model -/// -/// 事件主题模型 -#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, TardisCreateEntity, TardisEmptyBehavior, TardisEmptyRelation)] -#[sea_orm(table_name = "event_persistent")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: String, - pub message: Value, - pub inst_id: String, - pub mgr_node: bool, - pub subscribe_mode: bool, - pub topic: String, - pub status: String, - pub error: Option, - #[sea_orm(extra = "DEFAULT 0")] - pub retry_times: i32, - #[sea_orm(extra = "DEFAULT CURRENT_TIMESTAMP")] - pub create_time: chrono::DateTime, - #[sea_orm(extra = "DEFAULT CURRENT_TIMESTAMP")] - pub update_time: chrono::DateTime, -} - -#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] -pub enum Status { - Sending, - Success, - Failed, - Unknown, -} - -impl Status { - pub const fn as_str(&self) -> &'static str { - match self { - Status::Sending => "Sending", - Status::Success => "Success", - Status::Failed => "Failed", - _ => "Unknown", - } - } -} - -impl std::fmt::Display for Status { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(<&'static str>::from(*self)) - } -} - -impl From for &'static str { - fn from(val: Status) -> Self { - val.as_str() - } -} -impl From<&str> for Status { - fn from(value: &str) -> Self { - match value { - "Sending" => Self::Sending, - "Success" => Self::Success, - "Failed" => Self::Failed, - _ => Status::Unknown, - } - } -} diff --git a/backend/middlewares/event/src/event_initializer.rs b/backend/middlewares/event/src/event_initializer.rs index 47d7d2c85..9876ecce1 100644 --- a/backend/middlewares/event/src/event_initializer.rs +++ b/backend/middlewares/event/src/event_initializer.rs @@ -25,7 +25,7 @@ use crate::{ ca::{event_connect_api, event_register_api}, ci::event_topic_api, }, - domain::{event_message, event_topic}, + domain::{event_auth, event_message, event_topic}, event_config::{EventConfig, EventInfo, EventInfoManager}, event_constants::{DOMAIN_CODE, KIND_CODE}, mq_adapter::{BiosDurableAdapter, BiosEdgeAuthAdapter}, @@ -56,16 +56,16 @@ pub async fn init(web_server: &TardisWebServer) -> TardisResult<()> { } async fn init_db(domain_code: String, kind_code: String, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { + // Initialize event component RBUM item table and indexs + let _ = funs.db().init(event_topic::ActiveModel::init(TardisFuns::reldb().backend(), None, TardisFuns::reldb().compatible_type())).await; + let _ = funs.db().init(event_message::ActiveModel::init(TardisFuns::reldb().backend(), None, TardisFuns::reldb().compatible_type())).await; + let _ = funs.db().init(event_auth::ActiveModel::init(TardisFuns::reldb().backend(), None, TardisFuns::reldb().compatible_type())).await; if let Some(domain_id) = RbumDomainServ::get_rbum_domain_id_by_code(&domain_code, funs).await? { let kind_id = RbumKindServ::get_rbum_kind_id_by_code(&kind_code, funs).await?.expect("missing event kind"); EventInfoManager::set(EventInfo { kind_id, domain_id })?; return Ok(()); } - // Initialize event component RBUM item table and indexs - let _ = funs.db().init(event_topic::ActiveModel::init(TardisFuns::reldb().backend(), None, TardisFuns::reldb().compatible_type())).await; - let _ = funs.db().init(event_message::ActiveModel::init(TardisFuns::reldb().backend(), None, TardisFuns::reldb().compatible_type())).await; - // funs.db() // .init(event_persistent::ActiveModel::init( // TardisFuns::reldb().backend(), diff --git a/backend/middlewares/event/tests/test_event.rs b/backend/middlewares/event/tests/test_event.rs index 64e58bc49..0c345241b 100644 --- a/backend/middlewares/event/tests/test_event.rs +++ b/backend/middlewares/event/tests/test_event.rs @@ -76,12 +76,17 @@ pub async fn test_event_topic_api() -> Result<(), Box> { "topic_code": TEST_TOPIC_NAME, "overflow_policy": "RejectNew", "overflow_size": 500, + "check_auth": true, }}, ) .await; tracing::info!(?id, "event registered"); let topics = client.get::("/ci/topic?page_number=1&page_size=10").await; tracing::info!(?topics, "event paged list"); + let register_auth_result = client.put::(&format!("/ci/topic/{TEST_TOPIC_NAME}/register?read=true&write=true"), &Void).await; + + tracing::info!(?register_auth_result, "auth registered"); + let bind_result = client.put::("/ca/register", &Void).await; let node_id = bind_result["node_id"].as_str().expect("node_id is settled"); tracing::info!(?node_id, "bind context result"); diff --git a/backend/middlewares/flow/Cargo.toml b/backend/middlewares/flow/Cargo.toml index 5bae6cdd0..bacf4cb8d 100644 --- a/backend/middlewares/flow/Cargo.toml +++ b/backend/middlewares/flow/Cargo.toml @@ -25,11 +25,11 @@ rust_decimal_macros.workspace = true lazy_static.workspace = true itertools.workspace = true tardis = { workspace = true, features = ["reldb-postgres", "web-client"] } -bios-basic = { path = "../../basic", features = ["default"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = ["default"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = ["default"] } [dev-dependencies] tardis = { workspace = true, features = ["test", "web-client"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = ["default"] } -bios-spi-kv = { path = "../../spi/spi-kv" } -bios-spi-search = { path = "../../spi/spi-search" } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = ["default"] } +bios-spi-kv = { version = "0.2.0", path = "../../spi/spi-kv" } +bios-spi-search = { version = "0.2.0", path = "../../spi/spi-search" } diff --git a/backend/middlewares/flow/src/dto/flow_state_dto.rs b/backend/middlewares/flow/src/dto/flow_state_dto.rs index 829e7a037..116ebde70 100644 --- a/backend/middlewares/flow/src/dto/flow_state_dto.rs +++ b/backend/middlewares/flow/src/dto/flow_state_dto.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use tardis::{ basic::field::TrimString, chrono::{DateTime, Utc}, - db::sea_orm::{self, EnumIter}, + db::sea_orm::{self, prelude::*, EnumIter}, serde_json::Value, web::poem_openapi, }; @@ -118,7 +118,7 @@ pub struct FlowStateDetailResp { /// 状态类型 // #[sea_orm(rs_type = "String", db_type = "String(Some(255))")] #[derive(Clone, Default, Debug, PartialEq, Eq, Deserialize, Serialize, poem_openapi::Enum, EnumIter, sea_orm::DeriveActiveEnum)] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "FlowSysStateKind")] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(255))")] pub enum FlowSysStateKind { #[default] #[sea_orm(string_value = "start")] @@ -130,7 +130,7 @@ pub enum FlowSysStateKind { } #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, poem_openapi::Enum, EnumIter, sea_orm::DeriveActiveEnum)] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "FlowStateKind")] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(255))")] pub enum FlowStateKind { #[sea_orm(string_value = "simple")] Simple, diff --git a/backend/middlewares/flow/src/dto/flow_transition_dto.rs b/backend/middlewares/flow/src/dto/flow_transition_dto.rs index cd7e87f34..b81a83bf5 100644 --- a/backend/middlewares/flow/src/dto/flow_transition_dto.rs +++ b/backend/middlewares/flow/src/dto/flow_transition_dto.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use strum::Display; use tardis::{ basic::{error::TardisError, field::TrimString}, - db::sea_orm::{self, EnumIter}, + db::sea_orm::{self, prelude::*, EnumIter}, serde_json::Value, web::poem_openapi, TardisFuns, @@ -368,7 +368,7 @@ pub struct FlowTransitionActionChangeAgg { /// 后置动作类型,目前有状态修改和字段修改两种。 #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Default, Serialize, poem_openapi::Enum, EnumIter, sea_orm::DeriveActiveEnum)] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "FlowTransitionActionChangeKind")] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(255))")] pub enum FlowTransitionActionChangeKind { /// 字段修改 #[default] @@ -403,7 +403,7 @@ pub struct FlowTransitionActionByVarChangeInfo { /// 修改方式(清空,更改内容,更改为其他字段的值,加减值等) #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, poem_openapi::Enum, EnumIter, sea_orm::DeriveActiveEnum)] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "FlowTransitionActionByVarChangeInfoChangedKind")] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(255))")] pub enum FlowTransitionActionByVarChangeInfoChangedKind { /// 清空 #[sea_orm(string_value = "clean")] diff --git a/backend/middlewares/schedule/Cargo.toml b/backend/middlewares/schedule/Cargo.toml index 0fd38c738..d17b491c8 100644 --- a/backend/middlewares/schedule/Cargo.toml +++ b/backend/middlewares/schedule/Cargo.toml @@ -23,14 +23,14 @@ serde.workspace = true lazy_static.workspace = true # tokio-cron-scheduler = "*" tardis = { workspace = true, features = ["reldb-postgres", "web-server"] } -bios-basic = { path = "../../basic", features = ["default"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [ +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = [ "spi_log", "spi_kv", "event" ], default-features = false } tsuki-scheduler = { version = "0.1.3", features= ["cron", "tokio", "async-scheduler"]} [dev-dependencies] tardis = { workspace = true, features = ["test", "ws-client"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } -bios-spi-kv = { path = "../../spi/spi-kv" } -bios-spi-log = { path = "../../spi/spi-log" } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } +bios-spi-kv = { version = "0.2.0", path = "../../spi/spi-kv" } +bios-spi-log = { version = "0.2.0", path = "../../spi/spi-log" } diff --git a/backend/services/bios-all/Cargo.toml b/backend/services/bios-all/Cargo.toml index 78a67c78a..6878cb489 100644 --- a/backend/services/bios-all/Cargo.toml +++ b/backend/services/bios-all/Cargo.toml @@ -18,27 +18,27 @@ tardis = { workspace = true, features = [ "cluster", "tracing", ] } -bios-iam = { path = "../../supports/iam", features = ["spi_search", "spi_kv"] } -bios-auth = { path = "../../supports/auth", features = ["web-server"] } -bios-reach = { path = "../../supports/reach" } +bios-iam = { version = "0.2.0", path = "../../supports/iam", features = ["spi_search", "spi_kv", "event"] } +bios-auth = { version = "0.2.0", path = "../../supports/auth", features = ["web-server"] } +bios-reach = { version = "0.2.0", path = "../../supports/reach" } -bios-spi-cache = { path = "../../spi/spi-cache" } -bios-spi-graph = { path = "../../spi/spi-graph" } -bios-spi-kv = { path = "../../spi/spi-kv" } -bios-spi-log = { path = "../../spi/spi-log" } -bios-spi-object = { path = "../../spi/spi-object" } -bios-spi-plugin = { path = "../../spi/spi-plugin" } -bios-spi-reldb = { path = "../../spi/spi-reldb" } -bios-spi-search = { path = "../../spi/spi-search", features = ["default", "with-cn-tokenizer"] } -bios-spi-stats = { path = "../../spi/spi-stats" } -#bios-spi-conf = { path = "../../spi/spi-conf" } +bios-spi-cache = { version = "0.2.0", path = "../../spi/spi-cache" } +bios-spi-graph = { version = "0.2.0", path = "../../spi/spi-graph" } +bios-spi-kv = { version = "0.2.0", path = "../../spi/spi-kv" } +bios-spi-log = { version = "0.2.0", path = "../../spi/spi-log" } +bios-spi-object = { version = "0.2.0", path = "../../spi/spi-object" } +bios-spi-plugin = { version = "0.2.0", path = "../../spi/spi-plugin" } +bios-spi-reldb = { version = "0.2.0", path = "../../spi/spi-reldb" } +bios-spi-search = { version = "0.2.0", path = "../../spi/spi-search", features = ["default", "with-cn-tokenizer"] } +bios-spi-stats = { version = "0.2.0", path = "../../spi/spi-stats" } +#bios-spi-conf = { version = "0.2.0", path = "../../spi/spi-conf" } -bios-mw-schedule = { path = "../../middlewares/schedule" } -bios-mw-flow = { path = "../../middlewares/flow" } -bios-mw-event = { path = "../../middlewares/event" } +bios-mw-schedule = { version = "0.2.0", path = "../../middlewares/schedule" } +bios-mw-flow = { version = "0.2.0", path = "../../middlewares/flow" } +bios-mw-event = { version = "0.2.0", path = "../../middlewares/event" } # clients -bios-client-hwsms = { path = "../../../frontend/clients/hwsms", features = [ +bios-client-hwsms = { version = "0.2.0", path = "../../../frontend/clients/hwsms", features = [ "reach", ] } diff --git a/backend/services/bios-all/config/conf-default.toml b/backend/services/bios-all/config/conf-default.toml index 19a829e5b..08173d184 100644 --- a/backend/services/bios-all/config/conf-default.toml +++ b/backend/services/bios-all/config/conf-default.toml @@ -16,7 +16,7 @@ set_cate_sys_code_node_len = 4 id = "bios-serv-all" name = "BIOS All Services" desc = "BIOS All Services" -version = "0.1.0" +version = "0.2.0" default_lang = "zh-cn" [fw.web_server.modules.auth] diff --git a/backend/services/spacegate/Cargo.toml b/backend/services/spacegate/Cargo.toml index d15eb5f8d..95f496ac7 100644 --- a/backend/services/spacegate/Cargo.toml +++ b/backend/services/spacegate/Cargo.toml @@ -23,7 +23,7 @@ spacegate-shell = { workspace = true, features = [ "cache", ] } tardis = { workspace = true } -spacegate-plugins = { path = "../../gateways/spacegate-plugins" } +spacegate-plugins = { version = "0.2.0", path = "../../gateways/spacegate-plugins" } envy = "0.4" [dev-dependencies] pprof = { version = "0.13", features = ["flamegraph"] } diff --git a/backend/services/spi-all/Cargo.toml b/backend/services/spi-all/Cargo.toml index 805462488..e32625c2a 100644 --- a/backend/services/spi-all/Cargo.toml +++ b/backend/services/spi-all/Cargo.toml @@ -16,14 +16,14 @@ tardis = { workspace = true, features = [ "web-server", "conf-remote", ] } -bios-basic = { path = "../../basic", features = ["test"] } -bios-spi-cache = { path = "../../spi/spi-cache" } -bios-spi-graph = { path = "../../spi/spi-graph" } -bios-spi-kv = { path = "../../spi/spi-kv" } -bios-spi-log = { path = "../../spi/spi-log" } -bios-spi-object = { path = "../../spi/spi-object" } -bios-spi-plugin = { path = "../../spi/spi-plugin" } -bios-spi-reldb = { path = "../../spi/spi-reldb" } -bios-spi-search = { path = "../../spi/spi-search", features = ["default", "with-cn-tokenizer"] } -bios-spi-stats = { path = "../../spi/spi-stats" } -bios-spi-conf = { path = "../../spi/spi-conf" } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["test"] } +bios-spi-cache = { version = "0.2.0", path = "../../spi/spi-cache" } +bios-spi-graph = { version = "0.2.0", path = "../../spi/spi-graph" } +bios-spi-kv = { version = "0.2.0", path = "../../spi/spi-kv" } +bios-spi-log = { version = "0.2.0", path = "../../spi/spi-log" } +bios-spi-object = { version = "0.2.0", path = "../../spi/spi-object" } +bios-spi-plugin = { version = "0.2.0", path = "../../spi/spi-plugin" } +bios-spi-reldb = { version = "0.2.0", path = "../../spi/spi-reldb" } +bios-spi-search = { version = "0.2.0", path = "../../spi/spi-search", features = ["default", "with-cn-tokenizer"] } +bios-spi-stats = { version = "0.2.0", path = "../../spi/spi-stats" } +bios-spi-conf = { version = "0.2.0", path = "../../spi/spi-conf" } diff --git a/backend/services/spi-all/config/conf-default.toml b/backend/services/spi-all/config/conf-default.toml index 8ee5df1e8..49226b2da 100644 --- a/backend/services/spi-all/config/conf-default.toml +++ b/backend/services/spi-all/config/conf-default.toml @@ -5,7 +5,7 @@ id = "bios-spi-serv-all" name = "BIOS All SPI Services" desc = "BIOS All SPI Services" -version = "0.1.0" +version = "0.2.0" default_lang = "zh-cn" [fw.web_server] diff --git a/backend/services/spi-all/tests/config/conf-default.toml b/backend/services/spi-all/tests/config/conf-default.toml index e8f20c3ef..fb8db10aa 100644 --- a/backend/services/spi-all/tests/config/conf-default.toml +++ b/backend/services/spi-all/tests/config/conf-default.toml @@ -5,7 +5,7 @@ id = "bios-spi-serv-all" name = "BIOS All SPI Services" desc = "BIOS All SPI Services" -version = "0.1.0" +version = "0.2.0" default_lang = "zh-cn" [fw.web_server] diff --git a/backend/services/spi-conf/Cargo.toml b/backend/services/spi-conf/Cargo.toml index 5212eddf6..62b6eb92d 100644 --- a/backend/services/spi-conf/Cargo.toml +++ b/backend/services/spi-conf/Cargo.toml @@ -14,4 +14,4 @@ publish.workspace = true serde.workspace = true tardis = { workspace = true, features = ["web-server", "conf-remote"] } -bios-spi-conf = { path = "../../spi/spi-conf" } +bios-spi-conf = { version = "0.2.0", path = "../../spi/spi-conf" } diff --git a/backend/services/spi-conf/config/conf-default.toml b/backend/services/spi-conf/config/conf-default.toml index 809c87c37..90b1bcd36 100644 --- a/backend/services/spi-conf/config/conf-default.toml +++ b/backend/services/spi-conf/config/conf-default.toml @@ -7,7 +7,7 @@ id = "spi-conf-serv" name = "SPI Conf Services" desc = "SPI Conf Services" -version = "0.1.0" +version = "0.2.0" default_lang = "zh-cn" [fw.web_server] diff --git a/backend/spi/spi-cache/Cargo.toml b/backend/spi/spi-cache/Cargo.toml index 77caa89f8..05108eda4 100644 --- a/backend/spi/spi-cache/Cargo.toml +++ b/backend/spi/spi-cache/Cargo.toml @@ -21,8 +21,8 @@ spi-redis = ["tardis/cache"] [dependencies] serde.workspace = true tardis = { workspace = true, features = ["reldb-postgres", "web-server"] } -bios-basic = { path = "../../basic", features = ["default"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } diff --git a/backend/spi/spi-conf/Cargo.toml b/backend/spi/spi-conf/Cargo.toml index 638b77e11..c056b2fca 100644 --- a/backend/spi/spi-conf/Cargo.toml +++ b/backend/spi/spi-conf/Cargo.toml @@ -26,15 +26,15 @@ tardis = { workspace = true, features = [ "crypto", "web-server-grpc", ] } -bios-basic = { path = "../../basic", features = ["default"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } lazy_static = { workspace = true } jsonwebtoken = "9" -poem-grpc = { version = "0.4", optional = true } +poem-grpc = { version = "0.5", optional = true } prost-types = "0.13" prost = "0.13" strum = { version = "0.26", features = ["derive"] } tokio-stream = { version = "0.1.14", features = ["sync"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [ +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = [ "iam", "macro", ], default-features = false } @@ -42,8 +42,8 @@ ipnet = { version = "2", features = ["serde"] } [dev-dependencies] tardis = { workspace = true, features = ["test", "conf-remote", "mq"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } testcontainers-modules = { workspace = true } [build-dependencies] -poem-grpc-build = "0.4" +poem-grpc-build = "0.5" diff --git a/backend/spi/spi-conf/src/api/nacos/grpc/proto.rs b/backend/spi/spi-conf/src/api/nacos/grpc/proto.rs index fc117b523..abae17312 100644 --- a/backend/spi/spi-conf/src/api/nacos/grpc/proto.rs +++ b/backend/spi/spi-conf/src/api/nacos/grpc/proto.rs @@ -1,9 +1,7 @@ use tardis::poem_grpc; use tardis::web::poem; -use crate::api; // This file is @generated by prost-build. -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Metadata { #[prost(string, tag = "3")] @@ -13,7 +11,6 @@ pub struct Metadata { #[prost(map = "string, string", tag = "7")] pub headers: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Payload { #[prost(message, optional, tag = "2")] @@ -21,7 +18,6 @@ pub struct Payload { #[prost(message, optional, tag = "3")] pub body: ::core::option::Option<::prost_types::Any>, } -#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ConfigQueryRequest { #[prost(string, tag = "1")] @@ -38,22 +34,54 @@ pub trait Request: Send + Sync + 'static { fn request(&self, request: poem_grpc::Request) -> impl ::std::future::Future, poem_grpc::Status>> + Send; } #[allow(unused_imports)] -#[derive(Clone)] -pub struct RequestServer(::std::sync::Arc); +pub struct RequestServer { + inner: ::std::sync::Arc, + send_compressd: ::std::option::Option, + accept_compressed: ::std::sync::Arc<[poem_grpc::CompressionEncoding]>, +} +impl ::std::clone::Clone for RequestServer { + #[inline] + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + send_compressd: self.send_compressd, + accept_compressed: self.accept_compressed.clone(), + } + } +} impl poem_grpc::Service for RequestServer { const NAME: &'static str = "Request"; } #[allow(dead_code)] impl RequestServer { + /// Create a new GRPC server pub fn new(service: T) -> Self { - Self(::std::sync::Arc::new(service)) + Self { + inner: ::std::sync::Arc::new(service), + send_compressd: ::std::option::Option::None, + accept_compressed: ::std::sync::Arc::new([]), + } + } + /// Set the compression encoding for sending + pub fn send_compressed(self, encoding: poem_grpc::CompressionEncoding) -> Self { + Self { + send_compressd: Some(encoding), + ..self + } + } + /// Set the compression encodings for accepting + pub fn accept_compressed(self, encodings: impl ::std::convert::Into<::std::sync::Arc<[poem_grpc::CompressionEncoding]>>) -> Self { + Self { + accept_compressed: encodings.into(), + ..self + } } } impl poem::IntoEndpoint for RequestServer { type Endpoint = poem::endpoint::BoxEndpoint<'static, poem::Response>; #[allow(clippy::redundant_clone)] #[allow(clippy::let_and_return)] - fn into_endpoint(self) -> as tardis::web::poem::IntoEndpoint>::Endpoint { + fn into_endpoint(self) -> Self::Endpoint { use poem::endpoint::EndpointExt; let mut route = poem::Route::new(); #[allow(non_camel_case_types)] @@ -67,12 +95,12 @@ impl poem::IntoEndpoint for RequestServer { route = route.at( "/request", poem::endpoint::make({ - let svc = self.0.clone(); + let server = self.clone(); move |req| { - let svc = svc.clone(); + let server = server.clone(); async move { let codec = as ::std::default::Default>::default(); - poem_grpc::server::GrpcServer::new(codec).unary(RequestrequestService(svc.clone()), req).await + poem_grpc::server::GrpcServer::new(codec, server.send_compressd, &server.accept_compressed).unary(RequestrequestService(server.inner.clone()), req).await } } }), @@ -94,15 +122,47 @@ pub trait BiRequestStream: Send + Sync + 'static { ) -> impl ::std::future::Future>, poem_grpc::Status>> + Send; } #[allow(unused_imports)] -#[derive(Clone)] -pub struct BiRequestStreamServer(::std::sync::Arc); +pub struct BiRequestStreamServer { + inner: ::std::sync::Arc, + send_compressd: ::std::option::Option, + accept_compressed: ::std::sync::Arc<[poem_grpc::CompressionEncoding]>, +} +impl ::std::clone::Clone for BiRequestStreamServer { + #[inline] + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + send_compressd: self.send_compressd, + accept_compressed: self.accept_compressed.clone(), + } + } +} impl poem_grpc::Service for BiRequestStreamServer { const NAME: &'static str = "BiRequestStream"; } #[allow(dead_code)] impl BiRequestStreamServer { + /// Create a new GRPC server pub fn new(service: T) -> Self { - Self(::std::sync::Arc::new(service)) + Self { + inner: ::std::sync::Arc::new(service), + send_compressd: ::std::option::Option::None, + accept_compressed: ::std::sync::Arc::new([]), + } + } + /// Set the compression encoding for sending + pub fn send_compressed(self, encoding: poem_grpc::CompressionEncoding) -> Self { + Self { + send_compressd: Some(encoding), + ..self + } + } + /// Set the compression encodings for accepting + pub fn accept_compressed(self, encodings: impl ::std::convert::Into<::std::sync::Arc<[poem_grpc::CompressionEncoding]>>) -> Self { + Self { + accept_compressed: encodings.into(), + ..self + } } } impl poem::IntoEndpoint for BiRequestStreamServer { @@ -126,12 +186,14 @@ impl poem::IntoEndpoint for BiRequestStreamServer { route = route.at( "/requestBiStream", poem::endpoint::make({ - let svc = self.0.clone(); + let server = self.clone(); move |req| { - let svc = svc.clone(); + let server = server.clone(); async move { let codec = as ::std::default::Default>::default(); - poem_grpc::server::GrpcServer::new(codec).bidirectional_streaming(BiRequestStreamrequest_bi_streamService(svc.clone()), req).await + poem_grpc::server::GrpcServer::new(codec, server.send_compressd, &server.accept_compressed) + .bidirectional_streaming(BiRequestStreamrequest_bi_streamService(server.inner.clone()), req) + .await } } }), diff --git a/backend/spi/spi-conf/tests/spi_conf_api_test.rs b/backend/spi/spi-conf/tests/spi_conf_api_test.rs index 6ae19ec65..9f5a484da 100644 --- a/backend/spi/spi-conf/tests/spi_conf_api_test.rs +++ b/backend/spi/spi-conf/tests/spi_conf_api_test.rs @@ -11,7 +11,7 @@ use tardis::{ basic::{dto::TardisContext, result::TardisResult}, log, serde_json::{json, Value}, - testcontainers, tokio, TardisFuns, + tokio, TardisFuns, }; mod spi_conf_test_common; use spi_conf_test_common::*; @@ -20,7 +20,7 @@ use spi_conf_test_common::*; async fn spi_conf_namespace_test() -> TardisResult<()> { std::env::set_var("RUST_LOG", "info,sqlx=off,sea_orm=info,spi_conf_namespace_test=info,bios_spi_conf=TRACE"); - let container_hold = init_tardis(&docker).await?; + let container_hold = init_tardis().await?; start_web_server().await?; let mut client = TestHttpClient::new("https://127.0.0.1:8080/spi-conf".to_string()); client.set_auth(&TardisContext { diff --git a/backend/spi/spi-conf/tests/spi_conf_listener_test.rs b/backend/spi/spi-conf/tests/spi_conf_listener_test.rs index 6ee5622c2..0d08b4314 100644 --- a/backend/spi/spi-conf/tests/spi_conf_listener_test.rs +++ b/backend/spi/spi-conf/tests/spi_conf_listener_test.rs @@ -10,7 +10,7 @@ use tardis::{ log::{self, debug}, rand, serde_json::json, - testcontainers, tokio, + tokio, }; mod spi_conf_test_common; use spi_conf_test_common::*; @@ -19,7 +19,7 @@ use spi_conf_test_common::*; async fn spi_conf_namespace_test() -> TardisResult<()> { std::env::set_var("RUST_LOG", "error,spi_conf_listener_test=debug,sqlx=off,sea_orm=off,bios_spi_conf=DEBUG"); - let container_hold = init_tardis(&docker).await?; + let container_hold = init_tardis().await?; start_web_server().await?; let tardis_ctx = TardisContext::default(); let mut client = TestHttpClient::new("https://localhost:8080/spi-conf".to_string()); diff --git a/backend/spi/spi-conf/tests/spi_conf_nacos_compatible_test.rs b/backend/spi/spi-conf/tests/spi_conf_nacos_compatible_test.rs index 32fb44587..a6bde6a4f 100644 --- a/backend/spi/spi-conf/tests/spi_conf_nacos_compatible_test.rs +++ b/backend/spi/spi-conf/tests/spi_conf_nacos_compatible_test.rs @@ -10,7 +10,7 @@ use tardis::{ basic::{dto::TardisContext, result::TardisResult}, log, serde_json::json, - testcontainers, tokio, + tokio, web::web_resp::TardisResp, TardisFuns, }; @@ -26,12 +26,11 @@ async fn spi_conf_namespace_test() -> TardisResult<()> { ); std::env::set_var("PROFILE", "nacos"); - let container_hold = init_tardis(&docker).await?; + let container_hold = init_tardis().await?; let _web_server_handle = start_web_server().await; let tardis_ctx = TardisContext::default(); let mut client = TestHttpClient::new(format!("{SCHEMA}://127.0.0.1:8080/spi-conf")); client.set_auth(&tardis_ctx)?; - let funs = TardisFuns::inst_with_db_conn(DOMAIN_CODE.to_string(), None); let RegisterResponse { username, password } = client .put( "/ci/auth/register_bundle", diff --git a/backend/spi/spi-conf/tests/spi_conf_test_common.rs b/backend/spi/spi-conf/tests/spi_conf_test_common.rs index 212e92d9e..54f85e4f6 100644 --- a/backend/spi/spi-conf/tests/spi_conf_test_common.rs +++ b/backend/spi/spi-conf/tests/spi_conf_test_common.rs @@ -3,27 +3,27 @@ use bios_basic::{ test::test_http_client::TestHttpClient, }; use bios_spi_conf::{conf_constants::DOMAIN_CODE, conf_initializer}; -use tardis::testcontainers::GenericImage; use tardis::{ basic::{dto::TardisContext, result::TardisResult}, test::test_container::TardisTestContainer, - testcontainers::{clients::Cli, Container}, + testcontainers::ContainerAsync, TardisFuns, }; -use testcontainers_modules::redis::Redis; -pub struct Holder<'d> { - pub pg: Container<'d, GenericImage>, - pub redis: Container<'d, Redis>, +use testcontainers_modules::{postgres::Postgres, redis::Redis}; +#[allow(dead_code)] +pub struct Holder { + pub pg: ContainerAsync, + pub redis: ContainerAsync, } #[allow(dead_code)] -pub async fn init_tardis(docker: &Cli) -> TardisResult { - let reldb_container = TardisTestContainer::postgres_custom(None, docker); - let port = reldb_container.get_host_port_ipv4(5432); +pub async fn init_tardis() -> TardisResult { + let reldb_container = TardisTestContainer::postgres_custom(None).await?; + let port = reldb_container.get_host_port_ipv4(5432).await?; let url = format!("postgres://postgres:123456@127.0.0.1:{port}/test"); std::env::set_var("TARDIS_FW.DB.URL", url); - let redis_container = TardisTestContainer::redis_custom(docker); - let port = redis_container.get_host_port_ipv4(6379); + let redis_container = TardisTestContainer::redis_custom().await?; + let port = redis_container.get_host_port_ipv4(6379).await?; let url = format!("redis://127.0.0.1:{port}/0"); std::env::set_var("TARDIS_FW.CACHE.URL", url); let holder = Holder { diff --git a/backend/spi/spi-graph/Cargo.toml b/backend/spi/spi-graph/Cargo.toml index 16859e43f..4a1f17ef8 100644 --- a/backend/spi/spi-graph/Cargo.toml +++ b/backend/spi/spi-graph/Cargo.toml @@ -22,8 +22,8 @@ spi-pg = ["tardis/reldb-postgres"] serde.workspace = true itertools.workspace = true tardis = { workspace = true, features = ["reldb-postgres", "web-server"] } -bios-basic = { path = "../../basic", features = ["default"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } diff --git a/backend/spi/spi-kv/Cargo.toml b/backend/spi/spi-kv/Cargo.toml index c2b6d3c28..ff0f6245a 100644 --- a/backend/spi/spi-kv/Cargo.toml +++ b/backend/spi/spi-kv/Cargo.toml @@ -21,11 +21,11 @@ spi-pg = ["tardis/reldb-postgres"] [dependencies] serde.workspace = true tardis = { workspace = true, features = ["reldb-postgres", "web-server"] } -bios-basic = { path = "../../basic", features = ["default"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [ +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = [ "event", ], default-features = false } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } diff --git a/backend/spi/spi-log/Cargo.toml b/backend/spi/spi-log/Cargo.toml index 726c6e580..3684c5b20 100644 --- a/backend/spi/spi-log/Cargo.toml +++ b/backend/spi/spi-log/Cargo.toml @@ -21,11 +21,11 @@ spi-pg = ["tardis/reldb-postgres"] [dependencies] serde.workspace = true tardis = { workspace = true, features = ["reldb-postgres", "web-server"] } -bios-basic = { path = "../../basic", features = ["default"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [ +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = [ "event", ], default-features = false } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } diff --git a/backend/spi/spi-object/Cargo.toml b/backend/spi/spi-object/Cargo.toml index ecc98b2c0..db9a6d193 100644 --- a/backend/spi/spi-object/Cargo.toml +++ b/backend/spi/spi-object/Cargo.toml @@ -22,8 +22,8 @@ spi-s3 = ["tardis/os"] serde.workspace = true itertools.workspace = true tardis = { workspace = true, features = ["reldb-postgres", "web-server"] } -bios-basic = { path = "../../basic", features = ["default"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } diff --git a/backend/spi/spi-plugin/Cargo.toml b/backend/spi/spi-plugin/Cargo.toml index 985933c38..8e6eb6a66 100644 --- a/backend/spi/spi-plugin/Cargo.toml +++ b/backend/spi/spi-plugin/Cargo.toml @@ -22,11 +22,11 @@ spi-pg = ["tardis/reldb-postgres"] serde.workspace = true async-trait.workspace = true tardis = { workspace = true, features = ["reldb-postgres", "web-server"] } -bios-basic = { path = "../../basic", features = ["default"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = ["default"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = ["default"] } strum = { workspace = true, features = ["derive"] } percent-encoding = "2" [dev-dependencies] tardis = { workspace = true, features = ["test", "ws-client"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = ["default"] } \ No newline at end of file +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = ["default"] } \ No newline at end of file diff --git a/backend/spi/spi-reldb/Cargo.toml b/backend/spi/spi-reldb/Cargo.toml index e857d6357..9a79050e8 100644 --- a/backend/spi/spi-reldb/Cargo.toml +++ b/backend/spi/spi-reldb/Cargo.toml @@ -24,8 +24,8 @@ spi-mysql = ["tardis/reldb-mysql"] serde.workspace = true lazy_static.workspace = true tardis = { workspace = true, features = ["reldb-postgres", "web-server"] } -bios-basic = { path = "../../basic", features = ["default"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } diff --git a/backend/spi/spi-search/Cargo.toml b/backend/spi/spi-search/Cargo.toml index 22a054535..9f2a8623f 100644 --- a/backend/spi/spi-search/Cargo.toml +++ b/backend/spi/spi-search/Cargo.toml @@ -29,15 +29,15 @@ tardis = { workspace = true, features = [ "web-client", "openapi-rapidoc", ] } -bios-basic = { path = "../../basic", features = ["default"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } strum = { workspace = true, features = ["derive"] } pinyin = { version = "0.10" } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [ +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = [ "event", ], default-features = false } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } testcontainers-modules = { workspace = true } pinyin = { version = "0.10" } diff --git a/backend/spi/spi-stats/Cargo.toml b/backend/spi/spi-stats/Cargo.toml index bdcd0f1ea..dc539df36 100644 --- a/backend/spi/spi-stats/Cargo.toml +++ b/backend/spi/spi-stats/Cargo.toml @@ -19,17 +19,17 @@ default = ["spi-pg"] spi-pg = ["tardis/reldb-postgres"] [dependencies] -bios-basic = { path = "../../basic", features = ["default"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } serde.workspace = true lazy_static.workspace = true itertools.workspace = true tardis = { workspace = true, features = ["reldb-postgres", "web-server"] } serde_json = { workspace = true, features = ["preserve_order"] } strum = { workspace = true, features = ["derive"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [ +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = [ "event", ], default-features = false } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } diff --git a/backend/supports/iam/Cargo.toml b/backend/supports/iam/Cargo.toml index 0b2987ca5..481ae0553 100644 --- a/backend/supports/iam/Cargo.toml +++ b/backend/supports/iam/Cargo.toml @@ -19,8 +19,8 @@ default = ["ldap_server", "ldap_client"] ldap_server = ["ldap3_proto", "tardis/future", "tokio-util"] ldap_client = ["ldap3"] spi_kv = [] -spi_search = [] - +spi_search = ["event"] +event = ["bios-sdk-invoke/event", "bios-basic/with-mq"] [dependencies] serde.workspace = true @@ -35,8 +35,10 @@ tardis = { workspace = true, features = [ "web-client", "mail", ] } -bios-basic = { path = "../../basic", features = ["default", "with-mq"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = ["default", "event"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = [ + "default", +] } # ldap ldap3_proto = { version = "0.3", optional = true } @@ -48,5 +50,7 @@ nanoid = { version = "0.4" } strum = { workspace = true, features = ["derive"] } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = ["default"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = [ + "default", +] } diff --git a/backend/supports/iam/src/basic/serv/clients/iam_kv_client.rs b/backend/supports/iam/src/basic/serv/clients/iam_kv_client.rs index 33ddf6a4d..49f2eb5ed 100644 --- a/backend/supports/iam/src/basic/serv/clients/iam_kv_client.rs +++ b/backend/supports/iam/src/basic/serv/clients/iam_kv_client.rs @@ -89,26 +89,33 @@ impl IamKvClient { ctx: &TardisContext, ) -> TardisResult<()> { #[cfg(feature = "spi_kv")] - SpiKvClient::add_or_modify_item(key, value, info, disable, scope_level.map(|kind| kind.to_int()), funs, ctx).await + SpiKvClient::add_or_modify_item(key, value, info, disable, scope_level.map(|kind| kind.to_int()), funs, ctx).await?; + Ok(()) } pub async fn add_or_modify_key_name(tag: &str, key: &str, name: &str, disable: Option, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { #[cfg(feature = "spi_kv")] - SpiKvClient::add_or_modify_key_name(&format!("{}:{}", tag, key), name, disable, funs, ctx).await + SpiKvClient::add_or_modify_key_name(&format!("{}:{}", tag, key), name, disable, funs, ctx).await?; + Ok(()) } pub async fn delete_key_name(tag: &str, key: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { #[cfg(feature = "spi_kv")] - SpiKvClient::delete_item(&format!("__k_n__:{}:{}", tag, key), funs, ctx).await + SpiKvClient::delete_item(&format!("__k_n__:{}:{}", tag, key), funs, ctx).await?; + Ok(()) } pub async fn delete_item(key: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { #[cfg(feature = "spi_kv")] - SpiKvClient::delete_item(key, funs, ctx).await + SpiKvClient::delete_item(key, funs, ctx).await?; + Ok(()) } pub async fn get_item(key: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult> { - #[cfg(feature = "spi_kv")] - SpiKvClient::get_item(key.to_string(), None, funs, ctx).await + if cfg!(feature = "spi_kv") { + SpiKvClient::get_item(key.to_string(), None, funs, ctx).await + } else { + Ok(None) + } } } diff --git a/backend/supports/iam/src/basic/serv/clients/iam_log_client.rs b/backend/supports/iam/src/basic/serv/clients/iam_log_client.rs index a741393aa..2e18562ba 100644 --- a/backend/supports/iam/src/basic/serv/clients/iam_log_client.rs +++ b/backend/supports/iam/src/basic/serv/clients/iam_log_client.rs @@ -5,16 +5,12 @@ use bios_basic::{ serv::{rbum_crud_serv::RbumCrudOperation, rbum_item_serv::RbumItemCrudOperation, rbum_set_serv::RbumSetCateServ}, }, }; -use bios_sdk_invoke::clients::{ - event_client::{get_topic, mq_error, EventAttributeExt, SPI_RPC_TOPIC}, - spi_log_client::{LogItemAddReq, SpiLogClient}, -}; +use bios_sdk_invoke::clients::spi_log_client::{LogItemAddReq, SpiLogClient}; use serde::Serialize; use tardis::{ basic::{dto::TardisContext, result::TardisResult}, chrono::{DateTime, Utc}, - futures::TryFutureExt, serde_json::json, tokio, TardisFuns, TardisFunsInst, }; @@ -24,7 +20,7 @@ use crate::{ dto::iam_filer_dto::{IamAccountFilterReq, IamResFilterReq, IamRoleFilterReq, IamTenantFilterReq}, serv::{iam_account_serv::IamAccountServ, iam_cert_serv::IamCertServ, iam_res_serv::IamResServ, iam_role_serv::IamRoleServ, iam_tenant_serv::IamTenantServ}, }, - iam_constants::{self, IAM_AVATAR}, + iam_constants::{self}, iam_enumeration::IamCertKernelKind, }; pub struct IamLogClient; diff --git a/backend/supports/iam/src/basic/serv/clients/iam_search_client.rs b/backend/supports/iam/src/basic/serv/clients/iam_search_client.rs index e63ef92c9..a903d9756 100644 --- a/backend/supports/iam/src/basic/serv/clients/iam_search_client.rs +++ b/backend/supports/iam/src/basic/serv/clients/iam_search_client.rs @@ -2,10 +2,7 @@ use std::collections::HashSet; use bios_basic::rbum::{dto::rbum_filer_dto::RbumBasicFilterReq, serv::rbum_item_serv::RbumItemCrudOperation}; use bios_sdk_invoke::{ - clients::{ - event_client::{get_topic, EventCenterClient, SPI_RPC_TOPIC}, - spi_search_client::SpiSearchClient, - }, + clients::spi_search_client::SpiSearchClient, dto::search_item_dto::{SearchItemAddReq, SearchItemModifyReq, SearchItemVisitKeysReq}, }; use itertools::Itertools; @@ -25,7 +22,7 @@ use crate::{ serv::{iam_account_serv::IamAccountServ, iam_role_serv::IamRoleServ, iam_set_serv::IamSetServ, iam_tenant_serv::IamTenantServ}, }, iam_config::IamConfig, - iam_constants::{self, IAM_AVATAR}, + iam_constants, iam_enumeration::IamSetKind, }; pub struct IamSearchClient; @@ -185,11 +182,7 @@ impl IamSearchClient { }), kv_disable: Some(account_resp.disabled), }; - if let Some(_topic) = get_topic(&SPI_RPC_TOPIC) { - EventCenterClient { topic_code: SPI_RPC_TOPIC }.modify_item_and_name(&tag, &key, &modify_req, funs, ctx).await?; - } else { - SpiSearchClient::modify_item_and_name(&tag, &key, &modify_req, funs, ctx).await?; - } + SpiSearchClient::modify_item_and_name(&tag, &key, &modify_req, funs, ctx).await?; } else { let add_req = SearchItemAddReq { tag, @@ -231,11 +224,7 @@ impl IamSearchClient { }), kv_disable: Some(account_resp.disabled), }; - if let Some(_topic) = get_topic(&SPI_RPC_TOPIC) { - EventCenterClient { topic_code: SPI_RPC_TOPIC }.add_item_and_name(&add_req, Some(account_resp.name), funs, ctx).await?; - } else { - SpiSearchClient::add_item_and_name(&add_req, Some(account_resp.name), funs, ctx).await?; - } + SpiSearchClient::add_item_and_name(&add_req, Some(account_resp.name), funs, ctx).await? } Ok(()) } @@ -243,11 +232,7 @@ impl IamSearchClient { // account 全局搜索删除埋点方法 pub async fn delete_account_search(account_id: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { let tag = funs.conf::().spi.search_account_tag.clone(); - if let Some(_topic) = get_topic(&SPI_RPC_TOPIC) { - EventCenterClient { topic_code: SPI_RPC_TOPIC }.delete_item_and_name(&tag, account_id, funs, ctx).await?; - } else { - SpiSearchClient::delete_item_and_name(&tag, account_id, funs, ctx).await?; - } + SpiSearchClient::delete_item_and_name(&tag, account_id, funs, ctx).await?; Ok(()) } } diff --git a/backend/supports/iam/src/basic/serv/iam_role_serv.rs b/backend/supports/iam/src/basic/serv/iam_role_serv.rs index ae5e429e2..7f1aee9a4 100644 --- a/backend/supports/iam/src/basic/serv/iam_role_serv.rs +++ b/backend/supports/iam/src/basic/serv/iam_role_serv.rs @@ -614,7 +614,7 @@ impl IamRoleServ { Ok(role_id) } - pub async fn copy_role_agg(copy_req: &mut IamRoleAggCopyReq, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<(String)> { + pub async fn copy_role_agg(copy_req: &mut IamRoleAggCopyReq, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult { let copy_role = Self::get_item( ©_req.copy_role_id, &IamRoleFilterReq { diff --git a/backend/supports/reach/Cargo.toml b/backend/supports/reach/Cargo.toml index b13fb3b0d..545e22e1c 100644 --- a/backend/supports/reach/Cargo.toml +++ b/backend/supports/reach/Cargo.toml @@ -27,20 +27,20 @@ tardis = { workspace = true, features = [ "mail", "mq", ] } -bios-basic = { path = "../../basic", features = ["default"] } -bios-sdk-invoke = { path = "../../../frontend/sdks/invoke", features = [ +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default"] } +bios-sdk-invoke = { version = "0.2.0", path = "../../../frontend/sdks/invoke", features = [ "iam", "macro", ], default-features = false } -# simple-invoke-client-macro = { path = "../../sdks/simple-invoke-client-macro" } +# simple-invoke-client-macro = { version = "0.2.0", path = "../../sdks/simple-invoke-client-macro" } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -bios-basic = { path = "../../basic", features = ["default", "test"] } +bios-basic = { version = "0.2.0", path = "../../basic", features = ["default", "test"] } bios-reach = { path = "./", features = ["simple-client"] } toml = "*" -bios-client-hwsms = { path = "../../../frontend/clients/hwsms", features = ["reach"] } +bios-client-hwsms = { version = "0.2.0", path = "../../../frontend/clients/hwsms", features = ["reach"] } testcontainers-modules = { workspace = true } diff --git a/backend/supports/reach/src/dto/enums.rs b/backend/supports/reach/src/dto/enums.rs index dece65ea3..5bce23dbd 100644 --- a/backend/supports/reach/src/dto/enums.rs +++ b/backend/supports/reach/src/dto/enums.rs @@ -3,14 +3,14 @@ use std::{fmt::Display, str::FromStr}; use serde::{Deserialize, Serialize}; use tardis::{ basic::error::TardisError, - db::sea_orm::{self, DeriveActiveEnum, EnumIter}, + db::sea_orm::{self, prelude::*, DeriveActiveEnum, EnumIter}, web::poem_openapi, }; #[repr(u8)] #[derive(Debug, poem_openapi::Enum, EnumIter, Clone, Copy, DeriveActiveEnum, PartialEq, Eq, Serialize, Deserialize, Hash, Default)] #[oai(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "ReachChannelKind")] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(255))")] pub enum ReachChannelKind { #[sea_orm(string_value = "SMS")] #[default] @@ -62,7 +62,7 @@ impl FromStr for ReachChannelKind { #[derive(Debug, poem_openapi::Enum, EnumIter, Clone, Copy, DeriveActiveEnum, PartialEq, Eq, Serialize, Deserialize, Hash)] #[oai(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "ReachReceiveKind")] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(255))")] pub enum ReachReceiveKind { #[sea_orm(string_value = "ACCOUNT")] Account, @@ -77,7 +77,7 @@ pub enum ReachReceiveKind { #[derive(Debug, poem_openapi::Enum, EnumIter, Clone, Copy, DeriveActiveEnum, PartialEq, Eq, Serialize, Deserialize, Default)] #[oai(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "ReachStatusKind")] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(255))")] pub enum ReachStatusKind { #[sea_orm(string_value = "DRAFT")] Draft, @@ -101,7 +101,7 @@ pub enum ReachStatusKind { #[derive(Debug, poem_openapi::Enum, EnumIter, Clone, Copy, DeriveActiveEnum, PartialEq, Eq, Serialize, Deserialize)] #[oai(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "ReachDndStrategyKind")] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(255))")] pub enum ReachDndStrategyKind { #[sea_orm(string_value = "IGNORE")] Ignore, @@ -112,7 +112,7 @@ pub enum ReachDndStrategyKind { #[derive(Debug, poem_openapi::Enum, EnumIter, Clone, Copy, DeriveActiveEnum, PartialEq, Eq, Serialize, Deserialize, Default)] #[oai(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "ReachLevelKind")] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(255))")] pub enum ReachLevelKind { #[sea_orm(string_value = "URGENT")] Urgent, @@ -128,7 +128,7 @@ pub enum ReachLevelKind { #[derive(Debug, poem_openapi::Enum, EnumIter, Clone, Copy, DeriveActiveEnum, PartialEq, Eq, Serialize, Deserialize, Default)] #[oai(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "ReachTimeoutStrategyKind")] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(255))")] pub enum ReachTimeoutStrategyKind { #[sea_orm(string_value = "IGNORE")] #[default] @@ -140,7 +140,7 @@ pub enum ReachTimeoutStrategyKind { #[derive(Debug, poem_openapi::Enum, EnumIter, Clone, Copy, DeriveActiveEnum, PartialEq, Eq, Serialize, Deserialize, Default)] #[oai(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] -#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "ReachTemplateKind")] +#[sea_orm(rs_type = "String", db_type = "String(StringLen::N(255))")] pub enum ReachTemplateKind { #[sea_orm(string_value = "VCODE")] #[default] diff --git a/build-scripts/publish.sh b/build-scripts/publish.sh new file mode 100644 index 000000000..81b8f99b8 --- /dev/null +++ b/build-scripts/publish.sh @@ -0,0 +1,10 @@ +VERSION=$1 +PACKAGE_NAME=$2 +cargo search "$PACKAGE_NAME" --registry crates-io | grep -q "$PACKAGE_NAME = \"$VERSION\"" +if [ $? -eq 0 ]; then + echo "Version $VERSION of $PACKAGE_NAME is already published." +else + echo "Publishing version $VERSION of $PACKAGE_NAME" + cargo package -p $PACKAGE_NAME + cargo publish -p $PACKAGE_NAME --registry crates-io +fi diff --git a/frontend/clients/hwsms/Cargo.toml b/frontend/clients/hwsms/Cargo.toml index 6b042724f..8c613e042 100644 --- a/frontend/clients/hwsms/Cargo.toml +++ b/frontend/clients/hwsms/Cargo.toml @@ -18,4 +18,4 @@ reach = ["bios-reach"] [dependencies] serde.workspace = true tardis = { workspace = true } -bios-reach = { optional = true, path = "../../../backend/supports/reach" } +bios-reach = { optional = true, version = "0.2.0", path = "../../../backend/supports/reach" } diff --git a/frontend/enhance-wasm/src/mini_tardis/serde.rs b/frontend/enhance-wasm/src/mini_tardis/serde.rs index 9b9e29fc2..2e220c531 100644 --- a/frontend/enhance-wasm/src/mini_tardis/serde.rs +++ b/frontend/enhance-wasm/src/mini_tardis/serde.rs @@ -29,7 +29,7 @@ pub fn str_to_obj(obj: &str) -> TardisResult { #[allow(dead_code)] -pub fn copy(obj: &T) -> TardisResult { +pub fn copy(obj: &T) -> TardisResult { str_to_obj(&obj_to_str(obj)?) } diff --git a/frontend/sdks/invoke/Cargo.toml b/frontend/sdks/invoke/Cargo.toml index 629a8980d..15a106635 100644 --- a/frontend/sdks/invoke/Cargo.toml +++ b/frontend/sdks/invoke/Cargo.toml @@ -15,7 +15,7 @@ name = "bios_sdk_invoke" path = "src/lib.rs" [features] -default = ["spi_kv", "spi_log", "spi_search", "spi_stats", "iam", "event"] +default = ["spi_kv", "spi_log", "spi_search", "spi_stats", "iam"] spi_base = [] spi_kv = ["spi_base"] spi_log = ["spi_base", "iam"] @@ -35,12 +35,12 @@ tardis = { workspace = true, features = [ "crypto", "ws-client", ] } -simple-invoke-client-macro = { path = "../simple-invoke-client-macro", optional = true } +simple-invoke-client-macro = { version = "0.2.0", path = "../simple-invoke-client-macro", optional = true } crossbeam = "0.8" asteroid-mq = { workspace = true, features = ["cluster-k8s"], optional = true } [dev-dependencies] tardis = { workspace = true, features = ["test"] } -simple-invoke-client-macro = { path = "../simple-invoke-client-macro" } +simple-invoke-client-macro = { version = "0.2.0", path = "../simple-invoke-client-macro" } [[test]] name = "test_macros" diff --git a/frontend/sdks/invoke/src/clients/event_client.rs b/frontend/sdks/invoke/src/clients/event_client.rs index cc34c5988..5b2523248 100644 --- a/frontend/sdks/invoke/src/clients/event_client.rs +++ b/frontend/sdks/invoke/src/clients/event_client.rs @@ -1,19 +1,14 @@ -use std::{future::Future, iter, marker::PhantomData}; +use std::{future::Future, marker::PhantomData}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use tardis::{ basic::{dto::TardisContext, error::TardisError, result::TardisResult}, - web::{ - poem_openapi::{self, Object}, - web_resp::{TardisResp, Void}, - }, + web::poem_openapi::{self, Object}, TardisFuns, TardisFunsInst, }; use crate::invoke_config::InvokeConfigApi; -use super::base_spi_client::BaseSpiClient; - /****************************************************************************************************************** * Http Client ******************************************************************************************************************/ @@ -28,48 +23,6 @@ impl<'a> EventClient<'a> { pub fn new(url: &'a str, funs: &'a TardisFunsInst) -> Self { Self { base_url: url, funs } } - - pub async fn add_topic(&self, req: &EventTopicAddOrModifyReq) -> TardisResult<()> { - let url = format!("{}/topic", self.base_url.trim_end_matches('/')); - let ctx = TardisContext::default(); - let headers = BaseSpiClient::headers(None, self.funs, &ctx).await?; - let resp = self.funs.web_client().post::>(&url, req, headers).await?; - if let Some(resp) = resp.body { - if resp.data.is_some() { - Ok(()) - } else { - Err(self.funs.err().internal_error("event", "add_topic", &resp.msg, "")) - } - } else { - Err(self.funs.err().internal_error("event", "add_topic", "failed to add event topic", "")) - } - } - pub async fn register(&self, req: &EventListenerRegisterReq) -> TardisResult { - let url = format!("{}/listener", self.base_url.trim_end_matches('/')); - - let resp = self.funs.web_client().post::>(&url, req, iter::empty()).await?; - if let Some(resp) = resp.body { - if let Some(data) = resp.data { - return Ok(data); - } else { - return Err(self.funs.err().internal_error("event", "register", &resp.msg, "")); - } - } - return Err(self.funs.err().internal_error("event", "register", "failed to register event listener", "")); - } - - pub async fn remove(&self, listener_code: &str, token: &str) -> TardisResult<()> { - let url = format!("{}/listener/{}?token={}", self.base_url.trim_end_matches('/'), listener_code, token); - let resp = self.funs.web_client().delete::>(&url, iter::empty()).await?; - if let Some(resp) = resp.body { - if resp.data.is_some() { - return Ok(()); - } else { - return Err(self.funs.err().internal_error("event", "register", &resp.msg, "")); - } - } - return Err(self.funs.err().internal_error("event", "register", "failed to register event listener", "")); - } } #[derive(Serialize, Deserialize, Debug)] diff --git a/frontend/sdks/invoke/src/clients/spi_kv_client.rs b/frontend/sdks/invoke/src/clients/spi_kv_client.rs index 4f63dbd2e..885ef1ab3 100644 --- a/frontend/sdks/invoke/src/clients/spi_kv_client.rs +++ b/frontend/sdks/invoke/src/clients/spi_kv_client.rs @@ -10,7 +10,7 @@ use tardis::TardisFunsInst; use crate::invoke_enumeration::InvokeModuleKind; use super::base_spi_client::BaseSpiClient; - +#[cfg(feature = "event")] pub mod event { use asteroid_mq::prelude::*; impl EventAttribute for super::KvItemAddOrModifyReq { diff --git a/frontend/sdks/invoke/src/clients/spi_log_client.rs b/frontend/sdks/invoke/src/clients/spi_log_client.rs index 61cebc790..83143316f 100644 --- a/frontend/sdks/invoke/src/clients/spi_log_client.rs +++ b/frontend/sdks/invoke/src/clients/spi_log_client.rs @@ -99,7 +99,7 @@ impl SpiLogClient { ctx: &TardisContext, ) -> TardisResult<()> { let cfg = funs.conf::(); - let owner_name = IamClient::new("", funs, &ctx, cfg.module_urls.get("iam").expect("missing iam base url")).get_account(&ctx.owner, &ctx.own_paths).await?.owner_name; + let owner_name = IamClient::new("", funs, ctx, cfg.module_urls.get("iam").expect("missing iam base url")).get_account(&ctx.owner, &ctx.own_paths).await?.owner_name; let req = LogItemAddReq { tag: DYNAMIC_LOG.to_string(), content: TardisFuns::json.obj_to_json(content)?, @@ -113,7 +113,7 @@ impl SpiLogClient { owner: Some(ctx.owner.clone()), own_paths: Some(ctx.own_paths.clone()), msg: None, - owner_name: owner_name, + owner_name, push: false, }; Self::add(req, funs, ctx).await?; diff --git a/frontend/sdks/invoke/src/clients/spi_search_client.rs b/frontend/sdks/invoke/src/clients/spi_search_client.rs index b3fa10f9b..d97c52be1 100644 --- a/frontend/sdks/invoke/src/clients/spi_search_client.rs +++ b/frontend/sdks/invoke/src/clients/spi_search_client.rs @@ -2,15 +2,17 @@ use tardis::basic::dto::TardisContext; use tardis::basic::result::TardisResult; use tardis::TardisFunsInst; -use crate::clients::event_client::mq_error; + use crate::dto::search_item_dto::{SearchEventItemDeleteReq, SearchEventItemModifyReq, SearchItemAddReq, SearchItemModifyReq}; use crate::invoke_enumeration::InvokeModuleKind; use super::base_spi_client::BaseSpiClient; -use super::event_client::{EventAttributeExt, EventCenterClient}; +#[cfg(feature = "event")] +use super::event_client::{EventAttributeExt, EventCenterClient, mq_error, SPI_RPC_TOPIC, get_topic}; use super::spi_kv_client::{KvItemAddOrModifyReq, KvItemDeleteReq, SpiKvClient}; pub struct SpiSearchClient; +#[cfg(feature = "event")] pub mod event { use crate::dto::search_item_dto::{SearchEventItemDeleteReq, SearchEventItemModifyReq, SearchItemAddReq, SearchItemModifyReq}; use asteroid_mq::prelude::*; @@ -35,6 +37,10 @@ pub mod event { impl SpiSearchClient { pub async fn add_item_and_name(add_req: &SearchItemAddReq, name: Option, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { + #[cfg(feature = "event")] + if let Some(_topic) = get_topic(&SPI_RPC_TOPIC) { + return EventCenterClient { topic_code: SPI_RPC_TOPIC }.add_item_and_name(add_req, name, funs, ctx).await + } let search_url: String = BaseSpiClient::module_url(InvokeModuleKind::Search, funs).await?; let headers = BaseSpiClient::headers(None, funs, ctx).await?; funs.web_client().put_obj_to_str(&format!("{search_url}/ci/item"), add_req, headers.clone()).await?; @@ -44,6 +50,10 @@ impl SpiSearchClient { } pub async fn modify_item_and_name(tag: &str, key: &str, modify_req: &SearchItemModifyReq, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { + #[cfg(feature = "event")] + if let Some(_topic) = get_topic(&SPI_RPC_TOPIC) { + return EventCenterClient { topic_code: SPI_RPC_TOPIC }.modify_item_and_name(tag, key, modify_req, funs, ctx).await + } let search_url: String = BaseSpiClient::module_url(InvokeModuleKind::Search, funs).await?; let headers = BaseSpiClient::headers(None, funs, ctx).await?; funs.web_client().put_obj_to_str(&format!("{search_url}/ci/item/{tag}/{key}"), modify_req, headers.clone()).await?; @@ -55,6 +65,10 @@ impl SpiSearchClient { } pub async fn delete_item_and_name(tag: &str, key: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { + #[cfg(feature = "event")] + if let Some(_topic) = get_topic(&SPI_RPC_TOPIC) { + return EventCenterClient { topic_code: SPI_RPC_TOPIC }.delete_item_and_name(tag, key, funs, ctx).await + } let search_url = BaseSpiClient::module_url(InvokeModuleKind::Search, funs).await?; let headers = BaseSpiClient::headers(None, funs, ctx).await?; funs.web_client().delete_to_void(&format!("{search_url}/ci/item/{tag}/{key}"), headers.clone()).await?; @@ -62,7 +76,7 @@ impl SpiSearchClient { Ok(()) } } - +#[cfg(feature = "event")] impl EventCenterClient { pub async fn add_item_and_name(&self, add_req: &SearchItemAddReq, name: Option, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> { let topic = self.get_topic()?;