RedisKeyEnum.java 1.9 KB
package vion.constant;

import lombok.Getter;
import org.dromara.hutool.core.text.StrUtil;

import java.util.Arrays;

/**
 * @author vion
 * @date 2024/2/2
 */
@Getter
public enum RedisKeyEnum {

    /**
     * 字典 key
     */
    DICT_PREFIX("sys:dict:"),
    IMPLEMENT_TYPE("implementType"),
    PROJECT_STAGE("projectStage"),
    PROJECT_STATE("projectState"),
    PRODUCT_TYPE("productType"),
    BRAND("brand"),
    ORDER_TEMP_STATUS("orderTempStatus"),
    ORDER_STATUS("orderStatus"),
    FAULT_TYPE("faultType"),
    STATUS("status"),
    SOLVE_TYPE("solveType"),
    FILE_TYPE("fileType"),
    SOURCE_TYPE("sourceType"),
    INSPECT_TYPE("inspectType"),
    FAULT_REASON("faultReason"),
    SERVICE_ORDER_STATUS("serviceOrderStatus"),
    SERVICE_TYPE("serviceType"),
    PAY_TYPE("payType"),
    CONTRACT_TYPE("contractType"),
    FINANCIAL_STATUS("financialStatus"),
    PRODUCT_LINE("productLine"),
    CONSTRUCTION_STATUS("constructionStatus"),
    DIFF_TYPE("diffType"),
    OFFSET_ITEM("offsetItem"),
    POINT_STATUS("pointStatus"),
    REPAIR_STATUS("repairStatus"),
    PROJECT_SIZE("projectSize"),
    SERVICE_METHOD("serviceMethod"),

    /**
     * 钉钉 key
     */
    DING_PREFIX("dingtalk:"),
    USER_ID("user:id:"),
    USER_NAME("user:name:"),
    ACCESS_TOKEN("accessToken"),

    /**
     * 合同同步时间
     */
    CONTRACT_SYNC_TIME("contract:sync:time"),
    CONTRACT_SYNC_NEW_TIME("contract:sync:new:time"),

    /**
     * agent
     */
    AGENT("agent:");

    private final String val;

    RedisKeyEnum(String val) {
        this.val = val;
    }

    public static String getValByKey(String key) {
        return Arrays.stream(RedisKeyEnum.values())
                .filter(e -> StrUtil.equalsAnyIgnoreCase(e.name(), key))
                .findFirst()
                .map(RedisKeyEnum::getVal)
                .orElseThrow(() -> new IllegalArgumentException("未找到对应的枚举"));
    }
}