Skip to main content

bios_basic/rbum/dto/
rbum_item_dto.rs

1use serde::{Deserialize, Serialize};
2use tardis::basic::field::TrimString;
3use tardis::chrono::{DateTime, Utc};
4
5use tardis::db::sea_orm;
6
7use tardis::web::poem_openapi;
8
9use crate::rbum::rbum_enumeration::RbumScopeLevelKind;
10
11/// Add request for resource item
12///
13/// 资源项添加请求
14#[derive(Serialize, Deserialize, Debug, poem_openapi::Object)]
15pub struct RbumItemAddReq {
16    /// Resource item id
17    ///
18    /// 资源项id
19    #[oai(validator(min_length = "2", max_length = "255"))]
20    pub id: Option<TrimString>,
21    /// Resource item code
22    ///
23    /// 资源项编码
24    #[oai(validator(min_length = "2", max_length = "255"))]
25    pub code: Option<TrimString>,
26    /// Resource item name
27    ///
28    /// 资源项名称
29    #[oai(validator(min_length = "2", max_length = "255"))]
30    pub name: TrimString,
31    /// Associated [resource kind](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
32    ///
33    /// 关联的[资源类型](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
34    #[oai(validator(min_length = "2", max_length = "255"))]
35    pub rel_rbum_kind_id: String,
36    /// Associated [resource domain](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id
37    ///
38    /// 关联的[资源域](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id
39    #[oai(validator(min_length = "2", max_length = "255"))]
40    pub rel_rbum_domain_id: String,
41
42    pub scope_level: Option<RbumScopeLevelKind>,
43    pub disabled: Option<bool>,
44}
45
46impl Default for RbumItemAddReq {
47    fn default() -> Self {
48        Self {
49            id: Default::default(),
50            code: Default::default(),
51            name: TrimString::from(""),
52            rel_rbum_kind_id: Default::default(),
53            rel_rbum_domain_id: Default::default(),
54            scope_level: Default::default(),
55            disabled: Default::default(),
56        }
57    }
58}
59/// Add request for resource item kernel
60///
61/// 资源项内核添加请求
62///
63/// Different from [`crate::rbum::dto::rbum_item_dto::RbumItemAddReq`], this object is used when there is a resource item extension table,
64/// and the resource item contains kernel information (the ``rbum_item`` table) and extension information (the corresponding extension table).
65///
66/// 与 [`crate::rbum::dto::rbum_item_dto::RbumItemAddReq`] 不同,此对象用于有资源项扩展表的情况下使用,此时资源项包含了内核信息(``rbum_item``表)和扩展信息(对应的扩展表)。
67#[derive(Serialize, Deserialize, Debug)]
68#[serde(default)]
69pub struct RbumItemKernelAddReq {
70    /// Resource item id
71    ///
72    /// 资源项id
73    pub id: Option<TrimString>,
74    /// Resource item code
75    ///
76    /// 资源项编码
77    pub code: Option<TrimString>,
78    /// Resource item name
79    ///
80    /// 资源项名称
81    pub name: TrimString,
82    /// Associated [resource kind](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
83    ///
84    /// 关联的[资源类型](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
85    ///
86    /// Special kind can be set, otherwise the default kind will be used.
87    /// Note that setting special kind must ensure that the permissions are correct.
88    ///
89    /// 可以设置特殊的类型,否则将使用默认类型。
90    /// 注意设置特殊类型必须确保权限正确。
91    pub rel_rbum_kind_id: Option<String>,
92    /// Associated [resource domain](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id
93    ///
94    /// 关联的[资源域](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id
95    ///
96    /// Special domain can be set, otherwise the default domain will be used.
97    /// Note that setting special domain must ensure that the permissions are correct.
98    ///
99    /// 可以设置特殊的域,否则将使用默认域。
100    /// 注意设置特殊域必须确保权限正确。
101    pub rel_rbum_domain_id: Option<String>,
102    pub scope_level: Option<RbumScopeLevelKind>,
103    pub disabled: Option<bool>,
104}
105
106impl Default for RbumItemKernelAddReq {
107    fn default() -> Self {
108        Self {
109            id: None,
110            code: None,
111            name: TrimString("".to_string()),
112            rel_rbum_kind_id: None,
113            rel_rbum_domain_id: None,
114            scope_level: None,
115            disabled: None,
116        }
117    }
118}
119
120/// Modify request for resource item kernel
121///
122/// 资源项内核修改请求
123#[derive(Serialize, Deserialize, Debug, Default)]
124#[serde(default)]
125pub struct RbumItemKernelModifyReq {
126    /// Resource item code
127    ///
128    /// 资源项编码
129    pub code: Option<TrimString>,
130    /// Resource item name
131    ///
132    /// 资源项名称
133    pub name: Option<TrimString>,
134    pub scope_level: Option<RbumScopeLevelKind>,
135    pub disabled: Option<bool>,
136}
137
138/// Resource item summary information
139///
140/// 资源项概要信息
141#[derive(Serialize, Deserialize, Debug, poem_openapi::Object, sea_orm::FromQueryResult)]
142pub struct RbumItemSummaryResp {
143    /// Resource item id
144    ///
145    /// 资源项id
146    pub id: String,
147    /// Resource item code
148    ///
149    /// 资源项编码
150    pub code: String,
151    /// Resource item name
152    ///
153    /// 资源项名称
154    pub name: String,
155    /// Associated [resource kind](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
156    ///
157    /// 关联的[资源类型](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
158    pub rel_rbum_kind_id: String,
159    /// Associated [resource domain](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id
160    ///
161    /// 关联的[资源域](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id
162    pub rel_rbum_domain_id: String,
163
164    pub own_paths: String,
165    pub owner: String,
166    pub create_time: DateTime<Utc>,
167    pub update_time: DateTime<Utc>,
168
169    pub scope_level: RbumScopeLevelKind,
170    pub disabled: bool,
171}
172
173/// Resource item detail information
174///
175/// 资源项详细信息
176#[derive(Serialize, Deserialize, Debug, poem_openapi::Object, sea_orm::FromQueryResult)]
177pub struct RbumItemDetailResp {
178    /// Resource item id
179    ///
180    /// 资源项id
181    pub id: String,
182    /// Resource item code
183    ///
184    /// 资源项编码
185    pub code: String,
186    /// Resource item name
187    ///
188    /// 资源项名称
189    pub name: String,
190    /// Associated [resource kind](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
191    ///
192    /// 关联的[资源类型](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) id
193    pub rel_rbum_kind_id: String,
194    /// Associated [resource kind](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) name
195    ///
196    /// 关联的[资源类型](crate::rbum::dto::rbum_kind_dto::RbumKindDetailResp) 名称
197    pub rel_rbum_kind_name: String,
198    /// Associated [resource domain](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id
199    ///
200    /// 关联的[资源域](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) id
201    pub rel_rbum_domain_id: String,
202    /// Associated [resource domain](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) name
203    ///
204    /// 关联的[资源域](crate::rbum::dto::rbum_domain_dto::RbumDomainDetailResp) 名称
205    pub rel_rbum_domain_name: String,
206
207    pub own_paths: String,
208    pub owner: String,
209    pub owner_name: Option<String>,
210    pub create_time: DateTime<Utc>,
211    pub update_time: DateTime<Utc>,
212
213    pub scope_level: RbumScopeLevelKind,
214    pub disabled: bool,
215}