001/*
002 *    Copyright 2024-2025, Warm-Flow (290631660@qq.com).
003 *
004 *    Licensed under the Apache License, Version 2.0 (the "License");
005 *    you may not use this file except in compliance with the License.
006 *    You may obtain a copy of the License at
007 *
008 *       https://www.apache.org/licenses/LICENSE-2.0
009 *
010 *    Unless required by applicable law or agreed to in writing, software
011 *    distributed under the License is distributed on an "AS IS" BASIS,
012 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *    See the License for the specific language governing permissions and
014 *    limitations under the License.
015 */
016package org.dromara.warm.flow.core.enums;
017
018/**
019 * 流程用户类型
020 *
021 * @author xiarg
022 * @since 2024/5/10 16:04
023 */
024public enum UserType {
025
026    APPROVAL("1", "待办任务的审批人权限"),
027    TRANSFER("2", "待办任务的转办人权限"),
028    DEPUTE("3", "待办任务的委托人权限");
029
030    private String key;
031    private String value;
032
033    UserType(String key, String value) {
034        this.key = key;
035        this.value = value;
036    }
037
038    public static String getKeyByValue(String value) {
039        for (UserType item : UserType.values()) {
040            if (item.getValue().equals(value)) {
041                return item.getKey();
042            }
043        }
044        return null;
045    }
046
047    public static String getValueByKey(String key) {
048        for (UserType item : UserType.values()) {
049            if (item.getKey().equals(key)) {
050                return item.getValue();
051            }
052        }
053        return null;
054    }
055
056    public static UserType getByKey(String key) {
057        for (UserType item : UserType.values()) {
058            if (item.getKey().equals(key)) {
059                return item;
060            }
061        }
062        return null;
063    }
064
065    public String getKey() {
066        return key;
067    }
068
069    public String getValue() {
070        return value;
071    }
072}