use db_proc_macro::SqlxEnum;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use strum_macros:: Display;




// 1.SqlxEnum是 sqlx表中要用的 枚举,都自定义的反序化
#[derive(Debug, SqlxEnum, Clone, PartialEq, Eq, Display, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum RoleKind {
    Std,
    System,
    Admin,
    Guest,
}
#[allow(clippy::derivable_impls)]
impl Default for RoleKind {
    fn default() -> Self {
        RoleKind::Std
    }
}

#[derive(Debug, SqlxEnum, Clone, PartialEq, Eq, Display, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum OwnerKind {
    Private,
    System,
    Group,
    Pubilc,
}

#[derive(Debug, SqlxEnum, Clone, PartialEq, Eq, Display, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum APICategory {
    Ai,
    Storage,     // 对象存储（如 AWS S3, 阿里云 OSS）
    Translation, // 翻译服务
    Captcha,     // 验证码服务（图形/行为验证）
    Auth,        // 身份认证（OAuth, JWT）
    Biometric,   // 生物识别（人脸、指纹）
}

#[derive(Debug, SqlxEnum, Clone, PartialEq, Eq, Display, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum FileRouterScope {
    #[strum(serialize = "/public/file_temp")]
    Temp,
    #[strum(serialize = "/public/file_public")]
    Public,
    #[strum(serialize = "/api/file_get")]
    Api,
}

#[derive(Debug, SqlxEnum, Clone, PartialEq, Eq, Display, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum PermtKind {
    View,
    Edit,
    Super,
}

#[derive(Debug, SqlxEnum, PartialEq, Eq, Serialize, Clone, Display)]
#[serde(rename_all = "lowercase")]
pub enum AccessBucket {
    Public,
    Group,
    Temp,
    Private,
    Sign,
    Avatar,
    System,
    Null,
}

#[derive(Debug, SqlxEnum, Clone, PartialEq, Eq, Display, Serialize)]
pub enum DatabaseKind {
    Sqlite,
    MySql,
    Postgres,
    Access,
    Api,
    SqlServer,
}


// 2. 非表格数据的枚举
// 虽然属性前缀写的是 #[strum(...)]，
// 但实际处理它的是 strum_macros crate 中的宏逻辑。
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Display)]
pub enum Operator {
    #[serde(rename = "=")]
    #[strum(serialize = "=")]
    Eq,

    #[serde(rename = ">")]
    #[strum(serialize = ">")]
    Gt,

    #[serde(rename = ">=")]
    #[strum(serialize = ">=")]
    Gte,

    #[serde(rename = "<")]
    #[strum(serialize = "<")]
    Lt,

    #[serde(rename = "<=")]
    #[strum(serialize = "<=")]
    Lte,

    #[serde(rename = "!=")]
    #[strum(serialize = "!=")]
    Ne,

    #[serde(rename = "LIKE")]
    #[strum(serialize = "LIKE")]
    Like,

    #[serde(rename = "LIKE_ANY")]
    #[strum(serialize = "LIKE_ANY")]
    LikeAny,

    #[serde(rename = "BETWEEN")]
    #[strum(serialize = "BETWEEN")]
    Between,

    #[serde(rename = "NOT_BETWEEN")]
    #[strum(serialize = "NOT_BETWEEN")]
    NotBetween,

    #[serde(rename = "IN_QUERY")]
    #[strum(serialize = "IN_QUERY")]
    InQuery,

    #[serde(rename = "NOT_IN_QUERY")]
    #[strum(serialize = "NOT_IN_QUERY")]
    NotInQuery,

    #[serde(rename = "NOT_NULL")]
    #[strum(serialize = "NOT_NULL")]
    NotNull,

    #[serde(rename = "IS_NULL")]
    #[strum(serialize = "IS_NULL")]
    IsNull,

    #[serde(rename = "IN")]
    #[strum(serialize = "IN")]
    In,

    #[serde(rename = "NOT_IN")]
    #[strum(serialize = "NOT_IN")]
    NotIn,

    #[serde(rename = "REGEXP")]
    #[strum(serialize = "REGEXP")]
    Regexp,
}

#[derive(Debug, PartialEq, Eq, Clone, Serialize,Deserialize)]
pub enum Logical {
    #[serde(rename = "AND")]
    And,
    #[serde(rename = "OR")]
    Or,
}




#[test]
fn dev(){
    println!("{}",AccessBucket::Private.to_lower())
}
