package cd.casic.plugin.dataobject.dto;

import cd.casic.framework.commons.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import org.pf4j.Plugin;
import org.pf4j.PluginDependency;

import java.util.List;

/**
 * @description: TODO
 * @author: mianbin
 * @date: 2025/5/19 17:13
 * @version: 1.0
 */
@Data
@Builder
@TableName(value = "plugin_spec_storage")
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class PluginSpecStorage extends BaseDO {
    @TableId
    private String pluginId;
    private String pluginDescription;
    private String pluginClass = Plugin.class.getName();
    private String version;
    private String requires = "*";
    private String provider;
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<PluginDependency> dependencies;
    private String license;
    private String mapperXmlDir;
    private String staticDir;
    private StatusPhase enable;
    private String path;
    @TableField(exist = false)
    private String configFileName;
    @TableField(exist = false)
    private List<String> configFileActive;
    private String pluginDirPath;

    @Getter
    @AllArgsConstructor
    public enum EnableStatus {
        /**
         * 启用
         */
        ENABLE(1, "启用"),
        /**
         * 禁用
         */
        DISABLE(0, "禁用");
        private final Integer code;
        private final String value;
    }

    public enum StatusPhase {
        PENDING,
        STARTING,
        CREATED,
        DISABLING,
        DISABLED,
        RESOLVED,
        STARTED,
        STOPPED,
        FAILED,
        UNKNOWN,
        ;
    }

}
