diff --git a/backend/basic/src/rbum/domain/rbum_kind.rs b/backend/basic/src/rbum/domain/rbum_kind.rs
index d28ee2e89..6c395d7bd 100644
--- a/backend/basic/src/rbum/domain/rbum_kind.rs
+++ b/backend/basic/src/rbum/domain/rbum_kind.rs
@@ -7,25 +7,64 @@ use tardis::db::sea_orm::sea_query::{ColumnDef, IndexCreateStatement, Table, Tab
use tardis::db::sea_orm::*;
use tardis::TardisCreateIndex;
-/// Resource kind
+/// Resource kind model
///
-/// A resource kind is a set of common resources. \
+/// 资源类型模型
+///
+/// A resource kind is a set of common resources.
/// E.g. `/tenant/**` , `/app/**` these are all APIs, and these are all API-kind resources; `/tenant/list` ,
/// `/tenant/detail#more` these are all menus, and these are all menu-kind resources.
+///
+/// 资源类型是一组共同的资源。
+/// 例如 `/tenant/**` , `/app/**` 这些都是API,这些都是API类型的资源; `/tenant/list` , `/tenant/detail#more` 这些都是菜单,这些都是菜单类型的资源。
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, TardisCreateIndex)]
#[sea_orm(table_name = "rbum_kind")]
pub struct Model {
+ /// Resource kind id
+ ///
+ /// 资源类型id
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
- /// Resource kind code, which is required to conform to the scheme specification in the uri, matching the regular: ^[a-z0-9-.]+$
+ /// Resource kind module
+ ///
+ /// 资源类型模块
+ ///
+ /// 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`` 等多个资源类型。
+ pub module: String,
+ /// Resource kind code
+ ///
+ /// 资源类型编码
+ ///
+ /// 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-.]+$`` 。
#[index(unique)]
pub code: String,
+ /// Resource kind name
+ ///
+ /// 资源类型名称
pub name: String,
+ /// Resource kind note
+ ///
+ /// 资源类型备注
pub note: String,
+ /// Resource kind icon
+ ///
+ /// 资源类型图标
pub icon: String,
+ /// Resource kind sort
+ ///
+ /// 资源类型排序
pub sort: i64,
- pub module: String,
- /// Each resource kind can specify an extension table for storing customized data
+ /// Extension table name
+ ///
+ /// 扩展表名
+ ///
+ /// Each resource kind can specify an extension table for storing customized data.
+ ///
+ /// 每个资源类型可以指定一个扩展表用于存储自定义数据。
pub ext_table_name: String,
pub scope_level: i16,
@@ -57,11 +96,11 @@ impl TardisActiveModel for ActiveModel {
.col(ColumnDef::new(Column::Id).not_null().string().primary_key())
// Specific
.col(ColumnDef::new(Column::Code).not_null().string())
+ .col(ColumnDef::new(Column::Module).not_null().string())
.col(ColumnDef::new(Column::Name).not_null().string())
.col(ColumnDef::new(Column::Note).not_null().string())
.col(ColumnDef::new(Column::Icon).not_null().string())
.col(ColumnDef::new(Column::Sort).not_null().big_integer())
- .col(ColumnDef::new(Column::Module).not_null().string())
.col(ColumnDef::new(Column::ExtTableName).not_null().string())
// Basic
.col(ColumnDef::new(Column::OwnPaths).not_null().string())
diff --git a/backend/basic/src/rbum/domain/rbum_kind_attr.rs b/backend/basic/src/rbum/domain/rbum_kind_attr.rs
index 3087d1f60..e8db89e12 100644
--- a/backend/basic/src/rbum/domain/rbum_kind_attr.rs
+++ b/backend/basic/src/rbum/domain/rbum_kind_attr.rs
@@ -7,73 +7,250 @@ use tardis::db::sea_orm::sea_query::{ColumnDef, IndexCreateStatement, Table, Tab
use tardis::db::sea_orm::*;
use tardis::TardisCreateIndex;
-/// Resource kind extended attribute definition model
+/// Resource kind attribute definition model
+///
+/// 资源类型属性定义模型
///
/// General logic for dynamic request processing:
///
/// 1. dynamic values take precedence over static values
-/// 2. supports calling http to get data with GET request
-/// 3. request url supports attribute variable substitution, format is: `{attribute name}` .
-/// 4. if no attribute variable substitution exists and secret = false, the url is called directly and the corresponding value is returned,
-/// 5. if attribute variable substitution exists, then:
-/// 1) extract all attribute variables to be replaced
-/// 2) monitor changes of these attributes
-/// 3) substitute attribute variables with values into the url
-/// 4) if no longer an attribute variable substitution in the url and secret = false, call the url and return the corresponding value
-/// 6. before the resource object is saved, if secret = true and an attribute variable substitution in the url, call the url and return the corresponding value
+/// 1. supports calling http to get data with GET request
+/// 1. request url supports attribute variable substitution, format is: ``{attribute name}``
+/// 1. if no attribute variable substitution exists and ``secret = false`` , the url is called directly and the corresponding value is returned
+/// 1. if attribute variable substitution exists, then:
+/// 1. extract all attribute variables to be replaced
+/// 1. monitor changes of these attributes
+/// 1. substitute attribute variables with values into the url
+/// 1. if no longer an attribute variable substitution in the url and ``secret = false`` , call the url and return the corresponding value
+/// 1. before the resource object is saved, if ``secret = true`` and an attribute variable substitution in the url, call the url and return the corresponding value
+///
+/// For security reasons, the last step must be completed by the server.
+///
+/// 动态请求的通用逻辑处理:
+///
+/// 1. 动态值优先于静态值
+/// 1. 支持调用http获取数据,请求方式为GET
+/// 1. 请求url支持属性变量替换,格式为:``{属性名}``
+/// 1. 如果没有属性变量替换存在且 ``secret = false`` ,则直接调用url,返回对应值
+/// 1. 如果存在属性变量替换,则:
+/// 1. 提取所有需要替换的属性变量
+/// 1. 监听这些属性的变化
+/// 1. 将属性变量替换为值后,替换到url中
+/// 1. 如果url中不再存在属性变量替换且 ``secret = false`` ,则调用url,返回对应值
+/// 1. 在保存资源对象之前,如果 ``secret = true`` 且url中存在属性变量替换,则调用url,返回对应值
///
-/// For security reasons, step 6 must be done by the server side.
+/// 为了安全起见,最后一步须由服务端完成。
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, TardisCreateIndex)]
#[sea_orm(table_name = "rbum_kind_attr")]
pub struct Model {
+ /// Attribute definition id
+ ///
+ /// 属性定义id
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
-
- #[index(index_id = "id")]
- pub name: String,
+ /// Attribute definition module
+ ///
+ /// 属性定义模块
+ ///
+ /// Used to distinguish different instances of the same resource kind.
+ /// For example, the ``user`` kind resource, different tenants can have different Attribute definitions.
+ ///
+ /// 用于区别使用同一资源类型的不同实例。比如 ``用户`` 类型的资源,不同的租户可以有不同的属性定义。
#[index(index_id = "id")]
pub module: String,
+ /// Attribute definition name
+ ///
+ /// 属性定义名称
+ ///
+ /// Corresponds to the field name, such as ```` .
+ ///
+ /// 多对应于字段名,如 ```` 。
+ #[index(index_id = "id")]
+ pub name: String,
+ /// Attribute definition label
+ ///
+ /// 属性定义标签
+ ///
+ /// Corresponds to the field label, such as ```` .
+ ///
+ /// 多对应于字段标签,如 ```` 。
pub label: String,
+ /// Attribute definition note
+ ///
+ /// 属性定义备注
pub note: String,
+ /// Attribute definition sort
+ ///
+ /// 属性定义排序
pub sort: i64,
- pub main_column: bool,
+ /// 是否定位类型的属性定义
+ ///
+ /// Whether the Attribute is a positioning kind
+ ///
+ /// Positioning kind extension attributes are used to assist in locating resources other than ID,
+ /// such as ``ID card`` and ``work number``. Generally, an index will be added.
+ ///
+ /// 定位类型的属性用于除ID外辅助定位资源,比如 ``身份证`` ``工号`` 。 一般而言会加索引。
pub position: bool,
+ /// Whether the Attribute definition is a capacity kind
+ ///
+ /// 是否容量类型的属性定义
+ ///
+ /// Capacity kind extension attributes are used to store capacity information, such as ``disk capacity`` and ``memory capacity``.
+ /// These attributes can be "consumed" and are often used in conjunction with [`crate::rbum::domain::rbum_rel::Model`] and [`crate::rbum::domain::rbum_rel_attr::Model`],
+ /// the latter of which can record the consumed capacity.
+ ///
+ /// 容量类型的属性用于存储容量信息,如 ``磁盘容量`` ``内存容量`` 。
+ /// 这些属性是可以被“消耗”的,多与 [`crate::rbum::domain::rbum_rel::Model`] 及 [`crate::rbum::domain::rbum_rel_attr::Model`] 配合使用,后者可以记录消耗的容量。
pub capacity: bool,
+ /// Whether overload is allowed
+ ///
+ /// 是否允许超载
+ ///
+ /// This attribute is only valid when ``capacity = true``, and is used to indicate whether the capacity is allowed to be overloaded.
+ ///
+ /// 此属性仅当 ``capacity = true``` 时有效,用于表示容量是否允许超载。
pub overload: bool,
- pub hide: bool,
- /// When secret = true, the attribute information is not returned to the frontend(except in configuration)
+ /// Whether it is a secret
+ ///
+ /// 是否是秘密
+ ///
+ /// If ``true``, the value corresponding to this attribute will not be returned to the front end, but will only be processed on the server.
+ /// This attribute can ensure the security of attribute data.
+ ///
+ /// 当为 ``true`` 时属性对应的值不会返回给前端,仅在服务端处理。此属性可以保证属性数据安全。
pub secret: bool,
- /// Display condition, json format: `{:}`, currently only supports `and` operations
- pub show_by_conds: String,
+ /// Whether it is the main column
+ ///
+ /// 是否是主列
+ ///
+ /// If ``true``, it means that the attribute is the field corresponding to [`crate::rbum::domain::rbum_kind::Model::ext_table_name`] table,
+ /// otherwise the attribute value will be stored in the [`crate::rbum::domain::rbum_item_attr::Model`] table.
+ ///
+ /// 当为 ``true`` 时表示该属性是 [`crate::rbum::domain::rbum_kind::Model::ext_table_name`] 表对应的字段,
+ /// 否则会将该属性值存储在 [`crate::rbum::domain::rbum_item_attr::Model`] 表中。
+ pub main_column: bool,
/// Whether indexing is needed
+ ///
+ /// 是否需要索引
+ ///
+ /// This attribute is only valid when ``main_column = true``, used to indicate whether the attribute needs to be indexed.
+ ///
+ /// 此属性仅当 ``main_column = true`` 时有效,用于表示是否需要对该属性进行索引。
pub idx: bool,
+ /// Data kind
+ ///
+ /// 数据类型
+ ///
/// Associated [resource kind](crate::rbum::rbum_enumeration::RbumDataTypeKind)
pub data_type: String,
+ /// Show widget kind
+ ///
+ /// 显示控件类型
+ ///
/// Associated [resource kind](crate::rbum::rbum_enumeration::RbumWidgetTypeKind)
pub widget_type: String,
+ /// Number of columns occupied by the widget
+ ///
+ /// 控件占用列数
pub widget_columns: i16,
+ /// Whether to hide by default
+ ///
+ /// 默认是否隐藏
+ ///
+ /// If ``true``, the value corresponding to this attribute will be returned to the front end, but will not be displayed.
+ /// This attribute is often used for internal processing on the front end.
+ /// This attribute cannot guarantee the security of attribute data.
+ ///
+ /// 当为 ``true`` 时该属性对应的值会返给前端,但不会显示。多用于前端内部处理。此属性不能保证属性数据安全。
+ pub hide: bool,
+ /// Show conditions
+ ///
+ /// 显示条件
+ ///
+ /// Json format: ``{:}``, currently only supports ``and`` operations.
+ ///
+ /// Json格式:``{<属性名>:<属性值>}``,目前仅支持``and``操作。
+ pub show_by_conds: String,
+ /// Fixed default value
+ ///
+ /// 固定默认值
pub default_value: String,
/// Dynamic default value
- /// the return format is the same as `default_value`
- /// or `json` when `data_type` = `Json` and `widget_type` = `Control`
- /// or `array` when `data_type` = `Array` and `widget_type` = `Group`
+ ///
+ /// 动态默认值
+ ///
+ /// It can be a URL (with placeholders) or a set of placeholders.
+ /// Placeholders are wrapped in ``{...}``, and the corresponding values can come from other current attribute values or incoming context variables.
+ ///
+ /// 可以是一个URL(允许有占位符)或是一组占位符。占位符使用 ``{...}``包裹,对应的值可以来自当前的其它属性值、传入的上下文变量。
+ ///
+ /// The return format is the same as ``default_value``
+ /// or ``json`` when ``data_type = Json``` and ``widget_type = Control``
+ /// or ``array`` when ``data_type = Array`` and ``widget_type = Group``.
+ ///
+ /// 返回格式与 ``default_value`` 一致,
+ /// 或当 ``data_type = Json`` 且 ``widget_type = Control`` 时为 ``json`` ,
+ /// 或当 ``data_type = Array`` 且 ``widget_type = Group`` 时为 ``array``。
pub dyn_default_value: String,
- /// Fixed option, json array formatted as `[{name::value:}]`
+ /// Fixed options
+ ///
+ /// 固定选项
+ ///
+ /// Json array format: ``[{name::value:}]``.
+ ///
+ /// Json数组格式:``[{name:<显示名称>:value:<对应值>}]``。
pub options: String,
/// Dynamic options
- /// the return format is the same as `options`
+ ///
+ /// 动态选项
+ ///
+ /// It can be a URL (with placeholders) or a set of placeholders.
+ /// Placeholders are wrapped in ``{...}``, and the corresponding values can come from other current attribute values or incoming context variables.
+ ///
+ /// 可以是一个URL(允许有占位符)或是一组占位符。占位符使用 ``{...}``包裹,对应的值可以来自当前的其它属性值、传入的上下文变量。
+ ///
+ /// the return format is the same as `options`.
+ ///
+ /// 返回格式与 `options` 一致。
pub dyn_options: String,
+ /// Whether it is required
+ ///
+ /// 是否必填
pub required: bool,
+ /// Minimum length
+ ///
+ /// 最小长度
pub min_length: i32,
+ /// Maximum length
+ ///
+ /// 最大长度
pub max_length: i32,
- /// Used to implement multi-level attributes, default is empty
+ /// Parent attribute name
+ ///
+ /// 父属性名称
+ ///
+ /// Used to implement multi-level attributes.
+ ///
+ /// 用于实现多级属性。
pub parent_attr_name: String,
- /// Custom behavior attributes \
- /// E.g. user selection function, role selection function, etc.
+ /// Custom behavior
+ ///
+ /// 自定义行为
+ ///
+ /// For example: user selection function, role selection function, etc.
/// Custom behavior needs to be bound to the corresponding function code.
+ ///
+ /// 例如:用户选择函数、角色选择函数等。
+ /// 自定义行为需要绑定到对应的函数代码。
pub action: String,
+ /// Extension information
+ ///
+ /// 扩展信息
pub ext: String,
/// Associated [resource kind](crate::rbum::domain::rbum_kind::Model) id
+ ///
+ /// 关联的 [资源类型](crate::rbum::domain::rbum_kind::Model) id
#[index(index_id = "id")]
pub rel_rbum_kind_id: String,
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 5f63c209e..1872546d0 100644
--- a/backend/basic/src/rbum/dto/rbum_kind_attr_dto.rs
+++ b/backend/basic/src/rbum/dto/rbum_kind_attr_dto.rs
@@ -8,114 +8,618 @@ use tardis::web::poem_openapi;
use crate::rbum::rbum_enumeration::{RbumDataTypeKind, RbumScopeLevelKind, RbumWidgetTypeKind};
+/// Add request for resource kind attribute definition
+///
+/// 资源类型属性定义添加请求
#[derive(Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object))]
pub struct RbumKindAttrAddReq {
- #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))]
- pub name: TrimString,
+ /// Attribute definition module
+ ///
+ /// 属性定义模块
+ ///
+ /// Default is ``empty``
+ ///
+ /// 默认为 ``空``
+ ///
+ /// Used to distinguish different instances of the same resource kind.
+ /// 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")))]
pub module: Option,
+ /// Attribute definition name
+ ///
+ /// 属性定义名称
+ ///
+ /// Corresponds to the field name, such as ```` .
+ ///
+ /// 多对应于字段名,如 ```` 。
+ #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))]
+ pub name: TrimString,
+ /// Attribute definition label
+ ///
+ /// 属性定义标签
+ ///
+ /// Corresponds to the field label, such as ```` .
+ ///
+ /// 多对应于字段标签,如 ```` 。
#[cfg_attr(feature = "default", 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")))]
pub note: Option,
+ /// Attribute definition sort
+ ///
+ /// 属性定义排序
pub sort: Option,
- pub main_column: Option,
+ /// 是否定位类型的属性定义
+ ///
+ /// Whether the Attribute is a positioning kind
+ ///
+ /// Default is ``false``
+ ///
+ /// 默认为 ``false``
+ ///
+ /// Positioning kind extension attributes are used to assist in locating resources other than ID,
+ /// such as ``ID card`` and ``work number``. Generally, an index will be added.
+ ///
+ /// 定位类型的属性用于除ID外辅助定位资源,比如 ``身份证`` ``工号`` 。 一般而言会加索引。
pub position: Option,
+ /// Whether the Attribute definition is a capacity kind
+ ///
+ /// 是否容量类型的属性定义
+ ///
+ /// Default is ``false``
+ ///
+ /// 默认为 ``false``
+ ///
+ /// Capacity kind extension attributes are used to store capacity information, such as ``disk capacity`` and ``memory capacity``.
+ /// These attributes can be "consumed" and are often used in conjunction with [`crate::rbum::domain::rbum_rel::Model`] and [`crate::rbum::domain::rbum_rel_attr::Model`],
+ /// the latter of which can record the consumed capacity.
+ ///
+ /// 容量类型的属性用于存储容量信息,如 ``磁盘容量`` ``内存容量`` 。
+ /// 这些属性是可以被“消耗”的,多与 [`crate::rbum::domain::rbum_rel::Model`] 及 [`crate::rbum::domain::rbum_rel_attr::Model`] 配合使用,后者可以记录消耗的容量。
pub capacity: Option,
+ /// Whether overload is allowed
+ ///
+ /// 是否允许超载
+ ///
+ /// Default is ``false``
+ ///
+ /// 默认为 ``false``
+ ///
+ /// This attribute is only valid when ``capacity = true``, and is used to indicate whether the capacity is allowed to be overloaded.
+ ///
+ /// 此属性仅当 ``capacity = true``` 时有效,用于表示容量是否允许超载。
pub overload: Option,
- pub hide: Option,
+ /// Whether it is a secret
+ ///
+ /// 是否是秘密
+ ///
+ /// Default is ``false``
+ ///
+ /// 默认为 ``false``
+ ///
+ /// If ``true``, the value corresponding to this attribute will not be returned to the front end, but will only be processed on the server.
+ /// This attribute can ensure the security of attribute data.
+ ///
+ /// 当为 ``true`` 时属性对应的值不会返回给前端,仅在服务端处理。此属性可以保证属性数据安全。
pub secret: Option,
- pub show_by_conds: Option,
+ /// Whether it is the main column
+ ///
+ /// 是否是主列
+ ///
+ /// Default is ``false``
+ ///
+ /// 默认为 ``false``
+ ///
+ /// If ``true``, it means that the attribute is the field corresponding to [`crate::rbum::domain::rbum_kind::Model::ext_table_name`] table,
+ /// otherwise the attribute value will be stored in the [`crate::rbum::domain::rbum_item_attr::Model`] table.
+ ///
+ /// 当为 ``true`` 时表示该属性是 [`crate::rbum::domain::rbum_kind::Model::ext_table_name`] 表对应的字段,
+ /// 否则会将该属性值存储在 [`crate::rbum::domain::rbum_item_attr::Model`] 表中。
+ pub main_column: Option,
+ /// Whether indexing is needed
+ ///
+ /// 是否需要索引
+ ///
+ /// Default is ``false``
+ ///
+ /// 默认为 ``false``
+ ///
+ /// This attribute is only valid when ``main_column = true``, used to indicate whether the attribute needs to be indexed.
+ ///
+ /// 此属性仅当 ``main_column = true`` 时有效,用于表示是否需要对该属性进行索引。
pub idx: Option,
+ /// Data kind
+ ///
+ /// 数据类型
pub data_type: RbumDataTypeKind,
+ /// Show widget kind
+ ///
+ /// 显示控件类型
pub widget_type: RbumWidgetTypeKind,
+ /// Number of columns occupied by the widget
+ ///
+ /// 控件占用列数
+ ///
+ /// Default is ``0``, indicating self-adaptation
+ ///
+ /// 默认为 ``0`` , 表示自适应
+ #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))]
pub widget_columns: Option,
+ /// Whether to hide by default
+ ///
+ /// 默认是否隐藏
+ ///
+ /// Default is ``false``
+ ///
+ /// 默认为 ``false``
+ ///
+ /// If ``true``, the value corresponding to this attribute will be returned to the front end, but will not be displayed.
+ /// This attribute is often used for internal processing on the front end.
+ /// This attribute cannot guarantee the security of attribute data.
+ ///
+ /// 当为 ``true`` 时该属性对应的值会返给前端,但不会显示。多用于前端内部处理。此属性不能保证属性数据安全。
+ pub hide: Option,
+ /// Show conditions
+ ///
+ /// 显示条件
+ ///
+ /// Json format: ``{:}``, currently only supports ``and`` operations.
+ ///
+ /// Json格式:``{<属性名>:<属性值>}``,目前仅支持``and``操作。
+ pub show_by_conds: Option,
+ /// Fixed default value
+ ///
+ /// 固定默认值
#[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))]
pub default_value: Option,
+ /// Dynamic default value
+ ///
+ /// 动态默认值
+ ///
+ /// It can be a URL (with placeholders) or a set of placeholders.
+ /// Placeholders are wrapped in ``{...}``, and the corresponding values can come from other current attribute values or incoming context variables.
+ ///
+ /// 可以是一个URL(允许有占位符)或是一组占位符。占位符使用 ``{...}``包裹,对应的值可以来自当前的其它属性值、传入的上下文变量。
+ ///
+ /// The return format is the same as ``default_value``
+ /// or ``json`` when ``data_type = Json``` and ``widget_type = Control``
+ /// or ``array`` when ``data_type = Array`` and ``widget_type = Group``.
+ ///
+ /// 返回格式与 ``default_value`` 一致,
+ /// 或当 ``data_type = Json`` 且 ``widget_type = Control`` 时为 ``json`` ,
+ /// 或当 ``data_type = Array`` 且 ``widget_type = Group`` 时为 ``array``。
pub dyn_default_value: Option,
+ /// Fixed options
+ ///
+ /// 固定选项
+ ///
+ /// Json array format: ``[{name::value:}]``.
+ ///
+ /// Json数组格式:``[{name:<显示名称>:value:<对应值>}]``。
pub options: Option,
+ /// Dynamic options
+ ///
+ /// 动态选项
+ ///
+ /// It can be a URL (with placeholders) or a set of placeholders.
+ /// Placeholders are wrapped in ``{...}``, and the corresponding values can come from other current attribute values or incoming context variables.
+ ///
+ /// 可以是一个URL(允许有占位符)或是一组占位符。占位符使用 ``{...}``包裹,对应的值可以来自当前的其它属性值、传入的上下文变量。
+ ///
+ /// the return format is the same as `options`.
+ ///
+ /// 返回格式与 `options` 一致。
pub dyn_options: Option,
+ /// Whether it is required
+ ///
+ /// 是否必填
+ ///
+ /// Default is ``false``
+ ///
+ /// 默认为 ``false``
pub required: Option,
+ /// Minimum length
+ ///
+ /// 最小长度
+ ///
+ /// Default is ``0``, indicating no limit
+ ///
+ /// 默认为 ``0`` , 表示不限制
+ #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))]
pub min_length: Option,
+ /// Maximum length
+ ///
+ /// 最大长度
+ ///
+ /// Default is ``0``, indicating no limit
+ ///
+ /// 默认为 ``0`` , 表示不限制
+ #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))]
pub max_length: Option,
+ /// Parent attribute name
+ ///
+ /// 父属性名称
+ ///
+ /// Used to implement multi-level attributes.
+ ///
+ /// 用于实现多级属性。
pub parent_attr_name: Option,
+ /// Custom behavior
+ ///
+ /// 自定义行为
+ ///
+ /// For example: user selection function, role selection function, etc.
+ /// Custom behavior needs to be bound to the corresponding function code.
+ ///
+ /// 例如:用户选择函数、角色选择函数等。
+ /// 自定义行为需要绑定到对应的函数代码。
#[cfg_attr(feature = "default", 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")))]
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")))]
pub rel_rbum_kind_id: String,
pub scope_level: Option,
}
+/// Modify request for resource kind attribute definition
+///
+/// 资源类型属性定义修改请求
#[derive(Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object))]
pub struct RbumKindAttrModifyReq {
+ /// Attribute definition label
+ ///
+ /// 属性定义标签
+ ///
+ /// Corresponds to the field label, such as ```` .
+ ///
+ /// 多对应于字段标签,如 ```` 。
#[cfg_attr(feature = "default", 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")))]
pub note: Option,
+ /// Attribute definition sort
+ ///
+ /// 属性定义排序
pub sort: Option,
- pub main_column: Option,
+ /// 是否定位类型的属性定义
+ ///
+ /// Whether the Attribute is a positioning kind
+ ///
+ /// Positioning kind extension attributes are used to assist in locating resources other than ID,
+ /// such as ``ID card`` and ``work number``. Generally, an index will be added.
+ ///
+ /// 定位类型的属性用于除ID外辅助定位资源,比如 ``身份证`` ``工号`` 。 一般而言会加索引。
pub position: Option,
+ /// Whether the Attribute definition is a capacity kind
+ ///
+ /// 是否容量类型的属性定义
+ ///
+ /// Capacity kind extension attributes are used to store capacity information, such as ``disk capacity`` and ``memory capacity``.
+ /// These attributes can be "consumed" and are often used in conjunction with [`crate::rbum::domain::rbum_rel::Model`] and [`crate::rbum::domain::rbum_rel_attr::Model`],
+ /// the latter of which can record the consumed capacity.
+ ///
+ /// 容量类型的属性用于存储容量信息,如 ``磁盘容量`` ``内存容量`` 。
+ /// 这些属性是可以被“消耗”的,多与 [`crate::rbum::domain::rbum_rel::Model`] 及 [`crate::rbum::domain::rbum_rel_attr::Model`] 配合使用,后者可以记录消耗的容量。
pub capacity: Option,
+ /// Whether overload is allowed
+ ///
+ /// 是否允许超载
+ ///
+ /// This attribute is only valid when ``capacity = true``, and is used to indicate whether the capacity is allowed to be overloaded.
+ ///
+ /// 此属性仅当 ``capacity = true``` 时有效,用于表示容量是否允许超载。
pub overload: Option,
- pub hide: Option,
+ /// Whether it is a secret
+ ///
+ /// 是否是秘密
+ ///
+ /// If ``true``, the value corresponding to this attribute will not be returned to the front end, but will only be processed on the server.
+ /// This attribute can ensure the security of attribute data.
+ ///
+ /// 当为 ``true`` 时属性对应的值不会返回给前端,仅在服务端处理。此属性可以保证属性数据安全。
pub secret: Option,
- pub show_by_conds: Option,
+ /// Whether it is the main column
+ ///
+ /// 是否是主列
+ ///
+ /// If ``true``, it means that the attribute is the field corresponding to [`crate::rbum::domain::rbum_kind::Model::ext_table_name`] table,
+ /// otherwise the attribute value will be stored in the [`crate::rbum::domain::rbum_item_attr::Model`] table.
+ ///
+ /// 当为 ``true`` 时表示该属性是 [`crate::rbum::domain::rbum_kind::Model::ext_table_name`] 表对应的字段,
+ /// 否则会将该属性值存储在 [`crate::rbum::domain::rbum_item_attr::Model`] 表中。
+ pub main_column: Option,
+ /// Whether indexing is needed
+ ///
+ /// 是否需要索引
+ ///
+ /// This attribute is only valid when ``main_column = true``, used to indicate whether the attribute needs to be indexed.
+ ///
+ /// 此属性仅当 ``main_column = true`` 时有效,用于表示是否需要对该属性进行索引。
pub idx: Option,
+ /// Data kind
+ ///
+ /// 数据类型
pub data_type: Option,
+ /// Show widget kind
+ ///
+ /// 显示控件类型
pub widget_type: Option,
+ /// Number of columns occupied by the widget
+ ///
+ /// 控件占用列数
+ ///
+ /// Default is ``0``, indicating self-adaptation
+ ///
+ /// 默认为 ``0`` , 表示自适应
+ #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))]
pub widget_columns: Option,
+ /// Whether to hide by default
+ ///
+ /// 默认是否隐藏
+ ///
+ /// If ``true``, the value corresponding to this attribute will be returned to the front end, but will not be displayed.
+ /// This attribute is often used for internal processing on the front end.
+ /// This attribute cannot guarantee the security of attribute data.
+ ///
+ /// 当为 ``true`` 时该属性对应的值会返给前端,但不会显示。多用于前端内部处理。此属性不能保证属性数据安全。
+ pub hide: Option,
+ /// Show conditions
+ ///
+ /// 显示条件
+ ///
+ /// Json format: ``{:}``, currently only supports ``and`` operations.
+ ///
+ /// Json格式:``{<属性名>:<属性值>}``,目前仅支持``and``操作。
+ pub show_by_conds: Option,
+ /// Fixed default value
+ ///
+ /// 固定默认值
#[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "2000")))]
pub default_value: Option,
+ /// Dynamic default value
+ ///
+ /// 动态默认值
+ ///
+ /// It can be a URL (with placeholders) or a set of placeholders.
+ /// Placeholders are wrapped in ``{...}``, and the corresponding values can come from other current attribute values or incoming context variables.
+ ///
+ /// 可以是一个URL(允许有占位符)或是一组占位符。占位符使用 ``{...}``包裹,对应的值可以来自当前的其它属性值、传入的上下文变量。
+ ///
+ /// The return format is the same as ``default_value``
+ /// or ``json`` when ``data_type = Json``` and ``widget_type = Control``
+ /// or ``array`` when ``data_type = Array`` and ``widget_type = Group``.
+ ///
+ /// 返回格式与 ``default_value`` 一致,
+ /// 或当 ``data_type = Json`` 且 ``widget_type = Control`` 时为 ``json`` ,
+ /// 或当 ``data_type = Array`` 且 ``widget_type = Group`` 时为 ``array``。
pub dyn_default_value: Option,
+ /// Fixed options
+ ///
+ /// 固定选项
+ ///
+ /// Json array format: ``[{name::value:}]``.
+ ///
+ /// Json数组格式:``[{name:<显示名称>:value:<对应值>}]``。
pub options: Option,
+ /// Dynamic options
+ ///
+ /// 动态选项
+ ///
+ /// It can be a URL (with placeholders) or a set of placeholders.
+ /// Placeholders are wrapped in ``{...}``, and the corresponding values can come from other current attribute values or incoming context variables.
+ ///
+ /// 可以是一个URL(允许有占位符)或是一组占位符。占位符使用 ``{...}``包裹,对应的值可以来自当前的其它属性值、传入的上下文变量。
+ ///
+ /// the return format is the same as `options`.
+ ///
+ /// 返回格式与 `options` 一致。
pub dyn_options: Option,
+ /// Whether it is required
+ ///
+ /// 是否必填
pub required: Option,
+ /// Minimum length
+ ///
+ /// 最小长度
+ #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))]
pub min_length: Option,
+ /// Maximum length
+ ///
+ /// 最大长度
+ #[cfg_attr(feature = "default", oai(validator(minimum(value = "0", exclusive = "false"))))]
pub max_length: Option,
+ /// Parent attribute name
+ ///
+ /// 父属性名称
+ ///
+ /// Used to implement multi-level attributes.
+ ///
+ /// 用于实现多级属性。
pub parent_attr_name: Option,
+ /// Custom behavior
+ ///
+ /// 自定义行为
+ ///
+ /// For example: user selection function, role selection function, etc.
+ /// Custom behavior needs to be bound to the corresponding function code.
+ ///
+ /// 例如:用户选择函数、角色选择函数等。
+ /// 自定义行为需要绑定到对应的函数代码。
#[cfg_attr(feature = "default", 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")))]
pub ext: Option,
pub scope_level: Option,
}
+/// Resource kind attribute definition summary information
+///
+/// 资源类型属性定义概要信息
#[derive(Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))]
pub struct RbumKindAttrSummaryResp {
+ /// Attribute definition id
+ ///
+ /// 属性定义id
pub id: String,
- pub name: String,
+ /// Attribute definition module
+ ///
+ /// 属性定义模块
pub module: String,
+ /// Attribute definition name
+ ///
+ /// 属性定义名称
+ pub name: String,
+ /// Attribute definition label
+ ///
+ /// 属性定义标签
pub label: String,
+ /// Attribute definition note
+ ///
+ /// 属性定义备注
pub note: String,
+ /// Attribute definition sort
+ ///
+ /// 属性定义排序
pub sort: i64,
- pub main_column: bool,
+ /// 是否定位类型的属性定义
+ ///
+ /// Whether the Attribute is a positioning kind
pub position: bool,
+ /// Whether the Attribute definition is a capacity kind
+ ///
+ /// 是否容量类型的属性定义
pub capacity: bool,
+ /// Whether overload is allowed
+ ///
+ /// 是否允许超载
pub overload: bool,
- pub hide: bool,
+ /// Whether it is a secret
+ ///
+ /// 是否是秘密
pub secret: bool,
- pub show_by_conds: String,
+ /// Whether it is the main column
+ ///
+ /// 是否是主列
+ pub main_column: bool,
+ /// Whether indexing is needed
+ ///
+ /// 是否需要索引
pub idx: bool,
+ /// Data kind
+ ///
+ /// 数据类型
pub data_type: RbumDataTypeKind,
+ /// Show widget kind
+ ///
+ /// 显示控件类型
pub widget_type: RbumWidgetTypeKind,
+ /// Number of columns occupied by the widget
+ ///
+ /// 控件占用列数
pub widget_columns: i16,
+ /// Whether to hide by default
+ ///
+ /// 默认是否隐藏
+ pub hide: bool,
+ /// Show conditions
+ ///
+ /// 显示条件
+ ///
+ /// Json format: ``{:}``, currently only supports ``and`` operations.
+ ///
+ /// Json格式:``{<属性名>:<属性值>}``,目前仅支持``and``操作。
+ pub show_by_conds: String,
+ /// Fixed default value
+ ///
+ /// 固定默认值
pub default_value: String,
+ /// Dynamic default value
+ ///
+ /// 动态默认值
+ ///
+ /// Placeholders are wrapped in ``{...}``, and the corresponding values can come from other current attribute values or incoming context variables.
+ ///
+ /// 可以是一个URL(允许有占位符)或是一组占位符。占位符使用 ``{...}``包裹,对应的值可以来自当前的其它属性值、传入的上下文变量。
+ ///
+ /// The return format is the same as ``default_value``
+ /// or ``json`` when ``data_type = Json``` and ``widget_type = Control``
+ /// or ``array`` when ``data_type = Array`` and ``widget_type = Group``.
+ ///
+ /// 返回格式与 ``default_value`` 一致,
+ /// 或当 ``data_type = Json`` 且 ``widget_type = Control`` 时为 ``json`` ,
+ /// 或当 ``data_type = Array`` 且 ``widget_type = Group`` 时为 ``array``。
pub dyn_default_value: String,
+ /// Fixed options
+ ///
+ /// 固定选项
+ ///
+ /// Json array format: ``[{name::value:}]``.
+ ///
+ /// Json数组格式:``[{name:<显示名称>:value:<对应值>}]``。
pub options: String,
+ /// Dynamic options
+ ///
+ /// 动态选项
+ ///
+ /// It can be a URL (with placeholders) or a set of placeholders.
+ /// Placeholders are wrapped in ``{...}``, and the corresponding values can come from other current attribute values or incoming context variables.
+ ///
+ /// 可以是一个URL(允许有占位符)或是一组占位符。占位符使用 ``{...}``包裹,对应的值可以来自当前的其它属性值、传入的上下文变量。
+ ///
+ /// the return format is the same as `options`.
+ ///
+ /// 返回格式与 `options` 一致。
pub dyn_options: String,
+ /// Whether it is required
+ ///
+ /// 是否必填
pub required: bool,
+ /// Minimum length
+ ///
+ /// 最小长度
pub min_length: i32,
+ /// Maximum length
+ ///
+ /// 最大长度
pub max_length: i32,
+ /// Parent attribute name
+ ///
+ /// 父属性名称
+ pub parent_attr_name: String,
+ /// Custom behavior
+ ///
+ /// 自定义行为
pub action: String,
+ /// Extension information
+ ///
+ /// 扩展信息
pub ext: String,
- pub parent_attr_name: String,
+ /// Associated [resource kind](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
+ ///
+ /// 关联的 [资源类型](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
pub rel_rbum_kind_id: String,
pub own_paths: String,
@@ -126,37 +630,156 @@ pub struct RbumKindAttrSummaryResp {
pub scope_level: RbumScopeLevelKind,
}
+/// Resource kind attribute definition detail information
+///
+/// 资源类型属性定义详细信息
#[derive(Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))]
pub struct RbumKindAttrDetailResp {
+ /// Attribute definition id
+ ///
+ /// 属性定义id
pub id: String,
- pub name: String,
+ /// Attribute definition module
+ ///
+ /// 属性定义模块
pub module: String,
+ /// Attribute definition module
+ ///
+ /// 属性定义模块
+ pub name: String,
+ /// Attribute definition label
+ ///
+ /// 属性定义标签
pub label: String,
+ /// Attribute definition note
+ ///
+ /// 属性定义备注
pub note: String,
+ /// Attribute definition sort
+ ///
+ /// 属性定义排序
pub sort: i64,
- pub main_column: bool,
+ /// 是否定位类型的属性定义
+ ///
+ /// Whether the Attribute is a positioning kind
pub position: bool,
+ /// Whether the Attribute definition is a capacity kind
+ ///
+ /// 是否容量类型的属性定义
pub capacity: bool,
+ /// Whether overload is allowed
+ ///
+ /// 是否允许超载
pub overload: bool,
- pub hide: bool,
+ /// Whether it is a secret
+ ///
+ /// 是否是秘密
pub secret: bool,
- pub show_by_conds: String,
+ /// Whether it is the main column
+ ///
+ /// 是否是主列
+ pub main_column: bool,
+ /// Whether indexing is needed
+ ///
+ /// 是否需要索引
pub idx: bool,
+ /// Data kind
+ ///
+ /// 数据类型
pub data_type: RbumDataTypeKind,
+ /// Show widget kind
+ ///
+ /// 显示控件类型
pub widget_type: RbumWidgetTypeKind,
+ /// Number of columns occupied by the widget
+ ///
+ /// 控件占用列数
pub widget_columns: i16,
+ /// Whether to hide by default
+ ///
+ /// 默认是否隐藏
+ pub hide: bool,
+ /// Show conditions
+ ///
+ /// 显示条件
+ ///
+ /// Json format: ``{:}``, currently only supports ``and`` operations.
+ ///
+ /// Json格式:``{<属性名>:<属性值>}``,目前仅支持``and``操作。
+ pub show_by_conds: String,
+ /// Fixed default value
+ ///
+ /// 固定默认值
pub default_value: String,
+ /// Dynamic default value
+ ///
+ /// 动态默认值
+ ///
+ /// Placeholders are wrapped in ``{...}``, and the corresponding values can come from other current attribute values or incoming context variables.
+ ///
+ /// 可以是一个URL(允许有占位符)或是一组占位符。占位符使用 ``{...}``包裹,对应的值可以来自当前的其它属性值、传入的上下文变量。
+ ///
+ /// The return format is the same as ``default_value``
+ /// or ``json`` when ``data_type = Json``` and ``widget_type = Control``
+ /// or ``array`` when ``data_type = Array`` and ``widget_type = Group``.
+ ///
+ /// 返回格式与 ``default_value`` 一致,
+ /// 或当 ``data_type = Json`` 且 ``widget_type = Control`` 时为 ``json`` ,
+ /// 或当 ``data_type = Array`` 且 ``widget_type = Group`` 时为 ``array``。
pub dyn_default_value: String,
+ /// Fixed options
+ ///
+ /// 固定选项
+ ///
+ /// Json array format: ``[{name::value:}]``.
+ ///
+ /// Json数组格式:``[{name:<显示名称>:value:<对应值>}]``。
pub options: String,
+ /// Dynamic options
+ ///
+ /// 动态选项
+ ///
+ /// It can be a URL (with placeholders) or a set of placeholders.
+ /// Placeholders are wrapped in ``{...}``, and the corresponding values can come from other current attribute values or incoming context variables.
+ ///
+ /// 可以是一个URL(允许有占位符)或是一组占位符。占位符使用 ``{...}``包裹,对应的值可以来自当前的其它属性值、传入的上下文变量。
+ ///
+ /// the return format is the same as `options`.
+ ///
+ /// 返回格式与 `options` 一致。
pub dyn_options: String,
+ /// Whether it is required
+ ///
+ /// 是否必填
pub required: bool,
+ /// Minimum length
+ ///
+ /// 最小长度
pub min_length: i32,
+ /// Maximum length
+ ///
+ /// 最大长度
pub max_length: i32,
+ /// Parent attribute name
+ ///
+ /// 父属性名称
+ pub parent_attr_name: String,
+ /// Custom behavior
+ ///
+ /// 自定义行为
pub action: String,
+ /// Extension information
+ ///
+ /// 扩展信息
pub ext: String,
- pub parent_attr_name: String,
+ /// Associated [resource kind](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
+ ///
+ /// 关联的 [资源类型](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
pub rel_rbum_kind_id: String,
+ /// Associated [resource kind](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) name
+ ///
+ /// 关联的 [资源类型](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) name
pub rel_rbum_kind_name: String,
pub own_paths: String,
diff --git a/backend/basic/src/rbum/dto/rbum_kind_dto.rs b/backend/basic/src/rbum/dto/rbum_kind_dto.rs
index 0c5da1855..5e63d7717 100644
--- a/backend/basic/src/rbum/dto/rbum_kind_dto.rs
+++ b/backend/basic/src/rbum/dto/rbum_kind_dto.rs
@@ -8,53 +8,146 @@ use tardis::web::poem_openapi;
use crate::rbum::rbum_enumeration::RbumScopeLevelKind;
+/// Add request for resource kind
+///
+/// 资源类型添加请求
#[derive(Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object))]
pub struct RbumKindAddReq {
+ /// Resource kind module
+ ///
+ /// 资源类型模块
+ ///
+ /// Default is ``empty``
+ ///
+ /// 默认为 ``空``
+ ///
+ /// 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")))]
+ pub module: Option,
+ /// Resource kind code
+ ///
+ /// 资源类型编码
+ ///
+ /// 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")))]
pub code: TrimString,
+ /// Resource kind name
+ ///
+ /// 资源类型名称
#[cfg_attr(feature = "default", 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")))]
pub note: Option,
+ /// Resource kind icon
+ ///
+ /// 资源类型图标
#[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))]
pub icon: Option,
+ /// Resource kind sort
+ ///
+ /// 资源类型排序
pub sort: Option,
- #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))]
- pub module: Option,
+ /// Extension table name
+ ///
+ /// 扩展表名
+ ///
+ /// Each resource kind can specify an extension table for storing customized data.
+ ///
+ /// 每个资源类型可以指定一个扩展表用于存储自定义数据。
#[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))]
pub ext_table_name: Option,
pub scope_level: Option,
}
+/// Modify request for resource kind
+///
+/// 资源类型修改请求
#[derive(Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object))]
pub struct RbumKindModifyReq {
+ /// Resource kind module
+ ///
+ /// 资源类型模块
+ ///
+ /// 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")))]
+ pub module: Option,
+ /// Resource kind name
+ ///
+ /// 资源类型名称
#[cfg_attr(feature = "default", 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")))]
pub note: Option,
+ /// Resource kind icon
+ ///
+ /// 资源类型图标
#[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "1000")))]
pub icon: Option,
+ /// Resource kind sort
+ ///
+ /// 资源类型排序
pub sort: Option,
- #[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))]
- pub module: Option,
+ /// Extension table name
+ ///
+ /// 扩展表名
+ ///
+ /// Each resource kind can specify an extension table for storing customized data.
+ ///
+ /// 每个资源类型可以指定一个扩展表用于存储自定义数据。
#[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))]
pub ext_table_name: Option,
pub scope_level: Option,
}
+/// Resource kind summary information
+///
+/// 资源类型概要信息
#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))]
pub struct RbumKindSummaryResp {
+ /// Resource kind id
+ ///
+ /// 资源类型id
pub id: String,
+ /// Resource kind module
+ ///
+ /// 资源类型模块
+ pub module: String,
+ /// Resource kind code
+ ///
+ /// 资源类型编码
pub code: String,
+ /// Resource kind name
+ ///
+ /// 资源类型名称
pub name: String,
+ /// Resource kind icon
+ ///
+ /// 资源类型图标
pub icon: String,
+ /// Resource kind sort
+ ///
+ /// 资源类型排序
pub sort: i64,
- pub module: String,
+ /// Extension table name
+ ///
+ /// 扩展表名
pub ext_table_name: String,
pub own_paths: String,
@@ -65,16 +158,43 @@ pub struct RbumKindSummaryResp {
pub scope_level: RbumScopeLevelKind,
}
+/// Resource kind detail information
+///
+/// 资源类型详细信息
#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))]
pub struct RbumKindDetailResp {
+ /// Resource kind id
+ ///
+ /// 资源类型id
pub id: String,
+ /// Resource kind module
+ ///
+ /// 资源类型模块
+ pub module: String,
+ /// Resource kind code
+ ///
+ /// 资源类型编码
pub code: String,
+ /// Resource kind name
+ ///
+ /// 资源类型名称
pub name: String,
+ /// Resource kind note
+ ///
+ /// 资源类型备注
pub note: String,
+ /// Resource kind icon
+ ///
+ /// 资源类型图标
pub icon: String,
+ /// Resource kind sort
+ ///
+ /// 资源类型排序
pub sort: i64,
- pub module: String,
+ /// Extension table name
+ ///
+ /// 扩展表名
pub ext_table_name: String,
pub own_paths: String,
diff --git a/backend/basic/src/rbum/serv/rbum_item_serv.rs b/backend/basic/src/rbum/serv/rbum_item_serv.rs
index ef76c3e9f..3a8ccb9c8 100644
--- a/backend/basic/src/rbum/serv/rbum_item_serv.rs
+++ b/backend/basic/src/rbum/serv/rbum_item_serv.rs
@@ -1168,6 +1168,7 @@ impl RbumItemAttrServ {
for in_main_table_attr in in_main_table_attrs {
let column_name = Alias::new(&in_main_table_attr.name);
+ // TODO unwrap()
let column_val = add_req.values.get(&in_main_table_attr.name).unwrap().clone();
update_statement.value(column_name, Value::from(column_val));
}
diff --git a/backend/basic/src/rbum/serv/rbum_kind_serv.rs b/backend/basic/src/rbum/serv/rbum_kind_serv.rs
index edf1c40cb..549931087 100644
--- a/backend/basic/src/rbum/serv/rbum_kind_serv.rs
+++ b/backend/basic/src/rbum/serv/rbum_kind_serv.rs
@@ -37,37 +37,40 @@ impl RbumCrudOperation TardisResult<()> {
+ if !R_URL_PART_CODE.is_match(add_req.code.as_str()) {
+ return Err(funs.err().bad_request(&Self::get_obj_name(), "add", &format!("code {} is invalid", add_req.code), "400-rbum-*-code-illegal"));
+ }
+ if funs.db().count(Query::select().column(rbum_kind::Column::Id).from(rbum_kind::Entity).and_where(Expr::col(rbum_kind::Column::Code).eq(add_req.code.as_str()))).await? > 0
+ {
+ return Err(funs.err().conflict(&Self::get_obj_name(), "add", &format!("code {} already exists", add_req.code), "409-rbum-*-code-exist"));
+ }
+ Ok(())
+ }
+
async fn package_add(add_req: &RbumKindAddReq, _: &TardisFunsInst, _: &TardisContext) -> TardisResult {
Ok(rbum_kind::ActiveModel {
id: Set(TardisFuns::field.nanoid()),
+ module: Set(add_req.module.as_ref().unwrap_or(&"".to_string()).to_string()),
code: Set(add_req.code.to_string()),
name: Set(add_req.name.to_string()),
note: Set(add_req.note.as_ref().unwrap_or(&"".to_string()).to_string()),
icon: Set(add_req.icon.as_ref().unwrap_or(&"".to_string()).to_string()),
sort: Set(add_req.sort.unwrap_or(0)),
- module: Set(add_req.module.as_ref().unwrap_or(&"".to_string()).to_string()),
ext_table_name: Set(add_req.ext_table_name.as_ref().unwrap_or(&"".to_string()).to_string()),
scope_level: Set(add_req.scope_level.as_ref().unwrap_or(&RbumScopeLevelKind::Private).to_int()),
..Default::default()
})
}
- async fn before_add_rbum(add_req: &mut RbumKindAddReq, funs: &TardisFunsInst, _: &TardisContext) -> TardisResult<()> {
- if !R_URL_PART_CODE.is_match(add_req.code.as_str()) {
- return Err(funs.err().bad_request(&Self::get_obj_name(), "add", &format!("code {} is invalid", add_req.code), "400-rbum-*-code-illegal"));
- }
- if funs.db().count(Query::select().column(rbum_kind::Column::Id).from(rbum_kind::Entity).and_where(Expr::col(rbum_kind::Column::Code).eq(add_req.code.as_str()))).await? > 0
- {
- return Err(funs.err().conflict(&Self::get_obj_name(), "add", &format!("code {} already exists", add_req.code), "409-rbum-*-code-exist"));
- }
- Ok(())
- }
-
async fn package_modify(id: &str, modify_req: &RbumKindModifyReq, _: &TardisFunsInst, _: &TardisContext) -> TardisResult {
let mut rbum_kind = rbum_kind::ActiveModel {
id: Set(id.to_string()),
..Default::default()
};
+ if let Some(module) = &modify_req.module {
+ rbum_kind.module = Set(module.to_string());
+ }
if let Some(name) = &modify_req.name {
rbum_kind.name = Set(name.to_string());
}
@@ -80,9 +83,6 @@ impl RbumCrudOperation TardisResult<()> {
+ Self::check_scope(&add_req.rel_rbum_kind_id, RbumKindServ::get_table_name(), funs, ctx).await?;
+ if funs
+ .db()
+ .count(
+ Query::select()
+ .column(rbum_kind_attr::Column::Id)
+ .from(rbum_kind_attr::Entity)
+ .and_where(Expr::col(rbum_kind_attr::Column::Name).eq(add_req.name.as_str()))
+ .and_where(Expr::col(rbum_kind_attr::Column::Module).eq(add_req.module.as_ref().unwrap_or(&TrimString("".to_string())).as_str()))
+ .and_where(Expr::col(rbum_kind_attr::Column::RelRbumKindId).eq(add_req.rel_rbum_kind_id.as_str()))
+ .and_where(Expr::col(rbum_kind_attr::Column::OwnPaths).like(format!("{}%", ctx.own_paths).as_str())),
+ )
+ .await?
+ > 0
+ {
+ return Err(funs.err().conflict(&Self::get_obj_name(), "add", &format!("name {} already exists", add_req.name), "409-rbum-*-name-exist"));
+ }
+ Ok(())
+ }
+
async fn package_add(add_req: &RbumKindAttrAddReq, _: &TardisFunsInst, _: &TardisContext) -> TardisResult {
Ok(rbum_kind_attr::ActiveModel {
id: Set(TardisFuns::field.nanoid()),
- name: Set(add_req.name.to_string()),
module: Set(add_req.module.as_ref().unwrap_or(&TrimString("".to_string())).to_string()),
+ name: Set(add_req.name.to_string()),
label: Set(add_req.label.to_string()),
note: Set(add_req.note.as_ref().unwrap_or(&"".to_string()).to_string()),
sort: Set(add_req.sort.unwrap_or(0)),
- main_column: Set(add_req.main_column.unwrap_or(false)),
position: Set(add_req.position.unwrap_or(false)),
capacity: Set(add_req.capacity.unwrap_or(false)),
overload: Set(add_req.overload.unwrap_or(false)),
- hide: Set(add_req.hide.unwrap_or(false)),
secret: Set(add_req.secret.unwrap_or(false)),
- show_by_conds: Set(add_req.show_by_conds.as_ref().unwrap_or(&"".to_string()).to_string()),
+ main_column: Set(add_req.main_column.unwrap_or(false)),
idx: Set(add_req.idx.unwrap_or(false)),
data_type: Set(add_req.data_type.to_string()),
widget_type: Set(add_req.widget_type.to_string()),
widget_columns: Set(add_req.widget_columns.unwrap_or(0)),
+ hide: Set(add_req.hide.unwrap_or(false)),
+ show_by_conds: Set(add_req.show_by_conds.as_ref().unwrap_or(&"".to_string()).to_string()),
default_value: Set(add_req.default_value.as_ref().unwrap_or(&"".to_string()).to_string()),
dyn_default_value: Set(add_req.dyn_default_value.as_ref().unwrap_or(&"".to_string()).to_string()),
options: Set(add_req.options.as_ref().unwrap_or(&"".to_string()).to_string()),
@@ -178,28 +199,6 @@ impl RbumCrudOperation TardisResult<()> {
- Self::check_scope(&add_req.rel_rbum_kind_id, RbumKindServ::get_table_name(), funs, ctx).await?;
- // TODO This check does not consider scope level
- if funs
- .db()
- .count(
- Query::select()
- .column(rbum_kind_attr::Column::Id)
- .from(rbum_kind_attr::Entity)
- .and_where(Expr::col(rbum_kind_attr::Column::Name).eq(add_req.name.as_str()))
- .and_where(Expr::col(rbum_kind_attr::Column::Module).eq(add_req.module.as_ref().unwrap_or(&TrimString("".to_string())).as_str()))
- .and_where(Expr::col(rbum_kind_attr::Column::RelRbumKindId).eq(add_req.rel_rbum_kind_id.as_str()))
- .and_where(Expr::col(rbum_kind_attr::Column::OwnPaths).like(format!("{}%", ctx.own_paths).as_str())),
- )
- .await?
- > 0
- {
- return Err(funs.err().conflict(&Self::get_obj_name(), "add", &format!("name {} already exists", add_req.name), "409-rbum-*-name-exist"));
- }
- Ok(())
- }
-
async fn package_modify(id: &str, modify_req: &RbumKindAttrModifyReq, _: &TardisFunsInst, _: &TardisContext) -> TardisResult {
let mut rbum_kind_attr = rbum_kind_attr::ActiveModel {
id: Set(id.to_string()),
@@ -214,9 +213,6 @@ impl RbumCrudOperation) -> TardisResult {
let mut new_uri = uri.to_string();
for mat in EXTRACT_R.captures_iter(uri) {
- let old_key = mat.get(0).unwrap().as_str();
+ let old_key = mat.get(0).expect("ignore").as_str();
let key = &old_key[1..old_key.len() - 1];
if let Some(value) = values.get(key) {
new_uri = new_uri.replace(old_key, value);