bios_basic/
enumeration.rs

1//! Basic enumerations
2use serde::{Deserialize, Serialize};
3use strum::Display;
4
5use tardis::web::poem_openapi;
6
7/// API classification
8///
9/// API分类
10#[derive(Display, Debug, poem_openapi::Tags)]
11pub enum ApiTag {
12    /// Common Console, mostly starting with ``cc``, generally do not require authentication.
13    ///
14    /// 公共类型, 多使用 ``cc`` 开头,一般不需要认证
15    #[oai(rename = "Common Console")]
16    Common,
17    /// Tenant Console, mostly starting with ``ct``
18    ///
19    /// 租户类型, 多使用 ``ct`` 开头
20    #[oai(rename = "Tenant Console")]
21    Tenant,
22    /// App Console, mostly starting with ``ca``
23    ///
24    /// 应用类型, 多使用 ``ca`` 开头
25    #[oai(rename = "App Console")]
26    App,
27    /// System Console, mostly starting with ``cs``
28    ///
29    /// 系统类型, 多使用 ``cs`` 开头
30    #[oai(rename = "System Console")]
31    System,
32    /// Passport Console, mostly starting with ``cp``
33    ///
34    /// 通行证类型, 多使用 ``cp`` 开头
35    #[oai(rename = "Passport Console")]
36    Passport,
37    /// Interface Console, mostly starting with ``ci``, used for system-to-system calls, this type of interface generally uses ak/sk authentication
38    ///
39    /// 接口类型, 多使用 ``ci`` 开头, 用于系统间调用, 此类型接口一般使用ak/sk认证
40    #[oai(rename = "Interface Console")]
41    Interface,
42}
43
44/// Basic query operator
45///
46/// 基础查询操作符
47#[derive(Display, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, poem_openapi::Enum)]
48pub enum BasicQueryOpKind {
49    #[oai(rename = "=")]
50    Eq,
51    #[oai(rename = "!=")]
52    Ne,
53    #[oai(rename = ">")]
54    Gt,
55    #[oai(rename = ">=")]
56    Ge,
57    #[oai(rename = "<")]
58    Lt,
59    #[oai(rename = "<=")]
60    Le,
61    #[oai(rename = "like")]
62    Like,
63    #[oai(rename = "not_like")]
64    NotLike,
65    #[oai(rename = "l_like")]
66    LLike,
67    #[oai(rename = "not_l_like")]
68    NotLLike,
69    #[oai(rename = "r_like")]
70    RLike,
71    #[oai(rename = "not_r_like")]
72    NotRLike,
73    #[oai(rename = "in")]
74    In,
75    #[oai(rename = "not_in")]
76    NotIn,
77    #[oai(rename = "is_null")]
78    IsNull,
79    #[oai(rename = "is_not_null")]
80    IsNotNull,
81    #[oai(rename = "is_null_or_empty")]
82    IsNullOrEmpty,
83    #[oai(rename = "length")]
84    Len,
85}
86
87impl BasicQueryOpKind {
88    pub fn to_sql(&self) -> String {
89        match self {
90            BasicQueryOpKind::Eq => "=".to_string(),
91            BasicQueryOpKind::Ne => "!=".to_string(),
92            BasicQueryOpKind::Gt => ">".to_string(),
93            BasicQueryOpKind::Ge => ">=".to_string(),
94            BasicQueryOpKind::Lt => "<".to_string(),
95            BasicQueryOpKind::Le => "<=".to_string(),
96            BasicQueryOpKind::Like => "LIKE".to_string(),
97            BasicQueryOpKind::NotLike => "NOT LIKE".to_string(),
98            BasicQueryOpKind::LLike => "LIKE".to_string(),
99            BasicQueryOpKind::NotLLike => "NOT LIKE".to_string(),
100            BasicQueryOpKind::RLike => "LIKE".to_string(),
101            BasicQueryOpKind::NotRLike => "NOT LIKE".to_string(),
102            BasicQueryOpKind::In => "IN".to_string(),
103            BasicQueryOpKind::NotIn => "NOT IN".to_string(),
104            BasicQueryOpKind::IsNull => "IS NULL".to_string(),
105            BasicQueryOpKind::IsNotNull => "IS NOT NULL".to_string(),
106            BasicQueryOpKind::IsNullOrEmpty => "IS NULL".to_string(),
107            BasicQueryOpKind::Len => "=".to_string(),
108        }
109    }
110}