package com.qqchen.deploy.backend.workflow.entity;

import com.qqchen.deploy.backend.framework.annotation.LogicDelete;
import com.qqchen.deploy.backend.framework.domain.Entity;
import com.vladmihalcea.hibernate.type.json.JsonType;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;

import java.util.List;

/**
 * 工作流分类实体
 *
 * @author qqchen
 * @date 2025-10-24
 */
@Data
@Table(name = "workflow_category")
@jakarta.persistence.Entity
@EqualsAndHashCode(callSuper = true)
@LogicDelete
public class WorkflowCategory extends Entity<Long> {

    /**
     * 分类名称
     */
    @Column(name = "name", nullable = false, length = 100)
    private String name;

    /**
     * 分类编码（唯一，如SCRIPT_EXECUTION）
     */
    @Column(name = "code", nullable = false, length = 50, unique = true)
    private String code;

    /**
     * 分类描述
     */
    @Column(name = "description", length = 500)
    private String description;

    /**
     * 图标
     */
    @Column(name = "icon", length = 50)
    private String icon;

    /**
     * 排序
     */
    @Column(name = "sort", nullable = false)
    private Integer sort = 0;

    /**
     * 支持的触发方式列表（JSON数组，如["MANUAL","SCHEDULED"]）
     */
    @Type(JsonType.class)
    @Column(name = "supported_triggers", columnDefinition = "json")
    private List<String> supportedTriggers;

    /**
     * 是否启用
     */
    @Column(name = "enabled", nullable = false)
    private Boolean enabled = true;
}

