Skip to main content

bios_basic/rbum/dto/
rbum_kind_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 kind
12///
13/// 资源类型添加请求
14#[derive(Serialize, Deserialize, Debug, poem_openapi::Object)]
15pub struct RbumKindAddReq {
16    /// Resource kind module
17    ///
18    /// 资源类型模块
19    ///
20    /// Default is ``empty``
21    ///
22    /// 默认为 ``空``
23    ///
24    /// Used to further divide the resource  kind. For example, there are multiple resource  kinds under the ``cmdb compute`` module, such as ``ecs, ec2, k8s``.
25    ///
26    /// 用于对资源类型做简单的分类。比如 ``cmdb计算`` 模块下可以有 ``ecs、ec2、k8s`` 等多个资源类型。
27    #[oai(validator(min_length = "2", max_length = "255"))]
28    pub module: Option<String>,
29    /// Resource kind code
30    ///
31    /// 资源类型编码
32    ///
33    /// Resource kind code, which is required to conform to the scheme specification in the uri, matching the regular: ``^[a-z0-9-.]+$`` .
34    ///
35    /// 资源类型编码,需要符合uri中的scheme规范,匹配正则:``^[a-z0-9-.]+$`` 。
36    #[oai(validator(min_length = "2", max_length = "255"))]
37    pub code: TrimString,
38    /// Resource kind name
39    ///
40    /// 资源类型名称
41    #[oai(validator(min_length = "2", max_length = "255"))]
42    pub name: TrimString,
43    /// Resource kind note
44    ///
45    /// 资源类型备注
46    #[oai(validator(min_length = "2", max_length = "2000"))]
47    pub note: Option<String>,
48    /// Resource kind icon
49    ///
50    /// 资源类型图标
51    #[oai(validator(min_length = "2", max_length = "1000"))]
52    pub icon: Option<String>,
53    /// Resource kind sort
54    ///
55    /// 资源类型排序
56    pub sort: Option<i64>,
57    /// Extension table name
58    ///
59    /// 扩展表名
60    ///
61    /// Each resource kind can specify an extension table for storing customized data.
62    ///
63    /// 每个资源类型可以指定一个扩展表用于存储自定义数据。
64    #[oai(validator(min_length = "2", max_length = "255"))]
65    pub ext_table_name: Option<String>,
66
67    pub scope_level: Option<RbumScopeLevelKind>,
68}
69
70/// Modify request for resource kind
71///
72/// 资源类型修改请求
73#[derive(Serialize, Deserialize, Debug, poem_openapi::Object)]
74pub struct RbumKindModifyReq {
75    /// Resource kind module
76    ///
77    /// 资源类型模块
78    ///
79    /// Used to further divide the resource  kind. For example, there are multiple resource  kinds under the ``cmdb compute`` module, such as ``ecs, ec2, k8s``.
80    ///
81    /// 用于对资源类型做简单的分类。比如 ``cmdb计算`` 模块下可以有 ``ecs、ec2、k8s`` 等多个资源类型。
82    #[oai(validator(min_length = "2", max_length = "255"))]
83    pub module: Option<String>,
84    /// Resource kind name
85    ///
86    /// 资源类型名称
87    #[oai(validator(min_length = "2", max_length = "255"))]
88    pub name: Option<TrimString>,
89    /// Resource kind note
90    ///
91    /// 资源类型备注
92    #[oai(validator(min_length = "2", max_length = "2000"))]
93    pub note: Option<String>,
94    /// Resource kind icon
95    ///
96    /// 资源类型图标
97    #[oai(validator(min_length = "2", max_length = "1000"))]
98    pub icon: Option<String>,
99    /// Resource kind sort
100    ///
101    /// 资源类型排序
102    pub sort: Option<i64>,
103    /// Extension table name
104    ///
105    /// 扩展表名
106    ///
107    /// Each resource kind can specify an extension table for storing customized data.
108    ///
109    /// 每个资源类型可以指定一个扩展表用于存储自定义数据。
110    #[oai(validator(min_length = "2", max_length = "255"))]
111    pub ext_table_name: Option<String>,
112
113    pub scope_level: Option<RbumScopeLevelKind>,
114}
115
116/// Resource kind summary information
117///
118/// 资源类型概要信息
119#[derive(Serialize, Deserialize, Debug, Clone, poem_openapi::Object, sea_orm::FromQueryResult)]
120pub struct RbumKindSummaryResp {
121    /// Resource kind id
122    ///
123    /// 资源类型id
124    pub id: String,
125    /// Resource kind module
126    ///
127    /// 资源类型模块
128    pub module: String,
129    /// Resource kind code
130    ///
131    /// 资源类型编码
132    pub code: String,
133    /// Resource kind name
134    ///
135    /// 资源类型名称
136    pub name: String,
137    /// Resource kind icon
138    ///
139    /// 资源类型图标
140    pub icon: String,
141    /// Resource kind sort
142    ///
143    /// 资源类型排序
144    pub sort: i64,
145    /// Extension table name
146    ///
147    /// 扩展表名
148    pub ext_table_name: String,
149
150    pub own_paths: String,
151    pub owner: String,
152    pub create_time: DateTime<Utc>,
153    pub update_time: DateTime<Utc>,
154
155    pub scope_level: RbumScopeLevelKind,
156}
157
158/// Resource kind detail information
159///
160/// 资源类型详细信息
161#[derive(Serialize, Deserialize, Debug, Clone, poem_openapi::Object, sea_orm::FromQueryResult)]
162pub struct RbumKindDetailResp {
163    /// Resource kind id
164    ///
165    /// 资源类型id
166    pub id: String,
167    /// Resource kind module
168    ///
169    /// 资源类型模块
170    pub module: String,
171    /// Resource kind code
172    ///
173    /// 资源类型编码
174    pub code: String,
175    /// Resource kind name
176    ///
177    /// 资源类型名称
178    pub name: String,
179    /// Resource kind note
180    ///
181    /// 资源类型备注
182    pub note: String,
183    /// Resource kind icon
184    ///
185    /// 资源类型图标
186    pub icon: String,
187    /// Resource kind sort
188    ///
189    /// 资源类型排序
190    pub sort: i64,
191    /// Extension table name
192    ///
193    /// 扩展表名
194    pub ext_table_name: String,
195
196    pub own_paths: String,
197    pub owner: String,
198    pub owner_name: Option<String>,
199    pub create_time: DateTime<Utc>,
200    pub update_time: DateTime<Utc>,
201
202    pub scope_level: RbumScopeLevelKind,
203}