package com.cool.store.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author Admin
 * @ClassName FsEventTypeEnum
 * @Description fs的事件类型
 */
public enum FSEventTypeEnum {

    //
    USER_CREATED("contact.user.created_v3","员工入职"),
    USER_DELETED("contact.user.deleted_v3",  "员工离职"),
    USER_UPDATED("contact.user.updated_v3", "员工信息被修改"),

    DEPARTMENT_CREATED("contact.department.created_v3", "部门被创建"),
    DEPARTMENT_UPDATED("contact.department.updated_v3",  "部门信息被修改"),
    DEPARTMENT_DELETED("contact.department.deleted_v3",  "部门被删除"),

    APP_OPEN("app_open",  "首次启用应用"),
    APP_STATUS_CHANGE("app_status_change",  "应用停启用"),
    APP_TICKET("app_ticket", "app_ticket 事件"),
    APP_UNINSTALLED("app_uninstalled",  "应用卸载"),

    CONTACT_SCOPE_UPDATE("contact.scope.updated_v3",  "通讯录范围权限被更新"),
    ORDER_PAID("order_paid",  "应用商店应用购买"),
    ;


    private final String value;
    private final String remark;

    private static final Map<String, FSEventTypeEnum> map = Arrays.stream(values()).collect(Collectors.toMap(FSEventTypeEnum::getValue, Function.identity()));

    FSEventTypeEnum(String value, String remark) {
        this.value = value;
        this.remark = remark;
    }

    public String getValue() {
        return value;
    }

    public static FSEventTypeEnum parseValue(String value) {
        return map.get(value);
    }

    public static boolean isUserEvent(String eventType){
        return FSEventTypeEnum.USER_CREATED.getValue().equals(eventType) || FSEventTypeEnum.USER_UPDATED.getValue().equals(eventType) || FSEventTypeEnum.USER_DELETED.getValue().equals(eventType);
    }

    public static boolean isDepartmentEvent(String eventType){
        return FSEventTypeEnum.DEPARTMENT_CREATED.getValue().equals(eventType) || FSEventTypeEnum.DEPARTMENT_UPDATED.getValue().equals(eventType) || FSEventTypeEnum.DEPARTMENT_DELETED.getValue().equals(eventType);
    }
}
