
package org.jeecg.modules.workFlow.flowlong.engine.model;

import org.jeecg.modules.workFlow.flowlong.engine.core.FlowCreator;
import org.jeecg.modules.workFlow.flowlong.engine.entity.FlwTaskActor;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Map;

/**
 * JSON BPM 分配到任务的人或角色
 *

 */
@Getter
@Setter
public class NodeAssignee implements Serializable {
    /**
     * 租户ID
     */
    private String tenantId;
    /**
     * 主键ID
     */
    private String id;
    /**
     * 名称
     */
    private String name;
    /**
     * 权重（ 用于票签，多个参与者合计权重 100% ）
     */
    private Integer weight;
    /**
     * 扩展配置，用于存储头像、等其它信息
     */
    private Map<String, Object> extendConfig;

    public static NodeAssignee of(FlwTaskActor flwTaskActor) {
        NodeAssignee nodeAssignee = new NodeAssignee();
        nodeAssignee.setTenantId(flwTaskActor.getTenantId());
        nodeAssignee.setId(flwTaskActor.getActorId());
        nodeAssignee.setName(flwTaskActor.getActorName());
        nodeAssignee.setWeight(flwTaskActor.getWeight());
        return nodeAssignee;
    }

    public static NodeAssignee ofFlowCreator(FlowCreator flowCreator) {
        NodeAssignee nodeAssignee = new NodeAssignee();
        nodeAssignee.setTenantId(flowCreator.getTenantId());
        nodeAssignee.setId(flowCreator.getCreateId());
        nodeAssignee.setName(flowCreator.getCreateBy());
        return nodeAssignee;
    }
}
