package cn.axzo.workflow.core.service.converter;

import cn.axzo.workflow.common.model.response.bpmn.process.BpmnProcessInstancePageItemVO;
import org.flowable.engine.history.HistoricProcessInstance;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.Arrays;

import static org.mapstruct.NullValueCheckStrategy.ALWAYS;

/**
 * 流程实例分页模型的 MapStruts 转换器
 *
 * @author wangli
 * @since 2023/7/26 14:31
 */
@Mapper(
        componentModel = "spring",
        nullValueCheckStrategy = ALWAYS,
        imports = Arrays.class
)
public interface BpmnProcessInstancePageItemConverter extends EntityConverter<BpmnProcessInstancePageItemVO,
        HistoricProcessInstance> {

    @Mapping(target = "id", source = "id")
    @Mapping(target = "name", source = "name")
    @Mapping(target = "processDefinitionId", source = "processDefinitionId")
    @Mapping(target = "result", source = "businessStatus")
    @Mapping(target = "startTime", source = "startTime")
    @Mapping(target = "endTime", source = "endTime")
    @Override
    BpmnProcessInstancePageItemVO toVo(HistoricProcessInstance entity);
}
