Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ideal-world/bios
Browse files Browse the repository at this point in the history
  • Loading branch information
ljl committed May 10, 2024
2 parents 3bd13d1 + 3e82156 commit 310ab57
Show file tree
Hide file tree
Showing 16 changed files with 404 additions and 123 deletions.
28 changes: 23 additions & 5 deletions backend/basic/src/rbum/domain/rbum_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,44 @@ use tardis::db::sea_orm::prelude::*;
use tardis::db::sea_orm::*;
use tardis::{TardisCreateEntity, TardisEmptyBehavior, TardisEmptyRelation};

/// Resource model
/// Resource item model
///
/// 资源项模型
///
/// Used to represent a specific resource,
/// Each resource corresponds to a [resource kind](crate::rbum::domain::rbum_kind::Model) and [resource domain](crate::rbum::domain::rbum_domain::Model).
/// Each resource item corresponds to a [resource kind](crate::rbum::domain::rbum_kind::Model) and [resource domain](crate::rbum::domain::rbum_domain::Model).
///
/// 用于表示具体的资源,每个资源项对应一个[资源类型](crate::rbum::domain::rbum_kind::Model) 和 [资源域](crate::rbum::domain::rbum_domain::Model)。
///
/// Each resource item corresponds to a unique uri,
/// and the uri consists of ``<resource kind code>://<resource domain code>/<resource item code>`` .
///
/// Each resource corresponds to a unique uri,
/// and the uri consists of `<resource kind>://<resource domain>/<resource code>`
/// 每个资源项对应一个唯一的uri,uri 由 ``<资源类型编码>://<资源域编码>/<资源项编码>`` 组成。
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, TardisCreateEntity, TardisEmptyBehavior, TardisEmptyRelation)]
#[sea_orm(table_name = "rbum_item")]
pub struct Model {
/// Resource item id
///
/// 资源项id
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
/// Resource code
/// Resource item code
///
/// 资源项编码
#[index(index_id = "unique_id", unique)]
pub code: String,
/// Resource item name
///
/// 资源项名称
pub name: String,
/// Associated [resource kind](crate::rbum::domain::rbum_kind::Model) id
///
/// 关联的[资源类型](crate::rbum::domain::rbum_kind::Model) id
#[index(repeat(index_id = "unique_id", unique))]
pub rel_rbum_kind_id: String,
/// Associated [resource domain](crate::rbum::domain::rbum_domain::Model) id
///
/// 关联的[资源域](crate::rbum::domain::rbum_domain::Model) id
#[index(repeat(index_id = "unique_id", unique))]
pub rel_rbum_domain_id: String,

Expand Down
17 changes: 14 additions & 3 deletions backend/basic/src/rbum/domain/rbum_item_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,29 @@ use tardis::db::sea_orm::prelude::*;
use tardis::db::sea_orm::*;
use tardis::{TardisCreateEntity, TardisEmptyBehavior, TardisEmptyRelation};

/// Resource extended attribute value model
/// Resource item extended attribute value model
///
/// 资源项扩展属性值模型
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, TardisCreateEntity, TardisEmptyBehavior, TardisEmptyRelation)]
#[sea_orm(table_name = "rbum_item_attr")]
pub struct Model {
/// Extended attribute value id
///
/// 扩展属性值id
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
/// Extended attribute value
///
/// 扩展属性值
pub value: String,
/// Associated [resource](crate::rbum::domain::rbum_item::Model) id
/// Associated [resource item](crate::rbum::domain::rbum_item::Model) id
///
/// 关联的[资源项](crate::rbum::domain::rbum_item::Model) id
#[index(index_id = "id", unique)]
pub rel_rbum_item_id: String,
/// Associated [resource kind extended attribute](crate::rbum::domain::rbum_kind_attr::Model) id
/// Associated [resource kind attribute definition](crate::rbum::domain::rbum_kind_attr::Model) id
///
/// 关联的[资源类型属性定义](crate::rbum::domain::rbum_kind_attr::Model) id
#[index(index_id = "id", unique)]
pub rel_rbum_kind_attr_id: String,

Expand Down
4 changes: 2 additions & 2 deletions backend/basic/src/rbum/domain/rbum_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ pub struct Model {
///
/// 资源类型编码
///
/// Resource kind code, which is required to conform to the scheme specification in the uri, matching the regular: ``^[a-z0-9-.]+$`` .
/// Which is required to conform to the scheme specification in the uri, matching the regular: ``^[a-z0-9-.]+$`` .
///
/// 资源类型编码,需要符合uri中的scheme规范,匹配正则:``^[a-z0-9-.]+$`` 。
/// 需要符合uri中的scheme规范,匹配正则:``^[a-z0-9-.]+$`` 。
#[index(unique)]
pub code: String,
/// Resource kind name
Expand Down
84 changes: 74 additions & 10 deletions backend/basic/src/rbum/dto/rbum_item_attr_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,88 @@ 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))]
pub struct RbumItemAttrAddReq {
/// Extended attribute value
///
/// 扩展属性值
#[cfg_attr(feature = "default", 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")))]
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")))]
pub rel_rbum_kind_attr_id: String,
}

