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

import com.qqchen.deploy.backend.framework.converter.BaseConverter;
import com.qqchen.deploy.backend.workflow.dto.WorkflowNodeInstanceDTO;
import com.qqchen.deploy.backend.workflow.entity.WorkflowNodeInstance;
import com.qqchen.deploy.backend.workflow.dto.event.WorkflowNodeInstanceStatusChangeEvent;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

@Mapper(config = BaseConverter.class)
public interface WorkflowNodeInstanceConverter extends BaseConverter<WorkflowNodeInstance, WorkflowNodeInstanceDTO> {

    @Mappings({
        @Mapping(target = "processInstanceId", source = "processInstanceId"),
        @Mapping(target = "startTime", source = "startTime"),
        @Mapping(target = "endTime", source = "endTime"),
        @Mapping(target = "status", source = "status"),
        @Mapping(target = "executionId", source = "executionId"),
        @Mapping(target = "nodeId", source = "nodeId"),
        @Mapping(target = "nodeName", source = "nodeName"),
        @Mapping(target = "nodeType", source = "nodeType"),
    })
    WorkflowNodeInstance eventToEntity(WorkflowNodeInstanceStatusChangeEvent event);
}
