/**
 * 参数操作枚举，定义参数操作的不同类型
 *
 * @version 1.0
 * @since 2025
 */
package com.xdap.self_development.domain.enums;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum ParameterOperationEnum {
    /**
     * 新增
     */
    INSERT("insert", "新增"),
    /**
     * 更新
     */
    UPDATE("update", "更新"),
    /**
     * 删除
     */
    DELETE("delete", "删除"),
    /**
     * 未修改
     */
    UNCHANGED("unchanged", "未修改");

    /**
     * 编码
     */
    private final String code;
    /**
     * 描述
     */
    private final String description;

    ParameterOperationEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public static ParameterOperationEnum fromCode(String code) {
        return Arrays.stream(values())
                .filter(operation -> operation.code.equals(code))
                .findFirst()
                .orElse(UNCHANGED);
    }

}