/// Modify request for resource item extended attribute value
///
/// 资源项扩展属性值修改请求
#[derive(Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object))]
pub struct RbumItemAttrsAddOrModifyReq {
// name -> value
pub values: HashMap<String, String>,

#[cfg_attr(feature = "default", oai(validator(min_length = "2", max_length = "255")))]
pub rel_rbum_item_id: String,
pub struct RbumItemAttrModifyReq {
/// Extended attribute value
///
/// 扩展属性值
#[cfg_attr(feature = "default", oai(validator(min_length = "1", max_length = "2000")))]
pub value: String,
}

/// Batch add or modify request for resource item extended attribute values
///
/// 批量添加或修改资源项扩展属性值请求
#[derive(Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object))]
pub struct RbumItemAttrModifyReq {
#[cfg_attr(feature = "default", oai(validator(min_length = "1", max_length = "2000")))]
pub value: String,
pub struct RbumItemAttrsAddOrModifyReq {
/// Add or modify value collection
///
/// 添加或修改的值集合
///
/// Format: ``{ "field name": "field value" }``
///
/// ``field name``: [`crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp::name`]
pub values: HashMap<String, 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")))]
pub rel_rbum_item_id: String,
}

/// Resource item extended attribute value summary information
///
/// 源项扩展属性值概要信息
#[derive(Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))]
pub struct RbumItemAttrSummaryResp {
/// Extended attribute value id
///
/// 扩展属性值id
pub id: String,
/// Extended attribute value
///
/// 扩展属性值
pub value: String,
/// Associated [resource item](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id
///
/// 关联的[资源项](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id
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
pub rel_rbum_kind_attr_id: String,
/// Associated [resource kind attribute definition](crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp) name
///
/// 关联的[资源类型属性定义](crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp) 名称
pub rel_rbum_kind_attr_name: String,

pub own_paths: String,
Expand All @@ -51,13 +97,31 @@ pub struct RbumItemAttrSummaryResp {
pub update_time: DateTime<Utc>,
}

/// Resource item extended attribute value detail information
///
/// 源项扩展属性值详细信息
#[derive(Serialize, Deserialize, Debug)]
#[cfg_attr(feature = "default", derive(poem_openapi::Object, sea_orm::FromQueryResult))]
pub struct RbumItemAttrDetailResp {
/// Extended attribute value id
///
/// 扩展属性值id
pub id: String,
/// Extended attribute value
///
/// 扩展属性值
pub value: String,
/// Associated [resource item](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id
///
/// 关联的[资源项](crate::rbum::dto::rbum_item_dto::RbumItemDetailResp) id
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
pub rel_rbum_kind_attr_id: String,
/// Associated [resource kind attribute definition](crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp) name
///
/// 关联的[资源类型属性定义](crate::rbum::dto::rbum_kind_attr_dto::RbumKindAttrDetailResp) 名称
pub rel_rbum_kind_attr_name: String,

pub own_paths: String,
Expand Down
Loading

0 comments on commit 310ab57

Please sign in to comment.