package com.usky.issue.service.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 同步方向
 *
 * @author fyc
 * @date 2026-06-08
 */
@Getter
@AllArgsConstructor
public enum SyncDirection {

    UP("UP", "本地→云端"),
    DOWN("DOWN", "云端→本地"),
    BOTH("BOTH", "双向");

    private final String code;
    private final String desc;

    public static SyncDirection fromCode(String code) {
        if (code == null) {
            throw new IllegalArgumentException("未知同步方向: null");
        }
        String normalized = code.trim();
        for (SyncDirection direction : values()) {
            if (direction.code.equalsIgnoreCase(normalized)) {
                return direction;
            }
        }
        throw new IllegalArgumentException("未知同步方向: " + code);
    }
}
