package org.example.mybatisplus.model.auto;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 通用枚举
 *
 * @author jimmy
 * @version 1.0.1
 * @date 2022-10-29 18:37
 */
@NoArgsConstructor(access = AccessLevel.NONE)
public final class CommonType {

    /**
     * 数据权限类型
     *
     * @author jimmy
     * @version 1.0.0
     * @date 2022-12-02 18:40
     */
    @Getter
    @AllArgsConstructor
    public enum DataScopeType {

        ALL("ALL", 0, "全部"),
        CUSTOM("CUSTOM", 1, "自定义"),
        SET_AND_SUBSET("SET_AND_SUBSET", 2, "本级及子级"),
        SET("SET", 3, "本级"),
        SELF("SELF", 4, "本人");

        @EnumValue
        private final String type;
        private final Integer code;
        private final String description;
    }


    // 营地内容类型
    @Getter
    @AllArgsConstructor
    public enum ContentType {

        TEXT("TEXT", "文本"),
        IMAGE("IMAGE", "图片");

        @EnumValue
        private final String type;
        private final String description;

    }

    // 联系方式类型
    @Getter
    @AllArgsConstructor
    public enum ContactType {

        TELEPHONE("TEL", "电话"),
        WE_CHAT("WE_CHAT", "微信");

        @EnumValue
        private final String type;
        private final String description;

    }

    // 端类型
    @Getter
    @AllArgsConstructor
    public enum TerminalType {

        // WEB
        MEM_WEB_PLT("MEM_WEB_PLT", UserType.TO_C, "会员WEB平台"),
        SYS_WEB_PLT("SYS_WEB_PLT", UserType.TO_B, "管理员WEB平台"),

        // 小程序
        MEM_WECHAT_MP("MEM_WECHAT_MP", UserType.TO_C, "会员微信小程序"),
        SYS_WECHAT_MP("SYS_WECHAT_MP", UserType.TO_B, "管理员微信小程序");
        /**
         * 类型
         */
        @EnumValue
        private final String type;

        private final CommonType.UserType userType;

        /**
         * 描述
         */
        private final String description;

    }

    // 登录类型枚举
    @Getter
    @AllArgsConstructor
    public enum LoginType {

        PWD("PWD", "账号密码登录"),
        SMS("SMS", "验证码登录"),
        WE_CHAT("WE_CHAT", "微信小程序"),
        DING_TALK("DING_TALK", "钉钉"),
        WE_COM("WE_COM", "企业微信"),
        EMAIL("email", "邮箱"),
        CAS("CAS", "CAS 登录");

        /**
         * 类型
         */
        @EnumValue
        private final String type;

        /**
         * 描述
         */
        private final String description;

    }

    // 性别枚举
    @Getter
    @AllArgsConstructor
    public enum Gender {

        FEMALE("FEMALE", "女"),
        MALE("MALE", "男"),
        PRIVACY("PRIVACY", "保密");

        @EnumValue
        private final String type;
        private final String description;

        /**
         * 根据描述获取性别
         *
         * @param description 描述
         * @return 描述对应的性别，如果描述不存在反悔{@code Gender.PRIVACY}
         */
        public static Gender getGenderByDesc(String description) {
            for (Gender gender : Gender.values()) {
                if (gender.getDescription().equals(description)) {
                    return gender;
                }
            }
            return Gender.PRIVACY;
        }
    }

    // 身份信息类型
    @Getter
    @AllArgsConstructor
    public enum IdentityType {
        ID_CARD("ID_CARD", "身份证"),
        PASSPORT("PASSWORD", "护照");

        @EnumValue
        private final String type;
        private final String description;
    }

    // 网络协议
    @Getter
    @AllArgsConstructor
    public enum Protocol {
        HTTP("http", "http"),
        HTTPS("https", "https");

        @EnumValue
        private final String type;
        private final String description;

        public static Protocol of(String type) {
            for (Protocol p : Protocol.values()) {
                if (p.getType().equalsIgnoreCase(type)) {
                    return p;
                }
            }
            return null;
        }

    }

    // 格式类型
    @Getter
    @AllArgsConstructor
    public enum FormatType {
        PLAIN("PLAIN", "无格式"),
        JSON("JSON", "JSON"),
        XML("XML", "XML");


        @EnumValue
        private final String type;
        private final String description;
    }

    // http 请求方式
    @Getter
    @AllArgsConstructor
    public enum HttpMethod {

        GET("GET", "GET"),
        POST("POST", "POST"),
        DELETE("DELETE", "DELETE"),
        PUT("PUT", "PUT");

        @EnumValue
        private final String type;
        private final String description;

    }

    // FromData 类型
    @Getter
    @AllArgsConstructor
    public enum FromDataType {

        TEXT("TEXT", "TEXT"),
        FILE("FILE", "FILE"),
        ARRAY("ARRAY", "ARRAY");

        @EnumValue
        private final String type;
        private final String description;

    }

    // 执照 类型
    @Getter
    @AllArgsConstructor
    public enum LicenseType {

        BIZ_LICENSE("BIZ_LIC", "企业营执"),
        IND_ID("IND_ID", "个人身份证");

        @EnumValue
        private final String type;
        private final String description;

    }

    // 2b or 2c
    @Getter
    @AllArgsConstructor
    public enum UserType {

        TO_B("TO_B", "面向客户"),
        TO_C("TO_C", "面向用户");

        /**
         * 类型
         */
        @EnumValue
        private final String type;

        /**
         * 描述
         */
        private final String description;

    }

    // 操作人角色
    @Getter
    @AllArgsConstructor
    public enum PlayerType {

        PLATFORM("PLT", "代理平台"),
        ENTERPRISE("ENT", "企业"),
        AGENT("AGENT", "代理商"),
        VENDOR("VENDOR", "商家");

        @EnumValue
        private final String type;
        private final String description;

    }

    // 删除类型
    @Getter
    @AllArgsConstructor
    public enum DeleteType {
        SOFT("SOFT", "软删除"),
        HARD("HARD", "硬删除");

        @EnumValue
        private final String type;
        private final String description;
    }


    // 内容项类型
    @Getter
    @AllArgsConstructor
    public enum ContentItemType {
        TEXT("TEXT", "文字"),
        IMAGE("IMAGE", "图片");

        @EnumValue
        private final String type;
        private final String description;
    }

    // 内容项类型
    @Getter
    @AllArgsConstructor
    public enum OrderByType {
        ASC("ASC", "正序"),
        DESC("DESC", "倒序");

        @EnumValue
        private final String type;
        private final String description;
    }

    // 内容项类型
    @Getter
    @AllArgsConstructor
    public enum LogicType {

        BETWEEN("BETWEEN", "之间"),
        NOT_CONTAIN("NOT_CONTAIN", "不包含"),
        CONTAIN("CONTAIN", "包含"),
        EQ_ANY("EQ_ANY", "任意等于"),
        EQ("EQ", "等于"),
        NE("NE", "不等于"),
        GT("GT", "大于"),
        GE("GE", "大于等于"),
        LT("LT", "小于"),
        LE("LE", "小于等于");


        @EnumValue
        private final String type;
        private final String description;
    }

    /**
     * 规则字段类型
     *
     * @author snows
     * @date 2025/01/17
     */
    @Getter
    @AllArgsConstructor
    public enum RuleType {

        NUMBERIC("NUMBERIC", "数字"),
        STRING_ARRAY("STRING_ARRAY", "多个匹配文本");

        @EnumValue
        private final String ruleType;
        private final String description;

    }
}
