bios_basic/spi/dto/spi_bs_dto.rs
1use serde::{Deserialize, Serialize};
2use tardis::basic::error::TardisError;
3use tardis::basic::field::TrimString;
4use tardis::chrono::{DateTime, Utc};
5use tardis::db::sea_orm;
6use tardis::web::poem_openapi;
7
8use crate::rbum::dto::rbum_filer_dto::{RbumBasicFilterReq, RbumItemFilterFetcher, RbumItemRelFilterReq};
9use crate::spi::spi_funs;
10
11/// Add request for backend service
12///
13/// 后端服务添加请求
14#[derive(Serialize, Deserialize, Debug, poem_openapi::Object)]
15pub struct SpiBsAddReq {
16 /// Service name
17 ///
18 /// 服务名称
19 #[oai(validator(min_length = "2", max_length = "255"))]
20 pub name: TrimString,
21 /// SPI service type Id. Used to partition the type corresponding to this service
22 ///
23 /// SPI服务类型Id。用于分区该服务对应的类型
24 #[oai(validator(min_length = "2", max_length = "255"))]
25 pub kind_id: TrimString,
26 /// Connection URI
27 ///
28 /// 连接URI
29 #[oai(validator(min_length = "2", max_length = "2000"))]
30 pub conn_uri: String,
31 /// 连接用户名/凭证名
32 ///
33 /// Connection username/credential name
34 pub ak: TrimString,
35 /// 连接密码/凭证密码
36 ///
37 /// Connection password/credential password
38 pub sk: TrimString,
39 /// Extended information. Such as connection pool information
40 ///
41 /// 扩展信息。比如连接池信息
42 pub ext: String,
43 /// Is private. Private service can only be used by one subject of request (tenant or application)
44 ///
45 /// 是否私有。私有的服务只能用于一个请求主体(租户或应用)
46 pub private: bool,
47 /// Is disabled
48 ///
49 /// 是否禁用
50 pub disabled: Option<bool>,
51}
52
53/// Modify request for backend service
54///
55/// 后端服务修改请求
56#[derive(Serialize, Deserialize, Debug, poem_openapi::Object)]
57pub struct SpiBsModifyReq {
58 /// Service name
59 ///
60 /// 服务名称
61 #[oai(validator(min_length = "2", max_length = "255"))]
62 pub name: Option<TrimString>,
63 /// SPI service type Id. Used to partition the type corresponding to this service
64 ///
65 /// SPI服务类型Id。用于分区该服务对应的类型
66 #[oai(validator(min_length = "2", max_length = "255"))]
67 pub kind_id: Option<TrimString>,
68 /// Connection URI
69 ///
70 /// 连接URI
71 #[oai(validator(min_length = "2", max_length = "2000"))]
72 pub conn_uri: Option<String>,
73 /// Connection username/credential name
74 ///
75 /// 连接用户名/凭证名
76 #[oai(validator(min_length = "2"))]
77 pub ak: Option<TrimString>,
78 /// Connection password/credential password
79 ///
80 /// 连接密码/凭证密码
81 #[oai(validator(min_length = "2"))]
82 pub sk: Option<TrimString>,
83 /// Extended information. Such as connection pool information
84 ///
85 /// 扩展信息。比如连接池信息
86 pub ext: Option<String>,
87 /// Is private. Private service can only be used by one subject of request (tenant or application)
88 ///
89 /// 是否私有。私有的服务只能用于一个请求主体(租户或应用)
90 pub private: Option<bool>,
91 /// Is disabled
92 ///
93 /// 是否禁用
94 pub disabled: Option<bool>,
95}
96
97/// Backend service summary information
98///
99/// 后端服务概要信息
100#[derive(Serialize, Deserialize, Debug, poem_openapi::Object, sea_orm::FromQueryResult)]
101pub struct SpiBsSummaryResp {
102 /// Service Id
103 ///
104 /// 服务Id
105 pub id: String,
106 /// Service name
107 ///
108 /// 服务名称
109 pub name: String,
110 /// SPI service type Id
111 ///
112 /// SPI服务类型Id
113 pub kind_id: String,
114 /// SPI service type code
115 ///
116 /// SPI服务类型编码
117 pub kind_code: String,
118 /// SPI service type name
119 ///
120 /// SPI服务类型名称
121 pub kind_name: String,
122 /// Connection URI
123 ///
124 /// 连接URI
125 pub conn_uri: String,
126 /// Connection username/credential name
127 ///
128 /// 连接用户名/凭证名
129 pub ak: String,
130 /// Connection password/credential password
131 ///
132 /// 连接密码/凭证密码
133 pub sk: String,
134 /// Extended information. Such as connection pool information
135 ///
136 /// 扩展信息。比如连接池信息
137 pub ext: String,
138 /// Is private. Private service can only be used by one subject of request (tenant or application)
139 ///
140 /// 是否私有。私有的服务只能用于一个请求主体(租户或应用)
141 pub private: bool,
142 /// Is disabled
143 ///
144 /// 是否禁用
145 pub disabled: bool,
146 /// Create time
147 ///
148 /// 创建时间
149 pub create_time: DateTime<Utc>,
150 /// Update time
151 ///
152 /// 更新时间
153 pub update_time: DateTime<Utc>,
154}
155
156/// Backend service detail information
157///
158/// 后端服务详细信息
159#[derive(Serialize, Deserialize, Debug, poem_openapi::Object, sea_orm::FromQueryResult)]
160pub struct SpiBsDetailResp {
161 /// Service Id
162 ///
163 /// 服务Id
164 pub id: String,
165 /// Service name
166 ///
167 /// 服务名称
168 pub name: String,
169 /// SPI service type Id
170 ///
171 /// SPI服务类型Id
172 pub kind_id: String,
173 /// SPI service type code
174 ///
175 /// SPI服务类型编码
176 pub kind_code: String,
177 /// SPI service type name
178 ///
179 /// SPI服务类型名称
180 pub kind_name: String,
181 /// Connection URI
182 ///
183 /// 连接URI
184 pub conn_uri: String,
185 /// Connection username/credential name
186 ///
187 /// 连接用户名/凭证名
188 pub ak: String,
189 /// Connection password/credential password
190 ///
191 /// 连接密码/凭证密码
192 pub sk: String,
193 /// Extended information. Such as connection pool information
194 ///
195 /// 扩展信息。比如连接池信息
196 pub ext: String,
197 /// Is private. Private service can only be used by one subject of request (tenant or application)
198 ///
199 /// 是否私有。私有的服务只能用于一个请求主体(租户或应用)
200 pub private: bool,
201 /// Is disabled
202 ///
203 /// 是否禁用
204 pub disabled: bool,
205 /// Create time
206 ///
207 /// 创建时间
208 pub create_time: DateTime<Utc>,
209 /// Update time
210 ///
211 /// 更新时间
212 pub update_time: DateTime<Utc>,
213 /// Bound tenant or application Id
214 ///
215 /// 绑定的租户或应用Id
216 pub rel_app_tenant_ids: Vec<String>,
217}
218
219/// Backend service certificate information
220///
221/// 后端服务凭证信息
222#[derive(Serialize, Deserialize, Debug)]
223pub struct SpiBsCertResp {
224 /// SPI service type code
225 ///
226 /// SPI服务类型编码
227 pub kind_code: String,
228 /// Connection URI
229 ///
230 /// 连接URI
231 pub conn_uri: String,
232 /// Connection username/credential name
233 ///
234 /// 连接用户名/凭证名
235 pub ak: String,
236 /// Connection password/credential password
237 ///
238 /// 连接密码/凭证密码
239 pub sk: String,
240 /// Extended information. Such as connection pool information
241 ///
242 /// 扩展信息。比如连接池信息
243 pub ext: String,
244 /// Is private. Private service can only be used by one subject of request (tenant or application)
245 ///
246 /// 是否私有。私有的服务只能用于一个请求主体(租户或应用)
247 pub private: bool,
248}
249
250impl SpiBsCertResp {
251 pub fn bs_not_implemented(&self) -> TardisError {
252 spi_funs::bs_not_implemented(&self.kind_code)
253 }
254}
255
256/// Backend service query filter request
257///
258/// 后端服务的查询过滤请求
259#[derive(Serialize, Deserialize, Debug, Clone, Default, poem_openapi::Object)]
260#[serde(default)]
261pub struct SpiBsFilterReq {
262 /// Basic filter
263 ///
264 /// 基础过滤
265 pub basic: RbumBasicFilterReq,
266 /// Relational filter
267 ///
268 /// 关联过滤
269 pub rel: Option<RbumItemRelFilterReq>,
270 /// Relational filter 2
271 ///
272 /// 关联过滤2
273 pub rel2: Option<RbumItemRelFilterReq>,
274 /// Is private
275 ///
276 /// 是否私有
277 pub private: Option<bool>,
278 /// SPI service type code
279 ///
280 /// SPI服务类型编码
281 pub kind_code: Option<String>,
282 /// SPI service type codes
283 ///
284 /// SPI服务类型编码集合
285 pub kind_codes: Option<Vec<String>>,
286 /// SPI service type Id
287 ///
288 /// SPI服务类型Id
289 pub kind_id: Option<String>,
290 /// SPI service domain Id
291 ///
292 /// SPI服务Domain Id
293 pub domain_code: Option<String>,
294}
295
296impl RbumItemFilterFetcher for SpiBsFilterReq {
297 fn basic(&self) -> &RbumBasicFilterReq {
298 &self.basic
299 }
300 fn rel(&self) -> &Option<RbumItemRelFilterReq> {
301 &self.rel
302 }
303 fn rel2(&self) -> &Option<RbumItemRelFilterReq> {
304 &self.rel2
305 }
306}