
package com.lideeyunji.tool.framework.yunji.enums;


import com.lideeyunji.tool.framework.yunji.utils.FuncBase;

import java.util.Arrays;
import java.util.Optional;

/**
 * sql默认参数
 */
public enum SqlParamEnum {


    lideeyunji_ID("lideeyunji_id", "id"),
    lideeyunji_DATE_TIME("lideeyunji_date_time", "日期时间"),
    lideeyunji_DATE("lideeyunji_date", "日期"),
    lideeyunji_TIME("lideeyunji_time", "时间"),
    lideeyunji_IS_DELETED("lideeyunji_is_deleted", "是否删除"),
    lideeyunji_TENANT_ID("lideeyunji_tenant_id", "当前登录人租户"),
    lideeyunji_USER_ID("lideeyunji_user_id", "当前登录人id"),
    lideeyunji_USER_NAME("lideeyunji_user_name", "当前登录人账号"),
    lideeyunji_USER_NICKNAME("lideeyunji_user_nickname", "当前登录人名称"),
    lideeyunji_USER_DEPT("lideeyunji_user_dept", "当前登录人部门"),
    lideeyunji_USER_ALL_DEPT("lideeyunji_user_all_dept", "当前登录人所有部门（包括本部门）"),
    lideeyunji_MAIN_ID("lideeyunji_main_id", "主数据id"),
    lideeyunji_AUTO_WHERE("lideeyunji_auto_where", "自定义随机where");

    /**
     */
    private final String code;
    /**
     */
    private final String title;


    public String getCode() {
        return code;
    }

    public String getTitle() {
        return title;
    }

    SqlParamEnum(String code, String title) {
        this.code = code;
        this.title = title;
    }
    public static SqlParamEnum getByCode(String code) {
        Optional<SqlParamEnum> matchingEnum = Arrays.stream(SqlParamEnum.values())
                .filter(sqlParamEnum -> FuncBase.equals(sqlParamEnum.getCode(), code))
                .findFirst(); // findFirst()会返回第一个匹配的元素，或者如果找不到则返回一个空的Optional
        // 检查是否找到了匹配的枚举项
        if (matchingEnum.isPresent()) {
            return matchingEnum.get();
        }
        return null;

    }
}
